Programming
The SDMGeneric()
is used to turn the 12V and V+ terminals on and off.
Use SequentialMode
if the SDMGeneric()
instructions need to be inside a conditional statement.
SDMGeneric
(Dest, SDM_addr, 7, 1, hexVar, 0, 1, 1, -0
Dest
is a variable declared to hold any incoming bytes from the SDM device. SDM_addr
is the SDM address of the device. HexVar
is a 2-digit hex value that determines if a voltage is turned on or off. The left digit controls V+; the right digit controls 12V. Sending a 1 for a digit turns the relay and LED on; sending a 2 for a digit turns the relay and LED off; sending a 0 will not change the relay/LED value. For example:
-
hexVar0 = &H01: V+ unchanged, 12V ON
-
hexVar0 = &H10: V+ ON, 12V unchanged
-
hexVar0 = &H11 : V+ ON, 12V ON
-
hexVar0 = &H22: V+ OFF, 12V OFF
See Example using switched relay power for an example of how to write programs in CRBasic to turn the switched relay power on and off.
The normal serial port instructions such as SerialOpen()
and SerialIn()
are used with the SDM‑SIO2R to send and receive data. Aside from changes to the COMPort
and the SerialOpenFormat
parameter, a program written for a standard serial port will usually work with the SDM‑SIO2R. The main difference to be aware of, when trying to write fast running programs, is the extra delay needed to transfer data from the SDM‑SIO2R to the data logger (roughly equivalent to transferring data over a serial link at 38 kilobaud).
The following section gives further information about the CRBasic programming language and how the serial instructions are to be used with the SDM‑SIO2R.
This section assumes the user has knowledge of the CRBasic programming language. A useful introduction to programming for serial sensors can be found here:
https://s.campbellsci.com/documents/sp/technical-papers/serial.pdf
See Example data logger programs for two simple example CRBasic programs that send and receive data using the SDM‑SIO2R.
Please contact Campbell Scientific for further assistance or training. The Campbell Scientific user forum is also a useful resource to check if others might have already written code for a specific serial device.
Only the parameters that need special explanation or whose functionality has changed when used with the SDM‑SIO2R are listed in the following sections. Any other parameters should be taken as not having changed. Please refer to the data logger manual and/or the CRBasic Editor help system for more guidance.