Professional Documents
Culture Documents
ATS CONTROLLER HAT600 Module Protocol-En
ATS CONTROLLER HAT600 Module Protocol-En
Communication Protocol
CONTENTS
1 MODBUS BASIC RULES .....................................................................................2
2 DATA FRAME FORMAT ........................................................................................2
3 COMMUNICATION PROTOCOL ..........................................................................2
4 CRC-16 ALGORITHM PROCEDURE ...................................................................3
5 EXAMPLES OF INFORMATION FRAME FORMAT..............................................4
5.1 Function Code 01H ......................................................................................4
5.2 Function Code 03H ......................................................................................4
5.3 Function Code 05H ......................................................................................5
6 ERROR HANDLING .............................................................................................6
7 APPEDIX: ADDRESS AND DATA .........................................................................6
7.1 Table 1: Function Code 01H Map Data Field ...............................................6
7.2 Table 2: Function Code 03H Mapping Data Field ........................................8
7.3 Table 3: Function Code 05H Mapping Data Field ........................................8
1 MODBUS BASIC RULES
All RS485 should follow the master-slave mode. If so, data can be
transferred between a master (e.g. PC) and 32 slaves.
No communication can start from slaves.
In RS485 communication, all communication should be transmitted in
“information frame”.
If received information frame contains unknown command, no response
will be given.
3 COMMUNICATION PROTOCOL
When communication command is sent to the slave, corresponding slave
receives the communication command, then removes address code, and read
the information. If no mistakes, it will execute commands and sends the result
back to the master. Response information includes address code, function
code, data and error check code (CRC). If transmission error occurs, it will not
send any information.
Information Frame Format
Initiating Address Function Data End
CRC
structure code code field structure
Delay Delay
1 byte 1 byte N byte 2 bytes
(equivalent to (equivalent
8-bit 8-bit N*8-bit 16-bit
4 bytes) to 4 bytes)
Address Code
Address code is the first data byte in each transmitted information frame (8-bit)
limited to the range of 1–254.
Function Code
This is a second byte of each transmission. If the MSB of function code sent by
slave is 1 (function code range>127), it means there is no response or
response has error.
The following table shows the specific signification and operation of function
code.
Function code Definition Operation
01H Read Coils Read Coils
03H Read registers Read Holding Registers.
05H Write Single Coil Write Single Coil.
1) 01H Read Coils
With function code 01H command, master can read types of coils.
2) 03H Read Holding Registers
With function code 03H command, the master can read the numerical registers
inside the module. Read registers values from the device are 2 bytes (16-bit).
The slave received command format is slave address, function code, data field
and CRC code. The data of data field is in double bytes with every two bytes
for a group, and high byte is in advance.
3) 05H Write Single Coil
Master uses this command to save a single coil data into bit registers in the
device.
DATA Field
Data field varies with different function codes.
Error Check Code (CRC)
The Error Check Field consists of a 16 bit Cyclical Redundancy Check
(CRC16). The CRC is 2 bytes. When the CRC is appended to the message,
the low-order byte is appended first, followed by the high-order byte.
Read 1CH (28 Decimal) coils for slave address is 01 and starting address is
0000H.
Request Bytes Example (Hex)
Slave Address 1 01 Send to the slave 01
Function Code 1 01 Read coils
2 00 Starting address is 0000
Starting Address
00
2 00 Read 28 coils
Read Count
1C
2 3D CRC code from PC
CRC Code
C3
Note: Set FF00H as 1 and 0000H as 0, others are defined as illegal status that
won’t affect the digital input.
Request Bytes Example (Hex)
Slave Address 1 01 Slave address is 01
Function Code 1 05 Set single coil
2 00 Starting address is 0002
Starting Address
02
2 FF Set coil as 1
Data
00
2 2D CRC code from PC
CRC Code
FA
6 ERROR HANDLING
When device detected other errors except the CRC code, the slave must send
information to the master. The function code MSB is 1, which means the
response function code by slave should add 128 based on the function code.
Received information from the master, such as a CRC error, will be ignored by
the device.
The slave response error frame format is as follows (CRC excluded):
Address code 1 byte
Function code 1 byte (MSB is 1)
Error code 1 byte
CRC code 2 bytes