UnderAutomation
Une question ?

[email protected]

Contactez-nous
UnderAutomation
⌘Q
Cette page est disponible uniquement en anglais.

User frames: $MNUFRAME and the active UFRAME

Read the user frames $MNUFRAME of a Fanuc robot and watch the active UFRAME and UTOOL numbers ($MNUFRAMENUM, $MNUTOOLNUM) while a program runs, without a Karel program.

Which user frame is active while a Fanuc program runs, and what are its values? The user frames are the system variable $MNUFRAME and the active one is $MNUFRAMENUM. A PC reads them directly: no register to copy, no Karel program on the robot.

The variables

VariableTypeMeaningFile
$MNUFRAME[g,n]POSITIONUser frame n of motion group g: X, Y, Z, W, P, R. n is 1 to 9 on a standard controllersysframe.va
$MNUFRAMENUM[g]BYTENumber of the active user frame of group gsysframe.va
$MNUTOOLNUM[g]BYTENumber of the active tool of group gsysframe.va

A TP program selects them with UFRAME_NUM=n and UTOOL_NUM=n. The variables give the numbers in use now.

Read the user frames and watch the active numbers

GetSysframeFile() reads all the user frames in one request. Then the loop reads the two active numbers by name every second, through the web server of the controller.

parameters.Cgtp.Enable = true;
robot.Connect(parameters);
// The user frames of group 1: $MNUFRAME[1,n] is Mnuframe[0, n - 1]
SysframeFile frames = robot.Ftp.KnownVariableFiles.GetSysframeFile();
for (int n = 1; n <= frames.Mnuframe.GetLength(1); n++)
{
CartesianPositionVariable uf = frames.Mnuframe[0, n - 1];
if (uf != null) Console.WriteLine($"UFRAME {n}: X={uf.X} Y={uf.Y} Z={uf.Z} W={uf.W} P={uf.P} R={uf.R}");
}
// Watch the active numbers while a program runs
while (true)
{
int uframe = robot.Cgtp.ReadVariable("$MNUFRAMENUM[1]").IntegerValue;
int utool = robot.Cgtp.ReadVariable("$MNUTOOLNUM[1]").IntegerValue;
Console.WriteLine($"{DateTime.Now:T} UFRAME {uframe} UTOOL {utool}");
Thread.Sleep(1000);
}
}
}
Click to see the full code

The .NET array starts at 0: $MNUFRAME[1,3] is Mnuframe[0, 2]. In Python, mnuframe is one flat list with the user frames of group 1 first.

Log the numbers with the name of the running program (see Monitor task execution): you see which frame and which tool each program uses, without opening it on the pendant.

Read or write one user frame with RMI

With the RMI option (R912), ReadUFrame(n) and WriteUFrame(n, frame) read and write one user frame, GetUFrameUTool() and SetUFrameUTool() read and set the active numbers.

parameters.Rmi.Enable = true;
robot.Connect(parameters);
// Read UFRAME 1
RmiIndexedFrameResponse uf = robot.Rmi.ReadUFrame(1);
Console.WriteLine($"UFrame 1: X={uf.Frame.X:F1} Y={uf.Frame.Y:F1} Z={uf.Frame.Z:F1}");
// Write UFRAME 1
robot.Rmi.WriteUFrame(1, new XYZWPRPosition { X = 100, Y = 0, Z = 0, W = 0, P = 0, R = 0 });
// Read UTOOL 1
RmiIndexedFrameResponse ut = robot.Rmi.ReadUTool(1);
Console.WriteLine($"UTool 1: X={ut.Frame.X:F1} Y={ut.Frame.Y:F1} Z={ut.Frame.Z:F1}");
// Write UTOOL 1
robot.Rmi.WriteUTool(1, new XYZWPRPosition { X = 0, Y = 0, Z = 200, W = 0, P = 0, R = 0 });
// Get current UFRAME and UTOOL numbers
RmiUFrameUToolNumbersResponse current = robot.Rmi.GetUFrameUTool();
Console.WriteLine($"Active UFRAME={current.Frame} UTOOL={current.Tool}");
// Set the active UFRAME and UTOOL
robot.Rmi.SetUFrameUTool(uframe: 1, utool: 2);
robot.Disconnect();
}
Click to see the full code

The current position in a user frame

SNPX gives the current position of the robot in a user frame of your choice, with ReadUserFramePosition(n). See SNPX current position.

Cautions

  • A taught point keeps the number of its user frame, not the values of the frame. Change a user frame and every Cartesian point taught in it moves with it. This is what a user frame is for (move a fixture, teach the frame again), and also what breaks a cell when the wrong frame is changed.
  • Keep a copy of sysframe.va before you change a frame. See Back up and compare the frames of a fleet.

Without code

TouchUp, the robot workbench for VS Code, shows the user frames 1 to 9 and the active user frame of a connected Fanuc controller, or of a backup, as a table and in 3D. It reads them only: it does not write a user frame in this version. See User frames and tools.

See also

  • Fanuc system variables list
  • Tool frames: $MNUTOOL and $MNUTOOLNUM
  • CGTP registers & variables
  • Frames & orientations