0% found this document useful (0 votes)
4 views

RemoteAPI example program for Leantec Robot(ENG)

The document provides a comprehensive guide on using the RemoteAPI for Leantec Robots, detailing connection settings, basic and advanced operations, and programming methods. It includes instructions for establishing connections between the controller and PC, monitoring robot status, and executing commands. Additionally, it outlines safety warnings and troubleshooting tips for effective remote operation and programming.

Uploaded by

Văn Tuyến
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

RemoteAPI example program for Leantec Robot(ENG)

The document provides a comprehensive guide on using the RemoteAPI for Leantec Robots, detailing connection settings, basic and advanced operations, and programming methods. It includes instructions for establishing connections between the controller and PC, monitoring robot status, and executing commands. Additionally, it outlines safety warnings and troubleshooting tips for effective remote operation and programming.

Uploaded by

Văn Tuyến
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

RemoteAPI example program for Leantec Robot.

匯出日期:2024-11-29
修改日期:2021-07-29
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

內容

目錄

1. Introduction of RemoteAPI
2. Connection Setting
2.1 Connection Settings of Controller
2.2 Download RemoteAPI sample program
2.3 PC Connection Setting
2.4 Check Connection Status
3. Basic Operation
3.1 One-to-many connection
3.2 HMI Component Description
3.2.1 Status monitoring component
3.2.2 File operation compoenent
3.2.3 Machine running setting component
3.3 Robot programming operation
3.3.1 Programming with controller
3.3.2 Progamming with PC
4. Advanced Operation
5. Appendix
5.1 PLC Component Description
5.2 MACRO Variable
5.3 Robot Programming Syntax
6. Reference

–2
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

1 1. Introduction of RemoteAPI

Syntec controller architecture used a set of Application Programming Interface (API) to connect the Human-
Machine Interface (HMI) and the kernel, which allows user to use a simple, easy-to-understand and easy-to-
operate interface (such as handheld pendant, controller panel) to operate the machine. However, RemoteAPI
is developed due to the demand for remote operation and remote monitoring increases, and to meet the
needs of cross-platform program development. Syntec dipole function separates the HMI from the kernel,
which allows user to control the back-end controller through the Internet through the application of the front
desk (such as a standard HMI). User can utilize this architecture to perform remote monitoring and diagnosis,
and the development environment of front desk applications is no longer limited to Windows CE platform. The
applications can be developed in different platform such as Windows XP and Windows 7, which can be
developed to create unlimited possibility.
Applicable Software Version: 10.118.12A and above

 Warning
RemoteAPI sample code of the robot provides 'cycle start' function, but it is strongly not recommended
user to use unless necessary. If user wants to use cycle start function remotely, please ensure that the
robot is within user's sight, emergency stop button is located where the user can access easily, lower down
the override feedrate, and no error in the programs before cycle start.

Version 10.118.12G and below


The controller software version 10.118.12G and before required to modify its PLC in order to use
RemoteAPI to perform cycle start function. Below shows the modification the cycle start function in
PLC.

1. Introduction of RemoteAPI – 3
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Origin
al PLC

Modifi
ed PLC

1. Introduction of RemoteAPI – 4
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

2 2. Connection Setting
RemoteAPI used Ethernet to connect controller and PC. hence it is required to do setting on controller and PC
respectively. This chapter explains the steps of connection settings, check connection status and
troubleshooting. In addition, RemoteAPI also can connect to simulator but the HMI of the simulator and
RemoteAPI are different system, therefore the simulator will not show updated coordinate information when
execute moving command by RemoteAPI, and vice versa.

2.1 2.1 Connection Settings of Controller


1. Login to Level 3 (Expert Level) and above authority, if using RemoteAPI connects to simulator, then can
skip this connection settings.

2. Go to F5 System → F2 Maintain → F2 Network Setting → F5 Kernel Server, will show two parameters:
a. Start server at boot: Automatically activate the kernel Dipole function when booting, select "On".
b. Timeout (milliseconds): When there is no response from the network for more than the timeout
setting, the network connection will be interrupted. It is recommended to set to 0 (the network
connection is not interrupted).
Press F1 to start the server and F3 to confirm after setting completed.

3. Then make the following three sets of settings on the "IP Address Parameter" page:
a. IP Address Setting set as "Specify an IP Address.
b. Fill up the IP address, normally used 192.168.0.x
c. Subnet Mask used 255.255.255.0。

2. Connection Setting – 5
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Press F1 to save the settings after completed, then the connection settings of controller is done.

 Since the "Start server at boot" function has been turned on in step 3, hence no need to do
settings again after the next boot.
After the setting is completed, check the PLC S bit (S98). If S98 is on, it means that the kernel
server is turned on.

2.2 2.2 Download RemoteAPI sample program


Please go to Syntec official website to download RemoteAPI version 1.0.12_v4 (Software Download >
Application Tool > Syntec RemoteCNC API).
PC Environment requirement: Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
Please note that the sample program provided in this document is different from the one downloaded
from the official website. The following process will be explained with the RemoteAPI robot sample
program (RobotExample_V1.0) with the controller version 10.118.12A.

2.3 2.3 PC Connection Setting


1. Please go to Syntec official website to download latest version simulator.

