UnderAutomation
Eine Frage?

[email protected]

Kontakt
UnderAutomation
⌘Q
Fanuc SDK documentation
Program control via Telnet
Documentation home

Variables & I/O via Telnet

Read and write system variables, set output ports, simulate and unsimulate input ports using Telnet KCL.

Read and write system variables, set output ports, simulate and unsimulate input ports using Telnet KCL.

Read and write variables

// Read a variable
GetVariableResult result = robot.Telnet.GetVariable("$RMT_MASTER");
string value = result.RawValue;
// Write a variable
robot.Telnet.SetVariable("$RMT_MASTER", 1);
robot.Telnet.SetVariable("$MCR.$GENOVERRIDE", 50);
robot.Telnet.SetVariable("$[MY_PROG]my_var", "hello");
// Get current pose
GetCurrentPoseResult pose = robot.Telnet.GetCurrentPose();

You can read any system variable, program variable, or user-defined variable by name. The value must match the declared data type. Use brackets ([]) after the variable name to specify an array element.

Set and simulate I/O ports

// Set an output port (DOUT port 2 = OFF)
robot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);
// Set an output port (DOUT port 5 = ON)
robot.Telnet.SetPort(KCLPorts.DOUT, 5, 1);
// Simulate an input port (DIN port 3 = ON)
robot.Telnet.Simulate(KCLPorts.DIN, 3, 1);
// Stop simulating DIN port 3
robot.Telnet.Unsimulate(KCLPorts.DIN, 3);
// Stop simulating all ports
robot.Telnet.UnsimulateAll();

Available port types

The KCLPorts enum defines the available port types:

PortDescription
DIN / DOUTDigital Input / Output
GIN / GOUTGroup Input / Output
AIN / AOUTAnalog Input / Output
OPIN / OPOUTOperator Panel Input / Output
RDI / RDORobot Digital Input / Output
WDI / WDOWeld Digital Input / Output
PLCIN / PLCOUTPLC Input / Output
FLAGFlag register

Complete example

using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Telnet;
public class TelnetVariablesIo
{
static void Main()
{
FanucRobot robot = new FanucRobot();
ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
parameters.Telnet.Enable = true;
parameters.Telnet.TelnetKclPassword = "TELNET_PASS";
robot.Connect(parameters);
/**/
// Read a system variable
GetVariableResult result = robot.Telnet.GetVariable("$RMT_MASTER");
string value = result.RawValue;
// Write system variables
robot.Telnet.SetVariable("$RMT_MASTER", 1);
robot.Telnet.SetVariable("$MCR.$GENOVERRIDE", 50);
// Get current TCP pose
GetCurrentPoseResult pose = robot.Telnet.GetCurrentPose();
// Set an output port
robot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);
robot.Telnet.SetPort(KCLPorts.DOUT, 5, 1);
// Simulate an input port
robot.Telnet.Simulate(KCLPorts.DIN, 3, 1);
// Stop simulating a port
robot.Telnet.Unsimulate(KCLPorts.DIN, 3);
// Stop simulating all ports
robot.Telnet.UnsimulateAll();
/**/
}
}

API reference

Members of Common.Kcl.GetVariableResult :
public class GetVariableResult : Result {
public GetVariableResult()
// Indicates that responses have been completed and received
protected override void EndReceive()
// During implementation, return true if it is assumed that the frame has finished being received.
protected override bool FromResult(string data)
// Returns a structured object which represents the variable (not supported with Telnet)
public GenericVariable ParseResult()
// Gets the raw value of the variable as a string.
public string RawValue { get; }
// Controls whether the result should be finalized when an empty answer is received (i.e. a frame consisting only of VT100 escape sequences and whitespace).
// Override and return false until meaningful data has been accumulated, to prevent premature finalization caused by intermediate display-update frames.
// Default is true (backward compatible: finalize immediately on empty answer).
protected override bool ShouldCompleteOnEmptyAnswer()
public override string ToString()
}
Members of Common.Kcl.SetVariableResult :
public class SetVariableResult : SetValueResult {
public SetVariableResult()
// During implementation, return true if it is assumed that the frame has finished being received.
protected override bool FromResult(string data)
// Controls whether the result should be finalized when an empty answer is received (i.e. a frame consisting only of VT100 escape sequences and whitespace).
// Override and return false until meaningful data has been accumulated, to prevent premature finalization caused by intermediate display-update frames.
// Default is true (backward compatible: finalize immediately on empty answer).
protected override bool ShouldCompleteOnEmptyAnswer()
}
Members of Common.Kcl.SetPortResult :
public class SetPortResult : SetValueResult {
public SetPortResult()
// During implementation, return true if it is assumed that the frame has finished being received.
protected override bool FromResult(string data)
}
Members of Common.Kcl.SimulateResult :
public class SimulateResult : BaseResult {
public SimulateResult()
}
Members of Common.Kcl.KCLPorts :
public enum KCLPorts {
// Analog Input port.
AIN = 7
// Analog Output port.
AOUT = 8
// Digital Input port.
DIN = 0
// Digital Output port.
DOUT = 1
// General Input port.
GIN = 9
// General Output port.
GOUT = 10
// Operator Panel Output port.
OPOUT = 3
// Robot Digital Output port.
RDO = 2
// Teach Pendant Output port.
TPOUT = 4
// Weld Digital Input port.
WDI = 5
// Weld Digital Output port.
WDO = 6
}

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.