Template: Modbus RTU Analog Output 8CH Protocol

From Waveshare Wiki
Jump to: navigation, search

Development Protocol

Function Code Introduction

Function Code Note
03 Read Holding Registers
06 Write Single Holding Register
10 Write Multiple Holding Register

Register Address Introduction

Address (HEX) Address Storage Content Register Value Permissions Modbus Function Code
4x0000
……
4x0007
Channel 1 ~ 8 Output Data Unsigned hexadecimal Read/Write 0x03, 0x06, 0x10
4x2000 Serial port parameters High 8-bit is the parity mode: 0x00~0x02
Low 8-bit is the baud rate mode: 0x00~0x07
Read/Write 0x03, 0x06
4x4000 Device address Direct store Modbus addresses
Device address: 0x0001-0x00FF
Read/Write 0x03, 0x06
4x8000 Software version Convert to decimal and then shift the decimal point two places to the left to represent the software version
0x0064 = 100 = V1.00
Read 0x03

Set Single-channel Output Command

Send code: 01 06 00 00 03 E8 89 74

Fields Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 Command Write a single register command
00 00 Register Address 0x0000 - 0x0007 corresponds to 1~8 channel output data
03 E8 Value Setting Set the value to hexadecimal, unit in uA, high bits in the front, low bits at the end
0x03E8 = 1000uA, or 1mA
89 74 CRC16 CRC16 checksum of the first 6 bytes of data

Receive code: 01 06 00 00 03 E8 89 74

Fields Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 Command Write a single register command
00 00 Register Address 0x0000 - 0x0007 corresponds to 1~8 input channel data type
03 E8 Value Setting Set the value in hexadecimal, unit mV, high bits in the front, low bits in the end.
0x03E8 = 1000mV, or 1V
89 74 CRC16 CRC16 checksum of the first 6 bytes of data

For example:

[No.1 address device]

Set channel 1 output 1mA : 01 06 00 00 03 E8 89 74
Read channel 2 output 5mA : 01 06 00 01 13 88 D5 5C

Set Multiple-channel Output Command

Send command: 01 10 00 00 00 08 10 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 3C 05

Fields Description Note
01 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates the device address
10 10 Command Write multi-register command
00 00 Register Initial Address 0x0000 - 0x0007 corresponds to 1~8 output channels
00 08 Register Numbers Set the number of registers, up to 8 channels
10 Bytes Numbers Set the output bytes
03 E8
……
03 E8
Command Channel 1 analog output
……
Channel 8 analog output
Set the value in hexadecimal, unit in mV, high bits in the front, low bits in the end
0x03E8 = 1000uA, or 1mA
3C 05 CRC16 CRC16 checksum of the first 6 bytes of data

Receive code: 01 10 00 00 00 08 C1 CF

Fields Description Note
01 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
10 10 Command Write multi-register command
00 00 Register Initial Address 0x0000 - 0x0007 corresponds to 1~8 output channels
00 08 Register Numbers Set the register numbers, up to 8 channels
C1 CF CRC16 CRC16 checksum of the first 6 bytes of data

For example:

[No.1 address device]

Set channel 1-8 output 1mA: 01 10 00 00 00 08 10 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 3C 05
Set channel 3-5 output 2mA: 01 10 00 02 00 03 06 07 D0 07 D0 07 D0 84 0E

Read Channel Output Command

Send code: 01 03 00 00 00 08 44 0C

Fields Description Note
01 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
03 03 Command Read holding register
00 00 Register Initial Address 0x0000 - 0x0007 corresponds to 1~8 input channels
00 08 Register Numbers Read the register numbers, up to 8 channels
44 0C CRC16 CRC16 checksum of the first 6 bytes of data

Receive code: 01 03 10 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 03 E8 C1 91

Fields Description Note
01 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
03 03 Command Read holding register
10 Byte Numbers Number of bytes for returning status information
03 E8
……
03 E8
Output Value Channel 1 analog output
……
Channel 8 analog output
Set the value in hexadecimal, unit mV, high bits in the front, low bits in the end
0x03E8 = 1000uA, or 1mA
C1 91 CRC16 CRC16 checksum of the first 6 bytes of data

For example

[No.1 address device]

Read channel 1-8 data type: 01 03 00 00 00 08 44 0C
Read channel 1 data type: 01 03 00 00 00 01 84 0A
Read channel 2 data type: 01 03 00 01 00 01 D5 CA
Read channel 3-5 data type: 01 03 00 02 00 03 A4 0B

Set Baudrate Command