2. Connection Setting – 6
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

2. Copy the files in the simulator and replace the files in the sample program. (The picture below shows
the files that need to be copied according to the program environment 32-bit or 64-bit)

 Note
Develop a 64-bit program required use the 64-bit front-end SDK environment. Please ask the
R&D unit for the latest x64 dll.

 File path in simulator: DiskC\OpenCNC\Bin\


Sample program file path: bin_v4\

空行空行
3. This step is split into two operation scenarios:
a. Connect between RemoteAPI and the controller:
Open the Control Panel> Network and Internet> Network and Sharing Center> Change the
interface card settings, right-click the area connection location, and select "Properties".
Select "Internet Protocol Version 4 (TCP/IPv4)" and click "Properties".
Select "Use the following IP address" and set the IP address to the same domain as the controller,
that is, the first 3 addresses of this IP address are the same as the controller IP address.
The subnet mask is set to 255.255.255.0.

2. Connection Setting – 7
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

 The IP address of the computer and the controller can not be exactly the same,
otherwise there will be the connection error.

b. Connect between RemoteAPI and the simulator:


Open the OCAPIServer application in the simulator folder. After opening it, you can proceed with
the following operations.
Program path: DiskC\OpenCNC\Bin\

2. Connection Setting – 8
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

2.4 2.4 Check Connection Status


1. Open the .sln file in the sample program, and the following window will appear after entering the
Debug mode.

空白
2. Enter the IP of the controller in the "Connect to IP" field and click "Connect". This IP will appear in the
"Select Connected IP" list.
To connect between RemoteAPI and the simulator, the input IP is 127.0.0.1.

2. Connection Setting – 9
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

3. Select the IP address just entered, and then click "Information". The three fields on the right will show
the current controller information.

 Check the PLC S-bit on the controller when connecting. If S99 is on, it means the controller is
connected.

4. If it is fail to connect, try the following troubleshooting methods:


a. Check if the computer has installed the Visual Studio C++ 2005 Redistributable package
b. The computer firewall needs to open port 5566/5568/5570/5572 to connect the controller and the
computer:
Go to Control Panel> System and Security> Windows Firewall> Advanced Settings> Enter Rules>
Add Rule> Port> TCP> Enter 5568, 5570> Allow all connections
c. Note that if the computer has two network cards, then adjust the priority of the network card that
connected to the controller to a higher level, then it can be connected.
Go to Control Panel> Network and Internet> Network and Sharing Center> Change interface card
settings> Press F10 to display the toolbar> Advanced> Advanced settings> Adjust the network
card which connected to controller
d. When using the v4 version, if the network is unstable and an error message is returned, please try
to connect again after ten seconds.

2. Connection Setting – 10
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

3 3. Basic Operation
This chapter explains the functions and usage of the RemoteAPI robot sample program, including connection
establishment, status and coordinate monitoring, alarm prompts, robot program file operation and execution
processing, etc.
If need to use functions other than the sample program, refer to Chapter 4 Advanced Operation or the
RemoteAPI Operation Manual and modify the code.

3.1 3.1 One-to-many connection


This sample program provides one-to-many connection function, which one computer can be connected
to multiple controllers and operate at the same time.
1. Method 1:
Enter the IP of another controller in the "Connect to IP" field and click "Connect". The IP address will
appear in the "Select Connected IP" list.
Select the IP address in the list to monitor and operate the selected controller IP.

2. Method 2:
Setting by modifying the code. First open the .sln file in the example program, right-click

3. Basic Operation – 11
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

ExampleForm.cs in the Solution Explorer column on the left, and select "View Code".

Find the controller IP setting at the 31st line of the code, and set one or more groups of IP by user. After
entering the Debug mode, these IPs will appear in the "Select Connected IP" list.

// Add your CNCs' host-ip here


SyntecRemoteCNC cnc = new SyntecRemoteCNC( "192.168.0.91" );
m_CNC.Add( cnc );
cnc = new SyntecRemoteCNC( "127.0.0.1" );
m_CNC.Add( cnc );

3. Basic Operation – 12
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

3.2 3.2 HMI Component Description

3.2.1 3.2.1 Status monitoring component

1. Joint Coordinate List: Display the name of all axis and its joint coordinate, update every 300ms.
2. Tool Center Point (TCP) List: Display current coordinate in the current coordinate system,
update every 300ms.
3. Current Information List: Display current selected information, if controller have alarm then it
will display in this field and overwrite the current display information.
4. Information Button: Display information of the controller, includes controllable axes, machine
type, maximum axes, controller series, and controller version.
5. Status Button: Display current controller status, includes main program, current program,
current program line, machine mode, and machine status.
6. NC File List Button: Display all NC files in the controller.
7. PLC bits Column: Display PLC I/O/C/S/A bit or Register value.
For example, if want to display the value of S33 to confirm whether the boot is completed and the
system is normal, enter "S33" in this field and click the "Read" button, and the information will be
displayed in the Current Information list.
Similarly, if want to display the Register number 13 to confirm the current mode, enter "R13" and
click the "Read" button.

3. Basic Operation – 13
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

3.2.2 3.2.2 File operation compoenent

1. Upload NC File Button: Upload NC Files to controller.


