Program examples, 1 crbasic example, 2 edlog example – Campbell Scientific SDM-CD16D 16-Channel Digital Control Port Expansion Module User Manual

Page 13

Advertising
background image

SDM-CD16D 16 Channel Digital Control Port Expansion Module

a data bit on C1 (LSB first) on the falling edge of the C2 clock. The SDM-
CD16D shifts in the C1 data bit on the rising edge of the C2 clock.

The first eight bits clocked out represent the SDM-CD16D address. If the
address matches the SDM-CD16D’s address, the SDM-CD16D is enabled. If
enabled, the next 16 bits are shifted into the SDM-CD16D, each bit controlling
one port, the first of which controls output 1.

When the 16 control bits are clocked in, C2 is held high while C3 is pulsed low
then high to latch the control bits. The datalogger then lowers both C3 and C2
to complete the cycle.

8. Program Examples

8.1 CRBasic Example

In the following CR1000 program example, a counter is used to fill an array
called Src( ) that will control two SDM-CD16Ds.

'Dimension Variables
Public src(32)
Dim i, count, mask(16)

'Program
BeginProg
for i=1 to 16

mask(i) = 2^(i-1)

next

i

Scan(20,msec,2,0)

count = count + 1

for i=1 to 32

src(i) = count AND mask(((i-1) MOD 16) +1)

next

i

SDMCD16AC(src(),2,1)
NextScan
EndProg

8.2 Edlog Example

The example is written for the CR10(X) Measurement and Control Module.
The program concepts presented are the same for the CR23X, 21X and CR7
dataloggers with minor changes in the program code.

In this example, the SDM-CD16D is used to control the temperature between
23°C and 28°C in each of five greenhouses. In each greenhouse the SDM-
CD16D controls a heating unit, a refrigerating unit and an air mixing fan
according to the following conditions:

Heating unit:
Activate when temperature <23.5°C.
Deactivate when temperature >25.5°C.

9

Advertising