Skip to main content

Job file editing related

Insert motion control instructions into the job file

Before and after writing instructions to a job file, there are several related operations such as opening, pausing and stopping the job file, see section 3.13 for details

Insert MOVJ

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertMOVJ(int line, int vel, int acc, int dec, const NRC_Position& target, int pl=0) to insert MOVJ (i.e. point to point) instruction in the job file.

  • The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1).
  • The parameter "vel" is the running speed of the robot, expressed as a percentage of the robot's maximum speed. The range of the parameter is 0 < vel <= 100.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5

Insert MOVL

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertMOVL(int line, int vel, int acc, int dec, const NRC_Position& target, int pl=0) to insert MOVL (i.e. line) instruction in the job file.

  • The parameter 'vel' represents the running speed of the robot, which is the absolute running speed of the robot TCP, with the unit of millimeters per second (mm/s). The range of the parameter is vel > 1.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5.

Insert MOVC

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertMOVC(int line, int vel, int acc, int dec, const NRC_Position& target, int pl=0) to insert MOVC (i.e. circular arc) instruction into the job file. It should be noted that two MOVC instructions are required to execute.

  • The parameter 'vel' represents the running speed of the robot, which is the absolute speed of the robot TCP, with the unit of millimeters per second (mm/s). The range of the parameter is vel > 1.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint. The range of the parameter is 0 < dec <= 100.
  • The parameter "target" represents the target position of the robot's movement, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5. Insert the MOVC instruction in the job file:
//Move from pos1 to pos2 by means of circular interpolation at a speed of 100mm/s
NRC_JobfileInsertMOVC(1,100,50,50, pos1, 0);
NRC_JobfileInsertMOVC(2,100,50,50, pos2, 0);//Insert a MOVC

Insert IMOV

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

The IMOV instruction is to move from the current position according to the set incremental distance in the way of joint or linear interpolation. Call the function NRC_JobfileInsertIMOV(int line, int vel,int acc, int dec, const NRC_Position& deviation, int pl=0) to insert IMOV instruction in the job file. When the deviation.coord is NRC_ACS, the instruction will use the joint interpolation method, and when the deviation.coord is other values, the linear interpolation method will be used.

  • The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1).
  • The parameter "vel" is the running speed of the robot. When the deviation.coord is NRC_ACS, it is a percentage of the robot's maximum speed with a range of 0 < vel <= 100. When the deviation.coord is not NRC_ACS, it is the absolute running speed of the robot TCP in millimeters per second (mm/s), with a range of vel > 1.
  • The parameter "acc" represents the acceleration of the robot during movement, expressed as a percentage of the maximum acceleration of each joint. The range of the parameter is 0 < acc <= 100.
  • The parameter "dec" represents the deceleration of the robot during movement, expressed as a percentage of the maximum deceleration of each joint. The range of the parameter is 0 < dec <= 100.
  • The parameter "deviation" represents the movement deviation of the robot, see NRC_Position for details.
  • The parameter "pl" represents the smoothness, which refers to the smooth transition between the current and the next movement instructions. The higher the value of pl, the smoother the transition, but the greater the trajectory deviation. The range of the parameter is 0 <= pl <= 5.

Insert input and output instructions into the job file

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

To make a digital output port output high or low level, you can call the function NRC_JobfileInsertDOUT(int line, int port, int value) to insert a DOUT instruction into the job file.

  • The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1).
  • The parameter "port" indicates the number of the digital output port to output the level, and the range of the parameter is port > 0
  • The parameter "value" indicates the port output status, value=0: low level, value=1: high level

Insert timing instructions into the job file

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertTIMER(int line, double timeSec) to insert TIMER instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). The parameter "timeSec" indicates the delay time in seconds, and the range of the parameter is timeSec > 0.

Insert conditional control instructions into the job file

Insert WAIT

Before calling this function, call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertWAIT(int line, int port, int value, double timeoutSec, bool now=false) to insert WAIT instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). The parameter "port" represents the digital input port number to be detected, and the parameter range is: port > 0. The parameter "value" indicates the input state to wait for, the return value 0 means low level, and the return value 1 means high level. The parameter "timeoutSec" represents the timeout duration in seconds, with a parameter range of "timeoutSec >= 0". If the requirement is not met after waiting for "timeoutSec" seconds, the instruction will stop waiting and end. If the value is 0, it will wait indefinitely until the condition is met.

