19
预置多寄存器
Preset multiple
registers
把具体的二进制值装入一串连续的保持寄存器
Load specific binary values into a series of consecutive
holding registers
7.3.4 数据(Data)域 Data domain
数据域包含了终端执行特定功能所需的数据
或终端响应查询时采集到的数据。这些数据可能是
数值、参量地址或者设置值。
The data domain contains the data required for
the terminal to perform a specific function or the data
collected when the terminal responds to a query.
These data may be numeric values, parameter
addresses, or setting values.
例如:功能域告诉终端读取一个寄存器,数据
域则需要指明从哪个寄存器开始及读取多少个数
据,内嵌的地址和数据依照类型和从机之间的不同
而内容有所不同。
For example, the function domain tells the
terminal to read a register, and the data domain needs
to specify which register to start and how many data
to read. The embedded address and data differ
according to the type and the slave.
7.3.5
错误校验(
Check
)域
Error check domain
该域采用 CRC16 循环冗余校验,允许主机和终
端检查传输过程中的错误。有时由于电噪声和其它
干扰,一组数据从一个设备传输到另一个设备时,
在线路上可能会发生一些改变,错误校验能够保证
主机或从机不去响应那些发生改变的数据,这就提
高了系统的安全性、可靠性和效率。
This domain uses a CRC16 cyclic redundancy
check to allow hosts and terminals to check for errors
during transmission. Sometimes due to electrical noise
and other interference, when a group of data is
transferred from one device to another, some changes
may occur on the line. Error checking can ensure that
the master or slave does not respond to those changed
data. This improves the security, reliability, and
efficiency of system.
7.3.6
错误校验的方法
Error check method
错误校验(CRC)域占用两个字节,包含了一
个
16
位的二进制值。
CRC
值由传输设备计算出来,
然后附加到数据帧上,接收设备在接受数据时重新
计算
CRC
值,然后与接收到的
CRC
域中的值进行
比较,如果这两个值不相等,就发生了错误。
The error check (CRC) domain occupies two
bytes and contains a 16-bit binary value. The CRC
value is calculated by the transmitting device and then
appended to the data frame. The receiving device
recalculates the CRC value when receiving the data,
and then compares it with the value in the received
CRC domain. If the two values are not equal, it occurs
error.
CRC 运算时,首先将一个 16 位的寄存器预置
为全 1,然后连续把数据帧中的每个字节中的 8
位与该寄存器的当前值进行运算,仅仅每个字
节的
8
个数据位参与生成
CRC
,起始位和停止位以
及可能使用的奇偶位都不影响
CRC
。在生成
CRC
时,每个字节的
8
位与寄存器中的内容进行异或,
然后将结果向低位移位,高位则用“0”补充,最
低位(LSB)移出并检测,如果是 1,该寄存器就与
一个预设的固定值(0A001H)进行一次异或运算,
如果最低位为
0
,不作任何处理。
In the CRC operation, a 16-bit register is first
preset to all ones, and then 8 bits in each byte in the
data frame are successively operated on with the
current value of the register, only 8 data bits per byte
participate in generating a CRC, and neither the start
and stop bits nor the parity bits that may be used affect
the CRC. When the CRC is generated, the 8-bit of
each byte is XORed with the contents of the register,
and then the result is shifted to the low-order bit. The
high-order bit is complemented with "0" and the LSB
is shifted out and detected. If it is 1, This register is
XORed with a preset fixed value (0A001H). If the
least significant bit is 0, nothing is done.