
9. Programming
Programming basics for CRBasic data loggers are provided in the following sections. Complete
program examples for measuring the Modbus over RS-485 and analog outputs can be found in
(p. 9). Campbell Scientific recommends using Modbus over RS-485.
9.1 RS-485 programming
The RS-485 output can be directly read by a MeteoPV, CR6-series, CR1000X-series, or Modbus
RTU RS-485 network. Other Campbell Scientific data loggers can use an MD485 multidrop
interface to read the RS-485 output. Refer to the MD485 manual for information about using the
MD485. Refer to
www.campbellsci.com/videos/meteopv
for information about using the
MeteoPV.
A CR6 or CR1000X data logger programmed as a Modbus Master can retrieve the values stored in
the Input Registers (
(p. 6)). To do this, the CRBasic program requires
SerialOpen()
followed by
ModbusMaster()
. 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
ModbusMaster()
instruction has the following syntax:
ModbusMaster
(Result, ComPort, Baud, Addr, Function, Variable, Start, Length,
Tries, TimeOut, [ModbusOption])
The
Addr
parameter must match the sensor Modbus address. To collect all of the values, the
Start
parameter needs to be 1 and the
Length
parameter needs to correspond with the
register count (see
ModbusOption
is an optional parameter described in
the CRBasic Editor Help.
9.1.1 Register map
(p. 7) provides the register map for the most commonly used values. Calculated
irradiance uses the following equation:
CS325DM Silicon Irradiance Reference Sensor
6