Insert UNTIL, ENDUNTIL

Before calling these two functions, please call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertUNTIL(int line, int port, int value) to insert UNTIL instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). The parameter "port" represents the digital input port number to be detected, and the parameter range is: port > 0. The parameter "value" indicates the input state to wait for, the return value 0 means low level, and the return value 1 means high level. This function needs to be used in conjunction with NRC_JobfileInsertENDUNTIL(int line). Call the function NRC_JobfileInsertENDUNTIL(int line) to insert ENDUNTIL instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). This function needs to be used in conjunction with NRC_JobfileInsertUNTIL(int line, int port, int value).

Example of inserting UNTIL instruction in a job file:

The functions that need to be called are as follows:

//While running between UNTIL and ENDUNTIL, if the condition of UNTIL is met, the program will immediately interrupt the current running instruction and jump to ENDUNTIL for execution
NRC_JobfileInsertUNTIL(1, 5, 1);
NRC_JobfileInsertMOVJ(2, 100,50,50, pos1, 0);
NRC_JobfileInsertMOVL(3, 100,50,50, pos2, 0);
NRC_JobfileInsertDOUT(4, 1, 0);
NRC_JobfileInsertTIMER(5, 0.5);
NRC_JobfileInsertENDUNTIL(6);

It should be noted that when the program is running between UNTIL and ENDUNTIL, if the condition of UNTIL is not met, it will be executed in order, and if the condition is met, the current running instruction will be immediately interrupted and the instruction after ENDUNTIL will be executed.

Insert IF, ELSE, ENDIF

Before calling these three functions, please call NRC_CreateJobfile(std::string jobname)or NRC_OpenJobfile(std::string jobname) to create or open a job file.

Call the function NRC_JobfileInsertIF(int line, int port, int value) to insert IF instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). The parameter "port" represents the number of the digital input port to be detected, and the parameter range is port > 0. The parameter "value" indicates the input state to wait for, the return value 0 means low level, and the return value 1 means high level. This function needs to be used in conjunction with NRC_JobfileInsertENDIF(int line).

Call the function NRC_JobfileInsertELSE(int line) to insert ELSE instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). This function needs to be used in conjunction with NRC_JobfileInsertIF(int line, int port, int value) and NRC_JobfileInsertENDIF(int line).

Call the function NRC_JobfileInsertENDIF(int line) to insert ENDIF instruction in the job file. The parameter "line" indicates the line number where the instruction will be inserted, and the range of the parameter is 0 < line < (NRC_GetJobfileLineSum()+1). This function needs to be used in conjunction with NRC_JobfileInsertIF(int line, int port, int value). Example of inserting IF instruction in a job file:

The functions that need to be called are:

