PDA

View Full Version : Reset at midnight



malc-c
- 26th July 2010, 14:36
Guys,

I've been running my prototype thermostat over the weekend, and whilst it appears to run fine (temperatures in the vivariums are maintained to within 0.1 degree C) I've noticed that each morning the set temperatures have reverted to the default temps when the unit is first powered on. Anyway, I had a hunch that it was actually reverting to a pre-set night time temperature drop (normal temp is 30c - default on power up is 28c as is the pre-set night time temp) as I have this bit of code checking the times



timeH=(RTCHour>>4) 'convert the BCD format of the hours register and store in variable timeH
timeH=(timeH &$03)*10
timeH=timeH+(RTCHour&$0F)

timeM=(RTCMin>>4)
timeM=(timeM &$07)*10
timeM=timeM+(RTCMin&$0F) 'convert the BCD format of the mins register and store in variable timeM

LCDOut $FE,$D4+8,#setpoints(0)dig 2,#setpoints(0)dig 1,$FE,$D4+11,#setpoints(1)dig 2,#setpoints(1)dig 1 ' show current set temperatures
LCDOut $FE,$D4+14,#setpoints(2)dig 2,#setpoints(2)dig 1,$FE,$D4+17,#setpoints(3)dig 2,#setpoints(3)dig 1


FOR fn = 0 to 3
If StartHour[fn]=timeH and StartMin[fn]=timeM then 'compare value of each start time to current time and if matches
SetPoints[fn]=Droptemp[fn] 'change the corresponding set point to the drop temperature
LCDOut $FE, $94,"Night"
endif

if StopHour[fn]=timeH and StopMin[fn]=timeM then 'compare value of each stop time to current time and if matches
LCDOut $FE, $94," "
SetPoints[fn]= normtemp[fn] 'change value back to normal temperature
Endif

Next fn
RETURN


I sat watching the LCD last night and sure enough at 00:00 the set temps changes from 30c to 28c. My logic was that as the start time equals 00:00 (this is the starting point for setting the variables for the start of the night time temp drop) this would then cause the unit to switch to night temp mode, but then as the stop period also = 00:00 it should cancel out and change the set temp back to the norm temp value.

However, the reason I think the unit is restarting, is because it also ignores any setting for turning lights on (I have yet to implement DT's new routine for lights described in previous post). -

Any ideas as to what might be causing the PIC to reset at midnight ? the code is quite lengthy so it's not something I can include within a post.

aerostar
- 26th July 2010, 16:27
Have you thought of converting your times to minutes (word variable), 1440mins=24 hours, then your comparisons may be easier to do and the problem may be more obvious to see.