Witam.
Jestem zielony i nie wiem jak zmodyfikować kod programu, żeby histereza wynosiła 2°C
Proszę o pomoc i z góry dzięki.
Jestem zielony i nie wiem jak zmodyfikować kod programu, żeby histereza wynosiła 2°C
Code:
'Termostat
$regfile = "m8def.dat"
$crystal = 8000000 '
'
Config Pinb.1 = Input
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.5 , Db5 = Portd.6 , Db6 = Portd.7 , Db7 = Portd.4 , E = Portd.3 , Rs = Portd.2
Config Timer0 = Timer , Prescale = 1024
Enable Interrupts : Enable Timer0
On Timer0 Co4ms
'Config Pinb.3 = Input 'porty jako wejťciowe
Config Pinb.4 = Input 'porty jako wejťciowe
Config Pinb.5 = Input 'porty jako wejťciowe
'Set Portb.3 ' ustawia na stan wysoki
Set Portb.4 ' ustawia na stan wysoki
Set Portb.5 ' ustawia na stan wysoki
Config Portb.2 = Output
Config 1wire = Portd.1
Deflcdchar 1 , 4 , 10 , 4 , 32 , 32 , 32 , 32 , 32 'znak stopnia
Dim Tust As Byte 'temperatura ustawiana
Dim Tust1 As Byte
Dim T1 As Single
Dim T2 As Single
Dim B1 As Byte , B2 As Byte , R As Byte
Dim Tmp As String * 6
Dim Znak As String * 1
R = &HFF
Declare Sub 1wr 'podprogram resetujacy magistrale 1w
Tust = 25 'temperatura początkowwa na jakom jest ustawiony termostst
Cursor Off
Cls
Do
1wr 'podprogram 1wr
1wwrite &HCC 'komenda skip ROM
1wwrite &H44 'komenda convert T
Waitms 250
Waitms 250
1wr 'podprogram 1wr
1wwrite &HCC 'komenda skip ROM
1wwrite &HBE 'komenda read
B1 = 1wread() 'odczyt z termometru
B2 = 1wread()
1wr 'podprogram 1wr
If B2 >= 248 Then 'w przypadku temperatur ujemnych
B1 = R - B1
B2 = R - B2
Znak = "-"
Else
Znak = "+"
End If
T1 = B1 / 16 'Przesuniecie w pawo o 4 bajty
T2 = B2 * 16 'przesuniecie w lewo o 4 bajty
T1 = T1 + T2
Tmp = Fusing(t1 , " ###.&")
Cls
Tust1 = T1
If Tust1 > Tust Then Portb.2 = 1
If Tust1 < Tust Then Portb.2 = 0
Lcd "T ustawona:" ; Tust ; Chr(1) ; "C "
Lowerline
Lcd "aktualna:" ; Znak ; Tmp ; Chr(1) ; "C "
'Waitms 250
'Waitms 250
'Waitms 250
Waitms 50
Loop
Sub 1wr 'podprogram resetujacy magistrale
1wreset
End Sub
Co4ms:
If Pinb.4 = 0 Then
Waitms 155
Tust = Tust + 1
If Tust > 140 Then Tust = 140 'czyta swicze
End If
'End If
If Pinb.5 = 0 Then
Waitms 155
Tust = Tust - 1
If Tust < 1 Then Tust = 2 'czyta swicze
End If
Return
Proszę o pomoc i z góry dzięki.