Dini Argeo CPWEBELT-MODBUS - 01.00 - 10.10 - EN
Dini Argeo CPWEBELT-MODBUS - 01.00 - 10.10 - EN
MICROCONTROLLER
CPWE-BELT
MODBUS
Communication protocol
CPWE-BELT_01.00_10.10_EN_MODBUS
CPWE-BELT_MODBUS_APPENDIX
INDEX
1. GENERALITIES..................................................................................................................................................................2
2. SYMBOLS...........................................................................................................................................................................2
3. SELECTION OF THE “MODBUS” SERIAL COMMUNICATION MODE............................................................................2
4. RTU (BINARY) MODBUS TRANSMISSION MODE ...........................................................................................................3
5. DESCRIPTION OF THE COMPONENTS AND MESSAGE FORMAT................................................................................3
5.1 FRAME FORMAT IN RTU MODE................................................................................................................................3
5.2 THE DEVICE ADDRESS .............................................................................................................................................4
5.3 THE FUNCTION CODE ...............................................................................................................................................4
5.4 THE DATA ...................................................................................................................................................................4
5.5 THE ERROR CHECK ..................................................................................................................................................4
5.6 EXAMPLE OF THE MESSAGE COMPONENTS IN RTU............................................................................................5
6. MODBUS FUNCTIONS.......................................................................................................................................................6
6.1 LIST OF THE SUPPORTED FUNCTIONS ..................................................................................................................6
6.2 LIST OF THE TRANSMISSION STRINGS ..................................................................................................................6
6.3 FUNCTION 1: READ INPUT REGISTERS (04 Hex)....................................................................................................6
6.4 FUNCTION 2: PRESET SINGLE REGISTER (06 Hex) ...............................................................................................7
6.5 FUNCTION 3: PRESET MULTIPLE REGISTERS (16 Hex).........................................................................................8
7. ERROR CHECK METHODS ...............................................................................................................................................9
7.1 PARITY CHECK...........................................................................................................................................................9
7.2 CRC ALGORITHM: CYCLICAL REDUNDANCY CHECK (RTU MODE)......................................................................9
7.3 A PROCEDURE FOR CREATING THE CRC IS THE FOLLOWING ...........................................................................9
7.4 PLACING OF THE CRC IN THE MESSAGE .............................................................................................................10
7.5 EXAMPLE IN C LANGUAGE IN GENERATING THE CRC .......................................................................................10
8. MODBUS EXCEPTIONS ..................................................................................................................................................11
8.1 LIST OF THE DETECTED EXCEPTIONS .................................................................................................................11
9. INPUT AND OUTPUT DATA AREAS...............................................................................................................................11
9.1 INPUT DATA AREA: INPUT REGISTERS.................................................................................................................11
9.1.1 COMMAND STATUS REGISTER .....................................................................................................................13
9.1.2 BELT STATUS REGISTER ...............................................................................................................................14
9.1.3 INPUT STATUS REGISTER .............................................................................................................................15
9.1.4 OUTPUT STATUS REGISTER..........................................................................................................................15
9.1.5 SETPOINT STATUS REGISTER ......................................................................................................................16
9.2 OUTPUT DATA AREA: HOLDING REGISTERS .......................................................................................................16
9.2.1 COMMAND REGISTER ....................................................................................................................................17
1
CPWE-BELT_MODBUS_APPENDIX
1. GENERALITIES
The Modbus communication protocol defines the structure of the messages and the communication mode between a
“master” device which manages the system and one or more “slave” devices which respond to the interrogations of the
master (master-slave technique).
This protocol defines how the transmitter and receiver are identified, the data switch mode, the communication launch and
interruption modes and the error detection mode.
Only the master can start a transaction (Query) while the other devices (the slaves) respond by supplying the data
requested to the master or carrying out the actions requested in the query. The master can either address single slaves or
transmit a broadcast message to all. The slaves respond with a message (Response) to the queries which are individually
addressed, but do not transmit any answer to the master if there are broadcast messages.
A transaction can therefore have the following structures:
- Single question to a slave / Single answer from the slave
- Single broadcast message to all the slaves / No answer from the slaves
2. SYMBOLS
In the manual:
2
CPWE-BELT_MODBUS_APPENDIX
The address of the device with which the master has established the transaction (the address 0 corresponds to a
broadcast message transmitted to all the slave devices).
The function code which defines the requested action.
The data which must be transmitted.
The error check made up according to the CRC algorithm.
These fields are described in detail in the following paragraphs. For the Query and Response there is:
Query:
The function code tells the addressed slave device which action must be made. The data bytes contain some additional
information which the slave needs in order to execute the function. The error check field gives the slave a method in order to
confirm the integrity of the message contents.
Response:
If the slave gives a normal answer:
The function code is the echo of the query function code. The data bytes contain the data retrieved from the slave, like
the registers’ values or the states.
If a slave locates an error (format, parity, or in the CRC) or it is unable to execute the requested action:
The master message is considered non valid and rejected and consequently the action will not be executed; a Response
in which the function code is changed in order to indicate that is an error response and the data bytes contain a code
which describes the error.
3
CPWE-BELT_MODBUS_APPENDIX
CRC
START ADDRESS FUNCTION DATA CHECK END
Valid addresses for the slave devices are within a range from 0 to 247, in particular:
The communication strings are checked by a CRC (Cyclical Redundancy Check) algorithm, see Section 7 for further
details.
The error check field contains 16 bits (implemented as 2 bytes of 8 bits), which are the result of the calculation of a CRC
algorithm executed on the contents of the message.
This field is the last of the message and the first byte is the one of the low order and is followed by one of the high order,
which is the last one of the frame.
4
CPWE-BELT_MODBUS_APPENDIX
Query: “Read Input Registers” to the 01 Slave Device address, for the reading of the contents of 3 registers starting
from register n°8.
Response:
In the Response of the Slave there is the Function Echo indicating that it’s a normal type of answer.
The “Number of Bytes” field specifies how many groups of 8-bit data are given back, in other words, the number of bytes of
the “Data” fields is shown for the RTU.
For example the 63 Hex value is transmitted as a 8-bit byte (01100011).
5
CPWE-BELT_MODBUS_APPENDIX
6. MODBUS FUNCTIONS
Each function is exposed in detail in the following pages and is made up of a QUERY (Master request → Instrument) and a
RESPONSE (Instrument response → Master).
NOTE:
Each character is an Hexadecimal type of character (made up of 4 bits).
With 0x or Hex before a number it means that it has to do with a hexadecimal value.
Other fields for the message frames are described in detail in the various single functions.
NOTE: the following registers are defined, on which the functions operate:
- N°16 Input Registers (or “Input Registers”): written by the Instrument → read by the Master
- N°16 Output Registers (or “Holding Registers”): written by the Master → read by the Instrument
Query:
The Initial Register is specified (1st Register Address) from which the reading starts and the Number of Registers which
must be read (Nr. of Registers). The registers are addressed from 0: in this way the registers from 1 to 16 are addressed as
0 to 15.
6
CPWE-BELT_MODBUS_APPENDIX
Response:
The response message is made up of 2 bytes for each read register, with the binary content aligned on the right in each
byte. For each register the first byte contains the most significant bits and the second byte contains the least significant bits.
Example: A = 01;
- in the Query: 1st Register address = 00 08; Number of Registers = 00 01
- in the Response: 1st Register = 00 0A
Query:
One specifies the Register Address which must be set (Register Address) and the relative Value (Register Value). The
registers are addressed starting from 0: in this way the registers from 1 to 16 are addressed as 0 to 15.
Response:
It is the echo of the Query.
Address Function Address 1st Register Nr. of Registers Error
High Low High Low Check
A 06 00 01 00 03 CRC
Example: A = 01;
- in the Query: Register Address = 00 01; Register Value = 00 03
- in the Response: Register Address = 00 01; Register Value = 00 03
7
CPWE-BELT_MODBUS_APPENDIX
Query:
Here is specified the address of the First output Register which must be set (1st Register address), the Number of Registers
to be written (Nr. of Registers) starting from the first, the number of bytes transmitted for the values of the registers (2 bytes
for each register) or Nr. of Bytes and then the values to be assigned to the registers (1st Register value of 2 bytes, 2nd
Register Value, etc.) starting from the first one addressed.
Address Function 1st Register Nr. of Nr. of 1st Register 2nd Register Error Check
Address Registers bytes Value Value
High Low High Low High Low High Low
A 10 00 00 00 02 04 00 00 00 00 CRC
Response:
The response includes the identification of the modified registers (1st Register address and Nr. of Registers).
Example: A = 01;
- in the Query: 1st Register Address = 00 00; Nr. of Registers = 00 02; Nr. of bytes = 04;
1st Register Value = 00 00; 2nd Register Value = 00 00;
- in the Response: 1st Register Address = 00 00; Nr. or registers = 00 02;
8
CPWE-BELT_MODBUS_APPENDIX
Check on the character or parity (even or uneven), can be applied optionally to each character
Check on the frame (CRC algorithm), applied to the entire message.
Both the check on the character as well as the one on the frame of the message is created in the Master and applied to the
contents of the message before the transmission. The Slave checks each character and the entire frame of the message
during the reception.
2. OR-exclusive with the first byte of the message and the least significant byte of the CRC Register at 16 bit.
The result is inserted in the CRC register.
3. The CRC Register is shifted of 1 bit to the right (towards the LSB), a 0 is inserted in the place of the MSB. The LSB is
extracted and examined.
5. Steps 3. and 4. are repeated until 8 shifts have been made; after this a byte of 8 bits have been completely processed.
6. Steps 2 to 5 are repeated for the next byte of 8 bits of the message.
One continues until all the bytes are processed.
7. The final contents of the CRC Register are the CRC Value.
8. When the CRC is inserted within the message, its bytes (high and low) must be exchanged as described below.
9
CPWE-BELT_MODBUS_APPENDIX
For example, if the CRC value is 1241 Hex (0001 0010 0100 0001):
41 12
Fig. 5: Sequence of the CRC bytes.
NOTE: The function creates internally the swapping of the high and low bytes of the CRC. The bytes are already exchanged
in the CRC value which is given back by the function, which can then be placed directly in the message for the transmission.
unsigned char *puchMsg; → A pointer to the message buffer which contains the binary data to be used for
creating the CRC
→ The quantity of bytes in the message buffer
unsigned short usDataLen;→
10
CPWE-BELT_MODBUS_APPENDIX
8. MODBUS EXCEPTIONS
In a normal response (Normal Response) the Slave device echoes the Function Code of the Query, putting it in the
Response Function field. All the function codes have their own most significant bit (MSB) set at 0 (values less than 80 Hex).
In an exception response (Exception Response) the slave sets the MSB of the Function Code at 1 (equivalent to summing
the value 80 Hex to the normal response code) in order to signal that an anomaly has taken place, and the Exception Code
is given back in the Data Field, in order to indicate the type of exception.
Page 0
Page 1
In which the Result of the last received command can assume the following values:
OK = 0 Corrected and executed command
ExceptionCommandWrong = 1 Incorrect command
ExceptionCommandData = 2 Data in the incorrect command
ExceptionCommandNotAllowed = 3 Command not allowed
ExceptionNoCommand = 4 Inexistent command
13
CPWE-BELT_MODBUS_APPENDIX
In which
14
CPWE-BELT_MODBUS_APPENDIX
Bit meaning
Bit Description
0 1
(LSB)
0 Net Weight Polarity + --
1 Net Weight stability Unstable weight Stable weight
2 Underload Condition NO YES
3 Overload Condition NO YES
6 Gross ZERO zone Out of Zone 0 In Zone 0
5 Unit of measure (lsb) g kg
6 Unit of measure (msb)
7 Hourly Flow Polarity + --
(MSB)
8 Capacity/flow unit of measure (lsb) kg/h t/h
9 Capacity/flow unit of measure (msb)
10 Status of input IN1 disabled enabled
11 Status of input IN2 Belt speed = 0 Belt speed > 0
12 Status of input IN3 disabled enabled
13 Status of input IN4 disabled enabled
14 Status of input IN5 disabled enabled
15 Status of input IN6 disabled enabled
16 Status of input IN7 disabled enabled
17 Status of input IN8 disabled enabled
Table 5
In which Active Set point number can assume the following values:
00 NO FUNCTIONING (relay disabled).
01 GROSS SET POINT (enabling of the relay on the gross weight).
04 0 GROSS (activation of the relay on the gross weight at 0).
06 INSTABILITY (enabling of the relay upon weight instability)
22 BELT ENABLING (enabling the relay upon the dosage enabling).
23 CYCLE END
24 BELT PAUSE (enabling the relay on the dosage in pause).
25 SIDE-SLIPPING (enabling the relay on the belt side-slipping error)
26 > OVER FLOW (enabling the relay on the flow greater than the TARGET + <<F.R.ERR.>>)
27 < UNDER FLOW (enabling the relay on the flow less than the TARGET - <<F.R.ERR.>>)
28 ALARM (enabling the relay in the error condition)
29 BLOCK (enabling the relay upon the blocked dosage)
30 IMPULSE WEIGHT (enabling the relay, for non programmable 0.1 sec, when the increase of the weight total
reaches the value set in the F.Mode >> BELT >> PULSE.W step)
32 MATERIAL ENABLING (enabling the relay upon the dosage enabling only when the material dosage is
allowed, for example out of the zero flow execution)
33 SLOW FLOW WEIGHT (enabling the relay on the dosed weight greater than the TARGET - <<L.F.R.WEI>>)
34 BELT SPEED (enabling the relay when the speed is higher than 0)
Byte 30 -----------------------------------
15
Byte 31 -----------------------------------
Table 7
16
CPWE-BELT_MODBUS_APPENDIX
NOTE: the byte with the largest index is the LSB, while the one with the lowest index is the MSB.
Value of the Bytes of the Holding Register used
Implemented command
Command Register by the command (see table 7)
NO COMMAND 0 (0000 Hex) None
------------------------------- 1 (0001 Hex) -----------------------------
START DOSAGE
(only for REGULATOR mode,
TECH.MAN.REF.)
This command, in the flow reader mode, 2 (0002 Hex) None
offers the possibility to clear the dosed
partial total, with instrument in "INACTIVE"
status
PAUSE DOSAGE
(only for REGULATOR mode, 3 (0003 Hex) None
TECH.MAN.REF.)
RESET DOSAGE
(only for REGULATOR mode, 4 (0004 Hex) None
TECH.MAN.REF.)
SET TARGET FLOW
Bytes 2 and 3 must contain the flow
(only for REGULATOR mode, 5 (0005 Hex)
target.
TECH.MAN.REF.)
SET THE TARGET WEIGHT TO BE
DOSED. Byte 2 … 7 must contain the target
6 (0006 Hex)
(only for REGULATOR mode, weight to be dosed
TECH.MAN.REF.)
SET DOSAGE TIME
Byte 2 … 5 must contain the dosage
(only for REGULATOR mode, 7 (0007 Hex)
time.
TECH.MAN.REF.)
Bytes 2 and 3 must contain the number
PRINT FORMAT 8 (0008 Hex)
of format to be dosed
RESET GENERAL TOTAL 9 (0009 Hex) None
Bytes 2 and 3 must contain the relay
SET RELAY OUTPUTS 10 (000A Hex)
status of the instrument
PERMANENT SAVING OF CONFIGURED
11 (000B Hex) None
DATA
SELECTION OF SET POINT Byte 2 and Byte 3 must contain the
(The selected set point is visible in 12 (000CHex) number of set point to be selected
registers 11,12, 13, 14, 15; see table 4) (valid values: from 1 to 11)
Bytes 2 and 3 must contain the number
of set point to be modified
CONFIGURATION OF SET POINT
13 (000D Hex) Byte 4…7 must contain the ON value
of the set point
Byte 8…11 OFF value of the set point
Bytes 2 and 3 must contain the number
PAGE CHANGE COMMAND 14 (000E Hex)
of page to be read (0 or 1)
ZERO FLOW CALIBRATION (see section
8, USER.MAN.REF.). 15 (000F Hex) None
Table 8
17
CPWE-BELT_MODBUS_APPENDIX
Example: If 3 decimals have been set, to enter the value 3,000 → one should write 3000
If 2 decimals have been set, to enter the value 3,00 → one should write 300
RELAY setting
The status of the relays is settable through Parameter 1:
Parameter 1:
bit 0 → RELAY 1 in which bit 0 = 1 → RELAY 1 CLOSED; bit 0 = 0 → RELAY 1 OPEN
bit 1 → RELAY 2 in which bit 1 = 1 → RELAY 2 CLOSED ; bit 1 = 0 → RELAY 2 OPEN
bit 2 → RELAY 3
bit 3 → RELAY 4
bit 4 → RELAY 5
bit 5 → RELAY 6
bit 6 → RELAY 7
bit 7 → RELAY 8
bit 8 → RELAY 9
bit 9 → RELAY 10
bit 10 → RELAY 11
bit 11 → RELAY 12
bit 12 → RELAY 13
bit 13 → RELAY 14
bit 14 → RELAY 15
bit 15 → RELAY 16
NOTE: the relay configuration function works only with the relays which do not have assigned functions (therefore
programmed as "None", TECH.MAN.REF.)
18