2 crbasic programming, 1 sdmio16 instruction – Campbell Scientific SDM-IO16 16-Channel Input/Output Expansion Module User Manual

Page 16

Advertising
background image

SDM-IO16 16 Channel Input/Output Expansion Module

6.2 CRBasic Programming

Dataloggers that use CRBasic include our CR800, CR850, CR1000, CR3000,
and CR5000.

6.2.1 SDMIO16 Instruction

The SDMIO16 instruction in CRBasic supports all of the functions of the
SDM-IO16. The SDMIO16 instruction is described below; refer to section 7
for an example.

Syntax

SDMIO16 ( Dest, Status, Address, Command, Mode Ports 16-13, Mode Ports
12-9, Mode Ports 8-5, Mode Ports 4-1, Mult, Offset
)

Remarks

The ports on the SDM-IO16 can be configured for either input or output.
When configured as input, the SDM-IO16 can measure the logical state of
each port, count pulses, and measure the frequency of and determine the duty
cycle of applied signals. The module can also be programmed to generate an
interrupt signal to the datalogger when one or more input signals change state.
When configured as an output, each port can be set to 0 or 5 V by the
datalogger. In addition to being able to drive normal logic level inputs, when
an output is set high a ‘boost’ circuit allows it to source a current of up to 100
mA, allowing direct control of low voltage valves, relays, etc.

Dest

The Dest parameter is a variable or variable array in which to
store the results of the measurement (Command codes 1 - 69,
91, 92, 99) or the Source value for the Command Codes (70 -
85, 93 - 98). The variable array for this parameter must be
dimensioned to accommodate the number of values returned
(or sent) by the instruction.

Status

The Status parameter is used to hold the result of the command
issued by the instruction. If the command is successful a 0 is
returned; otherwise, the value is incremented by 1 with each
failure.

SDMAddress The SDMAddress parameter defines the address of the SDM-

IO16 with which to communicate. Valid SDM addresses are 0
through 14. Address 15 is reserved for the SDMTrigger
instruction. If the Reps parameter is greater than 1, the
datalogger will increment the SDM address for each
subsequent SDM-IO16 that it communicates with.

Command

The Command parameter is used to set up the SDM-IO16.
Please read section 6.4 for detailed description of the
controlling command codes.

Mode

Each Mode parameter is used to configure a bank of four ports
when a Command code 86 through 90 is used (if any other
Command Code is used, enter 0 for the Mode parameters).

10

Advertising