See comments in code > -----Original Message----- > From: Francois Robbertze [SMTP:fr10@PIXIE.CO.ZA] > Sent: Friday, January 05, 2001 9:45 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: Thermostat Routine? > > Dear Piclist Members > > The routine read the temperature from a Dallas1820 > UpperT = 27 deg C (54) > LowerT = 23 deg C (46) > Element is a Triac > > As the temperature rises with the Element on it will switch off at 27 deg > C which is OK. > As the temperature now decreases the Element should switch on below the > LowerT value, but it don't - It switch on at a value below 27 deg again??? > > Can someone tell me where am I going wrong... > > Main > call Thermostat > > Thermostat > call ReadTemp ; Subroutine to read temperature from Dallas1820 > movlw 'E' ;Test for failure in dallas1820 > subwf Temp,W > btfsc STATUS,Z > goto DallasError > > movfw Temp > subwf UpperT,W ; Subtract the current temperature from UpperT ; if current temperature is higher than UpperT, the result ; will be negative and Carry will be set > btfss STATUS,C ; this should be btfsc STATUS,C > call HeatingOff > > movfw Temp > subwf LowerT,W ; Subtract current temperature from LowerT ; If current temperature is lower than LowerT, the result ; will be positive and Carry will be clear > btfsc STATUS,C ; this should be btfss STATUS,C > call HeatingOn > return > > HeatingOn > bsf Element > return > > HeatingOff > bcf Element > return > > DallasError > bcf Element ; do no heating and > return ;return to main loop > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body