$regfile = "m16def.dat"
$crystal = 9000000
Config Porta = Input
Porta = &B11111100
Config Portc = Output
Portc = &B00000000
Config Portd = Input
Portd = &B11111111
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 , Db6 = Portb.1 , Db7 = Portb.0 , E = Portb.4 , Rs = Portb.5
Portb.6 = 1
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim V As Single
Dim A As Single
Dim P As Integer
Dim C As Integer
Dim R As Integer
Dim Z As Byte
Start Adc
Start:
P = 0
V = 0
A = 0
C = 0
R = 0
Z = 0
Deflcdchar 2 , 32 , 32 , 32 , 14 , 14 , 32 , 32 , 32 ' wskaznik przeplywu.
Deflcdchar 1 , 32 , 32 , 31 , 31 , 31 , 31 , 32 , 32 'miernik plynu
'------------------------------temp-------------------
Config 1wire = Porta.1
Deflcdchar 0 , 8 , 20 , 11 , 4 , 4 , 4 , 3 , 32 'znak stopnia Celcjusza
Dim Temp As Integer , Ss As String * 6
Dim Dsid As Byte
'-----------------------przeplyw
Dim L1 As Byte
L1 = 0
Dim L2 As Byte
L2 = 0
Config Debounce = 0
Cls
Locate 2 , 5
Lcd "Dzien Dobry"
Locate 3 , 2
Lcd "System chlodzenia"
Locate 4 , 6
Lcd "WLACZONY"
Wait 5
Cls
Do
Cursor Off
Debounce Pind.7 , 0 , Zwieksz , Sub '---przeplyw
Debounce Pina.7 , 0 , Wlacz , Sub
If L2 = 5 Then Gosub Plyn
If L2 = 5 Then L2 = 0
If Pind.1 = 0 Then Gosub Alarm1
If Portc.3 = 1 Then
Locate 4 , 8
Lcd "-"
End If
If Portc.3 = 0 Then
Locate 4 , 8
Lcd " "
End If
If Pina.6 = 0 Then Gosub Wyciek
'-----------------------napiecie
'----pobieranie
For Z = 1 To 10
P = P + Getadc(0)
Next T
P = P / 10
V = P / 80
A = Frac(v)
V = Int(v)
A = A * 10
R = Int(a) + 10
C = V
Locate 1 , 1
Lcd " Went."
Locate 2 , 1
Lcd "V = "
Lcd C
Lcd R
If V >= 10 Then
Locate 2 , 7
Lcd "."
Locate 2 , 9
Lcd "0"
End If
If V < 10 Then
Locate 2 , 6
Lcd "."
Locate 2 , 8
Lcd "0 "
End If
'---------------------temp
1wreset
1wwrite &H55
1wverify Dsid
1wwrite &HBE
Temp = 1wread(2)
1wreset
1wwrite &HCC
1wwrite &H44
Temp = Temp * 10
Temp = Temp / 16
Ss = Str(temp)
Ss = Format(ss , "0.0")
Locate 1 , 8
Lcd " Temp.Plynu"
Locate 2 , 14
Lcd ; Ss ; Chr(0)
If Temp >= 330 Then 'TEMP WLACZENIA 1 BIEGU
Portc.0 = 1
End If
If Temp <= 320 Then 'WYLACZENIA 1 BIEGU
Portc.0 = 0
End If
If Temp >= 340 Then 'WLACZENIE 2 BIEGU
Portc.1 = 1
End If
If Temp <= 320 Then 'WYLACZENIE 2 BIEGU
Portc.1 = 0
End If
If Temp >= 350 Then 'wlaczenie 3 bieg
Portc.2 = 1
End If
If Temp <= 320 Then 'wylaczenie 3 bieg
Portc.2 = 0
End If
Loop
End
Plyn:
'-----------------poziom wys
Locate 4 , 1
Lcd "E"
Locate 4 , 7
Lcd "F"
Portc.5 = 1
Waitms 100
If Pind.2 = 0 Then
Locate 4 , 2
Lcd Chr(1)
End If
If Pind.2 = 1 Then
Locate 4 , 2
Lcd " "
End If
If Pind.3 = 0 Then
Locate 4 , 3
Lcd Chr(1)
End If
If Pind.3 = 1 Then
Locate 4 , 3
Lcd " "
End If
If Pind.4 = 0 Then
Locate 4 , 4
Lcd Chr(1)
End If
If Pind.4 = 1 Then
Locate 4 , 4
Lcd " "
End If
If Pind.5 = 0 Then
Locate 4 , 5
Lcd Chr(1)
End If
If Pind.5 = 1 Then
Locate 4 , 5
Lcd " "
End If
If Pind.6 = 0 Then
Locate 4 , 6
Lcd Chr(1)
End If
If Pind.6 = 1 Then
Locate 4 , 6
Lcd " "
End If
If Pind.3 = 1 Then
Locate 3 , 1
Lcd "Malo plynu"
End If
If Pind.3 = 0 Then
Locate 3 , 1
Lcd "Poziom "
End If
If Pind.2 = 1 And Pind.3 = 1 Then Gosub Alarm
Portc.5 = 0
Return
Wlacz:
Toggle Portc.3
Return
Alarm:
Toggle Portc.4
Locate 3 , 1
Lcd " MALO "
Locate 4 , 1
Lcd " PLYNU "
If Portc.3 = 1 And Portc.4 = 1 Then Gosub Wylacz
Return
'---------------------do przeplyw
Zwieksz:
Locate 3 , 13
Lcd "Przeplyw"
Locate 4 , 13
Lcd Chr(2)
Locate 4 , 20
Lcd Chr(2)
Incr L1
If L1 = 10 Then L1 = 0
L1 = L1 Mod 10
If Portc.3 = 1 And L1 = 3 Then
Locate 4 , 9
Lcd "AUTO"
End If
If Portc.3 = 1 And L1 = 9 Then
Locate 4 , 9
Lcd "OFF "
End If
If Portc.3 = 0 And L1 = 6 Then
Locate 4 , 9
Lcd " "
End If
Locate 4 , 14
If L1 = 0 Then Lcd "* "
If L1 = 1 Then Lcd " * "
If L1 = 2 Then Lcd " * "
If L1 = 3 Then Lcd " * "
If L1 = 4 Then Lcd " * "
If L1 = 5 Then Lcd " *"
If L1 = 6 Then Lcd " * "
If L1 = 7 Then Lcd " * "
If L1 = 8 Then Lcd " * "
If L1 = 9 Then Lcd " * "
If L1 = 10 Then Lcd "* "
If L1 = 1 Then
Incr L2
End If
If L2 = 5 Then Waitms 1
Return
Wylacz:
Portc.6 = 1
Waitms 300
Portc.6 = 0
Portc.3 = 0
Return
Alarm1:
Portc.4 = 1
Wait 1
Portc.4 = 0
Locate 3 , 12
Lcd " WOLNY "
Locate 4 , 12
Lcd " przeplyw"
If Portc.3 = 1 And Pind.1 = 0 Then Gosub Wylacz
Return
Wyciek:
If Portc.3 = 1 And Pina.6 = 0 Then Gosub Wylacz
If Pina.6 = 0 Then
Locate 3 , 4
Lcd "Wyciek Plynu"
End If
Return
'------opis -----------------------------------------------------------------
'Portc.4--Piszczyk
'Portc.5--Zasilanie czujnika poziomu
'Od Pind.2 do Pind.6 --Poziom płynu
'Od Portc.0 Do Portc.2 --3 Biegi wentylatora
'Porta.1 --czujnik temperatury.
'Porta.0 --Voltomierz
'Pind.1 --czujnik wolny przepływ
'Pind.7 --wskaznik ruchu
' \Portc.6--do przekaźnika wylaczenia kompa.
'Porta.6--czujnik wycieku.