//If the IF condition is met, execute the IF code block, otherwise execute the ELSE code block; if there is no ELSE instruction and the IF condition is not met, the IF code block will be skipped, and the instruction after ENDIF will be executed directly
NRC_JobfileInsertIF(1,5,1);
NRC_JobfileInsertMOVJ(2,100,50,50,pos1,0);
NRC_JobfileInsertDOUT(3,1,0);
NRC_JobfileInsertELSE(4);
NRC_JobfileInsertMOVL(5,100,50,50,pos2,0);
NRC_JobfileInsertTIMER(6,0.5);
NRC_JobfileInsertENDIF(7);
#include <iostream>
#include "nrcAPI.h"
#include<stdio.h>
using namespace std;
int main()
{
SystemStartup();//System startup, see section 3.3 for details
RobotMsg();
SetServoMap();//Set the servo mapping relationship, see section 3.5
SettingofRobotRelatedParameters();//Robot-related parameter settings, see section 3.6 for details
NRC_SetServoReadyStatus(1);//Set servo ready status, see section 3.8 for details
NRC_SetInterpolationMethod(1);//Set to S-shaped interpolation, see section 3.12 for details
NRC_SetOperationMode(NRC_RUN_);//Set the operation mode to run mode, see section 3.11 for details
NRC_SetAutoRunSpeedPer(80);//Set the auto-run speed to 80, see section 3.11 for details
NRC_Delayms(1000);//Delay 1000ms

//Set four points (using the new version of definition)
double pos1[7] = { 296.71, -66.12, 606.38, 3.06, 0.15, -0.18,0.00 };
double pos2[7] = { 303.3191, 20.0862, 606.3863, 3.1038, 0.1630, -0.4658,0.0000 };
double pos3[7] = { 315.4386, 21.1369, 595.0522, 3.1006, 0.1196, -0.4678,0.0000 };
double pos4[7] = { 315.6836, -16.5291, 595.0751, 3.0866, 0.1140, -0.3479,0.0000 };
NRC_Position inexbot1 = { NRC_MCS,0,0,0,pos1 };
NRC_Position inexbot2 = { NRC_MCS,0,0,0,pos2 };
NRC_Position inexbot3 = { NRC_MCS,0,0,0,pos3 };
NRC_Position inexbot4 = { NRC_MCS,0,0,0,pos4 };

double devPos1[7] = { 10, 20, -10, 10, 0, 0 };
double devPos2 [7]= { -50, 50, 10, 0, 0, 0.1 };
NRC_Position dev1 = { NRC_ACS,0,0,0,devPos1}; //Set the deviation of dev1
NRC_Position dev2 = { NRC_MCS,0,0,0,devPos2 }; //Set the deviation of dev2

NRC_Position inexbot9;//Define the robot position structure object inexbot9
NRC_GetCurrentPos(NRC_MCS, inexbot9);//Assign the Cartesian coordinate system of the current robot to inexbot9
printf("inexbot9.pos=%f,%f,%f,,%f,%f,%f,%f,\n",inexbot9.pos[0],inexbot9.pos[1],inexbot9.pos[2],inexbot9.pos[3],inexbot9.pos[4],inexbot9.pos[5],inexbot9.pos[6]);//Output the current Cartesian coordinate position

//Implementation of job file-related instructions
if (NRC_JudgeJobIsExist("INEXBOT1") == 0)
{
cout << "Job file does not exist" << endl;
NRC_CreateJobfile("INEXBOT1");//Create job file INEXBOT1
NRC_OpenJobfile("INEXBOT1");
}
else
NRC_OpenJobfile("INEXBOT1");//Open job file INEXBOT1
NRC_JobfileInsertMOVJ(1, 50, 50, 50, inexbot1, 4); //Move to inexbot1 in a point-to-point manner
NRC_JobfileInsertMOVL(2, 500, 50, 50, inexbot2, 1);//Move to inexbot2 in a straight line
NRC_JobfileInsertMOVC(3, 300, 50, 50, inexbot3, 5);
NRC_JobfileInsertMOVC(4, 300, 50, 50, inexbot4, 5);//Move from inexbot3 to inexbot4 in a circular arc
NRC_JobfileInsertDOUT(5, 3, 1);//Digital output port 3 outputs high level
NRC_JobfileInsertWAIT(6, 3, 1, 3.3);//Wait for the digital input port 3 to input a high level, if the condition is still not met after 3.3 seconds, the instruction ends
NRC_JobfileInsertTIMER(7, 5.5);//Wait 5.5s
cout << "file line sum is " << NRC_GetJobfileLineSum() << endl;
NRC_ServoEnable(); //Servo power on
NRC_StartRunJobfile("INEXBOT1");//Start running the job file
//NRC_StepRunJobfile("INEXBOT1", 3);
while (NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(500); //Delay 100ms
printf("line=%d,time=%d\n", NRC_GetJobfileCurrentRunLine(), NRC_GetCycleTimeSec());
}
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot7;//Define the robot position structure object inexbot7
NRC_GetCurrentPos(NRC_MCS, inexbot7);//Assign the Cartesian coordinate position of the current robot to inexbot7
printf("inexbot7.pos=%f,%f,%f,,%f,%f,%f,\n", inexbot7.pos[0], inexbot7.pos[1], inexbot7.pos[2], inexbot7.pos[3], inexbot7.pos[4], inexbot7.pos[5]);//Output the current Cartesian coordinate position

if (NRC_JudgeJobIsExist("INEXBOT2") == 0)
{
cout << "Job file does not exist" << endl;
NRC_CreateJobfile("INEXBOT2");//Create job file INEXBOT2
NRC_OpenJobfile("INEXBOT2");
}
else
NRC_OpenJobfile("INEXBOT2");//Open job file INEXBOT2
//While running between UNTIL and ENDUNTIL, if the condition of UNTIL is met, the program will immediately interrupt the current running instruction and jump to ENDUNTIL for execution
NRC_JobfileInsertUNTIL(1, 5, 1);
NRC_JobfileInsertMOVJ(2, 100, 50, 50, inexbot1, 0);//Move to inexbot1 in a point-to-point manner
NRC_JobfileInsertMOVL(3, 100, 50, 50, inexbot2, 0);//Move to inexbot2 in a straight line
NRC_JobfileInsertDOUT(4, 1, 0);
NRC_JobfileInsertTIMER(5, 0.5);
NRC_JobfileInsertENDUNTIL(6);
NRC_ServoEnable(); //Servo power on
NRC_StartRunJobfile("INEXBOT2");//Start running the job file
//NRC_StepRunJobfile("INEXBOT1", 3);
while (NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(500); //Delay 100ms
printf("line=%d,time=%d\n", NRC_GetJobfileCurrentRunLine(), NRC_GetCycleTimeSec());
}
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot8;//Define the robot position structure object inexbot8
NRC_GetCurrentPos(NRC_MCS, inexbot8);//Assign the Cartesian coordinate position of the current robot to inexbot8
printf("inexbot8.pos=%f,%f,%f,,%f,%f,%f,%f,\n",inexbot8.pos[0],inexbot8.pos[1],inexbot8.pos[2],inexbot8.pos[3],inexbot8.pos[4],inexbot8.pos[5],inexbot8.pos[6]);//Output the current Cartesian coordinate position

if (NRC_JudgeJobIsExist("INEXBOT3") == 0)
{
cout << "Job file does not exist" << endl;
NRC_CreateJobfile("INEXBOT3");//Create job file INEXBOT3
NRC_OpenJobfile("INEXBOT3");
}
else
NRC_OpenJobfile("INEXBOT3");//Open job file INEXBOT3
//If the IF condition is met, execute the IF code block, otherwise execute the ELSE code block; if there is no ELSE instruction and the IF condition is not met, the IF code block will be skipped, and the instruction after ENDIF will be executed directly
NRC_JobfileInsertIF(1, 5, 1);
NRC_JobfileInsertMOVJ(2, 100, 50, 50, inexbot1, 0);//Move to inexbot1 in a point-to-point manner
NRC_JobfileInsertDOUT(3, 1, 0);
NRC_JobfileInsertELSE(4);
NRC_JobfileInsertMOVJ(5, 100, 50, 50, inexbot2, 0);//Move to inexbot2 in a point-to-point manner
NRC_JobfileInsertTIMER(6, 0.5);
NRC_JobfileInsertENDIF(7);
NRC_JobfileInsertIMOV(7, 50, 50, 50, dev1, 3);
NRC_JobfileInsertIMOV(8, 500, 50, 50, dev2, 0);
NRC_ServoEnable(); //Servo power on
NRC_StartRunJobfile("INEXBOT3");//Start running the job file
//NRC_StepRunJobfile("INEXBOT1", 3);
while (NRC_GetProgramRunStatus() != 0) //Wait for the run to finish
{
NRC_Delayms(500); //Delay 100ms
printf("line=%d,time=%d\n", NRC_GetJobfileCurrentRunLine(), NRC_GetCycleTimeSec());
}
NRC_ServoDisable(); //Servo power off
NRC_Position inexbot10;//Define the robot position structure object inexbot10
NRC_GetCurrentPos(NRC_MCS, inexbot10);//Assign the Cartesian coordinate position of the current robot to inexbot10
printf("inexbot10.pos=%f,%f,%f,,%f,%f,%f,%f,\n", inexbot10.pos[0], inexbot10.pos[1], inexbot10.pos[2], inexbot10.pos[3], inexbot10.pos[4], inexbot10.pos[5],inexbot10.pos[6]);//Output the current Cartesian coordinate position
while(1)//Keep the program running
{
NRC_Delayms(1000);
}


}