UnderAutomation
Eine Frage?

[email protected]

Kontakt
UnderAutomation
⌘Q
Diese Seite ist nur auf Englisch verfügbar.

Variables and registers

Read and write the B, I, D, R and S variables, the P, BP and EX position variables and the M registers of a Yaskawa controller.

This page shows how to read and write the variables and the registers of a Yaskawa Motoman controller with the SDK. A job and a PC exchange data through these variables: counters, offsets, recipe numbers, positions.

Variable types

VariableContentReadWrite.NET type
BByte, 0 to 255ReadByteWriteBytebyte[]
IInteger, 16 bitsReadIntegerWriteIntegershort[]
DDouble integer, 32 bitsReadDoubleIntegerWriteDoubleIntegerint[]
RReal, 32 bit floating pointReadRealWriteRealfloat[]
SString of 16 bytesRead16BytesCharWrite16BytesCharstring[]
SString of 32 bytesRead32BytesCharWrite32BytesCharstring[]
PRobot positionReadPositionVariableWritePositionVariableRobotPositionIntData[]
BPBase axis positionReadBasePositionWriteBasePositionRobotBasePositionData[]
EXStation axis positionReadExternalPositionWriteExternalPositionRobotExternalAxisData[]
MRegister of the concurrent I/O ladderReadRegisterWriteRegistershort[]

Every read method takes the number of the first variable and a count: ReadInteger(10, 2) reads I010 and I011. It returns an object whose Value is an array, one item per variable. Every write method takes the number of the first variable and an array: one call writes several variables in a row.

The numbers start at 0 (B000, I000...). The number of variables of each type depends on the controller and on its settings.

Numeric variables

var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
// B000 to B003: byte variables (0 to 255). Read and write an even number of values
byte[] b = robot.HighSpeedEServer.ReadByte(0, 4).Value;
robot.HighSpeedEServer.WriteByte(0, new byte[] { 1, 2, 3, 4 });
// I010 and I011: integer variables (16 bits)
short[] i = robot.HighSpeedEServer.ReadInteger(10, 2).Value;
robot.HighSpeedEServer.WriteInteger(10, new short[] { -100, 200 });
// D000: double integer variable (32 bits)
int[] d = robot.HighSpeedEServer.ReadDoubleInteger(0, 1).Value;
robot.HighSpeedEServer.WriteDoubleInteger(0, new[] { 100000 });
// R005 to R007: real variables (32 bit floating point)
float[] r = robot.HighSpeedEServer.ReadReal(5, 3).Value;
robot.HighSpeedEServer.WriteReal(5, new[] { 1.5f, -2.25f, 3f });
robot.Disconnect();
}
Click to see the full code
  • B variables are read and written by pairs: ReadByte rounds the count up to an even number, and WriteByte needs an even number of values.
  • D variables are 32 bit integers, not floating point values. Use R variables for decimal values.

String variables

var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
// S000 and S001: string variables of 16 bytes
string[] texts = robot.HighSpeedEServer.Read16BytesChar(0, 2).Value;
// Longer strings are cut to 16 characters
robot.HighSpeedEServer.Write16BytesChar(0, new[] { "PART-A", "BATCH 12" });
// String variables of 32 bytes, on the controllers that have them
string[] longTexts = robot.HighSpeedEServer.Read32BytesChar(0, 1).Value;
robot.HighSpeedEServer.Write32BytesChar(0, new[] { "Reference 2026-10-01 line 4" });
robot.Disconnect();
}
Click to see the full code

A string longer than the size of the variable is cut. Write ASCII characters only.

The 32 byte strings exist on the controllers that store their S variables in 32 bytes. On the others, the controller refuses the request.

Position variables

A P variable holds a robot position: in pulses, or in a Cartesian frame with a tool, a user frame and a posture.

var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
// P000: a position variable
RobotPositionIntData p0 = robot.HighSpeedEServer.ReadPositionVariable(0, 1).Value[0];
// PulseValue: Axes are pulses. Otherwise: X, Y, Z in micrometers, Rx, Ry, Rz in 1/10000 degree
Console.WriteLine($"{p0.DataType}, tool {p0.ToolNumber}: {string.Join(", ", p0.Axes)}");
// P001: a Cartesian position in the robot frame
var p1 = new RobotPositionIntData
{
DataType = RobotPositionDataType.RobotCoordinateValue,
Form = new RobotPosture(),
ToolNumber = 0,
UserCoordinateNumber = 0,
};
p1.Axis1 = 850000; // X = 850 mm
p1.Axis2 = 0; // Y
p1.Axis3 = 400000; // Z = 400 mm
p1.Axis4 = 1800000; // Rx = 180 degrees
p1.Axis5 = 0; // Ry
p1.Axis6 = 0; // Rz
robot.HighSpeedEServer.WritePositionVariable(1, new[] { p1 });
robot.Disconnect();
}
Click to see the full code
DataTypeAxes
PulseValueOne value per axis, in pulses
BaseCoordinateValue, RobotCoordinateValue, UserCoordinateValue, ToolCoordinateValueX, Y, Z in micrometers, then Rx, Ry, Rz in 1/10000 degree

