UnderAutomation
Une question ?

[email protected]

Contactez-nous
UnderAutomation
⌘Q
Fanuc SDK documentation
Enable TELNET on your robot
Documentation home

Overview of TELNET interface

Telnet KCL allows you to send commands to a Fanuc robot, such as resetting alarms, writing variables, setting an IO, and more.

Once the TELNET link has been set up on the robot, you can initiate a connection on this interface to send commands to the robot and retrieve its status.

Connect to the robot

Connect to a real robot

To connect to a real robot, you must specify the IP address of the robot and the Telnet password.

// Enable Telnet and set the password
ConnectionParameters = new ConnectionParameters("192.168.0.1");
parameters.Telnet.Enable = true;
parameters.Telnet.TelnetKclPassword = "TelnetPasswd";
// Create a new instance of the FanucRobot class
FanucRobot robot = new FanucRobot();
// Connect to the robot
robot.Connect(parameters);

Connect to a ROBOGUIDE simulated robot

To connect to a ROBOGUIDE simulated robot, you must specify the path to the robot folder, and not the IP address. The SDK will read the file services.txt located in this folder and extract the TCP ports to use.

// Enable Telnet and set the password
ConnectionParameters = new ConnectionParameters("C:\\path\\to\\your\\robot\\folder");
parameters.Telnet.Enable = true;
parameters.Telnet.TelnetKclPassword = "TelnetPasswd";
// Create a new instance of the FanucRobot class
FanucRobot robot = new FanucRobot();
// Connect to the robot
robot.Connect(parameters);

Try It

You can download the Windows Example to test the Telnet connection to your robot. It can be downloaded from the download page.

Fanuc

Send commands

Remote control via Telnet KCL can be used to send commands to the robot, such as resetting alarms, running a program, etc.

Reset alarms

/// Enables servo power after an error condition has shut off servo power, provided the cause of the error has been cleared.
/// The command also clears the message line on the CRT/KB display. The error message remains displayed if the error condition still exists.
/// The Reset() command has no effect on a program that is being executed. It has the same effect as the FAULT RESET button on the operator panel and the RESET function key on the teach pendant RESET screen.
robot.Telnet.Reset();

Set variable value

/// Assigns the specified value to the specified variable. You can assign constant values or variable values, but the value must be of the data type that has been declared for the variable.
/// You can assign values to system variables with KCL write access, to program variables, or to standard and user-defined variables and fields. You can assign only one ARRAY element.
/// Use brackets ([]) after the variable name to specify an element.
/// Certain data types like positions and vectors might have more than one value specified.
robot.Telnet.SetVariable("VariableName", NewValue);

Set ports

The following port types can be handled :

public enum KCLPorts {
DIN,
DOUT,
RDO,
OPOUT,
TPOUT,
WDI,
WDO,
AIN,
AOUT,
GIN,
GOUT
}

The SDK allows to simulate, unsimulate and set port values.

/// Assigns the specified value to a specified input or output port. SET PORT can be used either physical Or simulated output ports, but only With simulated input ports.
robot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);
/// Simulating I/O allows you to test a program that uses I/O. Simulating I/O does not actually send output signals or receive input signals.
/// When simulating a port value, you can specify its initial simulated value or allow the initial value to be the same as the physical port value. If no value is specified, the current physical port value is used.
robot.Telnet.Simulate(KCLPorts.DIN, 3, 1);
robot.Telnet.Unsimulate(KCLPorts.DIN, 3);
robot.Telnet.UnsimulateAll();

Handle programs

To enable the SDK to control the programs, the following variables must have the correct configuration values:

  • $REMOTE_CFG.$REMOTE_TYPE = 1 (1=remote, 2=local, 3=external IO, 4=op panel key)
  • $RMT_MASTER = 1 (0=UOP, 1=KCL, 2=PCDK, 3=Remote device)

Also go to Menu / NEXT / SYSTEM / Config and make sure "42 Remote / local setup" is on "1 Remote" (it can also be set to 3 or 4 if the external IO or Panel is in remote config)

// BTW, you can use the SDK to write these values, for example just after your app has connected to the robot
robot.Telnet.SetVariable("$REMOTE_CFG.$REMOTE_TYPE", 1);
robot.Telnet.SetVariable("$RMT_MASTER", 1);

You can run, pause, hold, abort or clear any TP or Karel program that is stored in the robot memory.