2. Download NC File Button: Download NC File to PC.
First press the "NC File List" button, and select the program to be downloaded listed in the
"Current Information" field, and then press this button to download the NC file.
3. Delete NC File Button: Delete the selected NC file in the controller.
First press the "NC File List" button, and select the program to be deleted listed in the "Current
Information" field, and then press this button to delete the NC file.
4. Set Main NC File Button: Assign the NC file in the controller as main program.
First press the "NC File List" button, and select the program to be assigned as main program
listed in the "Current Information" field, and then press this button to assign the NC file as main
program.

3. Basic Operation – 14
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

3.2.3 3.2.3 Machine running setting component

1. Auto Mode Button: Switch machine mode as "Auto Mode", same function as "Auto" button on
pendant.
2. Reset Button: Reset the controller, same function as "Reset" button on pendant, can reset some
alarms.
3. Rate- Button: Decrease 10% of override feedrate, same function as "OVRD -" button on pendant.
4. Rate+ Button: Increase 10% of override feedrate, same function as "OVRD +" button on pendant.
5. Start Button: Cycle start the main program, same function as "Start" button on pendant.

 If the robot is not in "Auto" mode or alarm has not been cleared, there will be no
function when press the start button.

6. Hold Button: Pause the running program, same function as "HOLD" button on the pendant.

3.3 3.3 Robot programming operation


There are two ways for robot programming operation. The first way is to edit directly on the "Program
Edit" page of the controller, and the other way is to write the MACRO code on the computer and upload it
to the controller via RemoteAPI. The following will be respectively explained these two methods.

 Do not directly set the MACRO code written on the computer as the main program of the controller,
otherwise an error will occur. Please refer to the steps in this chapter.

3. Basic Operation – 15
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

3.3.1
3.3.1 Programming with controller
1. User can access program edit page in 'F1 Program Edit' in the controller. For detailed
programming methods, please refer to the articulated robot operating manual.
The following figure shows a completed program, which the file name is 'RobotProgram'.

2. Open the RemoteAPI sample program and enter the Debug mode, enter the controller IP in the
"Connect to IP" field to connect to the robot controller, and select the IP to be operated in the
"Select Connected IP" list.
3. Click the "Status" button to confirm whether the main program is the program edited above,
please proceed with the following three steps if it is not the program:
a. Click the "NC File List" button to display all programs in the controller.
b. Select the program edited above, this example is RobotProgram.
c. Click "Set Main NC File" to set it as the main program.

3. Basic Operation – 16
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

4. Click the "Status" button to confirm whether the Mode is AUTO, click the "Auto Mode" button to
change the mode to auto mode if the robot is not in auto mode.
For safety purpose, please lower down the override feedrate when executing it for the first time.
安全起見,第一次執行前請先降低倍率。

5. Click the "Start" button to start running the program.

 Note
RemoteAPI sample code of the robot provides 'cycle start' function, but it is strongly not
recommended user to use unless necessary.
If user wants to use cycle start function remotely, please ensure that the robot is within
user's sight, emergency stop button is located where the user can access easily, lower
down the override feedrate, and no error in the programs before cycle start.

3.3.2 3.3.2 Progamming with PC


1. Call a subprogram called "SubProgram" in the 'F1 Program Edit' page in the controller. For
detailed programming methods, please refer to the articulated robot operating manual.
The following figure shows an edited program, which the file name is RobotProgram.

3. Basic Operation – 17
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

2. Write the MACRO code with PC and name the file as "SubProgram" without the extension.

 The program must end with "M99;", which represents the end of the subprogram.
3. Open the RemoteAPI sample program and enter the Debug mode, enter the controller IP in the
"Connect to IP" field to connect to controller, and select the IP to be operated in the "Select
Connected IP" list.

4. Click the "Upload NC File" button to upload the SubProgram file in the computer to the
controller.

5. Follow the step 3~5 in section 3.3.1 to start running the program.
Please do not to set SubProgram as the main program, otherwise an error will occur.
RobotProgram is set as the main program in this example.

 Note
RemoteAPI sample code of the robot provides 'cycle start' function, but it is strongly not
recommended user to use unless necessary.
If user wants to use cycle start function remotely, please ensure that the robot is within
user's sight, emergency stop button is located where the user can access easily, lower
down the override feedrate, and no error in the programs before cycle start.

3. Basic Operation – 18
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

4 4. Advanced Operation
The RemoteAPI library provides 10 groups of more than 70 APIs. If user required to use functions other than
the sample program, user can add or modify the code by theirself.
This chapter explains the common functions provided by the RemoteAPI library which did not include in
sample program. For complete functions and detailed explaination, please refer to the RemoteAPI operation
manual or the Syntec standard one-to-many API specification.

READ_time: Time

Syntax short READ_time( out int PowerOnTime, out int AccumulateCuttingTime,


out int CuttingTimePerCycle, out int WorkTime )

Argument
Variable Type [in/out] Description

PowerOnTime int out Time of Power On


(Seconds)

AccumulateCuttin int out Accumulate Cutting


gTime Time (Seconds)

CuttingTimePerCy int out Cutting Time per


cle Cycle (Seconds)

WorkTime int out Work Time (Seconds)