The units of a P variable are the raw units of the controller: 850 mm is 850000. They differ from GetRobotCartesianPosition(), which returns mm and degrees.

To write a variable, set Form: new RobotPosture() is the default posture. In Python, use RobotPosture.from_integer(0).

Base and station position variables

BP variables hold the position of base axes (travel tracks), EX variables the position of station axes (positioners). The values are in pulses, up to 8 axes.

var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
// BP000: base axis position variable (travel track)
RobotBasePositionVariableData bp = robot.HighSpeedEServer.ReadBasePosition(0, 1);
RobotBasePositionData bp0 = bp.Value[0];
Console.WriteLine($"{bp0.DataType}: {string.Join(", ", bp0.Axes)}");
// Change the first axis and write the variable back
bp0.Axis1 += 1000;
robot.HighSpeedEServer.WriteBasePosition(0, new[] { bp0 });
// EX000: station axis position variable (positioner), in pulses
RobotExternalAxisData ex0 = robot.HighSpeedEServer.ReadExternalPosition(0, 1).Value[0];
ex0.Axis1 = 0;
robot.HighSpeedEServer.WriteExternalPosition(0, new[] { ex0 });
robot.Disconnect();
}
Click to see the full code

The data type of a BP variable (pulses or base frame) cannot be set by the SDK: read the variable, change its axes and write it back, as above.

Registers

M registers are the 16 bit registers of the concurrent I/O ladder of the controller.

var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
// M000 to M009: registers of the concurrent I/O ladder (16 bits)
short[] registers = robot.HighSpeedEServer.ReadRegister(0, 10).Value;
Console.WriteLine(string.Join(", ", registers));
// Write M560 and M561. The controller refuses the registers reserved for the system
robot.HighSpeedEServer.WriteRegister(560, new short[] { 12, 34 });
robot.Disconnect();
}
Click to see the full code

The controller reserves some registers for its own use, and refuses to write them. Check the free registers in the concurrent I/O manual of your controller.

Errors

  • A variable number out of range makes the controller refuse the request: the SDK throws an InvalidDataAnswerException.
  • One write call takes a limited number of values, for example 120 D variables. Beyond, the SDK throws an exception that gives the maximum: split the array in several calls.

Try it in the demo application

Everything on this page can be tried without writing code, in the Variables page of the demo application.

Variables page of the Yaskawa SDK demo application

The demo application is open source. The C# source of this page is VariableControl.cs.

Reference