/// Executes the specified program (TP or Karel). The program must be loaded in memory
/// If no program is specified the default program is run. If uninitialized variables are encountered, program execution is paused.
/// Execution begins at the first executable line.
/// RUN is a motion command; therefore, the device from which it is issued must have motion control. If a RUN command is issued in a command file, it is executed as a NOWAIT command.
/// Therefore, the statement following the RUN command will be executed immediately after the RUN command is issued without waiting for the program, specified by the RUN command, to end.
robot.Telnet.Run("MyPrg");
/// Aborts the specified running or paused task. If prog_ name is not specified, the default program Is used.
/// Execution of the current program statement Is completed before the task aborts except for the current motion, DELAY, WAIT, Or READ statements, which are canceled.
robot.Telnet.Abort("MyPrg", force: true);
robot.Telnet.AbortAll(force: true);
/// Pauses the specified running task. If program is not specified, the default program is used.
/// Execution of the current motion segment and the current program statement is completed before the task is paused.
/// Condition handlers remain active. If the condition handler action is NOPAUSE and the condition is satisfied, task execution resumes.
/// If the statement is a WAIT FOR and the wait condition is satisfied while the task is paused, the statement following the WAIT FOR is executed immediately when the task is resumed.
/// If the statement is a DELAY, timing will continue while the task is paused.
/// If the delay time is finished while the task is paused, the statement following the DELAY is immediately executed when the task is resumed.
/// If the statement is a READ, it will accept input even though the task is paused.
/// The Continue() command resumes execution of a paused task.
/// When a task is paused, the CYCLE START button on the operator panel has the same effect as the KCL> CONTINUE command.
robot.Telnet.Pause(cbPrograms.Text, force: true);
/// Pauses the specified or default program that is being executed and holds motion at the current position (after a normal deceleration).
/// Use the Continue() command Or the CYCLE START button On the Operator panel To resume program execution.
robot.Telnet.Hold("MyPrg");
/// Continues program execution of the specified task (or all paused tasks if program argument is null) that has been paused by a hold, pause, or test run operation.
/// If the program Is aborted, the program execution Is started at the first executable line.
/// When a task Is paused, the CYCLE START button on the operator panel has the same effect as the Continue() command.
/// Continue is a motion command; therefore, the device from which it Is issued must have motion control.
robot.Telnet.Continue("MyPrg");
/// Clears the program data from memory for the specified or default program.
robot.Telnet.ClearProgram("MyPrg");
/// Clears the variable and type data associated with the specified or default program from memory.
/// Variables And types that are referenced by a loaded program are Not cleared.
robot.Telnet.ClearVars("MyPrg");

API Reference

