
`
- 17 -
numerical value,a reference address,or a setting value.For example,the function code tells the
terminal to read a register,the data area needs to indicate whichregister to start from and howmany
data to read,and the embedded address and data vary according to the type and the content between
the slave machine.
CRC check code:the error check(CRC) domain takes up two bytes and contains a 16-bit binary
value.CRC values are calculated by the transmission device and then appended to the data frame,and
the receiving the data.Then compared with the received value in the CRC domain,if the two values
are not equal,an error occurs.
The process for generating a CRC is:
a、Preset a 16-bit register to 0FFFFH(FULL 1),called CRC registe.
b、XOR the 8 bits of the first byte in the data frame with the low byte in the CRC register,and
the result is saved back to the CRC registe.
c、Move the CRC register one bit to the right,fill in the highest bit with 0,and the lowest
displacement is out and detected.
d、If the lowest is 0,repeat the third step(next shift);if the lowest is
1,XOR the CRC register
to a preset fixed value (0A001H).
e、Repeat steps 3 and 4 until 8 shifts.In this way,a complete eight digits have been dealt with.
f、Repeat steps 2 to 5 to process the next eight bits until all byte processing is over.
g、Finally,the value of the CRC register is the value of CRC.
In addition,there is also a method of calculating CRC using preset tables,the main feature of which
is that the calculation speed is fast,but the table requires a large storage space.This method is
not respeated here,see the relevant information.
7.3Brief introduction of function code
7.3.1Function code 03H
:
read registe
This feature allows users to obtain data and system parameters that are capyured and recorded
by the device,with no limit on the number of data requested by the host at a time,but not beyond
the defined address range.
The following example is the basic data collected from three machine-readable data from NO.01(2
byte per address in the data frame)where the address of UAB is 246(F6H),UBC is 247(F7H),UCA is
248(F8H).
Host send
Send
information
Return from the machine
Return
information
Address code
01H
Address code
01H