$regfile = "m16def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Portb.5 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.1 , E = Portb.4 , Rs = Portb.6
Config Lcd = 16 * 2
Config Pina.2 = Input : Config Pina.3 = Input : Config Pina.4 = Input : Config Pina.5 = Input : Config Pina.6 = Input : Config Pina.7 = Input
Config Portb.0 = Output 'podswietlenie lcd
Config Pinc.0 = Input : Config Pinc.1 = Input : Config Pinc.2 = Input : Config Pinc.3 = Input : Config Pinc.4 = Input : Config Pinc.5 = Input : Config Pinc.6 = Input : Config Pinc.7 = Input
Config Portd.0 = Output : Config Portd.1 = Output : Config Portd.2 = Output : Config Portd.3 = Output : Config Portd.4 = Output : Config Portd.5 = Output : Config Portd.6 = Output : Config Portd.7 = Output
Config Adc = Single , Prescaler = Auto , Reference = Internal
Klapa Alias Pina.2 : Reset Klapa
Hz3 Alias Pina.3 : Reset Hz3
Hz2 Alias Pina.4 : Reset Hz2
Hz1 Alias Pina.5 : Reset Hz1
Hb2 Alias Pina.6 : Reset Hb2
Hb1 Alias Pina.7 : Reset Hb1
Podsw Alias Portb.0 : Reset Podsw
Sw_wylacz Alias Pinc.0 : Set Sw_wylacz
Sw_wylej Alias Pinc.1 : Set Sw_wylej
Sw_nalej Alias Pinc.2 : Set Sw_nalej
Sw_czysc Alias Pinc.3 : Set Sw_czysc
Sw_pr1 Alias Pinc.4 : Set Sw_pr1
Sw_pr2 Alias Pinc.5 : Set Sw_pr2
Sw_pr3 Alias Pinc.6 : Set Sw_pr3
Sw_zegar Alias Pinc.7 : Set Sw_zegar
Out_1 Alias Portd.0 : Reset Out_1
Out_2 Alias Portd.1 : Reset Out_2
Out_3 Alias Portd.2 : Reset Out_3
Out_4 Alias Portd.3 : Reset Out_4
Out_5 Alias Portd.4 : Reset Out_5
Out_6 Alias Portd.5 : Reset Out_6
Out_7 Alias Portd.6 : Reset Out_7
Out_8 Alias Portd.7 : Reset Out_8
Dim Pr As Byte
Dim Test As Bit : Test = 0
Dim Czas As Word
Dim Cykl As Word : Cykl = 0
Dim Ac As Byte : Ac = 0
Dim Wart_ac1 As Word
Dim V1 As Single
Dim Wart_ac2 As Word
Dim V2 As Single
Dim Temp1 As String * 3
Dim Temp2 As String * 3
Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32
Cursor Off
Cls
Readeeprom Pr , 1
Gosub Standby
'********************************* GŁÓWNE MENU *********************************
Glowne:
Do
If Pr = 1 Then : Czas = 120 : End If
If Pr = 2 Then : Czas = 240 : End If
If Pr = 3 Then : Czas = 360 : End If
If Sw_nalej = 0 Then
Cls
Do
Locate 1 , 1 : Lcd "PRZYCISNIJ I ABY"
Locate 2 , 1 : Lcd " WEJSC W TEST "
If Sw_pr1 = 0 Then
Toggle Test
Do
Cls
Loop Until Sw_pr1 = 1
End If
Gosub Wyswietl
Loop Until Sw_nalej = 1
End If
If Sw_pr1 = 0 Then : Pr = 1 : Do : Gosub Wyswietl : Loop Until Sw_pr1 = 1 : Writeeeprom Pr , 1 : End If
If Sw_pr2 = 0 Then : Pr = 2 : Do : Gosub Wyswietl : Loop Until Sw_pr2 = 1 : Writeeeprom Pr , 1 : End If
If Sw_pr3 = 0 Then : Pr = 3 : Do : Gosub Wyswietl : Loop Until Sw_pr3 = 1 : Writeeeprom Pr , 1 : End If
If Sw_zegar = 0 Then : Gosub Mycie : End If
If Hz1 = 0 Then : Gosub Full : End If
If Sw_wylej = 0 Then : Gosub Wylej : End If
If Sw_wylacz = 0 Then : Gosub Standby : End If
Gosub Stan
Gosub Wyswietl
Loop
Return
'*******************************************************************************
'==================================== MYCIE ====================================
Mycie:
If Pr = 1 Then : Czas = 120 : End If
If Pr = 2 Then : Czas = 240 : End If
If Pr = 3 Then : Czas = 360 : End If
Do
Gosub Stan
Gosub Wyswietl
If Sw_wylacz = 0 Then : Gosub Standby : End If
If Klapa = 1 Then
Decr Czas
If Czas < 9 Then : Reset Out_6 : Wait 1 : Reset Out_7 : Else : Set Out_6 : Wait 1 : Set Out_7 : End If
If Czas < 6 Then : Set Out_5 : End If
If Czas = 0 Then : Incr Cykl : Gosub Gotowe : End If
Else
Reset Out_5
Reset Out_6
Reset Out_7
End If
Loop Until Sw_wylacz = 0
Gosub Standby
Return
'===============================================================================
'==================================== GOTOWE ===================================
Gotowe:
Reset Out_5 : Reset Out_6 : Reset Out_7
Cls
Do
Gosub Stan
Locate 1 , 1 : Lcd "GOTOWE CYKL " ; Cykl
Locate 2 , 1 : Lcd "T1 " ; Temp1
Locate 2 , 6 : Lcd Chr(0) ; "C "
Locate 2 , 10 : Lcd "T2 " ; Temp2
Locate 2 , 15 : Lcd Chr(0) ; "C "
If Sw_wylacz = 0 Then : Cls : Gosub Standby : End If
If Sw_wylej = 0 Then : Cls : Gosub Wylej : End If
If Klapa = 0 Then : Cls : Gosub Mycie : End If
If Sw_pr1 = 0 Then : Cls : Gosub Glowne : End If
If Sw_pr2 = 0 Then : Cls : Gosub Glowne : End If
If Sw_pr3 = 0 Then : Cls : Gosub Glowne : End If
If Sw_zegar = 0 Then : Cls : Gosub Mycie : End If
Loop
Return
'===============================================================================
'====================================== STAN ===================================
Stan:
If Ac = 0 Then
Start Adc
Wart_ac1 = Getadc(1)
Wart_ac1 = Wart_ac1 - 520
V1 = Wart_ac1 * 0.31
Temp1 = Fusing(v1 , "#.")
Wart_ac2 = Getadc(0)
Wart_ac2 = Wart_ac2 - 520
V2 = Wart_ac2 * 0.31
Temp2 = Fusing(v2 , "#.")
Stop Adc
End If
Incr Ac
If Ac > 50 Then : Ac = 0 : End If
If Hb1 = 0 Then
Reset Out_1
Reset Out_5
End If
If Hb2 = 0 Then
Reset Out_1
Set Out_3
Else
Reset Out_3
If Wart_ac1 < 280 Then : Set Out_1 : Else : Reset Out_1 : End If
End If
If Hz1 = 0 Then
Reset Out_2
Else
If Wart_ac2 < 180 Then : Set Out_2 : Else : Reset Out_2 : End If
End If
If Hz2 = 1 Then
Set Out_4
Else
Reset Out_4
End If
Return
'===============================================================================
'================================= NAPEŁNIANIE =================================
Full:
Do
Gosub Stan
Gosub Wyswietl
If Klapa = 1 Then
If Hb2 = 1 Then
If Wart_ac1 > 210 Then
Reset Out_1
Set Out_5
End If
End If
If Wart_ac1 < 190 Then : Reset Out_5 : End If
Else
Reset Out_5
End If
If Sw_wylacz = 0 Then : Gosub Standby : End If
Loop Until Hz1 = 1
Reset Out_5
Gosub Glowne
Return
'===============================================================================
'==================================== WYLEJ ====================================
Wylej:
Cykl = 0
Reset Out_1
Reset Out_2
Reset Out_3
Cls
Czas = 300
Do
If Sw_wylacz = 0 Then : Gosub Standby : End If
If Klapa = 1 Then
Cls
Locate 1 , 7 : Lcd Czas ; " sec "
Locate 2 , 2 : Lcd "WYLEWANIE WODY"
Set Out_4
Decr Czas
Wait 1
If Hz1 = 1 Then : Set Out_6 : Wait 1 : Set Out_7 : Else : Reset Out_6 : Reset Out_7 : End If
If Czas < 60 Then : Set Out_5 : End If
If Czas < 25 Then : Reset Out_5 : End If
If Czas = 0 Then : Gosub Standby : End If
Else
Reset Out_4
Reset Out_6
Reset Out_7
Locate 1 , 1 : Lcd " ZAMKNIJ KLAPE "
Locate 2 , 2 : Lcd " WYLEWANIE WODY "
End If
Loop Until Sw_wylacz = 0
Gosub Standby
Return
'===============================================================================
'================================ WYŚWIETLANIE =================================
Wyswietl:
If Test = 0 Then
If Hz1 = 1 Then
Locate 1 , 1 : Lcd "Pr " ; Pr
Locate 1 , 7 : Lcd Czas ; " sec "
Else
Locate 1 , 1 : Lcd " "
End If
If Wart_ac1 > 350 Then
Locate 2 , 1 : Lcd "T1 Error "
Wait 5
Gosub Standby
Else
Locate 2 , 1 : Lcd "T1 " ; Temp1
Locate 2 , 6 : Lcd Chr(0) ; "C "
End If
If Wart_ac2 > 350 Then
Locate 2 , 10 : Lcd "T2 Error "
Wait 5
Gosub Standby
Else
Locate 2 , 10 : Lcd "T2 " ; Temp2
Locate 2 , 15 : Lcd Chr(0) ; "C "
End If
Else
Locate 1 , 1 : Lcd "I " ; Sw_wylacz ; Sw_wylej ; Sw_nalej ; Sw_czysc ; Sw_pr1 ; Sw_pr2 ; Sw_pr3 ; Sw_zegar ; Hb1 ; Hb2 ; Hz1 ; Hz2 ; Hz3 ; Klapa
Locate 2 , 1 : Lcd "O " ; Out_1 ; Out_2 ; Out_3 ; Out_4 ; Out_5 ; Out_6 ; Out_7 ; Out_8 ; " TEST"
End If
Return
'===============================================================================
'================================== CZUWANIE ===================================
Standby:
Cls
Reset Podsw
Do
Reset Out_1
Reset Out_2
Reset Out_3
Reset Out_4
Reset Out_5
Reset Out_6
Reset Out_7
Reset Out_8
Locate 2 , 4 : Lcd "STAND-BY"
If Sw_wylej = 0 Then : Gosub Wylej : End If
Loop Until Sw_nalej = 0
Cls
Set Podsw
Gosub Glowne
Return
'===============================================================================