modbus-rtu protocol control method
Currently, the ModBus-RTU protocol of the force control gripper only supports function codes 03 and 06. The force control gripper is a ModBus-RTU slave, and the register length of the read function code 03 is only 1. The function code 03 represents read, and the function code 06 represents write
USB-485 module wiring:
Connect the 24V, GND, 485_A (T/R+, 485+), 485_B (T/R-, 485-) of the gripper end, a total of 4 wires, the power supply is a 24V DC regulated power supply, and insert the USB port of the module into the USB port of the computer
485A is connected to the 485 to USB module A+;
485B is connected to the 485 to USB module B-;
24V is connected to the positive pole of the 24V DC regulated power supply;
GND is connected to the negative pole of the 24V DC regulated power supply
Read the holding register (function code 0x03)
Take the example of reading the jaw opening angle
Master station request frame format:
Slave station address | Function code | Register address (high bit) | Register address (low bit) | Number of registers (high bit) | Number of registers (low bit) | CRC16 check high bit | CRC16 check low bit |
---|---|---|---|---|---|---|---|
0x0E | 0x03 | 0x00 | 0x0C | 0x00 | 0x01 | crc1 | crc2 |
Slave station response frame format: | Slave station address | Function code | Number of bytes | Register (high bit) | Register (low bit) | CRC16 check high bit |CRC16 check low bit| | -------- | ------ | -------- | -------------- | -------------- | ----- |----- | | 0x11 | 0x03 | 0x02 | 0x00 | 0x64 | crc1 | crc2|
Set the holding register (function code 0x06)
Set the jaw opening angle as an example Master request frame format:
Slave address | Function code | Start register (high bit) | Start register (low bit) | Data content (high bit) | Data content (low bit) | CRC16 check high bit | CRC16 check low bit |
---|---|---|---|---|---|---|---|
0x0E | 0x06 | 0x00 | 0x0B | 0x00 | 0x64 | crc1 | crc2 |
Slave response frame format:
Slave address | Function code | Start register (high bit) | Start register (low bit) | Data content (high bit) | Data content (low bit) | CRC16 check high bit | CRC16 check low bit |
---|---|---|---|---|---|---|---|
0x0E | 0x06 | 0x00 | 0x0B | 0x00 | 0x01 | crc1 | crc2 |
Register table
Register function | Register address | Read/write permission | Description |
---|---|---|---|
Read firmware main version number | 1 | Read | Version number*10 returns, starting from 1.0. For example, 1.0 returns 10 |
Read the firmware minor version number | 2 | Read | 0-255. Each time the major version number remains unchanged, submit the test minor version number + 1 |
Set device ID number | 3 | Write | 1 - 254 |
Read device ID number | 4 | Read | Return ID |
Set 485 baud rate | 5 | Write | 0 - 115200 (default) 1 - 1000000 2 - 57600 3 - 19200 4 - 9600 5 - 4800 |
Read 485 baud rate | 6 | Read | 0 - 115200 1 - 1000000 2 - 57600 3 - 19200 4 - 9600 5 - 4800 |
Set the gripper enable status | 10 | Write | 0 - Enable off 1 - Enable on |
Set the gripper angle | 11 | Write | Angle value: 0-100 |
Read the gripper angle | 12 | Read | Angle value: 0-100 |
Set the gripper zero position | 13 | Write | 0 - Failed 1 - Success |
Read the gripper clamping status | 14 | Read | 0 - Moving 1 - Stopped, no object detected 2 - Stopped, object detected 3 - After detecting that the object is clamped, the object falls |
Set the gripper P value | 15 | Write | Value range 0-254 |
Read the gripper P value | 16 | Read | Value range 0-254 |
Set the gripper D value | 17 | Write | Value range 0-254 |
Read the gripper D value | 18 | Read | Value range 0-254 |
Set the gripper I value | 19 | Write | Value range 0-254 |
Read the gripper I value | 20 | Read | Value range 0-254 |
Set the gripper clockwise operable error | 21 | Write | Value range 0-16 |
Read the gripper clockwise Runnable error | 22 | Read | Value range 0-150 |
Set the counterclockwise runnable error of the gripper | 23 | Write | Value range 0-16 |
Read the counterclockwise runnable error of the gripper | 24 | Read | Value range 0-150 |
Set the minimum starting force of the gripper | 25 | Write | Value range 0-254 |
Read the minimum starting force of the gripper | 26 | Read | Value range 0-150 |
Set torque | 27 | Write | Value range 0-100 |
Read torque | 28 | Read | Value range 100-300 |
IO output setting | 29 | Write | Value range :0,1,16,17 |
Set io opening angle | 30 | Write | Angle value: 0-100 |
Read io opening angle | 31 | Write | Angle value: 0-100 |
Set gripper speed | 32 | Write | Speed: 1-100 |
Read gripper default speed | 33 | Write | Speed: 1-100 |
Read Io opening angle | 34 | Write | Angle value: 0-100 |
Read Io closing angle | 35 | Write | Angle value: 0-100 |
Set absolute angle | 36 | Write | Angle value: 0-100 |
Pause motion | 37 | Write | Value: 0 |
Resume motion | 38 | Write | Value: 0 |
Stop motion | 39 | Write | Value: 0 |
Get the amount of data in the current queue | 40 | Read | Return the amount of data in the current absolute control queue |
Set the servo virtual position value | 41 | Write | Value: 0-100 |
Read the servo virtual position value | 42 | Read | Value: 0-100 |
Set the clamping current | 43 | Read | Value: 100-300 |
Read the clamping current | 44 | Read | Value: 1-300 |