SDM-CD16AC 16 Channel AC/DC Controller
12
EndIf
Next
I
If
TimeInToInterval
(10,15,Min)
Then
Flag(2) = True
If
TimeInToInterval
(0,15,Min)
Then
Flag(2) = False
If
Flag(2) = True
then
For
I = 1
to
5
Fan(I) = 1
Next
I
EndIf
For
I = 1
to
5
CD16_Output(I) = Heat(I)
CD16_Output(I+5) = Cool(I)
CD16_Output(I+10) = Fan(I)
Next
I
SDMCD16AC
(CD16_Output(), 1, 0)
NextScan
EndProg
uses an integer instead of an array to set the SDM-
CD16AC control outputs:
CRBasic Example 8-3. Using an Integer to Set SDM-CD16AC Control Outputs
'Program name: SDMCD16Example2.CR1
'\\\\\\\\\\\\\\\\\\\\\\\\\ DECLARATIONS /////////////////////////
Public
Temp(5)
Public
TimedFanOn
as
Boolean
Dim
I
as
Long
Dim
CD16_Output
as
Long
'Note: CD16_Output bits set the SDM-CD16AC 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