PR Communication Manual
PR Communication Manual
PR series
Modbus Communication Manual
UMPRCM01A
Rev B2, 11/2013
GRAPHIC SYMBOLS
INFORMATION, It helps users with more details about the topic and
failure to follow may lead to unpredictable results.
Protective Earth
DC Supply
PREFACE
2
TABLE OF CONTENTS
1. OVERVIEW............................................................................................. 4
3
1. OVERVIEW
Master, ID=1
Master, ID=1
Paperless
Recorder PC
RS485 RS485
4
1.1 Modbus conversion formula
The word data are regarded as unsigned (positive) data in the Modbus message.
However,the actual value of the parameter may be negative value with decimal
point. The high/low scale values for each parameter are used for the purpose of
such a conversion
Modbus value should be converted using scaling information to get actual value
A=M*(SH-SL)/65535+SL
A = ((M*(SH-SL))/(RH-RL))+SL
Note1: Please refer section 1.2 & 1.3 for Scale Low (SL) and Scale high (SH) values for
the Modbus registers
Note2: Please refer channel configuration directly in the Paperless Recorder for
Range low (RL) and Range high (RH)values for the IO channels including Analog Input,
Math, Analog Output ec..
5
1.2 Input Registers
6
48 AI47 AI 47 process value R
49 AI48 AI 48 process value R
50 DI1 DI 1 process value R
51 DI2 DI 2 process value R
52 DI3 DI 3 process value R
53 DI4 DI 4 process value R
54 DI5 DI 5 process value R
55 DI6 DI 6 process value R
56 DI7 DI 7 process value R
57 DI8 DI 8 process value R
58 DI9 DI 9 process value R
59 DI10 DI 10 process value R
60 DI11 DI 11 process value R
61 DI12 DI 12 process value R
62 DI13 DI 13 process value R
63 DI14 DI 14 process value R
64 DI15 DI 15 process value R
65 DI16 DI 16 process value R
66 DI17 DI 17 process value R
67 DI18 DI 18 process value R
68 DI19 DI 19 process value R
69 DI20 DI 20 process value R
70 DI21 DI 21 process value R
71 DI22 DI 22 process value R
72 DI23 DI 23 process value R
73 DI24 DI 24 process value R
74 DO1 DO 1 process value R
75 DO2 DO 2 process value R
76 DO3 DO 3 process value R
77 DO4 DO 4 process value R
78 DO5 DO 5 process value R
79 DO6 DO 6 process value R
80 DO7 DO 7 process value R
81 DO8 DO 8 process value R
82 DO9 DO 9 process value R
83 DO10 DO 10 process value R
84 DO11 DO 11 process value R
85 DO12 DO 12 process value R
86 DO13 DO 13 process value R
87 DO14 DO 14 process value R
88 DO15 DO 15 process value R
89 DO16 DO 16 process value R
90 DO17 DO 17 process value R
91 DO18 DO 18 process value R
92 DO19 DO 19 process value R
93 DO20 DO 20 process value R
94 DO21 DO 21 process value R
95 DO22 DO 22 process value R
96 DO23 DO 23 process value R
97 DO24 DO 24 process value R
98 AO1 AO 1 process value R
99 AO2 AO 2 process value R
100 AO3 AO 3 process value R
7
101 AO4 AO 4 process value R
102 AO5 AO 5 process value R
103 AO6 AO 6 process value R
104 AO7 AO 7 process value R
105 AO8 AO 8 process value R
106 AO9 AO 9 process value R
107 AO10 AO 10 process value R
108 AO11 AO 11 process value R
109 AO12 AO 12 process value R
* Note: If the register value is 65534, which value represents communication error.
Math Area
Modbus Address Notation Register Name Access
201 Math1 Math 1 process value high word R
202 Math1 Math 1 process value low word R
203 Math2 Math 2 process value high word R
204 Math2 Math 2 process value low word R
205 Math3 Math 3 process value high word R
206 Math3 Math 3 process value low word R
207 Math4 Math 4 process value high word R
208 Math4 Math 4 process value low word R
209 Math5 Math 5 process value high word R
210 Math5 Math 5 process value low word R
211 Math6 Math 6 process value high word R
212 Math6 Math 6 process value low word R
213 Math7 Math 7 process value high word R
214 Math7 Math 7 process value low word R
215 Math8 Math 8 process value high word R
216 Math8 Math 8 process value low word R
217 Math9 Math 9 process value high word R
218 Math9 Math 9 process value low word R
219 Math10 Math 10 process value high word R
220 Math10 Math 10 process value low word R
221 Math11 Math 11 process value high word R
222 Math11 Math 11 process value low word R
223 Math12 Math 12 process value high word R
224 Math12 Math 12 process value low word R
225 Math13 Math 13 process value high word R
226 Math13 Math 13 process value low word R
227 Math14 Math 14 process value high word R
228 Math14 Math 14 process value low word R
229 Math15 Math 15 process value high word R
230 Math15 Math 15 process value low word R
231 Math16 Math 16 process value high word R
232 Math16 Math 16 process value low word R
233 Math17 Math 17 process value high word R
234 Math17 Math 17 process value low word R
235 Math18 Math 18 process value high word R
236 Math18 Math 18 process value low word R
237 Math19 Math 19 process value high word R
238 Math19 Math 19 process value low word R
8
239 Math20 Math 20 process value high word R
240 Math20 Math 20 process value low word R
241 Math21 Math 21 process value high word R
242 Math21 Math 21 process value low word R
243 Math22 Math 22 process value high word R
244 Math22 Math 22 process value low word R
245 Math23 Math 23 process value high word R
246 Math23 Math 23 process value low word R
247 Math24 Math 24 process value high word R
248 Math24 Math 24 process value low word R
249 Math25 Math 25 process value high word R
250 Math25 Math 25 process value low word R
251 Math26 Math 26 process value high word R
252 Math26 Math 26 process value low word R
253 Math27 Math 27 process value high word R
254 Math27 Math 27 process value low word R
255 Math28 Math 28 process value high word R
256 Math28 Math 28 process value low word R
257 Math29 Math 29 process value high word R
258 Math29 Math 29 process value low word R
259 Math30 Math 30 process value high word R
260 Math30 Math 30 process value low word R
261 Math31 Math 31 process value high word R
262 Math31 Math 31 process value low word R
263 Math32 Math 32 process value high word R
264 Math32 Math 32 process value low word R
265 Math33 Math 33 process value high word R
266 Math33 Math 33 process value low word R
267 Math34 Math 34 process value high word R
268 Math34 Math 34 process value low word R
269 Math35 Math 35 process value high word R
270 Math35 Math 35 process value low word R
271 Math36 Math 36 process value high word R
272 Math36 Math 36 process value low word R
273 Math37 Math 37 process value high word R
274 Math37 Math 37 process value low word R
275 Math38 Math 38 process value high word R
276 Math38 Math 38 process value low word R
277 Math39 Math 39 process value high word R
278 Math39 Math 39 process value low word R
279 Math40 Math 40 process value high word R
280 Math40 Math 40 process value low word R
281 Math41 Math 41 process value high word R
282 Math41 Math 41 process value low word R
283 Math42 Math 42 process value high word R
284 Math42 Math 42 process value low word R
285 Math43 Math 43 process value high word R
286 Math43 Math 43 process value low word R
287 Math44 Math 44 process value high word R
288 Math44 Math 44 process value low word R
289 Math45 Math 45 process value high word R
290 Math45 Math 45 process value low word R
291 Math46 Math 46 process value high word R
9
292 Math46 Math 46 process value low word R
293 Math47 Math 47 process value high word R
294 Math47 Math 47 process value low word R
295 Math48 Math 48 process value high word R
296 Math48 Math 48 process value low word R
297 Math49 Math 49 process value high word R
298 Math49 Math 49 process value low word R
299 Math50 Math 50 process value high word R
300 Math50 Math 50 process value low word R
301 Math51 Math 51 process value high word R
302 Math51 Math 51 process value low word R
303 Math52 Math 52 process value high word R
304 Math52 Math 52 process value low word R
305 Math53 Math 53 process value high word R
306 Math53 Math 53 process value low word R
307 Math54 Math 54 process value high word R
308 Math54 Math 54 process value low word R
309 Math55 Math 55 process value high word R
310 Math55 Math 55 process value low word R
311 Math56 Math 56 process value high word R
312 Math56 Math 56 process value low word R
313 Math57 Math 57 process value high word R
314 Math57 Math 57 process value low word R
315 Math58 Math 58 process value high word R
316 Math58 Math 58 process value low word R
317 Math59 Math 59 process value high word R
318 Math59 Math 59 process value low word R
319 Math60 Math 60 process value high word R
320 Math60 Math 60 process value low word R
10
16 Ext16 Measured data on External 16 R/W
17 Ext17 Measured data on External 17 R/W
18 Ext18 Measured data on External 18 R/W
19 Ext19 Measured data on External 19 R/W
20 Ext20 Measured data on External 20 R/W
21 Ext21 Measured data on External 21 R/W
22 Ext22 Measured data on External 22 R/W
23 Ext23 Measured data on External 23 R/W
24 Ext24 Measured data on External 24 R/W
25 Ext25 Measured data on External 25 R/W
26 Ext26 Measured data on External 26 R/W
27 Ext27 Measured data on External 27 R/W
28 Ext28 Measured data on External 28 R/W
29 Ext29 Measured data on External 29 R/W
30 Ext30 Measured data on External 30 R/W
31 Ext31 Measured data on External 31 R/W
32 Ext32 Measured data on External 32 R/W
33 Ext33 Measured data on External 33 R/W
34 Ext34 Measured data on External 34 R/W
35 Ext35 Measured data on External 35 R/W
36 Ext36 Measured data on External 36 R/W
37 Ext37 Measured data on External 37 R/W
38 Ext38 Measured data on External 38 R/W
39 Ext39 Measured data on External 39 R/W
40 Ext40 Measured data on External 40 R/W
41 Ext41 Measured data on External 41 R/W
42 Ext42 Measured data on External 42 R/W
43 Ext43 Measured data on External 43 R/W
44 Ext44 Measured data on External 44 R/W
45 Ext45 Measured data on External 45 R/W
46 Ext46 Measured data on External 46 R/W
47 Ext47 Measured data on External 47 R/W
48 Ext48 Measured data on External 48 R/W
49 Ext49 Measured data on External 49 R/W
50 Ext50 Measured data on External 50 R/W
51 Ext51 Measured data on External 51 R/W
52 Ext52 Measured data on External 52 R/W
53 Ext53 Measured data on External 53 R/W
54 Ext54 Measured data on External 54 R/W
55 Ext55 Measured data on External 55 R/W
56 Ext56 Measured data on External 56 R/W
57 Ext57 Measured data on External 57 R/W
58 Ext58 Measured data on External 58 R/W
59 Ext59 Measured data on External 59 R/W
60 Ext60 Measured data on External 60 R/W
61 Ext61 Measured data on External 61 R/W
62 Ext62 Measured data on External 62 R/W
63 Ext63 Measured data on External 63 R/W
64 Ext64 Measured data on External 64 R/W
65 Ext65 Measured data on External 65 R/W
66 Ext66 Measured data on External 66 R/W
67 Ext67 Measured data on External 67 R/W
68 Ext68 Measured data on External 68 R/W
11
69 Ext69 Measured data on External 69 R/W
70 Ext70 Measured data on External 70 R/W
71 Ext71 Measured data on External 71 R/W
72 Ext72 Measured data on External 72 R/W
73 Ext73 Measured data on External 73 R/W
74 Ext74 Measured data on External 74 R/W
75 Ext75 Measured data on External 75 R/W
76 Ext76 Measured data on External 76 R/W
77 Ext77 Measured data on External 77 R/W
78 Ext78 Measured data on External 78 R/W
79 Ext79 Measured data on External 79 R/W
80 Ext80 Measured data on External 80 R/W
81 Ext81 Measured data on External 81 R/W
82 Ext82 Measured data on External 82 R/W
83 Ext83 Measured data on External 83 R/W
84 Ext84 Measured data on External 84 R/W
85 Ext85 Measured data on External 85 R/W
86 Ext86 Measured data on External 86 R/W
87 Ext87 Measured data on External 87 R/W
88 Ext88 Measured data on External 88 R/W
89 Ext89 Measured data on External 89 R/W
90 Ext90 Measured data on External 90 R/W
91 Ext91 Measured data on External 91 R/W
92 Ext92 Measured data on External 92 R/W
93 Ext93 Measured data on External 93 R/W
94 Ext94 Measured data on External 94 R/W
95 Ext95 Measured data on External 95 R/W
96 Ext96 Measured data on External 96 R/W
* Note: If the register value is 65534, which value represents communication error.
12
External 5
211 Ext6 The low word of measured data is on R/W
External 6
212 Ext6 The high word of measured data is on R/W
External 6
213 Ext7 The low word of measured data is on R/W
External 7
214 Ext7 The high word of measured data is on R/W
External 7
215 Ext8 The low word of measured data is on R/W
External 8
216 Ext8 The high word of measured data is on R/W
External 8
217 Ext9 The low word of measured data is on R/W
External 9
218 Ext9 The high word of measured data is on R/W
External 9
219 Ext10 The low word of measured data is on R/W
External 10
220 Ext10 The high word of measured data is on R/W
External 10
221 Ext11 The low word of measured data is on R/W
External 11
222 Ext11 The high word of measured data is on R/W
External 11
223 Ext12 The low word of measured data is on R/W
External 12
224 Ext12 The high word of measured data is on R/W
External 12
225 Ext13 The low word of measured data is on R/W
External 13
226 Ext13 The high word of measured data is on R/W
External 13
227 Ext14 The low word of measured data is on R/W
External 14
228 Ext14 The high word of measured data is on R/W
External 14
229 Ext15 The low word of measured data is on R/W
External 15
230 Ext15 The high word of measured data is on R/W
External 15
231 Ext16 The low word of measured data is on R/W
External 16
232 Ext16 The high word of measured data is on R/W
External 16
233 Ext17 The low word of measured data is on R/W
External 17
234 Ext17 The high word of measured data is on R/W
External 17
235 Ext18 The low word of measured data is on R/W
External 18
236 Ext18 The high word of measured data is on R/W
External 18
237 Ext19 The low word of measured data is on R/W
External 19
13
238 Ext19 The high word of measured data is on R/W
External 19
239 Ext20 The low word of measured data is on R/W
External 20
240 Ext20 The high word of measured data is on R/W
External 20
241 Ext21 The low word of measured data is on R/W
External 21
242 Ext21 The high word of measured data is on R/W
External 21
243 Ext22 The low word of measured data is on R/W
External 22
244 Ext22 The high word of measured data is on R/W
External 22
245 Ext23 The low word of measured data is on R/W
External 23
246 Ext23 The high word of measured data is on R/W
External 23
247 Ext24 The low word of measured data is on R/W
External 24
248 Ext24 The high word of measured data is on R/W
External 24
249 Ext25 The low word of measured data is on R/W
External 25
250 Ext25 The high word of measured data is on R/W
External 25
251 Ext26 The low word of measured data is on R/W
External 26
252 Ext26 The high word of measured data is on R/W
External 26
253 Ext27 The low word of measured data is on R/W
External 27
254 Ext27 The high word of measured data is on R/W
External 27
255 Ext28 The low word of measured data is on R/W
External 28
256 Ext28 The high word of measured data is on R/W
External 28
257 Ext29 The low word of measured data is on R/W
External 29
258 Ext29 The high word of measured data is on R/W
External 29
259 Ext30 The low word of measured data is on R/W
External 30
260 Ext30 The high word of measured data is on R/W
External 30
261 Ext31 The low word of measured data is on R/W
External 31
262 Ext31 The high word of measured data is on R/W
External 31
263 Ext32 The low word of measured data is on R/W
External 32
264 Ext32 The high word of measured data is on R/W
External 32
265 Ext33 The low word of measured data is on R/W
14
External 33
266 Ext33 The high word of measured data is on R/W
External 33
267 Ext34 The low word of measured data is on R/W
External 34
268 Ext34 The high word of measured data is on R/W
External 34
269 Ext35 The low word of measured data is on R/W
External 35
270 Ext35 The high word of measured data is on R/W
External 35
271 Ext36 The low word of measured data is on R/W
External 36
272 Ext36 The high word of measured data is on R/W
External 36
273 Ext37 The low word of measured data is on R/W
External 37
274 Ext37 The high word of measured data is on R/W
External 37
275 Ext38 The low word of measured data is on R/W
External 38
276 Ext38 The high word of measured data is on R/W
External 38
277 Ext39 The low word of measured data is on R/W
External 39
278 Ext39 The high word of measured data is on R/W
External 39
279 Ext40 The low word of measured data is on R/W
External 40
280 Ext40 The high word of measured data is on R/W
External 40
281 Ext41 The low word of measured data is on R/W
External 41
282 Ext41 The high word of measured data is on R/W
External 41
283 Ext42 The low word of measured data is on R/W
External 42
284 Ext42 The high word of measured data is on R/W
External 42
285 Ext43 The low word of measured data is on R/W
External 43
286 Ext43 The high word of measured data is on R/W
External 43
287 Ext44 The low word of measured data is on R/W
External 44
288 Ext44 The high word of measured data is on R/W
External 44
289 Ext45 The low word of measured data is on R/W
External 45
290 Ext45 The high word of measured data is on R/W
External 45
291 Ext46 The low word of measured data is on R/W
External 46
292 Ext46 The high word of measured data is on R/W
External 46
15
293 Ext47 The low word of measured data is on R/W
External 47
294 Ext47 The high word of measured data is on R/W
External 47
295 Ext48 The low word of measured data is on R/W
External 48
296 Ext48 The high word of measured data is on R/W
External 48
297 Ext49 The low word of measured data is on R/W
External 49
298 Ext49 The high word of measured data is on R/W
External 49
299 Ext50 The low word of measured data is on R/W
External 50
300 Ext50 The high word of measured data is on R/W
External 50
301 Ext51 The low word of measured data is on R/W
External 51
302 Ext51 The high word of measured data is on R/W
External 51
303 Ext52 The low word of measured data is on R/W
External 52
304 Ext52 The high word of measured data is on R/W
External 52
305 Ext53 The low word of measured data is on R/W
External 53
306 Ext53 The high word of measured data is on R/W
External 53
307 Ext54 The low word of measured data is on R/W
External 54
308 Ext54 The high word of measured data is on R/W
External 54
309 Ext55 The low word of measured data is on R/W
External 55
310 Ext55 The high word of measured data is on R/W
External 55
311 Ext56 The low word of measured data is on R/W
External 56
312 Ext56 The high word of measured data is on R/W
External 56
313 Ext57 The low word of measured data is on R/W
External 57
314 Ext57 The high word of measured data is on R/W
External 57
315 Ext58 The low word of measured data is on R/W
External 58
316 Ext58 The high word of measured data is on R/W
External 58
317 Ext59 The low word of measured data is on R/W
External 59
318 Ext59 The high word of measured data is on R/W
External 59
319 Ext60 The low word of measured data is on R/W
External 60
320 Ext60 The high word of measured data is on R/W
16
External 60
321 Ext61 The low word of measured data is on R/W
External 61
322 Ext61 The high word of measured data is on R/W
External 61
323 Ext62 The low word of measured data is on R/W
External 62
324 Ext62 The high word of measured data is on R/W
External 62
325 Ext63 The low word of measured data is on R/W
External 63
326 Ext63 The high word of measured data is on R/W
External 63
327 Ext64 The low word of measured data is on R/W
External 64
328 Ext64 The high word of measured data is on R/W
External 64
329 Ext65 The low word of measured data is on R/W
External 65
330 Ext65 The high word of measured data is on R/W
External 65
331 Ext66 The low word of measured data is on R/W
External 66
332 Ext66 The high word of measured data is on R/W
External 66
333 Ext67 The low word of measured data is on R/W
External 67
334 Ext67 The high word of measured data is on R/W
External 67
335 Ext68 The low word of measured data is on R/W
External 68
336 Ext68 The high word of measured data is on R/W
External 68
337 Ext69 The low word of measured data is on R/W
External 69
338 Ext69 The high word of measured data is on R/W
External 69
339 Ext70 The low word of measured data is on R/W
External 70
340 Ext70 The high word of measured data is on R/W
External 70
341 Ext71 The low word of measured data is on R/W
External 71
342 Ext71 The high word of measured data is on R/W
External 71
343 Ext72 The low word of measured data is on R/W
External 72
344 Ext72 The high word of measured data is on R/W
External 72
345 Ext73 The low word of measured data is on R/W
External 73
346 Ext73 The high word of measured data is on R/W
External 73
347 Ext74 The low word of measured data is on R/W
External 74
17
348 Ext74 The high word of measured data is on R/W
External 74
349 Ext75 The low word of measured data is on R/W
External 75
350 Ext75 The high word of measured data is on R/W
External 75
351 Ext76 The low word of measured data is on R/W
External 76
352 Ext76 The high word of measured data is on R/W
External 76
353 Ext77 The low word of measured data is on R/W
External 77
354 Ext77 The high word of measured data is on R/W
External 77
355 Ext78 The low word of measured data is on R/W
External 78
356 Ext78 The high word of measured data is on R/W
External 78
357 Ext79 The low word of measured data is on R/W
External 79
358 Ext79 The high word of measured data is on R/W
External 79
359 Ext80 The low word of measured data is on R/W
External 80
360 Ext80 The high word of measured data is on R/W
External 80
361 Ext81 The low word of measured data is on R/W
External 81
362 Ext81 The high word of measured data is on R/W
External 81
363 Ext82 The low word of measured data is on R/W
External 82
364 Ext82 The high word of measured data is on R/W
External 82
365 Ext83 The low word of measured data is on R/W
External 83
366 Ext83 The high word of measured data is on R/W
External 83
367 Ext84 The low word of measured data is on R/W
External 84
368 Ext84 The high word of measured data is on R/W
External 84
369 Ext85 The low word of measured data is on R/W
External 85
370 Ext85 The high word of measured data is on R/W
External 85
371 Ext86 The low word of measured data is on R/W
External 86
372 Ext86 The high word of measured data is on R/W
External 86
373 Ext87 The low word of measured data is on R/W
External 87
374 Ext87 The high word of measured data is on R/W
External 87
375 Ext88 The low word of measured data is on R/W
18
External 88
376 Ext88 The high word of measured data is on R/W
External 88
377 Ext89 The low word of measured data is on R/W
External 89
378 Ext89 The high word of measured data is on R/W
External 89
379 Ext90 The low word of measured data is on R/W
External 90
380 Ext90 The high word of measured data is on R/W
External 90
381 Ext91 The low word of measured data is on R/W
External 91
382 Ext91 The high word of measured data is on R/W
External 91
383 Ext92 The low word of measured data is on R/W
External 92
384 Ext92 The high word of measured data is on R/W
External 92
385 Ext93 The low word of measured data is on R/W
External 93
386 Ext93 The high word of measured data is on R/W
External 93
387 Ext94 The low word of measured data is on R/W
External 94
388 Ext94 The high word of measured data is on R/W
External 94
389 Ext95 The low word of measured data is on R/W
External 95
390 Ext95 The high word of measured data is on R/W
External 95
391 Ext96 The low word of measured data is on R/W
External 96
392 Ext96 The high word of measured data is on R/W
External 96
19
1.3 Modbus Communications
The function code is used to read from 1 to 120 contiguous input registers in
remote device.
Query
The query message specifies the starting register and quantity of registers to be
read. Registers are addressed starting at zero: register 1 – 16 are addressed as 0
– 15.
Here is an example of a request to read register 0 (register type is Input
Register, address is 1) from slave device 1:
Response
The register data in the response message are packed as two bytes per
registers, with the binary contents right justified within each byte. For each
register, the first byte contains the high order bits and the second contains the
low order bits.
The response is return when the data is completely assembled. Here is an
example of a response to the query on the opposite page:
20
1.3.2 Preset (Write) Multiple Registers (Function 0x10)
Query
The query message specified the register references to be preset. Registers are
addressed starting at zero: register 1 is addressed as 0. The requested preset
values are specified in the query data field. Data is packed as two bytes per
register.
Here is an example of a request to preset two registers starting at 40001 to 00
0A and 01 02 hex in slave device 1:
Response
The normal response returns the slave address, function code, starting address
and quantity of registers preset. Here is an example of a response to the query
shown above
21
1.3.3 Placing CRC into the message
When the 16 bit CRC (two 8 bit bytes) is transmitted in the message, the low
order byte will be transmitted first, followed by the high order byte.
For example, if the CRC value is 1241 hex:
/****************************************************************
/
// Parameter:
// puchMsg -> unsigned char* puchMsg: message to calculate CRC upon
// usDataLne -> unsigned short usDataLen: quantity of bytes in message
/****************************************************************
/
unsigned short CRC16(puchMsg, usDataLen)
{
unsigned char uchCRCHi=0xFF; /* high byte of CRC initialized */
unsigned char uchCRCLo=0xFF; /* low byte of CRC initialized */
unsigned uIndex; /* will index into CRC lookup table */
while (usDataLen––) /* pass through message buffer */
{
uIndex = uchCRCHi ^ *puchMsgg++; /* calculate the CRC */
uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex];
uchCRCLo = auchCRCLo[uIndex] ;
22
}
return (uchCRCHi << 8 | uchCRCLo) ;
}
23
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5,
0 x C 4 ,
0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9,
0 x 0 9 ,
0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF,
0 x 1 F , 0 x D D ,
0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12,
0 x 1 3 , 0 x D 3 ,
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6,
0 x F 7 ,
0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA,
0 x 3 A ,
0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA,
0 x E E ,
0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6,
0 x 2 6 ,
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3,
0 x A 2 ,
0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF,
0 x 6 F ,
0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79,
0 x B B ,
0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75,
0 x B 5 ,
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90,
0 x 9 1 ,
0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C,
0 x 5 C ,
0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98,
0 x 8 8 ,
0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C,
0 x 8 C ,
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81,
0 x 8 0 ,
0x40
};
24
1.4.2 Read Data Function
/****************************************************************
/
// Parameter:
// Addr -> Slave ID
// StReg -> Starting Register Address
// RegQuantities -> Register Quantities
// MbsBuf -> Receive Data Buffer
/****************************************************************
/
bool ReadData(unsigned char Addr, unsigned short StReg,
unsigned short RegQuantities, unsigned char* MbsBuf)
{
unsigned char msg[8];
unsigned char Func = 0x04;
unsigned short Crc;
msg[0] = Addr;
msg[1] = Func;
msg[2] = HIBYTE(StReg);
msg[3] = LOBYTE(StReg);
msg[4] = HIBYTE(RegQuantities);
msg[5] = LOBYTE(RegQuantities);
Crc = CRC16(msg,6);
msg[6] = HIBYTE(Crc);
msg[7] = LOBYTE(Crc);
int snd = 8; /* byte number of buffer msg */
int rcv = (5+(RegQuantities*2));
/* Send snd bytes content of msg to COMM port */
/* Receive rcv bytes of response from COMM port to MbsBuf */
if (receiving data length is same as rcv)
return true;
else
return false;
}
25
1.4.3 Convert Data Function
/****************************************************************
/
// Parameter:
// ValueRangeLo -> Minimum value of the value range
// ValueRangeHi -> Maximum value of the value range
// ScaleLo -> Minimum value of the scale value
// ScaleHi -> Maximum value of the scale value
// RegData -> Current register data from remote device
/****************************************************************
/
double ConvertData(double ValueRangeLo,
double ValueRangeHi,
double ScaleLo,
double ScaleHi,
double RegData)
{
double ConvertValue;
bool ReadAIData(void)
{
unsigned char MsgBuf[40];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 2;
unsigned short RegQuantities = 5;
int ScaleLo, ScaleHi,
ValueRangeLo, ValueRangeHi,
AiData;
unsigned short RegData;
26
// Step 1: Parsing data for AI1
RegData = MAKEWORD(MsgBuf[4], MsgBuf[3]);
bool ReadAOData(void)
{
unsigned char MsgBuf[48];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 601;
unsigned short RegQuantities = 5;
unsigned short RegData;
float AoData;
27
// Read register data from remote device
ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);
bool ReadMathData(void)
{
unsigned char MsgBuf[120];
unsigned char i, j;
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 201;
unsigned short RegQuantities = (10*2); // Math data is float type, so each
Math value take two registers
double ScaleLo, ScaleHi, ValueRangeLo, ValueRangeHi;
double RegData, MathData;
28
ScaleHi = 2147483647;
// Step 3: Please refer to the decimal value for the conversion of each
Math
switch(decimal value)
{
case 1:
ScaleLo = ScaleLo / 10;
ScaleHi = ScaleHi / 10;
break;
case 2:
ScaleLo = ScaleLo / 100;
ScaleHi = ScaleHi / 100;
break;
case 3:
ScaleLo = ScaleLo / 1000;
ScaleHi = ScaleHi / 1000;
break;
case 4:
ScaleLo = ScaleLo / 10000;
ScaleHi = ScaleHi / 10000;
break;
case 5:
ScaleLo = ScaleLo / 100000;
ScaleHi = ScaleHi / 100000;
break;
default:
break;
}
29
1.4.7 Read DI Function
bool ReadDIData(void)
{
unsigned char MsgBuf[96];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 50;
unsigned short RegQuantities = 5;
bool DiData;
bool ReadDOData(void)
{
unsigned char MsgBuf[48];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 74;
unsigned short RegQuantities = 5;
bool DoData;
30
1.4.9 Read External Channel Function
bool ReadExtData(void)
{
unsigned char MsgBuf[128];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 401;
unsigned short RegQuantities = 20;
unsigned short ExtData;
*
Note: Because the Input Register Ext data is same like Holding Register Ext data,
so the data type of the ExtData must according to the setting of real case, if the
data type of ExtData is 4 bytes, please refer to “ReadMathData” function in
Step 1, Step 2, Step 4 and Step 5 to convert data type of customer requirement
(Such as: Int32 or UInt32 or float data type).
}
*1: Above sample code is according to the PR20 setting, if user need to change
the MsgBuf size and RegQuantities value for other Recorders, please refer
to the user manual.
31
1.4.11 How to check Channel Range in Recorder
i. Press 『Menu』->『More』->『Config』
Fig. B-1
Fig. B-2
32
iii. Value of AI range is shown in the following screen
Previous AI Next AI
Fig. B-3
Assume for Analog Input Channel1. SL=-120, SH=1000 (Refer Fig B-3)
A = ((M*(SH-SL))/(RH-RL))+SL
33
Case-2: Modbus valve read by Modscan, M=65535
A = ((M*(SH-SL))/(RH-RL))+SL
A = ((M*(SH-SL))/(RH-RL))+SL
A = ((M*(SH-SL))/(RH-RL))+SL
A = ((M*(SH-SL))/(RH-RL))+SL
A = ((390451572* (10000 - 100)) / 4294967295) + 100
= (3865470562800/4294967295) + 100
= 900 + 100
= 1000
34
Case-3: Modbus valve read by Modscan, M= 4294967295
A = ((M*(SH-SL))/(RH-RL))+SL
A = ((M*(SH-SL))/(RH-RL))+SL
35