6. 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).
A CR6 or CR1000X data logger programmed as a Modbus Master can retrieve the values stored in
the Input Registers. To do this, the CRBasic program requires a
SerialOpen()
instruction
followed by the
ModbusMaster()
instruction.
The
SerialOpen
instruction has the following syntax:
SerialOpen
(ComPort, Baud, Format, TXDelay, BufferSize, Mode)
The
Format
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
(p. 4)).
ModbusOption
is an optional parameter
described in the CRBasic Editor Help. Refer to
(p. 5) for more
information.
7. SR20-D2 example program
Table 7-1: Wiring for example program
Wire color
Function
Data logger connection
Green
RS-485A
C5
White
RS-485B
C6
Red
Power in (12 V) 12V
Black
Power ground G
Clear
Shield
⏚
(analog ground)
SR20-D2 ISO Spectrally Flat Class A (Secondary Standard) Pyranometer
5