3 programming for modbus, 1 declarations, 2 crbasic instructions - modbus – Campbell Scientific CR800 and CR850 Measurement and Control Systems User Manual
Page 352: Figure 109: devconfig deployment | advanced tab

Section 8. Operation
352
RTU / PLC
Remote Telemetry Units (RTUs) and Programmable Logic Controllers
(PLCs) were at one time used in exclusive applications. As technology
increases, however, the distinction between RTUs and PLCs becomes
more blurred. A CR800 fits both RTU and PLC definitions.
8.6.2.3 Programming for Modbus
8.6.2.3.1 Declarations
Table CRBasic Ports, Flags, Variables, and Modbus Registers
(p. 352)
shows the
linkage between CR800 ports, flags and Boolean variables and Modbus registers.
Modbus does not distinguish between CR800 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 85. CRBasic Ports, Flags, Variables, and, Modbus Registers
CR800 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 CR800 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 CR800 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 CR800 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.