3. CNDE function operation

3.1. Input configuration and input data

The client sends data frames to the robot through CNDE to control the robot’s DO, AO output, input registers, etc. Before sending the input data, it is necessary to configure the functional content to be controlled. Table 2-1 shows the format of CNDE input configuration content, including recipe number and a series of input configuration function names (Table 1-2); The corresponding table 3-2 is the content format of input data, including recipe number and input data byte group.

CNDE data input supports up to 8 recipes. When sending input data, the robot will match the recipe number in the received data to the corresponding recipe configuration function name group, and analyze the data to get the input data value of each function name, and then control the robot according to the input data.

Table 3-1 Input Configuration Content Format

Name

Recipe number

Function name string

Length (byte)

1

Content

0 ~ 7

A series of input data function names

Table 3-2 Input Data Content Format

Name

Recipe number

Data byte group

Length(byte)

1

Content

0 ~ 7

Input data content

When inputting configuration, the robot controller will check each name after receiving the configuration name group. If the configured function names are correct, the robot will feed back the data type names of all configured functions divided by “,”; If the configured function name is wrong, the robot will feed back the corresponding error content. An example of the input configuration data frame (hexadecimal) is as follows:

../_images/00117.png

Among them, the total length of the configured input function name group is 54 bytes, plus 1 byte of the input recipe number, which is 55 bytes, which is converted into hexadecimal as 0x0037. In the Little-Endian mode, the data length in the corresponding input data frame is “37 00”.

At this time, the robot will feed back a data frame with the type of messages (Message in section 3.3.1 of this article):

../_images/00216.png

The message type “00” indicates that this is a successful feedback message. The client can extract the “Input Data Configuration Type” and compare it with Table 1-3 to get the byte length of the input configuration. In this example, the total data length is 1*5+4*30+8*30 = 365 bytes.

If the configuration name is entered incorrectly:

../_images/00317.png

The corresponding feedback information is:

../_images/00418.png

The input data can be input circularly according to a certain period, or only when necessary. The fastest period that the robot can process during cyclic input is 1ms, but the faster input period will bring some resource expenses to the robot system. It is suggested that you set the data input period reasonably according to the actual situation.

In addition, when sending a data frame to the robot, the robot will not have feedback information unless the length of the sent data frame or the data is abnormal. An example of an input data frame is as follows, in which the input data recipe number and the input data byte length should be consistent with the input configuration:

../_images/00517.png

3.2. Output configuration and output data

The client can customize the content and period of the state feedback through CNDE. Using the state feedback of the robot CNDE requires the following three steps: ①output configuration; ②Start the output; ③Receiving output data.

3.2.1. Output configuration

The output configuration frame includes the output period and the output function name group (see Table 1-1 for all configurable names). The configurable range of the output period is 1 ~ 200ms, and the maximum number of output data bytes supports 4096byte. The output function name group is a series of output function name strings separated by “,”.After the client sends the output configuration frame, the robot will check the configured function names. If the configured function names are all supported by the current robot CNDE, the robot will feed back a series of data type combinations separated by “,”; Otherwise, if the verification of the output configuration name fails, the corresponding error message is fed back.

Table 3-3 Output Configuration Contents

Nmae

Output period (ms)

Function name string

Length (byte)

2

内容

1-200

Output function name group

If the output configuration frame is as follows:

../_images/00618.png

Among them, the total length of the configured output function name group is 48 bytes, plus 2 bytes of the output period, totaling 50 bytes, which is converted into hexadecimal as 0x0032. In the Little-Endian mode, the data length in the corresponding input data frame is “32 00”.

At this time, the robot will feed back a data frame with the type of message (Message in section 3.3.1 of this article):

../_images/00717.png

The message type “00” indicates that this is a successful feedback message. The client can extract the “output data configuration type” and compare it with Table 1-3 to get the byte length of the output configuration. In this example, the total data length is 1+8*10+4 = 85 bytes.

If the input configuration name is wrong, such as “queue” wrongly written as “quene”:

../_images/00816.png

The corresponding feedback information is:

../_images/00914.png

3.2.2. Output start and stop

After the CNDE output configuration of the robot is completed, send a start command to start the CNDE output, and the robot will perform state feedback output according to the configured output period and output content, and also send a CNDE stop output command, and the robot will stop the state feedback output. CNDE start and stop commands have no command content, and the corresponding data length is 0.

Table 3-4 Start and Stop Contents of CNDE Output

Name

Data byte group

Length (byte)

0

Content

without

An example of starting the robot CNDE to output data frames is as follows:

../_images/01015.png

3.2.3. The client receives the output data

