My 95 year old father keeps leaving his freezer door open so I thought it would make an ideal and relatively simple PIC project.....
I have got so far and it all works on the sim but I have one issue I am struggling with......under hi-temp alarm condition and IF the door is also open, the LED goes bonkers as it is being flashed by both the alarm and also the door open routines..... I can see why but not how to workaround it
How can I "bypass" the door open bit under hi-temp alarm conditions ?... please keep it simple - you can probably tell by my code I am no expert !
Thanks
#picaxe 08m2 ' Freezer alarm monitors door open via magnetic reed switch and temperature using DS18B20
SYMBOL LED = 0 'PIC pin 7 / output 0 to LED's
SYMBOL temp = 4 'PIC pin 3 / input 4 from DSB1820 temp sensor
SYMBOL piezo = 2 'PIC pin 5 / output 2 to piezo sounder
SYMBOL setpoint = 140 '140 = -12 degC set point : note that for a minus values actual value is 128+12 (so minus 12 = actual value of 140)
SYMBOL temperature = b1 'store DS18B20 current temp reading in variable b1
LOW piezo 'piezo off : starting point = all off
LOW LED 'LED off : starting point = all off
' NB pin 0 refers to output 0 i.e. C.0 / PIC pin 7 (LED's)- ALWAYS flashing if door open
' pin 1 refers to input 1 i.e. C.1 / PIC pin 6 (door open = 1, close = 0)
' pin 2 refers to output 2 i.e. C.2 / PIC pin 5 (Piezo)
' pin 3 refers to input 3 i.e. C.3 / PIC pin 4 (rec attn normally 1, operated = momentary 0)
' pin 4 refers to input 4 i.e. C.4 / PIC pin 3 (temp sensor)
' pin 5 refers to C.5 / PIC pin 2 (programming input)
main:
gosub CheckTemp
gosub CheckDoor
goto main
end
CheckTemp:
readtemp 4, b1 ' read temp from DSB1820 PIC pin 3 / input C.4 into variable b1
if b1=> setpoint then gosub SoundPiezo ' temp too high
if pin3 = 0 then goto delay10 ' if PIC pin 4 / C.3 = 0, rec. attn pressed go to 10 min delay
'sertxd (" ", #b1,cr,lf)
if b1=> setpoint then goto checktemp
return
CheckDoor:
if pin1 = 1 then gosub FlashLED ' PIC pin 6 / input C.1 door open switch (hi = door open)
return
delay10: ' 600 sec / 10 min delay
low piezo ' silence piezo
for w4 = 1 to 5 ' test = 5 (3 sec), actual value will be 1000 (10 mins) ' 1000 steps @ 600msec increases response time if temp drops below setpoint
if pin1 = 1 then ' PIC pin 6 / input C.1 door open switch (hi = door open)
gosub FlashLED
endif
if b1< setpoint then goto main ' temp has reset
pause 600 ' 1000 steps @ 600msec
next w4
return
FlashLED:
high LED ' flash LED all the time door is open and temp is below setpoint
pause 500
low LED
return
SoundPiezo
high piezo ' PIC pin 5 / output C.2
high LED ' PIC pin 7 / output C.0
pause 500
low piezo
low LED
return
end
I have got so far and it all works on the sim but I have one issue I am struggling with......under hi-temp alarm condition and IF the door is also open, the LED goes bonkers as it is being flashed by both the alarm and also the door open routines..... I can see why but not how to workaround it
How can I "bypass" the door open bit under hi-temp alarm conditions ?... please keep it simple - you can probably tell by my code I am no expert !
Thanks
#picaxe 08m2 ' Freezer alarm monitors door open via magnetic reed switch and temperature using DS18B20
SYMBOL LED = 0 'PIC pin 7 / output 0 to LED's
SYMBOL temp = 4 'PIC pin 3 / input 4 from DSB1820 temp sensor
SYMBOL piezo = 2 'PIC pin 5 / output 2 to piezo sounder
SYMBOL setpoint = 140 '140 = -12 degC set point : note that for a minus values actual value is 128+12 (so minus 12 = actual value of 140)
SYMBOL temperature = b1 'store DS18B20 current temp reading in variable b1
LOW piezo 'piezo off : starting point = all off
LOW LED 'LED off : starting point = all off
' NB pin 0 refers to output 0 i.e. C.0 / PIC pin 7 (LED's)- ALWAYS flashing if door open
' pin 1 refers to input 1 i.e. C.1 / PIC pin 6 (door open = 1, close = 0)
' pin 2 refers to output 2 i.e. C.2 / PIC pin 5 (Piezo)
' pin 3 refers to input 3 i.e. C.3 / PIC pin 4 (rec attn normally 1, operated = momentary 0)
' pin 4 refers to input 4 i.e. C.4 / PIC pin 3 (temp sensor)
' pin 5 refers to C.5 / PIC pin 2 (programming input)
main:
gosub CheckTemp
gosub CheckDoor
goto main
end
CheckTemp:
readtemp 4, b1 ' read temp from DSB1820 PIC pin 3 / input C.4 into variable b1
if b1=> setpoint then gosub SoundPiezo ' temp too high
if pin3 = 0 then goto delay10 ' if PIC pin 4 / C.3 = 0, rec. attn pressed go to 10 min delay
'sertxd (" ", #b1,cr,lf)
if b1=> setpoint then goto checktemp
return
CheckDoor:
if pin1 = 1 then gosub FlashLED ' PIC pin 6 / input C.1 door open switch (hi = door open)
return
delay10: ' 600 sec / 10 min delay
low piezo ' silence piezo
for w4 = 1 to 5 ' test = 5 (3 sec), actual value will be 1000 (10 mins) ' 1000 steps @ 600msec increases response time if temp drops below setpoint
if pin1 = 1 then ' PIC pin 6 / input C.1 door open switch (hi = door open)
gosub FlashLED
endif
if b1< setpoint then goto main ' temp has reset
pause 600 ' 1000 steps @ 600msec
next w4
return
FlashLED:
high LED ' flash LED all the time door is open and temp is below setpoint
pause 500
low LED
return
SoundPiezo
high piezo ' PIC pin 5 / output C.2
high LED ' PIC pin 7 / output C.0
pause 500
low piezo
low LED
return
end
Attachments
-
2.3 KB Views: 3