DseriesProtocol en Temp Controller
DseriesProtocol en Temp Controller
DseriesProtocol en Temp Controller
INTERFACE
RS-485, RS-232
BAUD RATE
2400, 4800, 9600, 19200, 38400 bps
DATA FRAME
Data Bits8ParityNoneStart bit = 1Stop bit = 1
0
B0
B1
B2
B3
B4
B5
B6
B7
8 Data bits
1 Start bit
1 Stop bit
DATA FORMAT
ModBus Protocol RTU Mode
RTU RequestRead command
0
0x03
Station
Number
Func- Address
tion (MSB LSB)
Count
CRC16
(MSB LSB)
(LSB MSB)
0x03
Func- Byte
Data1
tion Count (MSB LSB)
Data2..
CRC16
(MSB LSB)
(LSB MSB)
0x06
Station
Number
Func- Address
tion (MSB LSB)
Data
CRC16
(MSB LSB)
(LSB MSB)
0x06
Func- Address
tion (MSB LSB)
Data
CRC16
(MSB LSB)
(LSB MSB)
ADDRESS INDEX
PARA
ADDR
PARA
ADDR
PARA
ADDR
Pv
0100H
Ar
001FH
O1HS
003FH
LEvL
0000H
P2
0020H
AO
0040H
LoCK
0001H
i2
0021H
O2LS
0041H
Sv
0002H
d2
0022H
O2HS
0042H
OutL
0003H
Ct2
0023H
t1SS
0043H
At
0004H
HSt2
0024H
t1On
0044H
mAn
0005H
db
0025H
t1ES
0045H
AL1S
0006H
SSv
0026H
t1oF
0046H
AL1L
0007H
Sout
0027H
t2SS
0047H
AL1U
0008H
StmE
0028H
t2On
0048H
AL2S
0009H
rUCy
0029H
t2ES
0049H
AL2L
000AH
rPt
002AH
t2oF
004AH
AL2U
000BH
StAt
002BH
inP1
004BH
AL3S
000CH
PvSt
002CH
LoSP
004CH
AL3L
000DH
wAit
002DH
HiSP
004DH
AL3U
000EH
Pid
002EH
LoAn
004EH
SOAK
000FH
EndP
002FH
HiAn
004FH
rAmP
0010H
AL1F
0030H
A1LS
0050H
PvoF
0011H
AL1H
0031H
A1HS
0051H
Pvrr
0012H
AL1t
0032H
unit
0052H
SvoF
0013H
AL1m
0033H
dP
0053H
Ct
0014H
AL2F
0034H
FiLt
0054H
HbA
0015H
AL2H
0035H
inP2
0055H
LbA
0016H
AL2t
0036H
A2LS
0056H
Lbd
0017H
AL2m
0037H
A2HS
0057H
rPtm
0018H
AL3F
0038H
bAud
0059H
P1
0019H
AL3H
0039H
Addr
005AH
i1
001AH
AL3t
003AH
LEv1
005BH
d1
001BH
AL3m
003BH
LEv2
005CH
Ct1
001CH
Act
003CH
LEv3
005DH
HSt1
001DH
Outm
003DH
LvSL
005EH
AtoF
001EH
O1LS
003EH
L1P1
005FH
PARA
ADDR
PARA
ADDR
PARA
ADDR
L1i1
0060H
tS1
0080H
1-12
00A0H
L1d1
0061H
Sv2
0081H
1-13
00A1H
L1Ar
0062H
tP2
0082H
1-14
00A2H
L1P2
0063H
tS2
0083H
1-15
00A3H
L1i2
0064H
Sv3
0084H
1-16
00A4H
L1d2
0065H
tP3
0085H
1-17
00A5H
L2P1
0066H
tS3
0086H
1-18
00A6H
L2i1
0067H
Sv4
0087H
1-19
00A7H
L2d1
0068H
tP4
0088H
1-20
00A8H
L2Ar
0069H
tS4
0089H
1-21
00A9H
L2P2
006AH
Sv5
008AH
1-22
00AAH
L2i2
006BH
tP5
008BH
2-14
00ABH
L2d2
006CH
tS5
008CH
2-15
00ACH
L3P1
006DH
Sv6
008DH
2-16
00ADH
L3i1
006EH
tP6
008EH
2-17
00AEH
L3d1
006FH
tS6
008FH
3-20
00AFH
L3Ar
0070H
Sv7
0090H
3-21
00B0H
L3P2
0071H
tP7
0091H
3-22
00B1H
L3i2
0072H
tS7
0092H
3-23
00B2H
L3d2
0073H
Sv8
0093H
3-24
00B3H
L4P1
0074H
tP8
0094H
3-25
00B4H
L4i1
0075H
tS8
0095H
3-26
00B5H
L4d1
0076H
1-2
0096H
3-27
00B6H
L4Ar
0077H
1-3
0097H
L4P2
0078H
1-4
0098H
L4i2
0079H
1-5
0099H
L4d2
007AH
1-6
009AH
SEG
007BH
1-7
009BH
TimE
007CH
1-8
009CH
EndS
007DH
1-9
009DH
Sv1
007EH
1-10
009EH
tP1
007FH
1-11
009FH
CRC Generation
The Cyclical Redundancy Check (CRC) field is two bytes, containing a 16bit binary value. The
CRC value is calculated by the transmitting device, which appends the CRC to the message. The
receiving device recalculates a CRC during receipt of the message, and compares the calculated
value to the actual value it received in the CRC field. If the two values are not equal, an error results.
The CRC is started by first preloading a 16bit register to all 1s. Then a process begins of applying
successive 8bit bytes of the message to the current contents of the register. Only the eight bits of
data in each character are used for generating the CRC. Start and stop bits, and the parity bit, do not
apply to the CRC.
During generation of the CRC, each 8bit 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
8bit character is exclusive ORed with the registers current value, and the process repeats for eight
more shifts as described above. The final content of the register, after all the characters of the
message have been applied, is the CRC value.
A procedure for generating a CRC is:
) Load a 16bit register with FFFF hex (all 1s). Call this the CRC register.
) Exclusive OR the first 8bit byte of the message with the loworder byte of the 16bit CRC
register, putting the result in the CRC register.
) Shift the CRC register one bit to the right (toward the LSB), zerofilling the MSB. Extract and
examine the LSB.
) (If the LSB was 0): Repeat Step 3 (another shift).(If the LSB was 1): Exclusive OR the CRC
register with the polynomial value A001 hex (1010 0000 0000 0001).
) Repeat Steps 3 and 4 until 8 shifts have been performed. When this is done, a complete 8bit
byte will have been processed.
) Repeat Steps 2 through 5 for the next 8bit byte of the message. Continue doing this until all
bytes have been processed.
) The final content of the CRC register is the CRC value.
) When the CRC is placed into the message, its upper and lower bytes must be swapped as
described below.
7
Addr
Func
Data
Count
Data
Data
Data
Data
CRCLo
CRCHi
41
12
N=0
No
Yes
Carry over
N=N+1
No
Yes
N>7
No
End of m essage
Yes
Following BYTE
END
XOR = exclusive or
N = num ber of inform ation bits
POLY = calculation polynom ial of the CRC 16 = 1010 0000 0000 0001
(Generating polynom ial = 1 + x2 + x 15 + x 16)
In the CRC 16, the 1st byte transm itted is the least significant one.
Move 5
Move 6
Move 7
Move 8
Move 2
Move 3
Move 4
Move 5
Move 6
Move 7
Move 8
1111
0000
1111
0111
1010
1101
0110
1010
1100
0110
0011
1010
1001
0100
0010
1010
1000
0100
0010
1010
1000
1111
0000
1111
1111
0000
1111
1111
0000
1111
0111
0011
0000
0011
1001
0100
0000
0100
0010
0001
0000
0001
1111
0000
1111
1111
0000
1111
1111
0000
1111
1111
1111
0000
1111
1111
1111
0000
1111
0111
0011
0000
0011
1111
0010
1101
1110|1
0001
1111
1111|1
0001
1110
1110|0
1111|1
0001
1110
1111|0
1111|1
0001
1110
1111|0
1111|1
0001
1110
FFFF
0002
FFFD
7FFE
A001
DFFF
6FFF
A001
CFFE
67FF
33FF
A001
93FE
49FF
24FF
A001
84FE
427F
213F
A001
813E
1000
0000
1000
0100
1010
1110
0111
1010
1101
0110
1010
1100
0110
0011
1010
1001
0100
0010
0001
0001
0000
0001
0000
0000
0000
0000
0000
0000
1000
0000
1000
0100
0010
0000
0010
1001
0100
0010
0011
0000
0011
1001
0000
1001
0100
0000
0100
0010
0000
0010
0001
0000
0000
0000
0000
1000
0100
1110
0111
1001
1100|1
0001
1101
1110|1
0001
1111
0111|1
0001
0110
0011|0
1001|1
0001
1000
0100|0
0010|0
0001|0
813E
0007
8139
409C
A001
E09D
704E
A001
D04F
6827
A001
C826
6413
3209
A001
9208
4904
2842
1241
Most significant least significant The CRC 16 of the frame is then: 4112
9
An example of a C language function performing CRC generation is shown on the following pages.
All of the possible CRC values are preloaded into two arrays, which are simply indexed as the
function increments through the message buffer.
One array contains all of the 256 possible CRC values for the high byte of the 16bit CRC field, and
the other array contains all of the values for the low byte.
Indexing the CRC in this way provides faster execution than would be achieved by calculating a new
CRC value with each new character from the message buffer.
) Note This function performs the swapping of the high/low CRC bytes internally. The bytes are
already swapped in the CRC value that is returned from the function.
Therefore the CRC value returned from the function can be directly placed into the message for
transmission.
The function takes two arguments:
unsigned char *puchMsg ;
10
11
12