EMSA HS500E 用户手册
C H A P T E R 6 : M O D B U S T C P P R O T O C O L
6.2
M
O D B U S
T C P
H
A N D S H A K I N G
Modbus TCP handshaking is governed by the changing of the “Overall Length”
value within a data packet. The Overall Length value is typically the first 2-bytes of a
command or response and indicates the total number of data words in the packet
(including one word for the Overall Length value).
value within a data packet. The Overall Length value is typically the first 2-bytes of a
command or response and indicates the total number of data words in the packet
(including one word for the Overall Length value).
Overall Length values are stored in the first holding register, 40001, of Device ID 1
(for commands)
(for commands)
and Device ID 33 (for responses). When the value at register 40001
(of Device ID 1) changes from 00, the HS500E will recognize that a command is
waiting to be executed. The HS500E will then execute the command and return a
response at Device ID 33.
waiting to be executed. The HS500E will then execute the command and return a
response at Device ID 33.
6 . 2 . 1
H o s t / H S 5 0 0 E M o d b u s T C P H a n d s h a k i n g
One implication of this process is that when the Host issues a command, it must first
write the entire command to the holding registers for Device ID 1, leaving the Overall
Length value to be written last.
write the entire command to the holding registers for Device ID 1, leaving the Overall
Length value to be written last.
For example, for the Host to issue the 6-word command “Read Data,” it must first
write the last 5 words of the command to Device ID 1, beginning at register 40002.
write the last 5 words of the command to Device ID 1, beginning at register 40002.
L
A S T
5
W
O R D S O F A
R
E A D
D
A T A
C
O M M A N D
Word
MSB
LSB
Description
02
AA
02
Command ID: Read Data
03
00 01
Node
ID
04
03 E8
Timeout Value of 1 second (measured in
ms)
ms)
05
00
20
Read Start Address: 0x20
06
00
04
Read 4 Bytes
After writing the last 5 words of the command, the Host will write the Overall Length
value to register 40001 of Device ID 1.
value to register 40001 of Device ID 1.
F
I R S T
W
O R D O F A
R
E A D
D
A T A
C
O M M A N D
Word
MSB
LSB
Description
01
00
06
Overall Length (in words)
The moment the Overall Length value at register 40001 of Device ID 1 changes to a
“non-zero” value, the HS500E will recognize the waiting data and will execute the
command.
“non-zero” value, the HS500E will recognize the waiting data and will execute the
command.
H S 5 0 0 E – O P E R A T O R ’ S M A N U A L
P / N : 1 7 - 1 3 0 5 R E V 0 2 ( 1 2 - 0 5 )
P A G E 5 5 O F 8 2