Methods of HighSpeedEServerClientBase :
C#
// Reads multiple 16-byte string variables (S variables) from the robot controller. String variables are fixed-length, null-terminated ASCII strings.
RobotStringVariableData Read16BytesChar(int firstIndex, int count);
// Reads multiple 32-byte string variables (S variables) from the robot controller (DX200 only). Extended string variables for longer text storage than 16-byte variants.
RobotStringVariableData Read32BytesChar(int firstIndex, int count);
// Reads multiple base position variables (BP variables) from the robot controller. Base position variables define reference coordinate frames for robot operations.
RobotBasePositionVariableData ReadBasePosition(int firstIndex, int count);
// Reads multiple byte variables (B variables) from the robot controller. Byte variables are 8-bit unsigned values used for compact data storage.
RobotByteVariableData ReadByte(int firstIndex, int count);
// Reads multiple double-precision variables (D variables) from the robot controller. Note: The protocol actually transmits float values which are then cast to double.
RobotDoubleIntegerVariableData ReadDoubleInteger(int firstIndex, int count);
// Reads multiple external axis variables (EX variables) from the robot controller. External axis variables store positions for additional axes beyond the main robot arm.
RobotExternalAxisVariableData ReadExternalPosition(int firstIndex, int count);
// Reads multiple integer variables (I variables) from the robot controller. Integer variables are 16-bit signed values (-32768 to 32767).
RobotIntegerVariableData ReadInteger(int firstIndex, int count);
// Reads multiple position variables (P variables) from the robot controller. Position variables store complete robot poses including position, orientation, and configuration.
RobotPositionVariableData ReadPositionVariable(int firstIndex, int count);
// Reads multiple real (single-precision float) variables (R variables) from the robot controller. Real variables are 32-bit IEEE 754 floating-point values.
RobotRealVariableData ReadReal(int firstIndex, int count);
// Reads multiple 16-bit register values (M variables) from the robot controller. Registers are used for general-purpose integer storage in robot programs.
RobotRegisterData ReadRegister(int firstIndex, int count);
// Writes 16-byte string variables (S variables) to the robot controller. Strings longer than 16 characters will be truncated.
RobotDataHeader Write16BytesChar(int firstIndex, string[] data);
// Writes 32-byte string variables (S variables) to the robot controller. Strings longer than 32 characters will be truncated.
RobotDataHeader Write32BytesChar(int firstIndex, string[] data);
// Writes base position variables (BP variables) to the robot controller.
RobotDataHeader WriteBasePosition(int firstIndex, RobotBasePositionData[] data);
// Writes byte variables (B variables) to the robot controller.
RobotDataHeader WriteByte(int firstIndex, byte[] data);
// Writes double-precision variables (D variables) to the robot controller.
RobotDataHeader WriteDoubleInteger(int firstIndex, int[] data);
// Writes external axis variables (EX variables) to the robot controller using generic type. Provided for backward compatibility with existing code.
RobotDataHeader WriteExternalPosition(int firstIndex, RobotAxisRawData<int>[] data);
// Writes external axis variables (EX variables) to the robot controller.
RobotDataHeader WriteExternalPosition(int firstIndex, RobotExternalAxisData[] data);
// Writes integer variables (I variables) to the robot controller.
RobotDataHeader WriteInteger(int firstIndex, short[] data);
// Writes position variables (P variables) to the robot controller.
RobotDataHeader WritePositionVariable(int firstIndex, RobotPositionIntData[] data);
// Writes real (single-precision float) variables (R variables) to the robot controller.
RobotDataHeader WriteReal(int firstIndex, float[] data);
// Writes multiple 16-bit register values (M variables) to the robot controller.
RobotDataHeader WriteRegister(int firstIndex, short[] data);
Class
RobotPositionIntDatainherits RobotPositionData<int>
C#

Represents robot position data with 32-bit integer axis values. This is the primary type used for pulse-based position data from the High Speed Ethernet Server. Axis values are in pulse units (encoder counts) or scaled coordinate values.

MemberTypeDescription
RobotPositionIntData()
Constructor
Creates a blank instance of RobotPositionIntData
RobotPositionIntData(RobotDataHeader)
Constructor
Creates a new instance of RobotPositionIntData with the specified header information.
  • header : Response header containing metadata about the communication.
Enum
RobotPositionDataType
C#

Defines the coordinate system type for position data.

NameValueDescription
BaseCoordinateValue
16
Position in base coordinate system (world frame, value 16).
PulseValue
0
Position in encoder pulse values (joint space).
RobotCoordinateValue
17
Position in robot coordinate system (robot base frame, value 17).
ToolCoordinateValue
18
Position in tool coordinate system (value 18).
UserCoordinateValue
19
Position in user-defined coordinate system (value 19).
Class
RobotBasePositionDatainherits RobotAxisRawData<int>
C#

Represents base position data for coordinated motion with travel units or external bases. Base positions define the location of the robot's base in world coordinates or pulse values.

MemberTypeDescription
RobotBasePositionData(RobotDataHeader)
Constructor
Creates a new instance of RobotBasePositionData with the specified header information.
  • header : Response header containing metadata about the communication.
DataType
Property
read only
RobotBasePositionType
Gets the data type indicating whether values are pulse or coordinate values.
Class
RobotExternalAxisDatainherits RobotAxisRawData<int>
C#

Represents external axis position data for positioners, travel units, or additional servo axes. External axes are coordinated with the robot motion for applications like welding positioners.

MemberTypeDescription
RobotExternalAxisData(RobotAxisRawData<int>)
Constructor
Creates a new instance of RobotExternalAxisData from a generic RobotAxisRawData. Used for conversion from generic types to specific types.
  • source : Source axis data to copy from.
RobotExternalAxisData(RobotDataHeader)
Constructor
Creates a new instance of RobotExternalAxisData with the specified header information.
  • header : Response header containing metadata about the communication.

Integrieren Sie Roboter von Universal Robots, Fanuc, Yaskawa, ABB oder Staubli ganz einfach in Ihre .NET-, Python-, LabVIEW- oder Matlab-Anwendungen

UnderAutomation
KontaktLegal

© All rights reserved.