3 programming for modbus, 1 declarations, 2 crbasic instructions - modbus – Campbell Scientific CR3000 Micrologger User Manual
Page 374

Section 8. Operation
374
8.6.2.3 Programming for Modbus
8.6.2.3.1 Declarations
Table CRBasic Ports, Flags, Variables, and Modbus Registers
(p. 374)
shows the
linkage between CR3000 ports, flags and Boolean variables and Modbus
registers. Modbus does not distinguish between CR3000 ports, flags, or Boolean
variables. By declaring only ports, or flags, or Boolean variables, the declared
feature is addressed by default. A typical CRBasic program for a Modbus
application will declare variables and ports, or variables and flags, or variables
and Boolean variables.
Table 92. CRBasic Ports, Flags, Variables, and, Modbus Registers
CR3000 Feature
Example CRBasic
Declaration
Equivalent Example
Modbus Register
Control Port (Port)
Public Port(8)
00001 to 00009
Flag
Public Flag(17)
00001 to 00018
Boolean Variable
Public ArrayB(56) as
Boolean
00001 to 00057
Variable
Public ArrayV(20)*
40001 to 40041* or
30001 to 30041*
*Because of byte-number differences, each CR3000 domain variable translates to two Modbus
domain input / holding registers.
8.6.2.3.2 CRBasic Instructions - Modbus
Complete descriptions and options of commands are available in CRBasic Editor
Help.
ModbusMaster()
Sets up a CR3000 as a Modbus master to send or retrieve data from a Modbus
slave.
Syntax
ModbusMaster(ResultCode, ComPort, BaudRate, ModbusAddr,
Function, Variable, Start, Length, Tries, TimeOut)
ModbusSlave()
Sets up a CR3000 as a Modbus slave device.
Syntax
ModbusSlave(ComPort, BaudRate, ModbusAddr, DataVariable,
BooleanVariable)
MoveBytes()
Moves binary bytes of data into a different memory location when translating
big‐endian to little‐endian data.
Syntax
MoveBytes(Dest, DestOffset, Source, SourceOffset, NumBytes)