DOWNLOAD_work_record: Download remote work record file

Syntax short DOWNLOAD_work_record( string Destination )

Argument
Variable Type [in/out] Description

Destination string in Downloaded file


pathway

READ_alm_history: Alarm History

Syntax short READ_alm_history( out string[] AlmMsg, out DateTime[]


AlmTime )

4. Advanced Operation – 19
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable Type [in/out] Description

AlmMsg string[] out Alarm Message

AlmTime DateTime[] out Alarm Pop Out Time


and Date

READ_macro_single: Obtain single macro variable (global variable) data

Syntax short READ_macro_single( int MacroNumber, out double MacroData )

Argument
Variable Tyoe [in/out] Desription

MacroNumber int in Macro Number

MacroData double out Macro Variable


Data

READ_nc_OPLog: Obtain Operation Log

Syntax short READ_nc_OPLog( out string[] OPLog, ref int count )

Argument
Variable Type [in/out] Description

OPLog string[] out Operation Log

count int in/out Number of records

Note 1. 'count' is the number of records to be read, and returns the number
of records read.
2. When 'count' is 0, it returns all operation logs
3. When timeout error occurs, use the SynetcRemoteCNC( ip, timeout)
constructor to increase the timeout time. Timeout = 0 means none,
and the unit of timeout is ms.
4. The OPLog returned can refer to the appendix for relevant
information.
5. If there is no Log, the original array is still returned and "No Log" is
written.

4. Advanced Operation – 20
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

READ_param_data: Obtain parameter data

Syntax short READ_param_data( int ParamStart, int ParamEnd, out int[]


ParamData )

Argument
Variable Type [in/out] Description

ParamStart int in Starting Parameter


Address

ParamEnd int in Ending Paramter


Address

ParamData int[] out Parameter Data

WRITE_param_single: Write Single Parameter Data

Syntax short WRITE_param_single( int ParamID, int val )

Argument
Variable Type [in/out] Description

ParamID int in Parameter ID

val int in Data to be overwrite to


parameter

WRITE_plc_ibit / WRITE_plc_cbit / WRITE_plc_sbit : Write PLC I/C/S-Bit Data

Syntax short WRITE_plc_ibit( int PlcStart, int PlcEnd, byte[] PlcData )


short WRITE_plc_cbit( int PlcStart, int PlcEnd, byte[] PlcData )
short WRITE_plc_sbit( int PlcStart, int PlcEnd, byte[] PlcData )

4. Advanced Operation – 21
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable Type [in/out] Description

PlcStart int in Starting Address

PlcEnd int in Ending Address

PlcData byte[] in PLC Data

WRITE_plc_register: Write PLC Register Address Data

Syntax short WRITE_plc_register( int PlcStart, int PlcEnd, int[] PlcData )

Argument
Variable Type [in/out] Description

PlcStart int in Starting Address

PlcEnd int in Ending Adress

PlcData int[] in PLC Data

READ_state_variable: System State Variable Data Information

Syntax short READ_state_variable( int StateStart, int StateEnd, out int[]


StateVariable )

Argument
Variable Type [in/out] Description

StateStart int in Starting Address

StateEnd int in Ending Address

StateVariable int[] out System State Variable


Data

READ_debug_variable: Obtain System Debug Diagnostic Data

4. Advanced Operation – 22
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Syntax short READ_debug_variable( int DebugStart, int DebugEnd, out int[]


DebugVariable )

Argument
Variable Type [in/out] Description

DebugStart int in Starting Address

DebugEnd int in Ending Address

DebugVariable int[] out System Debug


Diagnostic Data

