3 programming for modbus, 1 declarations, 2 crbasic instructions - modbus – Campbell Scientific CR1000 Measurement and Control System User Manual
Page 369

Section 8. Operation
369
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 CR1000 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. 369)
shows the
linkage between CR1000 ports, flags and Boolean variables and Modbus
registers. Modbus does not distinguish between CR1000 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 89. CRBasic Ports, Flags, Variables, and, Modbus Registers
CR1000 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 CR1000 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 CR1000 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 CR1000 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.