0% found this document useful (0 votes)
46 views

PR Communication Manual

This document provides a user manual for Modbus communication with PR series paperless recorders. It describes the Modbus register mapping for analog input, digital input/output, analog output and math channels. Conversion formulas are provided to convert between Modbus register values and actual process values based on channel scaling configurations. Sample code is also included to demonstrate functions for reading and writing registers as well as example conversions between Modbus and process values.

Uploaded by

Abdul Moeez Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

PR Communication Manual

This document provides a user manual for Modbus communication with PR series paperless recorders. It describes the Modbus register mapping for analog input, digital input/output, analog output and math channels. Conversion formulas are provided to convert between Modbus register values and actual process values based on channel scaling configurations. Sample code is also included to demonstrate functions for reading and writing registers as well as example conversions between Modbus and process values.

Uploaded by

Abdul Moeez Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

User 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.

WARNING, Failure to follow may lead to minor injury or damage /


malfunctioning of equipment

DANGER, Failure to follow may lead to injury or fatal accident to


operating personal or damage/malfunctioning of equipment

CAUTION, Failure to follow may lead to malfunctioning of equipment,


damage or repair

Protective Earth

DC Supply

PREFACE

Original equipment manufacturer reserves the right to change information


available in this document without notice. Original Equipment manufacturer is
not liable for any damages incurred to equipment/personal during installation
or use of equipment as explained in this document. User must acquire
sufficient knowledge & skills prior to use the equipment in the application and
follow all the local standards & regulations to meet safety requirements

2
TABLE OF CONTENTS
1. OVERVIEW............................................................................................. 4

1.1 MODBUS CONVERSION FORMULA .................................................................................... 5


1.2 INPUT REGISTERS .......................................................................................................... 6
1.2.1 AI/DI/DO/AO Channels ......................................................................................... 6
1.3 MODBUS COMMUNICATIONS ......................................................................................... 20
1.3.1 Read Input Registers (Function 0x04) ................................................................ 20
1.3.2 Preset (Write) Multiple Registers (Function 0x10) .............................................. 21
1.3.3 Placing CRC into the message ........................................................................... 22
1.4 SAMPLE CODE .............................................................................................................. 22
1.4.1 CRC Generation Function ................................................................................... 22
1.4.2 Read Data Function ............................................................................................ 25
1.4.3 Convert Data Function ........................................................................................ 26
1.4.4 Read AI Function ............................................................................................... 26
1.4.5 Read AO Function.............................................................................................. 27
1.4.6 Read Math Function ........................................................................................... 28
1.4.7 Read DI Function ............................................................................................... 30
1.4.8 Read DO Function ............................................................................................. 30
1.4.9 Read External Channel Function ........................................................................ 31
1.4.10 Modbus Register data type table ........................................................................ 31
1.4.11 How to check Channel Range in Recorder ......................................................... 32
1.4.12 Modbus to Proces value conversion AI example ................................................ 33
1.4.13 Modbus to Proces value conversion Math example ........................................... 34

3
1. OVERVIEW

PR series new generation Paperless Recorder support Modbus communications


including Serial (Modbus RTU) and Ethernet (Modbus TCP)

It is possible to configure PR series Recorder as Master/Slave on Serial network and


Server/Client in Ethernet network

Master, ID=1
Master, ID=1

Paperless
Recorder PC

RS485 RS485

IO-A IO-B Paperless Paperless


Recorder Recorder

Slave, ID=2 Slave, ID=3 Slave, ID=2 Slave, ID=3

Fig: Recorder- Master (Serial) Fig: Recorders- Slave (Serial)

Supported Function codes

SNo Function Code Description


1 03 Read Input Registers
2 04 Read/Write Holding Registers
3 10 Preset Multiple Registers

Note: Please refer PR series user manual for configuration of Recorder as


Master/Slave or Client/Server

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

In reality, Modbus value is different than process value.

Modbus value should be converted using scaling information to get actual value

Let M=Value of Modbus message


A=Actual value of the parameter
SL=Scale low value of the parameter
SH=Scale high value of the parameter
RH=Range low value of the parameter
RL=Range high value of the parameter
The conversion formulas are as follows:

A=M*(SH-SL)/65535+SL

For AI and Math, the conversion formulas are as follows:

