Írtam már több programot ami stabilan működik , de a két utolsó nem lett igazán megbízható.
Van amikor üzemel rendesen a készülék , van amikor a bekapcsolás után már baromságok futnak a kijelzőn össze-vissza!
Adott 1 kis sütő kemence amiben van
:kelesztő -1 hőfokszabályozás
:sütőtér - 1 hőfokszabályozás,gőzölés ,gőzölési idő, sütési idő
Mindez 8 beállítható programban.
Hibajelenség:
-Hihetetlen baromságokat ír a kijelzőre ,ami ráadásul fut rajta jobbra
: nem köthető semmihez hogy mitől.
-Van 1 stopgomb int0- án , kijelzőre írással ,változók nullázásával.
Ide is befut gombnyomás nélkül is! Megjelenik a kijelzőn a stopp felirat majd fut tovább a program ahogy kell.
-Start gomb megnyomásakor indul a gőzölés ,majd egy időzítés ami persze nem mindig indul el.
-Sokszor bekapcsolás után rögtön ráfut a stop megszakításra majd baromságok a kijelzőn , aztán semmi a kijelzőn.
A többit nem is írom le , mert már nagyon bosszant a sok ráköltött pénz amit lehet hogy velem fizettetnek ki.
Itt a kód elég terjedelmes , van benne némi komment is:
Kód: Egész kijelölése
$regfile = "m8def.dat"
$crystal = 4000000
Config Portb = Output
Config Portd.0 = Input
Config Portd.1 = Input
Config Portd.2 = Input
Config Portd.3 = Input
Config Portd.4 = Input
Config Portd.5 = Output
Config Portd.6 = Output
Config Portd.7 = Output
Deflcdchar 0 , 2 , 4 , 14 , 17 , 31 , 16 , 14 , 32 ' é
Deflcdchar 1 , 10 , 10 , 14 , 17 , 17 , 17 , 14 , 32 ' ő
Deflcdchar 2 , 10 , 10 , 32 , 17 , 17 , 17 , 14 , 32 ' ű
Deflcdchar 3 , 2 , 5 , 2 , 32 , 32 , 32 , 32 , 32 ' fok(C)
Deflcdchar 4 , 10 , 32 , 17 , 17 , 17 , 17 , 14 , 32 ' ü
Deflcdchar 5 , 10 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' ö
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 , Db6 = Portb.1 , Db7 = Portb.0 , E = Portb.4 , Rs = Portb.5
Config Int0 = Low Level
Config Adc = Single , Prescaler = Auto , Reference = Internal
Config Timer1 = Timer , Prescale = 64
Enable Interrupts
Enable Int0
Start Adc
Ajto Alias Pind.0
Start_sut Alias Pind.1
'Pind.2 = Stopgomb
Prog Alias Pind.3
Setp Alias Pind.4
Gozki Alias Portd.5
Ventillki Alias Portd.6
'Hangki Alias Portd.7
Kemence_fut Alias Portb.6
Keleszto_fut Alias Portb.7
Dim Hokemence As Byte
Dim Hmkemence As Long
Dim Hmkeleszto As Byte
Dim Gozido As Byte
Dim Sutido As Byte
Dim Eltelt_sutido As Byte
Dim Maradekido As Byte
Dim Hoa As Long
Dim Oa As Long
Dim Hob As Long
Dim Ob As Long
Dim Hoal As Long
Dim Hoah As Long
Dim Hobl As Long
Dim Hobh As Long
Dim Kem As Word 'eeprom tárhej
Dim Kel As Word 'eeprom tárhej
Dim Goz As Word 'eeprom tárhej
Dim Sut As Word 'eeprom tárhej
Dim His As Byte
Dim Perc As Byte
Dim E As Byte
' jelzőbitek
Dim A As Bit 'előfűtés megvolt
Dim B As Bit 'sütés
Dim C As Bit 'gőz megvolt
Dim D As Bit 'sütés kész
Dim F As Bit 'programozás
Dim P As Byte 'programszám
Enable Timer1
On Int0 Stopgomb
On Timer1 Idoszamlalo
Stop Timer1
Initlcd
Cls
Cursor Off
P = 1
Gosub Beolvas
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'*******************************************************************************
Foprog:
If B = 0 Then
If Prog = 0 Then
Waitms 200
P = P + 1
If P > 8 Then P = 1
Gosub Beolvas
End If
End If
'***************************************************
If Setp = 0 Then
Waitms 500
If Setp = 0 Then
Gosub Menu
End If
End If
Waitms 100
Cls
If Ajto = 0 Then
Set Ventillki
End If
Oa = Getadc(0)
Hoa = Oa - 180
Ob = Getadc(1)
Hob = Ob
'**************************************************
If Hob = Hobh Or Hob > Hobh Then Reset Keleszto_fut
If Hob = Hobl Or Hob < Hobl Then Set Keleszto_fut
'***************************************************
If A = 0 Then
If B = 0 Then
Lcd " Program:" ; P
Lowerline
Lcd "El" ; Chr(1) ; "f" ; Chr(2) ; "t" ; Chr(0) ; "s" ; " " ; Hoa ; Chr(3) ; "C"
If Ajto = 0 Then
If Hoa = Hoal Or Hoa < Hoal Then Set Kemence_fut
If Hoa = Hoah Or Hoa > Hoah Then
Reset Kemence_fut
A = 1
End If
End If
'>>>>>>>>>>>>>>>>>>>>
If Start_sut = 0 Then
Gosub Beep2
Cls
Lcd "Nincs felf" ; Chr(2) ; "tve!"
Wait 3
End If
'>>>>>>>>>>>>>>>>>>>>
End If
End If
'****************************************************
If A = 1 Then
If B = 0 Then
Lcd " Program:" ; P ;
Lowerline
Lcd "Felf" ; Chr(2) ; "tve" ; " " ; Hoa ; Chr(3) ; "C"
If Ajto = 0 Then
If Hoa = Hoah Or Hoa > Hoah Then Reset Kemence_fut
If Hoa = Hoal Or Hoa < Hoal Then Set Kemence_fut
End If
End If
End If
'****************************************************
If Ajto = 1 Then
Reset Ventillki
Reset Kemence_fut
Gosub Ajtonyitva
Waitms 250
End If
If A = 1 Then
If B = 0 Then
If Start_sut = 0 Then
Gosub Beep1
If C = 0 Then
Cls
Lcd " G" ; Chr(1) ; "z" ; Chr(5) ; "l" ; Chr(0) ; "s ! "
Wait 1
Set Gozki
Wait Gozido ' Gozido
Reset Gozki
Waitms 500
Gosub Beep1
C = 1
End If
B = 1
Timer1 = 0
Start Timer1
Eltelt_sutido = 0
End If
End If
End If
'****************************************************
If A = 1 Then
If B = 1 Then
'If Ajto = 1 Then
'Reset Ventillki
'Reset Kemence_fut
'Gosub Ajtonyitva
'Waitms 250
'End If
Lcd "Program:" ; P ; " " ; Hoa ; Chr(3) ; "C"
Lowerline
Lcd "S" ; Chr(4) ; "t" ; Chr(0) ; "s " ; Maradekido ; " perc"
If Ajto = 0 Then
If Hoa = Hoah Or Hoa > Hoah Then Reset Kemence_fut
If Hoa = Hoal Or Hoa < Hoal Then Set Kemence_fut
End If
End If
End If
'****************************************************
If B = 1 Then
If Eltelt_sutido = Sutido Or Eltelt_sutido > Sutido Then
Stop Timer1
Timer1 = 0
Cls
Lcd " S" ; Chr(4) ; "t" ; Chr(0) ; "s " ; " k" ; Chr(0) ; "sz !"
Gosub Beep2
Wait 1
End If
End If
Maradekido = Sutido - Eltelt_sutido
Goto Foprog
'******************************
Menu:
Cls
Lcd " Menu"
Wait 2
Menuben:
Cls
If Prog = 0 Then P = P + 1
If Start_sut = 0 Then P = P - 1
If P > 9 Then P = 1
If P < 1 Then P = 9
If P = 9 Then
Lcd " kilepes"
If Setp = 0 Then
Return
End If
End If
If P < 9 Then
Lcd " program : " ; P
'End If
If Setp = 0 Then
Gosub Beolvas
Waitms 100
Gosub Beallit
End If
End If
Waitms 250
Goto Menuben
'*******************************
Idoszamlalo:
Stop Timer1
Timer1 = 0
Perc = Perc + 1
If Perc = 60 Then
Eltelt_sutido = Eltelt_sutido + 1
Perc = 0
End If
Start Timer1
Return
'*******************************
Ajtonyitva:
Cls
Lcd "! Nyitott ajto !"
Waitms 500
'If B = 1 Then
Gosub Beep2
'End If
Return
'*******************************
Stopgomb:
Stop Timer1
Timer1 = 0
Cls
Lcd " stop"
Gosub Beep2
Reset Gozki
B = 0
C = 0
D = 0
Perc = 0
Eltelt_sutido = 0
Waitms 250
Return
'******************************
Beolvas:
Kem = P * 33
Kel = Kem + 9
Goz = Kem + 18
Sut = Kem + 27
Readeeprom Hokemence , Kem
Readeeprom Hmkeleszto , Kel
Readeeprom Gozido , Goz
Readeeprom Sutido , Sut
'Readeeprom His , 0
His = 1
Hmkemence = Hokemence + 100
Hoal = Hmkemence - His
Hoah = Hmkemence + His
Hobl = Hmkeleszto - His
Hobh = Hmkeleszto + His
Return
'******************************
Beallit:
Waitms 250
Cls
Lcd "set program" ; P
If F = 0 Then
If Prog = 0 Then E = E + 1
If Start_sut = 0 Then E = E - 1
If E > 5 Then E = 1
If E < 1 Then E = 5
End If
Select Case E
Lowerline
'************************************************xx
Case 1:
Lcd "gozoles ido :" ; Gozido
If F = 0 Then
If Setp = 0 Then
F = 1
Waitms 200
End If
End If
If F = 1 Then
Cls
Lcd "set"
Lowerline
Lcd "gozoles ido :" ; Gozido
If Prog = 0 Then Gozido = Gozido + 1
If Start_sut = 0 Then Gozido = Gozido -1
If Gozido < 1 Then Gozido = 1
If Gozido > 20 Then Gozido = 20
If Setp = 0 Then
If F = 1 Then
Writeeeprom Gozido , Goz
F = 0
Waitms 200
End If
End If
End If
'*************************************************xx
Case 2:
Lcd "sutes ido:" ; Sutido
If F = 0 Then
If Setp = 0 Then
F = 1
Waitms 200
End If
End If
If F = 1 Then
Cls
Lcd "set"
Lowerline
Lcd "sutes ido:" ; Sutido
If Prog = 0 Then Sutido = Sutido + 1
If Start_sut = 0 Then Sutido = Sutido -1
If Sutido < 5 Then Sutido = 5
If Sutido > 60 Then Sutido = 60
If Setp = 0 Then
If F = 1 Then
Writeeeprom Sutido , Sut
F = 0
Waitms 200
End If
End If
End If
'*************************************************xx
Case 3:
Lcd "sutes hofok:" ; Hmkemence
If F = 0 Then
If Setp = 0 Then
F = 1
Waitms 200
End If
End If
If F = 1 Then
Cls
Lcd "set"
Lowerline
Lcd "sutes hofok:" ; Hmkemence
If Prog = 0 Then Hmkemence = Hmkemence + 1
If Start_sut = 0 Then Hmkemence = Hmkemence -1
If Hmkemence < 101 Then Hmkemence = 101
If Hmkemence > 320 Then Hmkemence = 320
If Setp = 0 Then
If F = 1 Then
Hokemence = Hmkemence - 100
Writeeeprom Hokemence , Kem
F = 0
Waitms 200
End If
End If
End If
'*************************************************xx
Case 4:
Lcd "keleszt hofok" ; Hmkeleszto
If F = 0 Then
If Setp = 0 Then
F = 1
Waitms 200
End If
End If
If F = 1 Then
Cls
Lcd "set"
Lowerline
Lcd "keleszt hofok" ; Hmkeleszto
If Prog = 0 Then Hmkeleszto = Hmkeleszto + 1
If Start_sut = 0 Then Hmkeleszto = Hmkeleszto -1
If Hmkeleszto < 25 Then Hmkeleszto = 25
If Hmkeleszto > 33 Then Hmkeleszto = 33
If Setp = 0 Then
If F = 1 Then
Writeeeprom Hmkeleszto , Kel
F = 0
Waitms 200
End If
End If
End If
'*************************************************xx
Case 5:
Lcd "kilep"
If Setp = 0 Then
Cls
Return
End If
End Select
Goto Beallit
Return
'/*****************************
Beep1:
Sound Portd.7 , 500 , 200
Return
'/*****************************
Beep2:
Sound Portd.7 , 400 , 150
Waitms 300
Sound Portd.7 , 400 , 150
Return
Nem tudom a kód rossz-e , vagy a fordítás , vagy mi?