Program examples, 1 sdmio16 example – Campbell Scientific SDM-IO16 16-Channel Input/Output Expansion Module User Manual
Page 24

SDM-IO16 16 Channel Input/Output Expansion Module
7. Program Examples
7.1 SDMIO16 Example
The following program sets up and measures an SDM-IO16.
Public Version(4) 
Public ComsStat(3) 
Public Freq(16) 
Public Setup(1) 
 
Alias version(1)=OS_Ver 
Alias version(2)=OS_Sig 
Alias version(3)=WatchDog 
Alias version(4)=ComErr 
 
BeginProg 
 
'Set up the SDM-IO16. 
 Scan(1,sec,0,2) 
 
'Set IO ports 1-16 to input switch closure.
SDMIO16(Setup,ComsStat(1),0,90,3333,3333,3333,3333,1,0)
 NextScan 
 
'Measure. 
 Scan(1,sec,0,0) 
 
'get signature from io16
SDMIO16(Version,ComsStat(2),0,99,0,0,0,0,1,0)
'read frequency of all 16 channels
SDMIO16(Freq(),ComsStat(3),0,46,0,0,0,0,1,0)
 NextScan 
 
EndProg 
7.2 A CR10X Program Using the Outputs for Control of a
Greenhouse Heating and Cooling System.
The example is written for the CR10X 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 or use of different 
instructions as indicated. 
In this example, the SDM-IO16 is used to control the temperature between 23°C 
and 28°C in each of five greenhouses. In each greenhouse the SDM-IO16 
controls a heating unit, a refrigerating unit and an air mixing fan. Solid state 
relays might be used as the interface to these units. The rules for control are: 
Heating unit:  
Activate when temperature <23.5°C. 
Deactivate when temperature >25.5°C. 
18
