
7
2.1 Characters Format
The above mentioned packets referred to the transmitted character from
the PC or Supervisor.In this case this character cannot be modified
because they are set by Athena Controls. The default value is 8 , N, 1. It
means 8 data bits without parity check and with 1 stop bit.
2.2 The Address
As mentioned above, MODBUS transactions always involve the master,
which handles the line, and one slave at a time (except in the case of
broadcast messages). To identify the user to whom the message is sent,
the first character sent is a byte containing the numeric address of the
selected slave device. Each of the slaves will therefore be assigned a
different address that identifies it uniquely. The valid addresses range
from 1 to 247, while address 0, which cannot be assigned to a slave, set
at the start of the message sent by the master indicates that the message
is to be "broadcast", that is, sent to all the slaves at the same time.
Broadcast messages are exclusively those that do not require an answer
to carry out their function, i.e. assignments only.
2.3 The Function Code
The second character in the message identifies the function that is to be
performed in the message sent by the master, to which the slave
answers by sending back the same code to indicate that the function has
been performed. On ATHENA CONTROLS instruments, a subset of the
MODBUS functions has been implemented as follows:
• 01 Read Coil Status
• 02 Read Input Status
• 03 Read Holding Registers
• 04 Read Input registers
• 05 Force Single Coil
• 06 Preset Single register
• 07 Read Status
• 15 Force Multiple Coils
• 16 Preset Multiple Registers
In the implementation for ATHENA CONTROLS instruments, functions 01
and 02 are functionally identical and interchangeable, as are functions 03
and 04. For a full and detailed description of the functions, see chapter 3.
2.4 The CRC 16 Algorithm
The last two characters in the message contain the Cyclic Redundancy
Check based on the CRC16 algorithm. To calculate these two
characters, the message (address, function code and data without the
start, stop and parity bits) is considered as a single continuous binary
number whose most significant bit (MSB) is sent first. The message is
first multiplied by x
16
(shifted to the left by 16 bits) and then divided by
2
16
+2
15
+2
2
+1 expressed as a binary number (1100000000000101). The
integer part of the quotient is then rejected and the 16 bit remainder
(initialised at FFFFh at the start to avoid messages consisting exclusively
of zeros) is added on to the end of the message sent. The resulting
message, when divided by the same polynomial (2
16
+2
15
+2
2
+1) by the
receiving device must give zero as a remainder if no errors occurred (the
receiving device recalculates the CRC).
Comentários a estes Manuais