Modbus programming
The RS-485 output can be directly read by a for information about using the MeteoPV.
A CR6, CR1000X, or CR350-series data logger programmed as a Modbus client can retrieve the values stored in the input registers (Modbus measurements). To do this, the CRBasic program requires the SerialOpen()
instruction followed by ModbusClient()
instruction.
ModbusClient()
was formerly ModbusMaster()
. Campbell Scientific, in conjunction with the Modbus Organization, is now using "client-server" to describe Modbus communications. The Modbus client(s) initiates communications and makes requests of server device(s). Server devices process requests and return an appropriate response (or error message). See https://modbus.org for more information. Existing programs that use the old Modbus terminology will still compile in the data logger.
The SerialOpen
instruction has the following syntax:
SerialOpen
(ComPort, Baud, Format, TXDelay, BufferSize, Mode)
The Format
parameter is typically set to logic 1 low; even parity, one stop bit, 8 data bits. The Mode
parameter should configure the ComPort as RS-485 half-duplex, transparent.
The ModbusClient()
instruction has the following syntax:
ModbusClient
(Result, ComPort, Baud, Addr, Function, Variable, Start, Length, Tries, TimeOut, [ModbusOption])
The Addr
parameter must match the sensor Modbus address. Start
parameter needs to be 1 and the Length
parameter needs to correspond with the register count (see Modbus measurements).
ModbusOption
is an optional parameter described in the CRBasic Editor Help.