Appendix B – Modbus Protocol
NMBA-01 Installation and Start-up Guide
B-9
During generation of the CRC, each 8-bit character is exclusive ORed
with the register contents. Then the result is shifted in the direction of
the least significant bit (LSB), with a zero filled into the most significant
bit (MSB) position. The LSB is extracted and examined. If the LSB was
a 1, the register is then exclusive ORed with a preset, fixed value. If the
LSB was a 0, no exclusive OR takes place.
This process is repeated until eight shifts have been performed. After
the last (eighth) shift, the next 8-bit byte is exclusive ORed with the reg-
ister’s current value, and the process repeats for eight more shifts as
described above. The final contents of the register, after all the bytes of
the message have been applied, is the CRC value.
In ladder logic, the CKSM function calculates a CRC from the message
contents. For applications using host computers, a detailed example of
CRC generation is contained later in this appendix.
Modbus Function
Formats
This chapter describes in detail the data content on every Modbus
message supported by the NMBA-01.
How Numerical Values
are Expressed
Unless specified otherwise, numerical values (such as addresses,
codes, or data) are expressed as
decimal values in the text of this sec-
tion. They are expressed as hexadecimal values in the message fields
of the figures.
Data Addresses in
Modbus Messages
All data addresses in Modbus messages are referenced to zero. The
first occurrence of a data item is addressed as item number zero. For
example:
•
The coil known as ‘coil 1’ in a programmable controller is addressed
as coil 0000 in the data address field of a Modbus message.
•
Coil 127 decimal is addressed as coil 007E hex (126 decimal).
•
Holding register 40001 is addressed as register 0000 in the data
address field of the message. The function code field already speci-
fies a ‘holding register’ operation. Therefore the ‘4XXXX’ reference
is implicit.
•
Holding register 40108 is addressed as register 006B hex (107 dec-
imal).
Field Contents in
Modbus Messages
Figure B-3 ‘Master Query with RTU Framing’ shows an example of a
Modbus query message.
Figure B-4 ‘Slave Response with RTU Fram-
ing’ is an example of a normal response. Both examples show the field
contents in hexadecimal, and also show how a message is be framed
in RTU mode.
The master query is a Read Holding Registers request to slave device
address 06. The message requests data from three holding registers,
40108 through 40110. Note that the message specifies the starting
register address as 0107 (006B hex).
The slave response echoes the function code, indicating this is a nor-
efesotomasyon.com - Control Techniques,emerson,saftronics -ac drive-servo motor