A = ((M*(SH-SL))/(RH-RL))+SL

For AI, the RH = 32767, RL = -32768

For Math, the RH=4294967395, RL = 0

For AO, the conversion formulas are as follows:


A = ((M*SH)/RH)+SL
SH = 65.535, SL = -32.768
RH = 65535, RL = 0

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

1.2.1 AI/DI/DO/AO Channels

Modbus Address Notation Register Name Access


1 Reserve Reserve R
2 AI1 AI 1 process value R
3 AI2 AI 2 process value R
4 AI3 AI 3 process value R
5 AI4 AI 4 process value R
6 AI5 AI 5 process value R
7 AI6 AI 6 process value R
8 AI7 AI 7 process value R
9 AI8 AI 8 process value R
10 AI9 AI 9 process value R
11 AI10 AI 10 process value R
12 AI11 AI 11 process value R
13 AI12 AI 12 process value R
14 AI13 AI 13 process value R
15 AI14 AI 14 process value R
16 AI15 AI 15 process value R
17 AI16 AI 16 process value R
18 AI17 AI 17 process value R
19 AI18 AI 18 process value R
20 AI19 AI 19 process value R
21 AI20 AI 20 process value R
22 AI21 AI 21 process value R
23 AI22 AI 22 process value R
24 AI23 AI 23 process value R
25 AI24 AI 24 process value R
26 AI25 AI 25 process value R
27 AI26 AI 26 process value R
28 AI27 AI 27 process value R
29 AI28 AI 28 process value R
30 AI29 AI 29 process value R
31 AI30 AI 30 process value R
32 AI31 AI 31 process value R
33 AI32 AI 32 process value R
34 AI33 AI 33 process value R
35 AI34 AI 34 process value R
36 AI35 AI 35 process value R
37 AI36 AI 36 process value R
38 AI37 AI 37 process value R
39 AI38 AI 38 process value R
40 AI39 AI 39 process value R
41 AI40 AI 40 process value R
42 AI41 AI 41 process value R
43 AI42 AI 42 process value R
44 AI43 AI 43 process value R
45 AI44 AI 44 process value R
46 AI45 AI 45 process value R
47 AI46 AI 46 process value R

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

* Note: If the register value is 4294967294, which value represents communication


error.

Holding Register Parameter Table for Modbus RTU


Slave / TCP Server
2 Bytes Type Area
Modbus Address Notation Register Name Access
1 Ext1 Measured data on External 1 R/W
2 Ext2 Measured data on External 2 R/W
3 Ext3 Measured data on External 3 R/W
4 Ext4 Measured data on External 4 R/W
5 Ext5 Measured data on External 5 R/W
6 Ext6 Measured data on External 6 R/W
7 Ext7 Measured data on External 7 R/W
8 Ext8 Measured data on External 8 R/W
9 Ext9 Measured data on External 9 R/W
10 Ext10 Measured data on External 10 R/W
11 Ext11 Measured data on External 11 R/W
12 Ext12 Measured data on External 12 R/W
13 Ext13 Measured data on External 13 R/W
14 Ext14 Measured data on External 14 R/W
15 Ext15 Measured data on External 15 R/W

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.

4 Bytes Type Area


Modbus Address Notation Register Name Access
201 Ext1 The low word of measured data is on R/W
External 1
202 Ext1 The high word of measured data is on R/W
External 1
203 Ext2 The low word of measured data is on R/W
External 2
204 Ext2 The high word of measured data is on R/W
External 2
205 Ext3 The low word of measured data is on R/W
External 3
206 Ext3 The high word of measured data is on R/W
External 3
207 Ext4 The low word of measured data is on R/W
External 4
208 Ext4 The high word of measured data is on R/W
External 4
209 Ext5 The low word of measured data is on R/W
External 5
210 Ext5 The high word of measured data is on R/W

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

* Note: If the register value is 4294967294, which value represents communication


error.

19
1.3 Modbus Communications

1.3.1 Read Input Registers (Function 0x04)

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:

Field Name RTU example (Hex)


Slave Address 01
Function 04
Starting Address Hi 00
Starting Address Lo 00
Quantity of Registers Hi 00
Quantity of Registers Lo 01
Error Check Lo 31
Error Check Hi CA
Total Bytes 8

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:

Field Name RTU example (Hex)


