RS485 Manual
Single/2~24 input RS485 output instruction manual
■ 1. Physical interface
● Serial communication uses RS485.
● The transmission mode is half-duplex asynchronous mode, with 1 start bit, 8 data bits, and 1 stop bit, no checksum.
● The data transmission rate defaults to 9600bps (can be modified). Using MODBUS communication protocol RTU mode.
● The factory default address is 0x01, and the default baud rate is 9600bps.
● All register address bytes, register number bytes, and data bytes in the command are high-order first.
The low-order byte comes first; the low-order byte of the CRC check code comes first, and the high-order byte comes last.
● The CRC check code is calculated by the sending or receiving device through the CRC algorithm. The test software is generally it will have its own automatic CRC calculation function. Different device commands have different CRC check codes and must not be used randomly enter.
■2. Read all data command example
2. 1 Single input
● Single-channel COMMAND (single-channel input and download command)
slave device address |
function code |
Starting register address |
Number of registers |
CRC-L |
CRC-H |
||
01H |
03H |
00H |
56H |
00H |
01H |
64H |
1AH |
● Single-channel RETURN (single-channel input return information)
slave device address |
function code |
Number of bytes in data area |
Single channel data |
CRC-L |
CRC-H |
||
A/D-H |
A/D-L |
||||||
01H |
03H |
02H |
|
24H |
F6H |
23H |
02H |
2.2 Dual input
● Single-channel COMMAND (single-channel input and download command)
slave device address |
function code |
Starting register address |
Number of registers |
CRC-L |
CRC-H |
||
01H |
03H |
00H |
10H |
00H |
02H |
C5H |
CEH |
● Single-channel RETURN (single-channel input return information)
slave device address |
function code |
Number of registers |
1st channel output |
2cnd channel output |
CRC-L |
CRC-H |
||
A/D-H |
A/D-L |
A/D-H |
A/D-L |
CBH |
6CH |
|||
01H |
03H |
04H |
1FH |
3FH |
0AH |
74H |
Note: Special note on the combination of current and voltage dual-channel inputs corresponding to RS485 outputs:
RS485 first channel output: voltage; RS485 second channel output: current.
2.3 Three-phase (three-channel) inputs
● Single-channel COMMAND (single-channel input and download command)
slave device address |
function code |
Starting register address |
Number of registers |
CRC-L |
CRC-H |
||
01H |
03H |
00H |
10H |
00H |
03H |
04H |
0EH |
● RETURN (return information)
slave device address |
function code |
Number of registers |
1st channel output |
2nd channel output |
3rd channel output |
CRC-L |
CRC-H |
|||
A/D-H |
A/D-L |
A/D-H |
A/D-L |
A/D-H |
A/D-L |
CBH |
6CH |
|||
01H |
03H |
06H |
1EH |
AFH |
1EH |
1CH |
1EH |
B1H |
● Special instructions for three-phase voltage input:
1.Three-phase three-wire voltage input corresponds to RS485 output: RS485 first channel output: UAB
RS485 second channel output: UBC
RS485 third channel output: UAC
2. Three-phase four-wire voltage input corresponds to RS485 output: RS485 first channel output: UAN
RS485 second channel output: UBN
RS485 third channel output: UCN
3.Three-phase current input corresponds to RS485 output: RS485 first channel output: IA
RS485 second channel output: IB
RS485 third channel output: IC
2.4 Multiple inputs (4~24 channels)
● Read 4~24 channels of data COMMAND (read 4~24 channels of data and download the command)
slave device address |
function code |
Starting register address |
Number of registers |
CRC-L |
CRC-H |
||
01H |
03H |
00H |
10H |
00H |
XXH |
XXH |
XXH |
Note: 1. In " Number of Registers" : XX=number of sensor measurement channels, for example, 4-channel XX=04, 8-channel XX=08, 12-channel XX=0C, 18-channel XX=12, 24-channel XX=18.
2. Starting from register 10, read XX register data continuously. Each measured value data occupies one register.
● Read data RETURN (read return information)
slave device address |
function code |
Number of bytes in data area |
1st channel data |
2nd~23rd channel data |
24th channel data |
CRC-L |
CRC-H |
||
A/D-H |
A/D-L |
........... |
A/D-H |
A/D-L |
XXH |
XXH |
|||
01H |
03H |
XXH |
1EH |
AFH |
........... |
1EH |
B1H |
Note: 1. In "Number of Bytes in Data Area", XX=2*Number of Measurement Channels
2. The XX in the CRC check code should be derived based on actual data
3. Return data restoration instructions example:
3. 1 A/D-H = the high 8 bits of the measured data, A/D-L = the low 8 bits of the measured data.
For example, in the single-channel return data in 2. 1 above, A/D-H=24H and A/D-L=F6H are synthesized into hexadecimal =24F6.
3.2 Return data calculation formula:
Basic calculation method: Calculate according to the linear relationship between the input rated value range and the output data 0~10000 digital quantity.
Bx=DATA*(Af-A0)/10000 - |A0 |
Bx --Measurement value of the calibrated sensor
DATA--returned data value (A/D-H+D/D-L converted to decimal value)
Af --the upper limit of the input nominal value of the calibrated sensor
A0 --The lower limit of the nominal input value of the calibrated sensor
For example (1): The nominal value of the sensor input is the voltage 0~700V (effective value),
The above 2. 1 single-channel return data DATA=24F6 (hexadecimal) =9462 (decimal),
Then the measured actual voltage
Bx=DATA*(Af-A0)/10000 - |A0 |
=9462*(700-0)/10000- |0 |=662.34V
For example (2): The nominal value of the sensor input is the bidirectional DC voltage - 100V~+200V,
The above 2. 1 single-channel return data DATA=24F6 (hexadecimal) =9462 (decimal),
Then the measured actual voltage
Bx=DATA*(Af-A0)/10000 - |A0 |
=9462*(200-(- 100))/10000- |-100 |=183.86V
Note: 1. The current sensor is calculated in the same way as the above voltage sensor.
2. The data type is unsigned; data ending with "H" only represents that data. It is in hexadecimal, please do not enter "H" during communication detection.
■3. Example of command to modify address
● COMMAND (download command, address changes from ADD1-01 to ADD2-02)
slave device address |
function code |
Starting register address |
Number of registers |
Number of data bytes |
Data written to register |
CRC-L |
CRC-H |
|||
01H (ADD1) |
10H |
00H |
57H |
00H |
01H |
02H |
00H |
02H (ADD2) |
2AH |
76H |
● RETURN (return information)
02H |
10H |
00H |
57H |
00H |
01H |
B0H |
2AH |
Note: 1. The above command ADD1 is the address number of the original sensor, and ADD2 is the address number that is about to be
changed.
2. The factory default address of the sensor is 01H.ADD1, and the settable range of ADD2 is 00-FF, with a total of 256 addresses.
3. If you don’t know what the current address is, you can use the FA command to reset the address to 01 (factory address). The specific download command is as follows (COMMAND): FAH 10H 00H 57H 00H 01H 02H 00H 01H 1DH 43H
4. When ADD1=FAH, it is a broadcast command. No matter what the sensor address is on the RS485 bus, this command will always
change the sensor address to ADD2.
■4. Example of command to modify the baud rate (change the baud rate to 4800bps)
● COMMAND (download command)
slave device address |
function code |
Starting register address |
Number of registers |
Number of data bytes |
Data written to register |
CRC-L |
CRC-H |
|||
01H |
10H |
00H |
20H |
00H |
01H |
02H |
00H |
05H (Changed baud rate code) |
61H |
33H |
Note: Baud rate code setting
03-1200bps ; 04-2400bps ; 05-4800bps
06-9600bps ; 07- 19200bps;
After writing the above baud rate code into the register, follow the baud rate corresponding to the code just communicate.
■5.Message format
5. 1 Function code 03H-Query slave register data
● Host message (download) |
● Slave message (response) |
||
slave address |
1 byte (00H~FFH) |
slave address |
1 byte (00H~FFH) |
function code |
1 byte (03H) |
function code |
1 byte (03H) |
Starting register address |
2 bytes |
Number of bytes in data area |
2*Number of registers 1 byte |
Number of registers |
2 bytes |
data area |
Number of bytes = 2X number of registers |
CRC check code |
2 bytes |
CRC check code |
2 bytes |
5.2 Function code 10H-Set the slave
● Host message (download) |
● Slave message (response) |
||
slave address |
1 byte (00H~FFH) |
slave address |
1 byte (data written to register) |
function code |
1 byte (10H) |
function code |
1 byte (10H) |
Register address |
2 bytes (00H 57H or 00H 20H) |
Register address |
2 bytes |
|
2 bytes |
Number of registers |
2 bytes |
Number of bytes in data area |
1 byte (2X number of registers) |
CRC check code |
2 bytes |
Data written to register |
Number of bytes = 2X number of registers |
|
|
CRC check code |
2 bytes |
● Noted: CRC check code low bit first, high bit last; register address, register number, the data are all in high order first and low order last.
■6.Register description
● 6. 1 Single input
Register address |
Register contents |
Number of registers |
Register status |
data range |
0056H |
Single channel power |
1 |
read only |
0~10000 |
● 6.2 Multiple inputs (2~24 channels)
Register address |
Register contents |
Number of registers |
Register status |
Rated range |
maximum range |
0010H |
2st Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0011H |
2nd Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0012H |
3rd Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0013H |
4th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0014H |
5th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0015H |
6th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0016H |
7th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0017H |
8th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0018H |
9th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0019H |
10th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
001AH |
11th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
001BH |
12th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
001CH |
13th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
001DH |
14th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
001EH |
15th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
001FH |
16th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0020H |
17th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0021H |
18th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0022H |
119th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0023H |
20th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0024H |
21st Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0025H |
22nd Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0026H |
23rd Channel Power |
1 |
read only |
0~10000 |
0~12000 |
0027H |
24th Channel Power |
1 |
read only |
0~10000 |
0~12000 |
● Noted: No. 1~24 power supply" corresponds to the " No. 1~24" input parameters of the sensor label.
■7. Schematic diagram of sensor and computer connection
● The sensor can be connected to the computer through RS485/RS232 or RS485/USB converter, and communicate with it using the serial port debugging assistant to check whether the sensor is normal.
● Noted: 1. Sensor indicator light status, if the red light interval flashing frequency is 500mS, it is working normally;
The blue light flashes during normal communication and goes out when there is no communication; please connect the sensor correctly. The output terminals A and B of the sensor are reversely connected and cannot communicate; the sensor has been accurately
calibrated when leaving the factory. Users generally do not need to verify again. (Some models have no indicator light, just use it normally)
2. Sampling frequency >200mS
■8.The sensor adopts the RTU mode in the MODBUS communication protocol
RTU frame
Using RTU mode, message sending must start with a pause interval of at least 3.5 character times. This is easiest to implement with various character times at network baud rates (as shown in T 1-T2-T3-T4 in the figure below) ). The first field transferred is the device address. The transmission characters that can be used are hexadecimal 0...9,A...F. Network devices continuously monitor the network bus, including during pause intervals. When the first field (address field) is received, each device decodes it to see if it is destined for its own. After the last transmitted character, a pause of at least 3.5 characters marks the end of the message. A new message can be started after this pause. |
The entire message frame must be transmitted as one continuous stream. If there is a pause of more than 1.5 characters before the frame is completed, the receiving device will flush the incomplete message and assume that the next byte is the address field of a new message. Likewise, if a new message begins after the previous message in less than 3.5 characters, the receiving device will consider it a continuation of the previous message. This will cause an error because the value in the last CRC field cannot be correct. A typical message frame looks like this: |
start bit |
Device address |
function code |
data |
CRC |
Check terminator |
T1-T2-T3-T4 |
8Bit |
8Bit |
n*8Bits |
16Bit |
T1-T2-T3-T4 |
■9.Sensor input and output table (theoretical value)
input value percentage(%) |
input value |
Rs485 output |
decimal |
0% |
A0 |
0x0000 |
0 |
20% |
A0+ (Af-A0)*20% |
0x07D0 |
2000 |
40% |
A0+ (Af-A0)*40% |
0x0FA0 |
4000 |
60% |
A0+ (Af-A0)*60% |
0x1770 |
6000 |
80% |
A0+ (Af-A0)*80% |
0x1F40 |
8000 |
100% |
Af |
0x2710 |
10000 |
Af --the input nominal value of the calibrated sensor
A0 --Lower limit of nominal input value of the calibrated sensor
Appendix 1: MOD BUS_CRC 16 check code calculation method The cyclic redundancy check CRC area is 2 bytes and contains a 16-bit binary data. The sending device calculates the CRC value and attaches the calculated value to the message. When the receiving device receives the message, it recalculates the CRC value and compares the calculated value with the received time value in the CRC area. If the two are not the same , an error occurs. At the beginning of CRC computation, initialize the 16-bit register with all bits set to " 1". Then, place the data of two adjacent 8-bit bytes into the current register. Only the 8 bits of data from each character are used for CRC generation, excluding the start bit, stop bit, and parity bit, which are not included in the CRC. During CRC generation, perform an XOR operation between each 8-bit data and the value in the register. Shift the result one position to the right (towards LSB), filling the MSB (most significant bit) with "0". Check the LSB (least significant bit), if LSB is " 1", XOR it with a predetermined fixed value; if LSB is "0", no XOR operation is performed. Repeat the aforementioned process until shifting has been performed 8 times. After completing the 8th shift, XOR the next 8-bit data with the current value in the register. After processing all the information, the final value in the register represents the CRC value. |
The process of generating CRC: 1.Set the 16-bit CRC register to FFFFH. 2. Perform an XOR operation between the lower 8 bits of the CRC register and the first 8-bit data, and place the result into the CRC register. 3.Shift the CRC register one position to the right, fill the MSB with zero, and check the LSB. 4.(If LSB is 0): Repeat step 3, then shift one position to the right. (If LSB is 1:) Perform an XOR operation between the CRC register and A001H. 5.Repeat steps 3 and 4 until 8 shifts are completed, completing the processing of an 8-bit byte. 6.Repeat steps 2 through 5, processing the next 8-bit data, until all bytes are processed. 7. The final value in the CRC register represents the CRC value. 8. When inserting the CRC value into the information, the high 8 bits and low 8 bits should be placed separately. |
Insert the CRC value into the information.
When sending the 16-bit CRC value in the information, transmit the low 8 bits first, followed by the high 8 bits. If the
CRC value is 1A64:
slave device address |
function code |
Starting register address |
Number of registers |
CRC-L |
CRC-H |
||
|
|
|
|
|
|
64H |
1AH |