After the CNDE data output of the robot is started, the client needs a cycle to receive the data information fed back by the robot, and the cycle receiving frequency of the client is higher than the configured output data frequency, otherwise data packet loss may occur. The contents of robot output data are shown in Table 3-5. The length of the byte group of robot output data is the sum of the byte lengths of all the function data configured for output, and the byte array is a combination of all the state data in the order of configured functions with 1 byte alignment.

Table 3-5 CNDE Output Data Content

Name

Data byte group

Length(byte)

Content

Output data byte group

Examples of robot output data frames are as follows:

../_images/01114.png

3.3. CNDE auxiliary function

3.3.1. Messages

The client and the robot can send messages to each other through CNDE, including message types and message strings (Table 3-6), where the message types are defined in Table 3-7. When the CNDE client sends commands such as input configuration, output configuration, output start and output stop to the robot, the robot replies with a message.

If the above commands are executed successfully, the feedback message type of the robot is “successful”, and the numerical code of the corresponding message type is 0x00;; On the other hand, if the above commands fail to be executed, the message type fed back by the robot is “error”, and the corresponding message type value is 0x03. The client can judge the command execution result according to the feedback message type, and if the message type is “error”, the error information can be extracted to analyze the cause of the error.

Table 3-6 Content of Message

Name

Message type

Message string

Length(byte)

1

Content

0 ~ 4

Message string

Table 3-7 Robot CNDE Message Types

Type

Numerical value

SUCCESS

0x00

INFORMATION

0x01

WARINING

0x02

ERROR

0x03

FAULT

0x04

3.3.2. Switch the version number of CNDE protocol of robot

At present, there is only one version of the robot CNDE, and the version number is “FR-CNDE-V0001”, so this function is reserved and has not been put into use yet.

3.3.3. Acquire that version information of the robot soft firmware

The client sends an command to get the software firmware version information to the robot through CNDE, and the command content is empty. After receiving the request, the robot will feed back a message, including the robot model, robot software version, robot firmware version, robot hardware version and other related information.

3.4. End-Effector Transparent Transmission Function Periodic Data Acquisition (CNDE)

3.4.1. CNDE Configuration Description

After the end-effector transparent transmission function is enabled, the “axle_gen_com_data” option and period can be configured in CNDE to obtain the periodic data of the peripheral read by the end-effector. The feedback data frame is defined as follows.

Table 3-8 End-Effector Transparent Transmission Function Periodic Data CNDE Feedback Protocol Definition

Byte 1

Byte 2

Byte 3-130

ErrorCode

Len

Data

0 - Communication normal

Length of periodic data

Data frame buffer

1 - Communication abnormality between end-effector and robot

Length cleared when error code is non-zero

Buffer cleared when error code is non-zero

2 - End-effector 485 communication abnormality

Taking the DIO Health Care Moxibustion Head peripheral periodic data configuration as an example, the code shows the configuration to obtain the end-effector periodic transparent transmission data with an acquisition period of 50ms.

End-Effector Transparent Transmission CNDE Configuration Code Example:

 1tring outputCfg = "axle_gen_com_data";    //Obtain end-effector transparent transmission periodic data
 2byte[] sendBuffer = new byte[] { };
 3byte[] cfgBuffer = Encoding.UTF8.GetBytes(outputCfg);
 4CNDEPkg pkg  = new CNDEPkg();
 5pkg.type = 1;  //Output configuration
 6pkg.len = (ushort)(2 + outputCfg.Length);
 7pkg.data.Clear();
 8UInt16 period = 50;   //50ms update
 9byte[] periodBt = new byte[2] {0, 0};
10Int16ToByte(period, ref periodBt);
11pkg.data.AddRange(periodBt);  //Communication period
12pkg.data.AddRange(cfgBuffer);
13pkg.ToBytes(ref sendBuffer);

