UnderAutomation
¿Una pregunta?

[email protected]

Contactos
UnderAutomation
⌘Q
Esta página solo está disponible en inglés.

Monitor the state of the robot

Poll the mode, the servo, the hold, the alarms and the job of a Yaskawa controller, and print each change of state.

  • Prerequisites
  • What to read
  • Example
  • Polling period
  • Troubleshooting
  • What to read next

This article shows how to follow the state of a Yaskawa Motoman controller from a PC, in C# or Python. It gives a complete program that reads the mode, the servo, the hold, the alarm and the job every 200 ms, and prints each change.

Prerequisites

  • The SDK is connected to the controller: see Connect to your robot.
  • Nothing else: all these reads work in any mode.

What to read

InformationMethod
Mode, servo, running, hold, alarmGetStatusInformation()
Name and line of the executing jobGetExecutingJobInformation()
Code and text of the alarmGetAlarm(RobotRecentAlarm.Latest)
Position of the robotGetRobotCartesianPosition()
Variables written by the jobReadInteger, ReadByte...

The SDK has no event: it reads when you call it. A monitor is a loop that reads, compares with the last value, and reacts to the changes.

Example

using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;
public class HowToMonitorState
{
static void Main()
{
var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
string last = null;
// Poll every 200 ms for 1 minute and print each change
for (int i = 0; i < 300; i++)
{
RobotStatusData status = robot.HighSpeedEServer.GetStatusInformation();
RobotJobData job = robot.HighSpeedEServer.GetExecutingJobInformation();
string mode = status.Play ? "PLAY" : status.Teach ? "TEACH" : "?";
string state = $"{mode} servo={(status.ServoOn ? "on" : "off")} running={status.Running} " +
$"hold={status.InHoldStatusPendant || status.InHoldStatusExternally || status.InHoldStatusByCommand} " +
$"alarm={status.Alarming} job={job.Name}";
if (state != last)
{
Console.WriteLine($"{DateTime.Now:HH:mm:ss} {state}");
if (status.Alarming)
{
RobotAlarmData alarm = robot.HighSpeedEServer.GetAlarm(RobotRecentAlarm.Latest);
Console.WriteLine($" alarm {alarm.Code}: {alarm.Text}");
}
last = state;
}
Thread.Sleep(200);
}
robot.Disconnect();
}
}

The program builds a line of text from the status and the job, and prints it only when it changes. When an alarm is active, it also prints the latest alarm.

Polling period

Each read is one request. Two reads every 200 ms is 10 requests per second. Choose the period from what you need to see: 100 ms to 500 ms for a supervision screen, a few seconds for a log.

Run the loop in its own thread, so that the user interface stays responsive. One YaskawaRobot can be used by several threads: the SDK sends one request at a time.

Troubleshooting

  • A SocketException from time to time: a request did not get its answer before DataTimeoutMilliseconds. Catch it in the loop, count the failures, and report a lost connection after several failures in a row.
  • The job name is empty: no job is selected.

What to read next

  • Status and servo: all the flags of the status.
  • Read and reset alarms.

Integre fácilmente robots Universal Robots, Fanuc, Yaskawa, ABB o Staubli en sus aplicaciones .NET, Python, LabVIEW o Matlab

UnderAutomation
ContactosLegal

© All rights reserved.