Send code: 00 06 20 00 00 05 43 D8

Fields Description Note
00 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
06 06 Command Set the baud rate and device addresses
20 00 Command Register 0x2000 for setting baudrate, 0x4000 for setting device addresses
00 Parity Method 0x00 is no parity, 0x01 is even parity, 0x02 is odd parity
05 Baudrate Value 0x00: 4800
0x01: 9600
0x02: 19200
0x03: 38400
0x04: 57600
0x05: 115200
0x06: 128000
0x07: 256000
43 D8 CRC16 CRC16 checksum of the first 6 bytes of data

Receive code: 00 06 20 00 00 05 43 D8

Fields Description Note
00 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
06 06 Command Set the baud rate and device addresses
20 00 Command Register 0x2000 is setting the baud rate, 0x4000 is setting the device address
00 Parity Method 0x00 is no parity, 0x01 is even parity, 0x02 is odd parity
05 Baudrate 0x00: 4800
0x01: 9600
0x02: 19200
0x03: 38400
0x04: 57600
0x05: 115200
0x06: 128000
0x07: 256000
43 D8 CRC16 CRC16 checksum of the first 6 bytes of data

For example:

[No.1 address device]

Set baud rate 4800: 00 06 20 00 00 00 83 DB
Set baud rate 9600: 00 06 20 00 00 01 42 1B
Set baud rate 115200: 00 06 20 00 00 05 43 D8

Set Device Address Command

Sending code: 00 06 40 00 00 01 5C 1B

Fields Description Note
00 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
06 06 Command Set the baud rate and device addresses
40 00 Command Register 0x2000 is setting baudrate, 0x4000 is setting the device address
00 01 Device Address Set the device address: 0x0001-0x00FF
5C 1B CRC16 CRC16 checksum of the first 6 bytes of data

Receive code: 00 06 40 00 00 01 5C 1B

Fields Description Note
00 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
06 06 Command Set the baud rate and device addresses
40 00 Command Register 0x2000 is setting baudrate, 0x4000 is setting the device address
00 01 Device Address Set the device address, 0x0001-0x00FF
5C 1B CRC16 CRC16 checksum of the first 6 bytes of data

For example:

[No.1 address device]

Set the device address as 0x01: 00 06 40 00 00 01 5C 1b
Set the device address as 0x02: 00 06 40 00 00 02 1C 1A
Set the device address as 0x03: 00 06 40 00 00 03 DD DA

Read Device Address Command

Send code: 00 03 40 00 00 01 90 1B

Fields Description Note
00 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
03 03 Command Read device address command
40 00 Command Register 0x4000 for read device address, 0x8000 for read software version
00 01 Byte Numbers Fixed 0x0001
90 1B CRC16 CRC16 checksum of the first 6 bytes of data

Received code: 01 03 02 00 01 79 84

Fields Description Note
00 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
03 03 Command Read the software version and the device address
02 Byte Numbers Return byte numbers
00 01 Device Address Set the device address: 0x0001-0x00FF
79 84 CRC16 CRC16 checksum of the first 6 bytes of data

For example:

[No.1 address device]

Send: 00 03 40 00 00 01 90 1B
Receive: 01 03 02 00 01 79 84 //address 0x01

[No.2 address device]

Send: 00 03 40 00 00 01 90 1B
Receive: 02 03 02 00 02 7D 85 //address 0x02
[No.3 address device]

Send: 00 03 40 00 00 01 90 1B
Receive: 03 03 02 00 03 81 85 //address 0x03

Read Software Version Command

Sending code: 00 03 80 00 00 01 AC 1B

Fields Description Note
01 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
03 03 Command Read the software version and the device address
80 00 Command Register 0x4000 is reading software version, 0x8000 is reading device address
00 01 Byte Numbers Fixed 0x0001
8F CA CRC16 CRC16 checksum of the first 6 bytes of data

Receive code: 01 03 02 00 64 B9 AF

Fields Description Note
01 Device Address 0x00 indicates the broadcast address; 0x01-0xFF indicates device address
03 03 Command Read the software version and the device address
02 Byte Numbers Received Byte Numbers
00 64 Software Version Convert to decimal and then shift the decimal point two places to the left to represent the software version.
0x0064 = 100 = V1.00
B9 AF CRC16 CRC16 checksum of the first 6 bytes of data

For example:

[No.1 address device]

Send: 00 03 80 00 00 01 AC 1B
Receive: 01 03 02 00 64 B9 AF //0x0064 = 100 =V1.00