Slave Address 01
Function 04
Byte Count 02
Data Hi 00
Data Lo 0A
Error Check Lo 39
Error Check Hi 37
Total Bytes 7

20
1.3.2 Preset (Write) Multiple Registers (Function 0x10)

The function code is used to write a block of contiguous registers (1 to 120


registers) in remote device.

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:

Field Name RTU example (Hex)


Slave Address 01
Function 10
Starting Address Hi 00
Starting Address Lo 00
Quantity of Registers Hi 00
Quantity of Registers Lo 02
Byte Count 04
Data Hi 00
Data Lo 0A
Data Hi 01
Data Lo 02
Error Check Lo 53
Error Check Hi FC
Total Bytes 13

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

Field Name RTU example (Hex)


Slave Address 01
Function 10
Starting Address Hi 00
Starting Address Lo 00
Quantity of Registers Hi 00
Quantity of Registers Lo 02
Error Check Lo 41
Error Check Hi C8
Total Bytes 13

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:

Slave Address Function Data CRC Lo CRC Hi


-- -- -- 41 12

* Note: Broadcast is not supported.

1.4 Sample code

1.4.1 CRC Generation Function

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 16 bit 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.

/****************************************************************
/
// 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) ;
}

High-Order Byte Table


/* Table of CRC values for high–order byte */
static unsigned char auchCRCHi[] = {
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
0 x 8 1 ,
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,
0 x C 0 ,
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
0 x 0 1 ,
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80,
0 x 4 1 ,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1,
0 x 8 1 ,
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,
0 x C 0 ,
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0 x 0 1 ,
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
0 x 4 0 ,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
0 x 8 1 ,
0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01,
0 x C 0 ,
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
0 x 0 1 ,
0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
0 x 4 1 ,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
0 x 8 1 ,
0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01,
0 x C 0 ,
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0 x 0 1 ,
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
0 x 4 1 ,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
0 x 8 1 ,
0x40
};
Low-Order Byte Table
/* Table of CRC values for low–order byte */
static char auchCRCLo[] = {

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;

ConvertValue = (((RegData*(ScaleHi - ScaleLo))/


(ValueRangeHi - ValueRangeLo))
+ ScaleLo);
return ConvertValue;
}

1.4.4 Read AI Function

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;

// Read register data from remote device


ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);

26
// Step 1: Parsing data for AI1
RegData = MAKEWORD(MsgBuf[4], MsgBuf[3]);

// Step 2: Set value range


// Because AI data type was set as 2 bytes, the value range would be
// showing between -32768 to 32767
ValueRangeLo = -32768;
ValueRangeHi = 32767;

// Step 3: Set value range for scale


// The default of Sensor type in AI1 is set as『Thermocouple K Type』.
// Scale low value is showing “-120”, scale high value is showing
// “1000”
// Please refer to Appendix B, it will explain that how to inquire AI
// range in PR, as for another scale range of AI, please refer to AI
// configuration
ScaleLo = -120;
ScaleHi = 1000;

// Step 4: Execute converted function


AiData = (int)ConvertData(ValueRangeLo,
ValueRangeHi,
ScaleLo,
ScaleHi,
RegData);

// Step 5: Repeat Step 1 to Step 4 for getting another AI data

* Note: Please refer to Appendix C for more details.


}

1.4.5 Read AO Function

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);

// Because the AO expression is specific, so we need using specific


// expression to convert the value as following:
// Step 1: Parsing data for AO1
RegData = MAKEWORD(MsgBuf[4], MsgBuf[3]);

// Step2: To do converted expression for AO1


AoData = ((RegData * 65.535)/65535)-32.768;

// Step 3: Repeat Step 1 to Step 2 for getting another AO data

* Note: Please refer to Appendix C for more details.


}

1.4.6 Read Math Function

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;

// Read register data from remote device


ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);

// Step 1: Set value range


// The default of Math data type was set as 4 bytes, the value range
// will be showing between 0 to 4294967295
ValueRangeLo = 0;
ValueRangeHi = 4294967295;

// Step 2: Set value range for scale


// When the property of “Transformation” in scale was set as disable,
// the range will be showing -2147483648 to 2147483647
// If the property of “Transformation” in Scale was set as “Value” or
// “Math Channel”, please refer to Appendix D
ScaleLo = -2147483648;

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;
}

