Section 8. Operation
482
8.10.3.6 Modbus Over RS-232 7/E/1
Q: Can Modbus be used over an RS-232 link, 7 data bits, even parity, one stop
bit?
A: Yes. Precede ModBusMaster() / ModBusSlave() with SerialOpen() and set
the numeric format of the COM port with any of the available formats, including
the option of 7 data bits, even parity. SerialOpen() and ModBusMaster() can
be used once and placed before Scan().
8.10.3.7 Converting Modbus 16-Bit to 32-Bit Longs
Concatenation of two Modbus long 16-bit variables to one Modbus long 32
bit number is shown in the following example:
Concatenating Modbus Long Variables
'This program example demonstrates concatenation (splicing) of Long data type variables
'for Modbus operations.
'
'NOTE: The CR3000 uses big-endian word order.
'Declarations
Public
Combo
As Long
'Variable to hold the combined 32-bit
Public
Register(2)
As Long
'Array holds two 16-bit ModBus long
'variables
'Register(1) = Least Significant Word
'Register(2) = Most Significant Word
Public
Result
'Holds the result of the ModBus master
'query
'Aliases used for clarification
Alias
Register(1) = Register_LSW
'Least significant word.
Alias
Register(2) = Register_MSW
'Most significant word.
BeginProg
'If you use the numbers below (un-comment them first)
'Combo is read as 131073 decimal
'Register_LSW=&h0001 'Least significant word.
'Register_MSW=&h0002 ' Most significant word.
Scan
(1,Sec,0,0)
'In the case of the CR3000 being the ModBus master then the
'ModbusMaster instruction would be used (instead of fixing
'the variables as shown between the BeginProg and SCAN instructions).
ModbusMaster
(Result,COMRS232,-115200,5,3,Register(),-1,2,3,100)
'MoveBytes(DestVariable,DestOffset,SourceVariable,SourceOffSet,
'NumberOfBytes)
MoveBytes
(Combo,2, Register_LSW,2,2)
MoveBytes
(Combo,0, Register_MSW,2,2)
NextScan
EndProg
Summary of Contents for CR3000 Micrologger
Page 2: ......
Page 3: ......
Page 4: ......
Page 6: ......
Page 30: ......
Page 34: ......
Page 36: ......
Page 96: ......
Page 485: ...Section 8 Operation 485 8 11 2 Data Display FIGURE 110 Keyboard and Display Displaying Data ...
Page 487: ...Section 8 Operation 487 FIGURE 112 CR1000KD Real Time Custom ...
Page 491: ...Section 8 Operation 491 FIGURE 116 Keyboard and Display File Edit ...
Page 496: ......
Page 502: ......
Page 564: ...Section 11 Glossary 564 FIGURE 126 Relationships of Accuracy Precision and Resolution ...
Page 566: ......
Page 594: ......
Page 598: ......
Page 600: ......
Page 602: ......
Page 624: ......
Page 642: ......
Page 643: ......