Thank You, Mr.Darrel !
I have already do this, but...Maybe it's another mistake..So, I put the code.
I read the temperature :
Code:OWOut DQ, 1, [$CC, $44] OWOut DQ, 1, [$CC, $BE] OWIn DQ, 2, [temperature.byte0, temperature.byte1] SignBit = 0 if temperature.15 then temperature = ~ temperature + 1 SignBit = 1 endif Dummy = 625 * Temperature TempC = DIV32 10 TempC = (Temperature & $7FF) >> 4 Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2 Temperature=TempC*100 + Float If SignBit then V= 10000 - Temperature ' 25'C=12500 0'C=10000 -10'C=9000 SignBit = 0 else V= 10000 + Temperature EndIf If V >= 10000 then ' Above 0 C. Temperature=V-10000 else Temperature=10000-V ' Below 0 C. EndIf GoSub SelectSign ' +/blank/- SignAt the beginning I set the hysterezis for thermostat :Code:SelectSign: If v = 10000 then ' Temperature = 0 C. Sign=" " ' No sign Else If v < 10000 then ' <> 0 Sign="-" ' Temperature below 0 C. Else Sign="+" ' Temperature above 0 C. EndIf EndIf Return
and I try to do this :Code:If Mode=1 then ' Set Hysteresis LcdReg = %10000000 + 12 ' cursor X call PrintCtrlLcd LcdReg = %01000010 ' cursor Y call PrintCtrlLcd Char = 21 call PrintChar Char = 19 call PrintChar Char = 20 call PrintChar Char = 15 call PrintChar Gosub DTemp ' Display Hysteresis If (PORTB.1=0) Or (PORTB.2=0) then ' Up or down button pushed If PORTB.2=0 then ' Down button if hyst > 5 then hyst=hyst-5 If Hyst < 5 then Hyst=5 Gosub Debounce EndIf If PORTB.1=0 then ' Up button hyst=hyst+5 If Hyst > 50 then Hyst=50 Gosub Debounce EndIf Gosub DTemp ' Display Hysteresis EndIf EndIf ..... DTemp : LcdReg = %10100000 + 14 ' cursor X call PrintCtrlLcd LcdReg = %01000100 ' cursor Y call PrintCtrlLcd Char = (hyst dig 2) + 2 call PrintChar Char = 14 call PrintChar Char = (hyst dig 1) + 2 call PrintChar Char = (hyst DIG 0) + 2 Call PrintChar Return
Everything works great, but this "if temperature > (tref + hyst) then" return wrong results.Code:check: if temperature > (tref + hyst) then tref=temperature duratavar=(temperature-tref)/hyst duratavar=duratavar*durata if tipsun=2 then sound PORTB.6, [varsnd, duratavar] else sound PORTB.6, [varsnd, 20] endIf endif if temperature < (tref - hyst) then tref=temperature duratavar=(tref-temperature)/hyst duratavar=duratavar*durata if tipsun=2 then sound PORTB.6, [varsnd2, duratavar] else sound portb.6, [varsnd2, 10] endif endif Return
Note : hyst, temperature, tref are var Word.
Hysterezis must be max 0.50 'C, with step of 0.05 'C. On display works fine, but inside the code I think I made mistake...Thank You !




Bookmarks