page 8/15 KKEW9LC05-A/0-20160901
一、
MODBUS serial communication protocol
1
1
8
No
EW9L series energy meter adopts Modbus RTU communication protocol RS485 half duplex communication , read function code 0x03,
write function code 0x10 , adopts 16 digit CRC check, the energy meter does not feedback the check error.
Start bit
Data bit
Stop bit
Check bit
Communication protocol
(1) All the RS485 communication should comply with host/slave method. Under this method, information and data is transmitted between one host
and maximum 32 slaves (monitoring equipment);
(2) Host will initialize and control all information transmitted in RS485 communication circuit.
(3) In any case, communication can never be started from a slave.
(4) All the RS485 communication is sending by packet . One data packet is a simple string (every string has 8 bit). One packet include 128 byte
at most. The bytes in the packet formed in standard asynchronous serial data , and transmitting in the mode of 8 data bits, 1 stop bit, no check bit.
(5) Host sending is called request, slave sending is called response.
(6) In any case, slave can only respond to one request of host.
2. Each MODBUS data packet is consisted several parts as below:
(1) Slave address; (2) Function code to be executed; (3) Register address (variate address); (4) Data; (5) CRC check;
(1) Slave address: address length is 1 byte, effective slave address range is 1-247, if slave receives a data packet, whose frame address information
is consonant with its own address information , it will execute the order of data packet.
(2) Function code length in MODBUS data packet is one byte, used to inform the slave what kind of operation needs to be executed. The slave
response data packet should have the same function code byte of the operation requested by host.
Please refer to below table for related function code:
Transmitting package in RS485 network should follow the time regulation as follows:
(1) When baud rate set as 9600, the delay time between two host request is recommended to be 300ms or more, lesser time may cause the
loss of data packet.
(2) When the recommended baud rate is 9600, if use smaller baud rate, please enlarge delay time properly. For example, when baud rate is 2400,
two request should be set as more than 500ms.
II. Network time consideration
III. Abnormal communication processing
If host send a illegal data packet or host request a invalid data register, abnormal data response will happen. This abnormal data response is
consisted of slave address, function code, error code and check area. When the high bit position of function code area is 1, it means the present
data frame is abnormal response.
Below table illustrates the meaning of abnormal function code:
According to MODBUS communication requirement, abnormal response function code=request function code+0x80; when abnormal response,
put 1 on the highest bit of function code. For example: if host request function code is 0x04, slave response function code is 0x84.
0x01
Function code error
Meter received the unsupported function code
Variable address error Data location designated by host exceeds range of meter, or receive illegal register operation.
Variable value error
Data value sent from host exceeds the corresponding data range of meter, or data structure is incomplete
0x02
0x03
0x03
Read register
0x06
Write single-register
(3) Register address variable: data area storage location when slave executes effective order. Different variable seizes differents numbers of
register, some address variable seizes two register, 4 byte data, somevariable seizes one register, 2 byte data, please use according to
actual situation.
(4) Data area: data area includes the data required by terminal to execute specified function or collected data when terminal respond to query.
The content of the data could be numerical value, reference address or set value; for example: function code tells terminal to read a register,
data area needs to indicate which register to started from and how much data to be read, embedded address and data will be different
according to different content between type and slave; register numerical value send sequence : high byte in the front, low byte in the back.
(5) CRC check: MODBUS-RTU mode adopts 16 bit CRC check. Sending equipment should do CRC16 calculation for each data of packet,
final result is stored in check area. Receiving equipment also make CRC16 calculation for each data of packet (except check area), and
compare result area with check area; only the same packet can be accepted, for the specific CRC check algorithm please refer to appendix.
0x10
Write multi-register
Read one or more present register value
Write specified value into one internal register
Write specified value into several internal registers (Factory default write single register)
Function code Meaning Function
Error code type Name Contents illustration
1. Read multi-register
For example, host reads UA (A phase voltage), suppose measured A phase voltage is 220.0V.
The address code of UA is 0x4000, because UA is fixed data (4 byte), seizes 2 data register, the hexadecimal data of 220.0V is
0x0000898 (2200)
.
IV. Communication frame format illustration