Members of Telnet.TelnetClient :
public class TelnetClient : TelnetClientBase {
// Create a new instance of a robot communication
public TelnetClient()
// Connect to a robot
public void Connect(string ip, string telnetKclPassword)
}
Members of Telnet.Internal.TelnetClientBase :
public abstract class TelnetClientBase {
protected TelnetClientBase()
// Aborts the specified running or paused task. If prog_ name is not specified, the default program Is used.
// Execution of the current program statement Is completed before the task aborts except for the current motion, DELAY, WAIT, Or READ statements, which are canceled.
public DefaultResult Abort(string program, bool force)
// Aborts all running or paused tasks.
// Execution of the current program statement Is completed before the task aborts except for the current motion, DELAY, WAIT, Or READ statements, which are canceled.
public DefaultResult AbortAll(bool force)
// Clears all KAREL and teach pendant programs and variable data from memory.
// All cleared programs And variables (if they were saved with the SaveVars() command) can be reloaded into memory Using the Load() command.
public DefaultResult ClearAll()
// Clears the program data from memory for the specified or default program.
public DefaultResult ClearProgram(string program)
// Clears the variable and type data associated with the specified or default program from memory.
// Variables And types that are referenced by a loaded program are Not cleared.
public DefaultResult ClearVars(string program)
// Occurs when a KCL command is received.
public event EventHandler<KclCommandReceived> CommandReceived
// Occurs when a command is sent.
public event EventHandler<CommandSentEventArgs> CommandSent
// Is Telnet client connected
public bool Connected { get; }
// Continues program execution of the specified task (or all paused tasks if program argument is null) that has been paused by a hold, pause, or test run operation.
// If the program Is aborted, the program execution Is started at the first executable line.
// When a task Is paused, the CYCLE START button on the operator panel has the same effect as the Continue() command.
// Continue is a motion command; therefore, the device from which it Is issued must have motion control.
public DefaultResult Continue(string program = null)
// Disconnect Telnet client from robot
public void Disconnect()
// Occurs when an error occurs in the KCL client.
public event EventHandler<KclClientErrorEventArgs> ErrorOccured
// Returns the position of the TCP relative to the current user frame of reference with an x, y, and z location in millimeters; w, p, and r orientation in degrees; and the current configuration string. Be sure the robot is calibrated.
public DefaultResult GetCurrentPose()
// Returns the status information of the specified or default program being executed.
public DefaultResult GetProgramInformation(string name)
// Return the task control data for the specified task. If prog_name is not specified, the default program is used
public TaskInformationResult GetTaskInformation(string prog_name)
// Get the name, type, and value of the specified variable.
// You can display the values of system variables that allow KCL read access or the values of program variables.
// Use brackets ([]) after the variable name to specify a specific ARRAY element. If you do not specify a specific element the entire variable is displayed. '''
public GetVariableResult GetVariable(string name, string program = null)
// Pauses the specified or default program that is being executed and holds motion at the current position (after a normal deceleration).
// Use the Continue() command Or the CYCLE START button On the Operator panel To resume program execution.
public DefaultResult Hold(string program = null)
// Connect robot IP address or host name
public string IP { get; }
// Occurs when a message is received.
public event EventHandler<MessageReceivedEventArgs> MessageReceived
// Pauses the specified running task. If program is not specified, the default program is used.
// Execution of the current motion segment and the current program statement is completed before the task is paused.
// Condition handlers remain active. If the condition handler action is NOPAUSE and the condition is satisfied, task execution resumes.
// If the statement is a WAIT FOR and the wait condition is satisfied while the task is paused, the statement following the WAIT FOR is executed immediately when the task is resumed.
// If the statement is a DELAY, timing will continue while the task is paused.
// If the delay time is finished while the task is paused, the statement following the DELAY is immediately executed when the task is resumed.
// If the statement is a READ, it will accept input even though the task is paused.
// The Continue() command resumes execution of a paused task.
// When a task is paused, the CYCLE START button on the operator panel has the same effect as the KCL&gt; CONTINUE command.
public DefaultResult Pause(string program = null, bool force = false)
// Occurs when raw data is received.
public event EventHandler<RawDataReceivedEventArgs> RawDataReceived
// Enables servo power after an error condition has shut off servo power, provided the cause of the error has been cleared.
// The command also clears the message line on the CRT/KB display. The error message remains displayed if the error condition still exists.
// The Reset() command has no effect on a program that is being executed. It has the same effect as the FAULT RESET button on the operator panel and the RESET function key on the teach pendant RESET screen.
public DefaultResult Reset()
// Executes the specified program. The program must be loaded in memory
// If no program is specified the default program is run. If uninitialized variables are encountered, program execution is paused.
// Execution begins at the first executable line.
// RUN is a motion command; therefore, the device from which it is issued must have motion control. If a RUN command is issued in a command file, it is executed as a NOWAIT command.
// Therefore, the statement following the RUN command will be executed immediately after the RUN command is issued without waiting for the program, specified by the RUN command, to end. '''
public DefaultResult Run(string program)
// Assigns the specified value to a specified input or output port. SET PORT can be used either physical Or simulated output ports, but only With simulated input ports.
public DefaultResult SetPort(KCLPorts port, int index, int value)
// Assigns the specified value to the specified variable. You can assign constant values or variable values, but the value must be of the data type that has been declared for the variable.
// You can assign values to system variables with KCL write access, to program variables, or to standard and user-defined variables and fields. You can assign only one ARRAY element.
// Use brackets ([]) after the variable name to specify an element.
// Certain data types like positions and vectors might have more than one value specified. '''
public DefaultResult SetVariable(string name, int value, string program = null)
// Assigns the specified value to the specified variable. You can assign constant values or variable values, but the value must be of the data type that has been declared for the variable.
// You can assign values to system variables with KCL write access, to program variables, or to standard and user-defined variables and fields. You can assign only one ARRAY element.
// Use brackets ([]) after the variable name to specify an element.
// Certain data types like positions and vectors might have more than one value specified. '''
public DefaultResult SetVariable(string name, string value, string program = null)
// Simulating I/O allows you to test a program that uses I/O. Simulating I/O does not actually send output signals or receive input signals.
// When simulating a port value, you can specify its initial simulated value or allow the initial value to be the same as the physical port value. If no value is specified, the current physical port value is used. '''
public DefaultResult Simulate(KCLPorts port, int index, int value)
// Skips execution of the current statement in the specified task.
// If programm is not specified, the default program is used.
// It has no effect when a task is running or when the system is in a READY state.
// Entire motion statements are skipped with this command. You cannot skip single motion segments.
// The Continue() command resumes execution of the paused task with the statement following the last skipped statement. END statements cannot be skipped.
// If you skip the last RETURN statement in a function routine, there is no way to return the value of the function to the calling program. Therefore, when executing the END statement of the routine, the task will abort.
// If you skip into a FOR loop, you have skipped the statement that initializes the loop counter. When the ENDFOR statement is executed the program will try to remove the loop counter from the stack. If the FOR loop was nested in another FOR loop, the loop counter for the previous FOR loop will be removed from the stack, causing potentially invalid results. If the FOR loop was not nested, a stack underflow error will occur, causing the task to abort.
// READ, MOVE, DELAY, WAIT FOR, and PULSE statements can be paused after they have begun execution. In these cases, when the task is resumed, execution of the paused statement must be finished before subsequent statements are executed. Subsequent skipped statements will not be executed.
// In particular, READ and WAIT FOR statements often require user intervention, such as entering data, before statement execution is completed.
// Step mode operation and step mode type have no effect on the Skip() command.
public object Skip(string program = null)
public TpCoordinates TpCoordinates { get; }
// Occurs when TP coordinates are received.
public event EventHandler<TpCoordinatesReceivedEventArgs> TpCoordinatesReceived
// Discontinues simulation of the specified input or output port. When a port is unsimulated, the physical value replaces the simulated value.
public object Unsimulate(KCLPorts port, int index)
// Discontinues simulation on all input or output port. When a port is unsimulated, the physical value replaces the simulated value.
public object UnsimulateAll()
}

Intégrez facilement les robots Universal Robots, Fanuc, Yaskawa ou Staubli dans vos applications .NET, Python, LabVIEW ou Matlab

UnderAutomation
Contactez-nousTarifs • DistributeursDevis • CommandeLegal

© All rights reserved.