CNDE-Based DIO Health Care Moxibustion Head Periodic Data Unpacking Code Example:

 1if (pkg.type == 4)
 2{
 3    int size = Marshal.SizeOf(putDate);
 4    IntPtr structPtr = Marshal.AllocHGlobal(size);
 5    Marshal.Copy(pkg.data.ToArray(), 0, structPtr, size);
 6    putDate = (OUTPKG)Marshal.PtrToStructure(structPtr, typeof(OUTPKG));
 7
 8    int errorcode = putDate.axle_gen_com_data[0];
 9    int datalen = putDate.axle_gen_com_data[1];
10    // Filter out abnormal packets
11    if ((errorcode != 0) || (datalen == 0) ||
12    (putDate.axle_gen_com_data[2] != 0xAB) ||
13    (putDate.axle_gen_com_data[3] != 0xBA))
14    {
15        Console.WriteLine($"rcv data is error");
16        continue;
17    }
18    // Package according to DIO Health Care Moxibustion Head protocol
19    int curTem = putDate.axle_gen_com_data[6];
20    int targetTem = putDate.axle_gen_com_data[7];
21    int genData1 = putDate.axle_gen_com_data[8] << 8 | putDate.axle_gen_com_data[9];
22    int genData2 = putDate.axle_gen_com_data[10] << 8 | putDate.axle_gen_com_data[11];
23    int genData3 = putDate.axle_gen_com_data[12] << 8 | putDate.axle_gen_com_data[13];
24    int genData4 = putDate.axle_gen_com_data[14] << 8 | putDate.axle_gen_com_data[15];
25    int genData5 = putDate.axle_gen_com_data[16] << 8 | putDate.axle_gen_com_data[17];
26    int genData6 = putDate.axle_gen_com_data[18] << 8 | putDate.axle_gen_com_data[19];
27
28    Console.WriteLine($"the data is errorcode {errorcode};  datalen  {datalen}  curTem  {curTem}; targetTem  {targetTem}  genData1  {genData1}  genData2  {genData2}  genData3  {genData3}  genData4  {genData4}  genData5  {genData5}  genData6  {genData6}  ");
29    udpClient.Client.ReceiveTimeout = 100;
30    Marshal.FreeHGlobal(structPtr);
31}

End-Effector Transparent Transmission Function-Based DIO Health Care Moxibustion Head Non-Periodic Data Communication Code Example:

 1void testAxleGenCom()
 2{
 3    int[] led_on = new int[6] { 0xAB, 0xBA, 0x12, 0x01, 0x01, 0x79 };
 4    int[] led_off = new int[6] { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
 5    int[] version = new int[5]{ 0xAB, 0xBA, 0x11, 0x00, 0x76 };
 6    int[] state = new int[6] { 0xAB, 0xBA, 0x1B,0x01, 0xAA, 0x2B };
 7    int[] cycleState = new int[6] { 0xAB, 0xBA, 0x12, 0x01, 0x00, 0x78 };
 8
 9    int[] rcvdata = new int[16];
10    int ret = 0;
11    int cnt = 1;
12
13    JointPos p1Joint = new JointPos(88.708, -86.178, 140.989, -141.825, -89.162, -49.879);
14    DescPose p1Desc = new DescPose(188.007, -377.850, 260.207, 178.715, 2.823, -131.466);
15
16    JointPos p2Joint = new JointPos(112.131, -75.554, 126.989, -139.027, -88.044, -26.477);
17    DescPose p2Desc = new DescPose(368.003, -377.848, 260.211, 178.715, 2.823, -131.465);
18
19    ExaxisPos exaxisPos = new ExaxisPos(0, 0, 0, 0);
20    DescPose offdese = new DescPose(0, 0, 0, 0, 0, 0);
21
22    //Enable end-effector transparent transmission function
23    robot.SetAxleGenComEnable(1);
24    robot.SetAxleLuaEnable(1);
25
26    while(cnt<=10)
27    {
28        //Read version number
29        ret = robot.SndRcvAxleGenComCmdData(5, version, 10, ref rcvdata);
30        Console.WriteLine($" hard version : {rcvdata[4]},hard code:{rcvdata[5]}, soft version:{rcvdata[6]} {rcvdata[7]}, soft code:{rcvdata[8]}");
31        if (ret != 0)
32        {
33            break;
34        }
35        Thread.Sleep(1000);
36        //Read moxibustion head presence status
37        ret = robot.SndRcvAxleGenComCmdData(6, state, 6, ref rcvdata);
38        Console.WriteLine($" state : {rcvdata[4]}");
39        Thread.Sleep(1000);
40        //Turn on moxibustion head laser
41        ret = robot.SndRcvAxleGenComCmdData(6, led_on, 6, ref rcvdata);
42        Console.WriteLine($"led on rcv data is: {rcvdata[0]},{rcvdata[1]}, {rcvdata[2]}, {rcvdata[3]}, {rcvdata[4]}, {rcvdata[5]}");
43        robot.MoveJ(p1Joint, p1Desc, 0, 0, 100, 100, 100, exaxisPos, -1, 0, offdese);
44        Thread.Sleep(4000);
45        //Turn off moxibustion head laser
46        ret = robot.SndRcvAxleGenComCmdData(6, led_off, 6, ref rcvdata);
47        Console.WriteLine($"led off rcv data is: {rcvdata[0]},{rcvdata[1]}, {rcvdata[2]}, {rcvdata[3]}, {rcvdata[4]}, {rcvdata[5]}");
48        robot.MoveJ(p2Joint, p2Desc, 0, 0, 100, 100, 100, exaxisPos, -1, 0, offdese);
49        Thread.Sleep(1000);
50        Console.WriteLine($"***********************complate No. {cnt}  SDK test*****************************");
51        cnt++;
52    }
53
54}