---
title: "Back up and compare the frames of a fleet"
description: "Save the tool and user frames (sysframe.va) of every Fanuc robot of a plant in one run, and find the UTOOL or UFRAME that changed since the last backup."
---

# Back up and compare the frames of a fleet

Somebody changed a tool frame on one of your 30 robots, and the parts are now 1.5 mm off. Which robot, which tool, and what were the old values? A daily read of the frames of every robot answers it, and gives the values back after a controller swap.

## Where the frames are

| File | Content | Note |
| --- | --- | --- |
| `sysframe.sv` | Tool frames `$MNUTOOL`, user frames `$MNUFRAME`, active numbers `$MNUTOOLNUM`, `$MNUFRAMENUM` | Binary. Loaded only at a controlled start. Belongs to one robot |
| `sysframe.va` | The same variables as text | Readable by a person and by the SDK |
| `framevar.*` | Setup data and comments of the frames | Binary, not read by the SDK |

The usual way to get an old tool back is long: load the old backup on the robot, read the values on the pendant, load the new files again. With the `.va` listing, the old values are read on the PC.

![One PC reads the frames of every robot and compares them with the last run.](/fanuc/documentation/diagrams/frames-fleet-compare.svg)

## Back up and compare the frames of every robot

The loop connects to each robot by FTP, keeps a dated copy of `sysframe.va`, reads the tools and user frames of group 1, and compares them with the last run. The difference is printed when a value moved by more than 0.01 mm or 0.01°.

**C# : FramesFleetBackup**
```csharp
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Common;
using UnderAutomation.Fanuc.Common.Files.Variables;

public class FramesFleetBackup
{
    static void Main()
    {
        /**/
        string[] robots = { "192.168.0.11", "192.168.0.12", "192.168.0.13" };
        foreach (string ip in robots)
        {
            var parameters = new ConnectionParameters(ip);
            parameters.Ftp.Enable = true;
            var robot = new FanucRobot();
            robot.Connect(parameters);

            // Dated copy of the listing, readable in any text editor
            robot.Ftp.DirectFileHandling.DownloadFileFromController($"{ip}-{DateTime.Now:yyyy-MM-dd}-sysframe.va", "md:/sysframe.va");
            SysframeFile frames = robot.Ftp.KnownVariableFiles.GetSysframeFile();
            robot.Disconnect();

            // Tools and user frames of group 1, by name
            var now = new Dictionary<string, double[]>();
            for (int n = 0; n < frames.Mnutool.GetLength(1); n++) now[$"UTOOL {n + 1}"] = Values(frames.Mnutool[0, n]);
            for (int n = 0; n < frames.Mnuframe.GetLength(1); n++) now[$"UFRAME {n + 1}"] = Values(frames.Mnuframe[0, n]);

            // Compare with the last run, 0.01 mm or degree of tolerance
            string last = $"frames-{ip}.json";
            if (File.Exists(last))
            {
                var before = JsonSerializer.Deserialize<Dictionary<string, double[]>>(File.ReadAllText(last));
                foreach (var item in now)
                    if (before.TryGetValue(item.Key, out double[] old) && old.Zip(item.Value, (a, b) => Math.Abs(a - b)).Max() > 0.01)
                        Console.WriteLine($"{ip} {item.Key} changed: {string.Join(" ", old)} -> {string.Join(" ", item.Value)}");
            }
            File.WriteAllText(last, JsonSerializer.Serialize(now));
        }
        /**/
    }

    // X, Y, Z, W, P, R. shortcut: an angle that goes from 179.99 to -179.99 is reported as a change.
    static double[] Values(CartesianPosition p) => p == null ? new double[6] : new[] { p.X, p.Y, p.Z, p.W, p.P, p.R };
}
```

**Python : FramesFleetBackup**
```python
import json
import os
from datetime import date

from underautomation.fanuc.fanuc_robot import FanucRobot
from underautomation.fanuc.connection_parameters import ConnectionParameters


# X, Y, Z, W, P, R. shortcut: an angle that goes from 179.99 to -179.99 is reported as a change.
def values(p):
    return [p.x, p.y, p.z, p.w, p.p, p.r]


##
robots = ["192.168.0.11", "192.168.0.12", "192.168.0.13"]
for ip in robots:
    parameters = ConnectionParameters(ip)
    parameters.ftp.enable = True
    robot = FanucRobot()
    robot.connect(parameters)

    # Dated copy of the listing, readable in any text editor
    robot.ftp.direct_file_handling.download_file_from_controller(f"{ip}-{date.today()}-sysframe.va", "md:/sysframe.va")
    frames = robot.ftp.known_variable_files.get_sysframe_file()
    robot.disconnect()

    # Tools and user frames of group 1 (flat lists, group 1 first)
    tools = frames.mnutool[: len(frames.mnutool) // len(frames.mnutoolnum)]
    uframes = frames.mnuframe[: len(frames.mnuframe) // len(frames.mnuframenum)]
    now = {f"UTOOL {n}": values(t) for n, t in enumerate(tools, start=1)}
    now.update({f"UFRAME {n}": values(uf) for n, uf in enumerate(uframes, start=1)})

    # Compare with the last run, 0.01 mm or degree of tolerance
    last = f"frames-{ip}.json"
    if os.path.exists(last):
        with open(last) as f:
            before = json.load(f)
        for name, new in now.items():
            old = before.get(name)
            if old and max(abs(a - b) for a, b in zip(old, new)) > 0.01:
                print(f"{ip} {name} changed: {old} -> {new}")
    with open(last, "w") as f:
        json.dump(now, f)
##
```

Run it once a day with the Windows task scheduler or cron. Add the other groups with `Mnutool[g - 1, n]`, and write to a database or a CSV file instead of JSON if your plant needs it.

The dated `.va` copies are a history: open two of them in a text editor or a diff tool to see what changed and when.

## After a controller swap

- Write the old values back one by one: on the pendant, or from the PC with RMI `WriteUTool(n, frame)` and `WriteUFrame(n, frame)`, see [RMI frames, I/O & status](/fanuc/documentation/rmi-frames-io).
- Never load the `sysframe` or `sysmast` file of another robot. The frames and the mastering belong to the arm they were taught on.
- Check the programs at low speed after the write.

## Cautions

- Change a tool or a user frame and every Cartesian point taught with it moves. The comparison tells you which frame changed, not whether the change was right: ask who changed it before you write the old value back.
- The comparison in the code is simple: an angle that goes from 179.99° to -179.99° shows as a change.
- The SDK reads `.va` files, not `.sv` files. A backup made on the pendant that holds only `.sv` files cannot be read on the PC: download the `.va` files by FTP, as the code does.

## Without code

[TouchUp](/touchup), the robot workbench for VS Code, backs up a Fanuc controller into a dated folder and compares two backups, or the robot with its last backup. The section `User frames and tools` of the compare lists only the frames that changed, with the difference (for example `Z +1.5 mm`). It reads the frames of a controller or of a backup. It does not write them in this version.

- [Back up a controller](/touchup/documentation/backup)
- [Compare backups](/touchup/documentation/compare)
- [User frames and tools](/touchup/documentation/user-frames-and-tools)

## See also

- [Tool frames: $MNUTOOL and $MNUTOOLNUM](/fanuc/documentation/fanuc-tool-frame-utool)
- [User frames: $MNUFRAME and the active UFRAME](/fanuc/documentation/fanuc-user-frame-uframe)
- [Upload, download & backup files](/fanuc/documentation/upload-download-backup-files)
- [Offline file parsing](/fanuc/documentation/offline-file-parsing): read old `.va` files in .NET, without a robot