// Step 4: Parsing data for Math1


RegData = (UINT)MAKELONG(MAKEWORD(MsgBuf[j+1],
MsgBuf[j]),
MAKEWORD(MsgBuf[j+3],
MsgBuf[j+2]));

// Step 5: Execute converted function


MathData = ConvertData(ValueRangeLo,
ValueRangeHi,
ScaleLo,
ScaleHi,
RegData);

// Step 6: Repeat Step 1 to Step 5 for getting another data of Math

* Note: Please refer to Appendix D for more details.


}

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;

// Read register data from remote device


ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);

// Step 1: Parsing data for DI1


DiData = (bool)MAKEWORD(MsgBuf[4], MsgBuf[3]);

// Step 2: Repeat Step 1 for getting another DI data


}

1.4.8 Read DO Function

bool ReadDOData(void)
{
unsigned char MsgBuf[48];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 74;
unsigned short RegQuantities = 5;
bool DoData;

// Read register data from remote device


ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);

// Step 1: Parsing data for DO1


DiData = (bool)MAKEWORD(MsgBuf[4], MsgBuf[3]);

// Step 2: Repeat Step 1 for getting another DO data


}

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;

// Read register data from remote device


ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);

// Step 1: Parsing data for Ext1


DiData = MAKEWORD(MsgBuf[4], MsgBuf[3]);

// Step 2: Repeat Step 1 for getting another Ext data


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.

1.4.10 Modbus Register data type table

Modbus RTU Slave / TCP Server Register data type table

Field Name Data Size Data Type Note


AI 2 Bytes WORD Little Endian
Math 4 Bytes UINT32 Little Endian
DI 2 Bytes WORD Little Endian
AO 2 Bytes WORD Little Endian
DO 2 Bytes WORD Little Endian
External 2 Bytes/4 Bytes WORD Little Endian
Table A-1

31
1.4.11 How to check Channel Range in Recorder

i. Press 『Menu』->『More』->『Config』

Fig. B-1

ii. Please select『AI』

Fig. B-2

32
iii. Value of AI range is shown in the following screen

Previous AI Next AI
Fig. B-3

1.4.12 Modbus to Proces value conversion AI example

Modbus Master : Modscan 32


Modbus Slave : Recorder

Channel-1, Modbus value is showing 0. What is the actual process value?

// Anlog Input - Example

As per section 1.1.1, for AI, the RH = 32767, RL = -32768

Assume for Analog Input Channel1. SL=-120, SH=1000 (Refer Fig B-3)

Case-1: Modbus valve read by Modscan, M=0

A = ((M*(SH-SL))/(RH-RL))+SL

= ((0 * (1000+120))/(32767+32768) +(– 120)


= (0/65535)-120
= -120

33
Case-2: Modbus valve read by Modscan, M=65535

A = ((M*(SH-SL))/(RH-RL))+SL

= ((65535 * (1000+120))/(32767+32768) +(– 120)


= (65535 * 1120/65535)-120
= (73399200 / 65535)-120
= 1120 -120
= 1000

Case-3: Modbus valve read by Modscan, M=32768

A = ((M*(SH-SL))/(RH-RL))+SL

= ((32768 * (1000+120))/(32767+32768) +(– 120)


= (32768 * 1120/65535)-120
= (36700160 / 65535)-120
= 560 -120
= 440

1.4.13 Modbus to Proces value conversion Math example

// Math Channel - Example

As per section 1.1.1, for Math, the RH=4294967395, RL = 0

Assume for Math Channel1. SL=100, SH=10000

Case-1: Modbus valve read by Modscan, M=0

A = ((M*(SH-SL))/(RH-RL))+SL

A = ((0 * (10000 - 100)) / 4294967295) + 100


= ((0 / 4294967295) + 100)
= 100

Case-2: Modbus valve read by Modscan, M=390451572

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 = ((4294967295 * (10000 - 100)) / 4294967295) + 100


= (42520176220500/4294967295) + 9900
= 9900 + 100
= 10000

Case-4: Modbus valve read by Modscan, M= 38625

A = ((M*(SH-SL))/(RH-RL))+SL

A = ((38625 * 65.535)/65535) - 32.768


= (2531289.375/65535) - 32.768
= 38.625-32.768
= 5.857

35

You might also like