2 control temperature and fans – cr10x – Campbell Scientific SDM-CD16S 16-Channel Solid State DC Relay Controller Module User Manual
Page 16

SDM-CD16S 16 Channel Solid State DC Control Module
The Example 2 program uses an integer instead of an array to set the SDM-
CD16S control outputs:
'Program name: SDMCD16Example2.CR1
'Date written: 6/25/2007
'\\\\\\\\\\\\\\\\\\\\\\\\\ DECLARATIONS /////////////////////////
Public Temp(5)
Public TimedFanOn as Boolean
Dim I as Long
Dim CD16_Output as Long
'Note: CD16_Output bits set the SDM-CD16S ports. bits 0 to 4 are for ‘Heat,
‘5 to 9 are for Cooling, 10 to 14 are for Fans
'\\\\\\\\\\\\\\\\\\\\\\\\\\\ PROGRAM ////////////////////////////
BeginProg
Scan(5,Sec, 3, 0)
For I = 1 to 5
If (Temp(I) < 23.5) Then
'Set appropriate Heater Bit High:
CD16_Output
=
CD16_Output
OR
2^(I-1)
ElseIf (Temp(I) >= 25.5) Then
'Set appropriate Heater Bit Low:
CD16_Output
=
CD16_Output AND (&H7FFF - 2^(I-1))
EndIf
If (Temp(I) >= 27.5) Then
'Set appropriate Cooler Bit High:
CD16_Output
=
CD16_Output
OR
2^(I+4)
ElseIf (Temp(I) < 24.5) Then
'Set appropriate Cooler Bit Low:
CD16_Output
=
CD16_Output AND (&H7FFF - 2^(I+4))
EndIf
Next I
CD16_Output = (CD16_Output AND &H3FF) 'Set all Fan Bits Low
'Turn on Fan Bits for active Heaters or Coolers:
CD16_Output = CD16_Output OR (((CD16_Output*2^5) OR (CD16_Output*2^10)) AND &H7C00)
If TimeInToInterval(10,15,Min) Then TimedFanON = True
If TimeInToInterval(0,15,Min) Then TimedFanON = False
If TimedFanON = True Then
CD16_Output = CD16_Output OR &H7C00
SDMCD16AC(CD16_Output(),
1,
0)
NextScan
EndProg
8.2 Control Temperature and Fans – CR10X
The example is written for the CR10(X) Measurement and Control Module.
The program concepts presented are the same for the 21X and CR7 dataloggers
with minor program code changes.
The conditions and set points are the same as for example 8.1.
The program assumes the temperature measurements have been made, and the
average temperature for each greenhouse is computed and residing in Input
Locations 1 through 5.
12