' AV-Fan.bas
' control A/V cabinet cooling fan based on temperature reported by DS18B20
'
' Adapted from DS18B20_08M_3.Bas - PICAXE-08M
'
' Illustrates an interface with the DS18B20 in monitoring temperature. An alarm
' is associated with the temperature.
'
' If the temperature measured on the DS18B20 associated with IN1 is abve HighTrip, a relay
' on Out4 (term 3) is operated. It is released when the temperature falls below LowTrip
'
' Note that HighTrip and LowTrip are specified as the temperature plus 60 degrees C to avoid
' working with negative numbers.
'
' Note that a 4.7K pullup to +5 VDC is required on the DQ lead. +5 VDC is required on the
' V+ terminal of the DS18B20.
'
' 08M DS18B20
'
' IO1 (term 7) ------------------ DQ (term 2)
'
' 2N4401 ---(FAN)-- +
' |/
' OUT4 (term 3) ------- 4K7 ----->|\
' -- GRD
'
' Uses 68 of 2048 bytes (08M2) - or 65 of 256 bytes.(08M)
'
' original DS18B20 code copyright, Peter H Anderson, Baltimore, MD, Sept, '04
' AV-Fan changes copyright John E Carter 24 Sept 2006
symbol counter = b1
Symbol TempC_100 = W3
Symbol DevNum = W6
Symbol Temp_8 = B9
'need 100 as HighTrip and 98 as LowTrip for Traces 3210A solar controller external fan
Symbol HighTrip = 98 '(100.4F) ' 38 + 60 - fan on when temp hits 100F - adjust as necessary
Symbol LowTrip = 96 '(96.8F) ' 36 + 60 - fan off when 2 deg cooler
low 0 'set unused pin
high 4 'operation verification on power up (fan on)
high 2 '(status LED on)
pause 600
low 2
Low 4 ' turn off alarm
Top:
high 2 'indicate a read is in progress (power/activity light)
ReadTemp 1, Temp_8 ' read the high 8 bits - approx temp in deg C
low 2
' respond to the temperature
Temp_8 = Temp_8 + 60 ' to avoid negative numbers
If Temp_8 >= HighTrip Then OperateAlarm
if Temp_8 < LowTrip then continue
'indicate if above LowTrip but below HighTrip
for counter = 1 to 2
pause 200
high 2
pause 200
low 2
next counter
continue:
If Temp_8 < LowTrip Then ReleaseAlarm
' else
Goto SequenceDone
OperateAlarm:
High 4
Goto SequenceDone
ReleaseAlarm:
Low 4
Goto SequenceDone
SequenceDone:
Pause 1000 'was 20000
GoTo Top