READ_system_variable: Obtain System Coord Data (#)

Syntax short READ_system_variable( int SystemID, int SystemStart, int


SystemEnd, out double[] SystemVariable )

Argument
Variable Type [in/out] Description

SystemID int in Axis Group ID

SystemStart int in Starting Address

SystemEnd int in Ending Address

SystemVariable double[] out System Coord


Data

 The return value of 0 means the command is completed. For other information, please refer to the
operation manual for the return error description.

4. Advanced Operation – 23
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

5 5. Appendix

5.1 5.1 PLC Component Description


For a detail description, please refer to the PLC interface document. For the developing method, please
refer to the PLC development tool operating manual.
Component Overview:

Na Definition Specification Quantity


me

I Actual Input According to actual I/O card hardware installed

O Actual Output

A Auxiliary Input/Output Bit device A0~A511

C PLC Command to CNC Bit device C0~C511

S PLC Read CNC Status Bit device S0~S511

R PLC and CNC Read/Write 32- Word device R0~R65535


bit Registry

CT Auxiliary Counter Can select counting up, counting down, CT0~CT255


or repeat counter

TM Auxiliary Timer Can select unit of 1s, 0.1s, 0.01s, 0.001s TM0~TM255

Commonly used C bit:


1. C0: Cycle Start
2. C1: Feedhold/Pause
3. C6~C11: XYZ Axis JOG
4. C16~C18: Axis MPG selection
5. C20: MPG Simulation
6. C36: Emergency Stop
7. C37: External Reset Signal

Commonly used S bit:


1. S0: System Busy/Running Program
2. S1: Feedhold/Pause
3. S16~S18: Axis Homing Done

5. Appendix – 24
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

4. S32: Reset Triggered


5. S33: NC Ready
6. S98: OCAPI Server is Running
7. S99: Dipole connection in use

Commonly used R bit:

Name Description

R13 Mode Selection 1: Edit


2: Auto
3: MDI
4: JOG
5: INCJOG
6: MPG
7: HOME

R14 Increment Feed INCJOG Mode:


1: x1 LIU
2: x10 LIU
3: x100 LIU
4: x1000 LIU

MPG Mode:
1: x1 LIU
2: x10 LIU
3: x100 LIU
4: The magnified rate is set in Pr2001

Note: Please refer to Pr17 for the definition of


LIU.

R16 Feedrate Override Value shows feedrate override percentage,


minimum 10%, maximum 100%
Eg. R16=10 means override feedrate
percentage is 10%.

R17 JOG Override Same specification as R16

5. Appendix – 25
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Commonly used R-bit resources distribution list:


CNC system interface area: store the CNC system status, and the current system information can be read
by these R bits.
User-defined area: It is used as a register when the user edits the Ladder program.

Number Description Reading/Writing Regulations Bit Storage Permanent


(HMI, PLC, MACRO) Preservation

R0~R39 CNC System According to definition listed in Yes No


Interface PLC interface

R40~R49 PLC Alarm


Message

R50~R80 User-defined Read/Wirte Yes No

R103~R255 Yes

R256~R511 No

R512~R639 CNC System According to definition listed in Yes No


Interface PLC interface
R640~R1023 No

R1024~R2049 User-defined Read/Write No No

R2091~R2099

R3101~R4095

R4096~R5999 CNC System According to definition listed in No No


Interface PLC interface

R6000~R7999 User-defined Read/Write No Yes

R8000~R8255 CNC System Read/Write No Yes


Interface
R8256~R9999 Read Only No No

R11000~R14999

R20000~R65535 User-defined Read/Write No No

5. Appendix – 26
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

5.2 5.2 MACRO Variable


When writing the MACRO program and required to read/write the PLC Register, please refer to the
corresponding relationship between the public variables and the PLC Register in the following table.
For a detail description, please refer to the MACRO Variable Specification. For the developing method,
please refer to the MACRO Development Tool Operation Manual.
Global Variable

Number ID Description Read/Write Regulation Type

@0 VACANT Read -

@1~@400 Variables for general operations Read/Write Double

@656~@999 Memorable variables (which still exist after Read/Write Double


shutting down)
@1001~@1999

@100000~@165 Correspond to Registry R0~R65535 Read/Write Long


535

Note • Unless being power-off, all global variables have no life cycle limit.
• If @1~@400 needs to be remained after power-off, please goes with
No3811.

Local Variable

Number ID Description Read/Write Type


Regulation

#0 VACANT Read -

#1~#26 System-reserved local Read/Write Double


variables for MACRO
arguments

#27~#400 Local variables for MACRO Read/Write Double


program and subprogram

5. Appendix – 27
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Number ID Description Read/Write Type


Regulation

Note • The life cycle of local variables applied in MACRO is limited to the MACRO
execution. After execution is done, local variable returns to VACANT
automatically.
• Subprogram can share local variables with main program, the life cycle of local
variable also ends when main program is completed.

5.3 5.3 Robot Programming Syntax


For the complete description of robot syntax, please refer to the robot syntax instruction specification.
Robot Command Syntax

Movement Syntax

Linear Motion MOVL

Joint Motion MOVJ

Joint Motion II (Position-Input) MOVJ

Circular Motion MOVC

Incremental Linear Motion INCMOVL

Incremental Joint Motion INCMOVJ

Incremental Joint Motion (Position-Input) INCMOVJ

Application Syntax

Swaitsig SWAITSIG

Syncout SYNCOUT

Stitch Output STITCHON / STITCHOFF

Collision Avoidance PZENABLE / PZDISABLE

5. Appendix – 28
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Application Syntax

Tool Coordinate System TOOLCOR

Object Coordinate System OBJCORON / OBJCOROFF / OBJCORCLEAR

User Coordinate System USERCOR

Conveyor Tracking WAITSYNC / ENDSYNC

Interrupt Program M96 / M97

Weave WEAVEON / WEAVEOFF

Point Offset SHIFTON / SHIFTOFF

Skip SKIPCOND / SKIP

Additional Command

Speed Command FJ / FEJ / FL / FR

Smooth PL / PQ / PR

Sample Program
Using MOVL and MOVJ Command of 6-Axis Articulate Robot Arm as example, this sample program is a
sub-program, hence end the program with M99.

USERCOR P0; // WORLD COORDINATE


TOOLCOR P0; // TOOL COORDINATE: FLANGE
FL100.; // MOVEL LINEAR MOVEMENT SPEED
FJ50.; // MOVEJ JOINT MOVEMENT SPEED
MOVJ C1=0. C2=0. C3=0. C4=0. C5=20. C6=0.;
// MOVE TO Joint: 0. 0. 0. 0. 20. 0.
MOVL X190.449 Y-502.416 Z345.217 A-86.583 B139.601 C25.258 P1 Q2;
// SWITCH TO USER COORDINATE 1, TOOL COORDINATE 2
// MOVE TO COORDINATE: X190.449 Y-502.416 Z345.217 A-86.583 B139.601 C25.258
MOVJ X99.39 Y312.235 Z676.587 A-91.229 B99.508 C166.498 P2 Q2;
// MAINTAIN TOOL COORDINATE 2, SWITCH TO USER COORDINATE 2
// MOVE TO COORDINATE: X99.39 Y312.235 Z676.587 A-91.229 B99.508 C166.498

5. Appendix – 29
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

G91 MOVL Y-90. P2 Q2;


// MAINTAIN TOOL COORDINATE 2, USER COORDINATE 2
// MOVE TO COORDINATE: X99.39 Y222.236 Z676.586 A-91.229 B99.509 C166.498
TOOLCOR P0;
USERCOR P0;
// ROBOT MAINTAIN CURRENT POSITION BUT SWITCH TO TOOL COORDINATE 0 (FLANGE), USER
COORDINATE 0 (WORLD COORDINATE)
M99;

5. Appendix – 30
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

6 6. Reference
1. RemoteAPI 操作手冊
2. 新代科技標準一對多API規格書
3. 新版關節型機器人操作手冊
4. PLC介面說明
5. PLC發展工具操作手冊
6. MACRO變數規格
7. MACRO發展工具操作手冊
8. 機器人語法指令規格

6. Reference – 31
联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

7 RemoteAPI function introduction.

7.1 Data Type & Return value

Data Type
Type memory

byte 8 bits

short 16 bits

int 32 bits

float 32 bits

string XX

Return error description


Ret Error Name Introduce
urn
valu
e
(sho
rt)

-18 Not supported Not supported

-17 Protocol error (Ethernet Data from Ethernet Board is incorrect.Contact with the service
version only) section or the section in charge.

-16 Socket error (Ethernet Investigate CNC power supply, Ethernet cable and I/F board.
version only)

-15 DLL file error There is no DLL file for each CNC series corresponding to specified
node.

RemoteAPI function introduction. – 32


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Ret Error Name Introduce


urn
valu
e
(sho
rt)

-14 USBEmpty USB is empty

-13 NoUSB No USB is pulgin

-8 Handle number error Get the library handle number.

-7 Version mismatch between The CNC/PMC version does not match that of the library.Replace
the CNC/PMC and library the library or the CNC/PMC control software.

-6 Abnormal library state An unanticipated error occurred.Contact with the section in


charge.

-2 Reset or stop request The RESET or STOP button was pressed.Call the termination
function.

-1 CNC Busy Wait until the completion of CNC processing, or retry.

0 Normal termination Done,NoError

1 Error(function is not Specific function which must be executed beforehand has not
executed, or not available) been executed.Otherwise that function is not available.

2 Error(data block length Check and correct the data block length or number of data.
error, error of number of
data)

3 Error(data number error) Check and correct the data number.

4 Error(data attribute error) Check and correct the data attribute.

5 Error(data error) Check and correct the data.

6 Error(no option) There is no corresponding CNC option.

7 Error(write protection) Write operation is prohibited.

RemoteAPI function introduction. – 33


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Ret Error Name Introduce


urn
valu
e
(sho
rt)

8 Error(memory overflow) CNC tape memory is overflowed.

9 Error(CNC parameter error) CNC parameter is set incorrectly.

10 Error(buffer empty/full) The buffer is empty or full.

11 Error(path number error) A path number is incorrect.

12 Error(CNC mode error) The CNC mode is incorrect.Correct the CNC mode.

13 Error(CNC execution The execution at the CNC is rejected.Check the condition of


rejection) execution.

14 Error(Data server error) Some errors occur at the data server.

15 Error(alarm) The function cannot be executed due to an alarm in CNC.Remove


the cause of alarm.

16 Error(stop) CNC status is stop or emergency.

17 Error(State of data Data is protected by the CNC data protection function.


protection)

18 Error(Not found Machine ID) Please Check or not send CNC_CONNECTION command.

19 Error(No out) Please Check NO.

20 Error(Need to Update RemoteAPI version is too old for connected controller, need to
RemoteCnc Version) update RemoteAPI version.

RemoteAPI function introduction. – 34


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

7.2 Basic

isUSBExist
Function Name bool isUSBExist( )

Argument
Variable name Type [in/out] Introduce

None

Return value True => USB, False => None USB

SeriesNo:Controller Series No
Function Name string SeriesNo(…)

Argument
Variable Type [in/out] Introduce
name

None

Return value SeriesNo or empty

CncOption: Cnc Option

Function Name string CncOption(…)

Argument
Variable Type [in/out] Introduce
name

None

Return value Cnc Option

RemoteAPI function introduction. – 35


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

MainBoardPlatformName:Main Board Platform Name

Function Name string MainBoardPlatformName (…)

Argument
Variable name Type [in/out] Introduce

None

Return value Main Board Platform Name

READ_information:Information
Function Name short READ_information(…)

Argument
Variable name Type [in/out]

Axes short out

CncType string out

MaxAxes short out

Series string out

Nc_Ver string out

AxisName string[] out

Return value 0:Complete the operation, please refer to Return error


description

READ_status:status
Function Name short READ_status(…)

RemoteAPI function introduction. – 36


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable name Type [in/out] Introduce

MainProg string out Main prog name

CurProg string out Current execute


prog

CurSeq x out No support,


default -1

Mode string out ex:"MDI",


"MEM"…

Status string out ex:"STOP",


"START"…

Alarm string out ex:"ALARM",


"****"

EMG string out ex:"EMG", "****"

Return value 0:Complete the operation, please refer to Return error


description

READ_position:Position
Function short READ_position(…)
Name

RemoteAPI function introduction. – 37


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable Type [in/out] Introduce
name

AxisName string[] out X

DecPoint short out X

Unit string[] out X

Mach float[] out Mach


Position

Abs float[] out Absolute


Position

Rel float[] out Relative


Position

Dist float[] out Remain


Position

Return 0:Complete the operation, please refer to Return error


value description

READ_gcode:G Code
Function Name short READ_gcode(…)

Argument
Variable name Type [in/out] Introduce

Gdata string[] out G Code

Return value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 38


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

READ_othercode:Other Code(H Code,D Code,T Code,M Code,B Code,F Code,S


Code)
Function Name short READ_othercode(…)

Argument
Variable name Type [in/out] Introduce

HCode int out H Code

DCode int out D Code

TCode int out T Code

MCode int out M Code

FCode int out F Code

SCode int out S Code

Return value 0:Complete the operation, please refer to Return error


description

READ_spindle:spindle speed
Function Name short READ_spindle(…)

Argument
Variable name Type [in/out] Introduce

OvFeed float out Feed Rate Over


Ride

OvSpindle float out Spindle Over Ride

ActFeed float out Feed

ActSpindle int out Spindle spedd

RemoteAPI function introduction. – 39


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Return value 0:Complete the operation, please refer to Return error


description

READ_time:time
Function Name short READ_time(…)

Argument
Variable name Type [in/out]

PowerOnTime int out

AccumulateCuttingTime int out

CuttingTimePerCycle int out

WorkTime int out

Return value 0:Complete the operation, please refer to Return error


description

DOWNLOAD_work_record:
Function Name short DOWNLOAD_work_record (…)

Argument
Variable name Type [in/out] Introduce

Destination string in Destination


path

Return value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 40


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

READ_MakerConfigInfo
Function Name short READ_MakerConfigInfo(…)

Argument
Variable name Type [in/out]

szModel string out

szMachSN string out

szDate string out

szDevSN string out

szPhone string out

Return value 0:Complete the operation, please refer to Return error


description

WRITE_MakerConfigInfo
Function Name short WRITE_MakerConfigInfo(…)

Argument
Variable name Type [in/out]

szModel string in

szMachSN string in

szDate string in

szDevSN string in

szPhone string in

Return value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 41


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

7.3 Alarm Function

READ_alm_current:Current alarm
Function Name short READ_alm_current(…)

Argument
Variable name Type [in/out]

IsAlarm bool out

AlmMsg String[] out

AlmTime DateTime[] out

Return value 0:Complete the operation, please refer to Return error


description

READ_alm_history:alarm history
Function Name short READ_alm_history(…)

Argument
Variable name Type [in/out]

AlmMsg string[] out

AlmTime DateTime[] out

Return value 0:Complete the operation, please refer to Return error


description

Function Name short READ_alm_history(…)

RemoteAPI function introduction. – 42


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable name Type [in/out]

AlmMsg string[] out

AlmTime DateTime[] out

Duration uint[] out

Clear bool[] out

Return value 0:Complete the operation, please refer to Return error


description

7.4 Nc Program Function

WRITE_nc_main:Define which program to execute


Function Name short WRITE_nc_main(…)

Argument1
Variable name Type [in/out]

szProgName string in

Argument2
Variable name Type [in/out] Introduce

szProgName int in X

nCoordID int in set 1

nLineNumber int in Start line no

Return value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 43


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

READ_nc_mem_list:Get program list


Function Name short READ_nc_mem_list(…)

Argument
Variable Type [in/out] Introduce
name

NcList string[][] out program list

Return value 0:Complete the operation, please refer to Return error


description

UPLOAD_nc_mem:Upload program from controller


Function Name short UPLOAD_nc_mem(…)

Argument
Variable name Type [in/out] Introduce

Source string in File path

Return value 0:Complete the operation, please refer to Return error


description

DOWNLOAD_nc_mem:Download program from controller


Function Name short UPLOAD_nc_mem(…)

Argument
Variable name Type [in/out] Introduce

Source string in Program name

Destination string in Path

RemoteAPI function introduction. – 44


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Return value 0:Complete the operation, please refer to Return error


description

DEL_nc_mem:Delete controller program


Function Name short DEL_nc_mem(…)

Argument
Variable name Type [in/out]

Name string in

Return value 0:Complete the operation, please refer to Return error


description

READ_nc_freespace:Controller free space


Function Name short READ_nc_freespace(…)

Argument
Variable name Type [in/out]

FreeSpace Long out

Return value 0:Complete the operation, please refer to Return error


description

7.5 PLC Function

READ_plc_type:Get PLC component Type


Function Name short READ_plc_type(…)

RemoteAPI function introduction. – 45


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable name Type [in/out] Introduce

Addr string in ex:I,O,C,S,A,R

PlcType short out 0:byte 1:short


2:int

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_type2:Get PLC component Type


Function Name short READ_plc_type2(…)

Argument
Variable name Type [in/out] Introduce

Addr string in ex:I,O,C,S,A,R

PlcType short out 0:byte 1:short


2:int

PlcStart int out Plc Start address

PlcEnd int out Plc End address

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_addr:Get PLC address


Function Name short READ_plc_addr(…)

RemoteAPI function introduction. – 46


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable Type [in/out] Introduce
name

Addr string in ex:I,O,C,S,A,R

PlcStart int in Plc Start address

PlcEnd int in Plc End address

PlcType short out 0:byte 1:short


2:int

PlcDataB byte[] out X

PlcDataS short[] out X

PlcDataI int[] out X

Return Value 0:Complete the operation, please refer to Return error


description

WRITE_plc_addr:Write PLC address


Function Name short WRITE_plc_addr(…)

RemoteAPI function introduction. – 47


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable Type [in/out] Introduce
name

Addr string in ex:I,C,S,R

PlcStart int in Plc Start address

PlcEnd int in Plc End address

PlcType short in 0:byte 1:short


2:int

PlcDataB byte[] in X

PlcDataS short[] in X

PlcDataI int[] in X

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_ver:PLC version
Function Name short READ_plc_ver(…)

Argument
Variable name Type [in/out]

Version string out

Return Value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 48


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

READ_plc_ibit:Get PLC I Bit

READ_plc_obit:Get PLC O Bit

READ_plc_cbit:Get PLC C Bit

READ_plc_sbit:Get PLC S Bit

READ_plc_abit:Get PLC A Bit


Function Name short READ_plc_ibit(…)
short READ_plc_obit(…)
short READ_plc_cbit(…)
short READ_plc_sbit(…)
short READ_plc_abit(…)

Argument
Variable name Type [in/out] Introduce

PlcStart int in Start address

PlcEnd int in End address

PlcData byte[] out Plc Data(byte)

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_register:Get PLC Register


Function Name short READ_plc_register(…)

RemoteAPI function introduction. – 49


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable name Type [in/out] Introduce

PlcStart int in Start address

PlcEnd int in End address

PlcData int[] out X

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_register:Get PLC Register String Data


Function Name short READ_plc_register(…)

Argument
Variable name Type [in/out] Introduce

RAddress int in X

PlcData string out X

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_timer:Get PLC Timer


Function Name short READ_plc_timer(…)

RemoteAPI function introduction. – 50


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

Argument
Variable name Type [in/out] Introduce

PlcStart int in Start address

PlcEnd int in End address

PlcTimerValue int[] out X

PlcTimerSettin int[] out X


g

PlcTimerState short[] out X

Return Value 0:Complete the operation, please refer to Return error


description

READ_plc_counter:Get PLC Counter


Function Name short READ_plc_timer(…)

Argument
Variable name Type [in/out] Introduce

PlcStart int in Start address

PlcEnd int in End address

PlcCounterValue int[] out X

PlcCounterSetti int[] out X


ng

PlcCounterState short[] out X

Return Value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 51


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

WRITE_plc_ibit:Write PLC I BIT

WRITE_plc_cbit:Write PLC C BIT

WRITE_plc_sbit:Write PLC S BIT


Function Name short WRITE_plc_ibit(…)
short WRITE_plc_cbit(…)
short WRITE_plc_sbit(…)

Argument
Variable name Type [in/out] Introduce

PlcStart int in Start address

PlcEnd int in End address

PlcData byte[] in X

Return Value 0:Complete the operation, please refer to Return error


description

WRITE_plc_register:Write PLC Register


Function Name short WRITE_plc_register(…)

Argument
Variable name Type [in/out] Introduce

PlcStart int in Start address

PlcEnd int in End address

PlcData int[] in X

Return Value 0:Complete the operation, please refer to Return error


description

RemoteAPI function introduction. – 52


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

RemoteAPI function introduction. – 53


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

8 RemoteAPI sample code download.


System Provider Release date Version Files Instructions
version

10.118.22B~, @林晉 2020-7- V1.1 RobotExample_ • Modified the automatic


毅 1 V1.1.zip and manual feedrate
10.118.24~
adjustment logic for
ROBOT-353.
• Added manual mode,
coordinate system
switching and axes JOG
buttons.

RemoteAPI sample code download. – 54


联达产品/LEANTEC Products

RemoteAPI example program for Leantec Robot.

System Provider Release date Version Files Instructions


version

10.118.12A~ @林晉 2019-1-8 V1.0 RobotExample_ • Modification of PLC is


毅 V1.0.rar required for software
version 10.118.12G and
below.

Version
10.118.12G and
below

The controller
software version
10.118.12G and
before required to
modify its PLC in
order to use
RemoteAPI to
perform cycle
start function.
Below shows the
modification the
cycle start
function in PLC.

Origina
l PLC

Modifie
d PLC

• It is recommended to
add custom
modifications based on
this file.

RemoteAPI sample code download. – 55

You might also like