MOL81 485 1312/MOL81 485 1337
MOL81 485 1312-MOL81 485 1337-UM-1.4-EN
10/20
6 MESSAGES RECEIVED BY READER
6.1 MODBUS Protocol
This is a master/slave protocol. Each exchange is initiated by the master and consists, except in one case
(broadcast message), of an exchange of two frames - a command issued by the master and a reply from the
slave. All frames have the following structure:
1 byte
1 byte
n bytes
2 bytes
Slave address
Function code
data
control
The MOL1312 is a slave on a MODBUS network
The commands issued by the master are either addressed to one slave (identified by its address) or to all
slaves on the network (broadcast).
Each message or frame contains 4 fields:
•
The slave address (1 byte):
Specifies the destination, from 1 to 254. If the address is 0 (zéro), it is a broadcast message. In this case
there is no reply.
•
the function code (1 byte):
Determines the type of action to be performed (read, write, bit, word) and, in the reply, indicates if the
message was received correctly.
•
The data field (n bytes):
Contains the parameters associated with the function: command code, number of bytes, values.
•
Control field (2 bytes):
For error detection
(CRC 16).
The MODBUS protocol defines 12 functions (second field in frame). Two of them are implemented on the
MOL81:
•
function code 3 or 4
- read n words (*)
•
function code 16
- write n words
(*) for reading n words, the MOL 81 accepts function codes 3 and 4.
If the message is received with errors (CRC incorrect), the reader does not reply. If the message is received
correctly but the reader cannot process it, an error message is sent. This error message has its function code
field modified, (the msb is set to 1) and the data field contains one byte, an error code with the following values
:
Error type
Error code
Function code unknown
1
Command unknown
2
Data incorrect
3
System non ready
4
Execution failure
8
Figure 6-1: MODBUS error codes