Dokładam 3-ci kod przedmuchy, $regfile = "m8def.dat" $crystal = 16000000 'Config Porta = &B00111111 : Porta = &B11111111 Config Portb = &B11111000 : Portb = &B11111111 Config Portc = &B11111111 : Portc = &B11111111 Config Portd = &B00011111 : Portd = &B11111111 Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 'mirley UPT M16 Config Lcd = 16 * 2 Cls Cursor Off Noblink Config 1wire = Pind.2 Sw_port Alias Pinb 'nazwa portu Pompa Alias Portd.3 Zawor Alias Portd.4 Buzz Alias Portd.1 Light Alias Portd.0 Ds1r Alias Pind.7 Ds2r Alias Pind.6 Ds3r Alias Pind.5 Led_a Alias Portb.5 Led_p Alias Portb.3 Led_z Alias Portb.4 Config Timer0 = Timer , Prescale = 256 Enable Timer0 : On Timer0 Prztimer0 Enable Interrupts '********** Konfiguracja uC Koniec ************ '****************** Zmienne ******************* '*********************************************** Dim Stan_sw As Byte , Sw As Byte , Licznik_sw As Byte 'sw Dim Wyswietlanie As Byte , Poz_wysw As Byte , Wyswietlono As Bit 'Lcd Dim Mig As Bit , Poz_ust As Byte Dim Autosave As Byte , Autopowrot As Byte , Autolight As Byte Dim Ds1(8) As Byte , Ds2(8) As Byte , Ds3(8) As Byte , Ds4(8) As Byte , Ds(8) As Byte , Ds_adr As Byte , Ds_ok As Bit 'DS18B20 Dim Ktory_ds As Byte , Lsb As Byte , Msb As Byte , Minusy As Byte Dim T(4) As Word Dim T_min As Word , T_alarm As Word Dim T_minz As Word Dim Dzielnik(2) As Byte 'dzielniki timera Dim Flaga_4ms As Bit , Flaga_500ms As Bit , Flaga_1s As Bit 'flagi przerwa? Dim Hbyte(2) As Byte , Hword(3) As Word , N As Byte , Hbit As Bit , M As Byte Dim Buzz_en As Bit Dim Tryb_letni As Bit '0- tryb zimowy, 1- tryb letni '************* Zmienne Koniec **************** '************ Warunki Poczatkowe *************** '*********************************************** Light = 0 Lcd " Sterownik C.O." Lowerline Lcd " By Szymon w.1.1" Wait 1 If Ds1r = 1 And Ds2r = 0 And Ds3r = 0 Then Ds_adr = 30 Gosub Ds_reg Cls Lcd "Ds Piec" End If If Ds1r = 0 And Ds2r = 1 And Ds3r = 0 Then Ds_adr = 40 Gosub Ds_reg Cls Lcd "Ds Bojler" End If If Ds1r = 1 And Ds2r = 1 And Ds3r = 0 Then Ds_adr = 50 Gosub Ds_reg Cls Lcd "Ds Pokoj" End If If Ds1r = 0 And Ds2r = 0 And Ds3r = 1 Then Ds_adr = 60 Gosub Ds_reg Cls Lcd "Ds Zewnatrz" End If For N = 1 To 8 Hbyte(1) = 30 + N Readeeprom Ds1(n) , Hbyte(1) Hbyte(1) = 40 + N Readeeprom Ds2(n) , Hbyte(1) Hbyte(1) = 50 + N Readeeprom Ds3(n) , Hbyte(1) Hbyte(1) = 60 + N Readeeprom Ds4(n) , Hbyte(1) Next N Readeeprom T_min , 2 Readeeprom T_alarm , 4 Readeeprom Hbyte(1) , 6 Readeeprom T_minz , 7 Tryb_letni = Hbyte(1).0 If T_min < 100 Or T_min > 950 Then T_min = 400 If T_alarm < 100 Or T_alarm > 950 Then T_alarm = 850 If T_minz < 100 Or T_minz > 950 Then T_minz = 350 Wait 1 Wyswietlono = 1 Wyswietlanie = 1 Autosave = 5 Autolight = 0 '******* Warunki Poczatkowe Koniec *********** '************** Petla glowna ****************** '*********************************************** Do '*********************************************** co 4ms If Flaga_4ms = 1 Then Flaga_4ms = 0 Gosub Przyciski If Wyswietlono = 1 Then Gosub Wysw_lcd End If '*********************************************** '*********************************************** co 500ms If Flaga_500ms = 1 Then Flaga_500ms = 0 Mig = Not Mig Portd.6 = Buzz_en If Pompa = 0 Then Led_p = Mig Else Led_p = 1 If Zawor = 0 Then Led_z = Mig Else Led_z = 1 Led_a = Buzz Wyswietlanie = Poz_wysw End If '*********************************************** co 1s If Flaga_1s = 1 Then Flaga_1s = 0 If Light = 0 Then Incr Autolight If Autolight >= 20 Then Light = 1 Else Autolight = 0 End If If Poz_wysw <> 1 Then Incr Autopowrot If Autopowrot = 6 Then 'Poz_wysw = 1 Wyswietlanie = 1 Poz_ust = 0 End If Else Autopowrot = 0 End If If Autosave < 5 Then Incr Autosave If Autosave = 5 Then 'tu zapis do eeprom Writeeeprom T_min , 2 Writeeeprom T_alarm , 4 Writeeeprom T_minz , 7 Hbyte(1) = 0 Hbyte(1).0 = Tryb_letni Writeeeprom Hbyte(1) , 6 Poz_ust = 0 End If End If Gosub Temperatura Gosub Sterowanie End If '*********************************************** Loop End '************ Petla glowna Koniec ************** '************ Przerwanie timer 0 *************** '*********************************************** Prztimer0: Timer0 = 5 Set Flaga_4ms Incr Dzielnik(1) If Dzielnik(1) = 125 Then Dzielnik(1) = 0 Set Flaga_500ms Incr Dzielnik(2) If Dzielnik(2) = 2 Then Dzielnik(2) = 0 Set Flaga_1s End If End If Return '******** Przerwanie timer 0 Koniec ************ '*********************************************** '***************** Przyciski ************** Przyciski: Sw = Sw_port And &B00000111 'maska na piny nieu?ywane jako sw If Sw <> &B00000111 And Stan_sw = Sw Then Incr Licznik_sw If Licznik_sw = 68 Then Licznik_sw = 0 Select Case Stan_sw Case &B00000011: 'incr '*********************************************************** Select Case Poz_wysw Case 3: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_min < 950 Then T_min = T_min + 10 Case 2: If T_alarm < 950 Then T_alarm = T_alarm + 10 End Select Autosave = 0 Case 4: If Poz_ust = 0 Then Poz_ust = 1 Else Tryb_letni = Not Tryb_letni Autosave = 0 Case 5: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_minz < 950 Then T_minz = T_minz + 10 End Select Autosave = 0 End Select If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Light = 0 Autolight = 0 Case &B00000101: 'ustaw next '*********************************************************** If Poz_ust = 0 Then Wyswietlanie = Poz_wysw + 1 If Wyswietlanie = 6 Then Wyswietlanie = 1 Else Select Case Poz_wysw Case 3: Incr Poz_ust If Poz_ust = 3 Then Poz_ust = 0 Case 4: Incr Poz_ust If Poz_ust = 2 Then Poz_ust = 0 Case 5: Incr Poz_ust If Poz_ust = 3 Then Poz_ust = 0 End Select End If If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Light = 0 Autolight = 0 Case &B00000110: 'decr '*********************************************************** Select Case Poz_wysw Case 3: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_min > 100 Then T_min = T_min - 10 Case 2: If T_alarm > 100 Then T_alarm = T_alarm - 10 End Select Autosave = 0 Case 4: If Poz_ust = 0 Then Poz_ust = 1 Else Tryb_letni = Not Tryb_letni Autosave = 0 Case 5: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_minz > 100 Then T_minz = T_minz - 10 End Select Autosave = 0 End Select If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Light = 0 Autolight = 0 End Select End If Else Stan_sw = Sw Licznik_sw = 60 End If Return '*********************************************** '*********************************************** '************** LCD *********** Wysw_lcd: If Wyswietlanie <> 0 Then Wyswietlono = 0 Select Case Wyswietlanie Case 1: 'temp piec bojler '************************************************************** If Poz_wysw <> 1 Then Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien 'Deflcdchar 1 , 4 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' o kreskowane Cls Lcd "Piec:" Lowerline Lcd "Bojler:" End If For N = 1 To 2 Hword(1) = T(n) / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) If Minusy.n = 1 Then Decr Hword(2) Locate N , Hword(2) Hword(2) = T(n) Mod 10 If Minusy.n = 1 Then Lcd "-" Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" Next N Case 2: 'temb banka,dom '************************************************************** If Poz_wysw <> 2 Then Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien Deflcdchar 1 , 4 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' litera ó Deflcdchar 2 , 32 , 32 , 14 , 1 , 15 , 17 , 15 , 1 ' a kreskowane Cls Lcd "Pok" ; Chr(1) ; "j:" Lowerline Lcd "Zewn" ; Chr(2) ; "trz:" End If For N = 3 To 4 Hword(1) = T(n) / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) If Minusy.n = 1 Then Decr Hword(2) M = N - 2 Locate M , Hword(2) Hword(2) = T(n) Mod 10 If Minusy.n = 1 Then Lcd "-" Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" Next N Case 3: '************************************************************** If Poz_wysw <> 3 Then Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien 'Deflcdchar 1 , 4 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' o kreskowane Cls Lcd "T.Min:" Lowerline Lcd "T.Alarm" End If If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else 't minimalna Hword(1) = T_min / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 1 , Hword(2) Hword(2) = T_min Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C " End If If Poz_ust = 2 And Mig = 1 Then Locate 2 , 10 Lcd " " Else 't alarmowa Hword(1) = T_alarm / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 2 , Hword(2) Hword(2) = T_alarm Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" End If Case 4: '************************************************************** If Poz_wysw <> 4 Then Cls Lcd "Tryb: " End If Locate 1 , 7 If Poz_ust = 1 And Mig = 1 Then Lcd " " Else If Tryb_letni = 1 Then Lcd "Letni" Else Lcd "Zimowy" End If Case 5: '************************************************************** If Poz_wysw <> 5 Then Cls Lcd "Tmin zaw:" End If If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else 't minimalna zaworu Hword(1) = T_minz / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 1 , Hword(2) Hword(2) = T_minz Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C " End If End Select Poz_wysw = Wyswietlanie Wyswietlanie = 0 Wyswietlono = 1 End If Return '************** LCD Koniec *********** '********** rejestracja DS ********* Ds_reg: Disable Interrupts 1wreset 1wwrite &H33 Ds(1) = 1wread(8): Enable Interrupts If Ds(1) <> 255 Or Ds(2) <> 255 Or Ds(3) <> 255 Or Ds(4) <> 255 Or Ds(5) <> 255 Or Ds(6) <> 255 Or Ds(7) <> 255 Or Ds(8) <> 255 Then Ds_ok = 1 For N = 1 To 8 Hbyte(1) = Ds_adr + N Writeeeprom Ds(n) , Hbyte(1) Next N Else Ds_ok = 0 End If Return '****** rejestracja DS Koniec ****** '************* Temperatura *********** Temperatura: Disable Interrupts 1wreset Select Case Ktory_ds Case 0: 1wwrite &HCC 1wwrite &H44 Case 1: 1wwrite &H55 1wwrite Ds1(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 2: 1wwrite &H55 1wwrite Ds2(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 3: 1wwrite &H55 1wwrite Ds3(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 4: 1wwrite &H55 1wwrite Ds4(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): End Select Enable Interrupts If Ktory_ds > 0 Then T(ktory_ds) = Msb * 256 T(ktory_ds) = T(ktory_ds) + Lsb Minusy.ktory_ds = Msb.7 If Minusy.ktory_ds = 1 Then T(ktory_ds) = Not T(ktory_ds) T(ktory_ds) = T(ktory_ds) + 1 End If T(ktory_ds) = T(ktory_ds) * 10 T(ktory_ds) = T(ktory_ds) / 16 Else If Poz_wysw = 1 And Wyswietlono = 1 Then Wyswietlanie = 1 End If Incr Ktory_ds If Ktory_ds = 5 Then Ktory_ds = 0 Return '********** Temperatura Koniec ********* '************ Sterowanie *************** '*********************************************** Sterowanie: If Tryb_letni = 1 Then If T(1) >= T_min Then Hword(1) = T(2) + 70 Hword(2) = T(2) + 30 If T(1) >= Hword(1) Then Pompa = 0 If T(1) <= Hword(2) Then Pompa = 1 Else Pompa = 1 End If Else If T(1) >= T_min Then Pompa = 0 Else Pompa = 1 End If End If If Tryb_letni = 1 Then If T(1) >= T_minz Then Hword(1) = T(2) + 30 Hword(2) = T(2) + 20 If T(1) >= Hword(1) Then Zawor = 0 If T(1) <= Hword(2) Then Zawor = 1 End If Else If T(1) >= T_minz Then Hword(1) = T(2) + 30 Hword(2) = T(2) + 20 If T(1) >= Hword(1) Then Zawor = 0 If T(1) <= Hword(2) Then Zawor = 1 End If End If If T(1) >= T_alarm Or T(2) >= T_alarm Then If Buzz_en = 1 Then Buzz = Not Buzz Else Buzz = 1 Else Buzz = 1 Hword(1) = T_alarm - 50 If T(1) <= Hword(1) And T(2) <= Hword(1) Then Buzz_en = 1 End If Return Drugi z kodów to ten który przerobiłem dla kolegi grek1209.Program zawiera sterowanie pompą co. bez zmian, dodatkowo sterowanie wentylatorem temperatura po jakiej ma się wyłączyć nastawiana z poziomu menu ponowne włączenie wentylatora następuje po spadnięciu temperatury o 2 stopnie. w obydwu przypadkach nie ma sterowania przedmuchami!!!! $regfile = "m8def.dat" $crystal = 16000000 'Config Porta = &B00111111 : Porta = &B11111111 Config Portb = &B11111000 : Portb = &B11111111 Config Portc = &B11111111 : Portc = &B11111111 Config Portd = &B00011111 : Portd = &B11111111 Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 'mirley UPT M16 Config Lcd = 16 * 2 Cls Cursor Off Noblink Config 1wire = Pind.2 Sw_port Alias Pinb 'nazwa portu Pompa Alias Portd.3 Went Alias Portd.4 Buzz Alias Portd.1 Light Alias Portd.0 Ds1r Alias Pind.7 Ds2r Alias Pind.6 Ds3r Alias Pind.5 Led_a Alias Portb.5 Led_p Alias Portb.3 Led_w Alias Portb.4 Config Timer0 = Timer , Prescale = 256 Enable Timer0 : On Timer0 Prztimer0 Enable Interrupts '********** Konfiguracja uC Koniec ************ '****************** Zmienne ******************* '*********************************************** Dim Stan_sw As Byte , Sw As Byte , Licznik_sw As Byte 'sw Dim Wyswietlanie As Byte , Poz_wysw As Byte , Wyswietlono As Bit 'Lcd Dim Mig As Bit , Poz_ust As Byte Dim Autosave As Byte , Autopowrot As Byte , Autolight As Byte Dim Ds1(8) As Byte , Ds2(8) As Byte , Ds3(8) As Byte , Ds4(8) As Byte , Ds(8) As Byte , Ds_adr As Byte , Ds_ok As Bit 'DS18B20 Dim Ktory_ds As Byte , Lsb As Byte , Msb As Byte , Minusy As Byte Dim T(4) As Word Dim T_min As Word , T_alarm As Word Dim T_went As Word Dim Dzielnik(2) As Byte 'dzielniki timera Dim Flaga_4ms As Bit , Flaga_500ms As Bit , Flaga_1s As Bit 'flagi przerwa? Dim Hbyte(2) As Byte , Hword(3) As Word , N As Byte , Hbit As Bit , M As Byte Dim Buzz_en As Bit Dim Tryb_letni As Bit '0- tryb zimowy, 1- tryb letni Dim Hist As Integer '************* Zmienne Koniec **************** '************ Warunki Poczatkowe *************** '*********************************************** Light = 0 Lcd " Sterownik C.O." Lowerline Lcd " .1.1 " Wait 1 If Ds1r = 1 And Ds2r = 0 And Ds3r = 0 Then Ds_adr = 30 Gosub Ds_reg Cls Lcd "Ds Piec" End If If Ds1r = 0 And Ds2r = 1 And Ds3r = 0 Then Ds_adr = 40 Gosub Ds_reg Cls Lcd "Ds Bojler" End If If Ds1r = 1 And Ds2r = 1 And Ds3r = 0 Then Ds_adr = 50 Gosub Ds_reg Cls Lcd "Ds Pokoj" End If If Ds1r = 0 And Ds2r = 0 And Ds3r = 1 Then Ds_adr = 60 Gosub Ds_reg Cls Lcd "Ds Zewnatrz" End If For N = 1 To 8 Hbyte(1) = 30 + N Readeeprom Ds1(n) , Hbyte(1) Hbyte(1) = 40 + N Readeeprom Ds2(n) , Hbyte(1) Hbyte(1) = 50 + N Readeeprom Ds3(n) , Hbyte(1) Hbyte(1) = 60 + N Readeeprom Ds4(n) , Hbyte(1) Next N Readeeprom T_min , 2 Readeeprom T_alarm , 4 Readeeprom Hbyte(1) , 6 Readeeprom T_went , 7 Tryb_letni = Hbyte(1).0 If T_min < 100 Or T_min > 950 Then T_min = 400 If T_alarm < 100 Or T_alarm > 950 Then T_alarm = 850 If T_went < 100 Or T_went > 850 Then T_went = 350 Wait 1 Wyswietlono = 1 Wyswietlanie = 1 Autosave = 5 Autolight = 0 '******* Warunki Poczatkowe Koniec *********** '************** Petla glowna ****************** '*********************************************** Do '*********************************************** co 4ms If Flaga_4ms = 1 Then Flaga_4ms = 0 Gosub Przyciski If Wyswietlono = 1 Then Gosub Wysw_lcd End If '*********************************************** '*********************************************** co 500ms If Flaga_500ms = 1 Then Flaga_500ms = 0 Mig = Not Mig Portd.6 = Buzz_en If Pompa = 0 Then Led_p = Mig Else Led_p = 1 If Went = 0 Then Led_w = Mig Else Led_w = 1 Led_a = Buzz Wyswietlanie = Poz_wysw End If '*********************************************** co 1s If Flaga_1s = 1 Then Flaga_1s = 0 If Light = 0 Then Incr Autolight If Autolight >= 20 Then Light = 1 Else Autolight = 0 End If If Poz_wysw <> 1 Then Incr Autopowrot If Autopowrot = 6 Then 'Poz_wysw = 1 Wyswietlanie = 1 Poz_ust = 0 End If Else Autopowrot = 0 End If If Autosave < 5 Then Incr Autosave If Autosave = 5 Then 'tu zapis do eeprom Writeeeprom T_min , 2 Writeeeprom T_alarm , 4 Writeeeprom T_went , 7 Hbyte(1) = 0 Hbyte(1).0 = Tryb_letni Writeeeprom Hbyte(1) , 6 Poz_ust = 0 End If End If Gosub Temperatura Gosub Sterowanie End If '*********************************************** Loop End '************ Petla glowna Koniec ************** '************ Przerwanie timer 0 *************** '*********************************************** Prztimer0: Timer0 = 5 Set Flaga_4ms Incr Dzielnik(1) If Dzielnik(1) = 125 Then Dzielnik(1) = 0 Set Flaga_500ms Incr Dzielnik(2) If Dzielnik(2) = 2 Then Dzielnik(2) = 0 Set Flaga_1s End If End If Return '******** Przerwanie timer 0 Koniec ************ '*********************************************** '***************** Przyciski ************** Przyciski: Sw = Sw_port And &B00000111 'maska na piny nieu?ywane jako sw If Sw <> &B00000111 And Stan_sw = Sw Then Incr Licznik_sw If Licznik_sw = 68 Then Licznik_sw = 0 Select Case Stan_sw Case &B00000011: 'incr '*********************************************************** Select Case Poz_wysw Case 3: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_min < 950 Then T_min = T_min + 10 Case 2: If T_alarm < 950 Then T_alarm = T_alarm + 10 End Select Autosave = 0 Case 4: If Poz_ust = 0 Then Poz_ust = 1 Else Tryb_letni = Not Tryb_letni Autosave = 0 Case 5: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_went < 850 Then T_went = T_went + 10 End Select Autosave = 0 End Select If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Light = 0 Autolight = 0 Case &B00000101: 'ustaw next '*********************************************************** If Poz_ust = 0 Then Wyswietlanie = Poz_wysw + 1 If Wyswietlanie = 6 Then Wyswietlanie = 1 Else Select Case Poz_wysw Case 3: Incr Poz_ust If Poz_ust = 3 Then Poz_ust = 0 Case 4: Incr Poz_ust If Poz_ust = 2 Then Poz_ust = 0 Case 5: Incr Poz_ust If Poz_ust = 3 Then Poz_ust = 0 End Select End If If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Light = 0 Autolight = 0 Case &B00000110: 'decr '*********************************************************** Select Case Poz_wysw Case 3: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_min > 100 Then T_min = T_min - 10 Case 2: If T_alarm > 100 Then T_alarm = T_alarm - 10 End Select Autosave = 0 Case 4: If Poz_ust = 0 Then Poz_ust = 1 Else Tryb_letni = Not Tryb_letni Autosave = 0 Case 5: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_went > 100 Then T_went = T_went - 10 End Select Autosave = 0 End Select If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Light = 0 Autolight = 0 End Select End If Else Stan_sw = Sw Licznik_sw = 60 End If Return '*********************************************** '*********************************************** '************** LCD *********** Wysw_lcd: If Wyswietlanie <> 0 Then Wyswietlono = 0 Select Case Wyswietlanie Case 1: 'temp piec bojler '************************************************************** If Poz_wysw <> 1 Then Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien 'Deflcdchar 1 , 4 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' o kreskowane Cls Lcd "Piec:" Lowerline Lcd "Bojler:" End If For N = 1 To 2 Hword(1) = T(n) / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) If Minusy.n = 1 Then Decr Hword(2) Locate N , Hword(2) Hword(2) = T(n) Mod 10 If Minusy.n = 1 Then Lcd "-" Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" Next N Case 2: 'temb banka,dom '************************************************************** If Poz_wysw <> 2 Then Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien Deflcdchar 1 , 4 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' litera ó Deflcdchar 2 , 32 , 32 , 14 , 1 , 15 , 17 , 15 , 1 ' a kreskowane Cls Lcd "Pok" ; Chr(1) ; "j:" Lowerline Lcd "Zewn" ; Chr(2) ; "trz:" End If For N = 3 To 4 Hword(1) = T(n) / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) If Minusy.n = 1 Then Decr Hword(2) M = N - 2 Locate M , Hword(2) Hword(2) = T(n) Mod 10 If Minusy.n = 1 Then Lcd "-" Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" Next N Case 3: '************************************************************** If Poz_wysw <> 3 Then Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien 'Deflcdchar 1 , 4 , 32 , 14 , 17 , 17 , 17 , 14 , 32 ' o kreskowane Cls Lcd "T.Min:" Lowerline Lcd "T.Alarm" End If If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else 't minimalna Hword(1) = T_min / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 1 , Hword(2) Hword(2) = T_min Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C " End If If Poz_ust = 2 And Mig = 1 Then Locate 2 , 10 Lcd " " Else 't alarmowa Hword(1) = T_alarm / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 2 , Hword(2) Hword(2) = T_alarm Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" End If Case 4: '************************************************************** If Poz_wysw <> 4 Then Cls Lcd "Tryb: " End If Locate 1 , 7 If Poz_ust = 1 And Mig = 1 Then Lcd " " Else If Tryb_letni = 1 Then Lcd "Letni" Else Lcd "Zimowy" End If Case 5: '************************************************************** If Poz_wysw <> 5 Then Cls Lcd "T wentyl.:" End If If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else 't minimalna wentylatora Hword(1) = T_went / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 1 , Hword(2) Hword(2) = T_went Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C " End If End Select Poz_wysw = Wyswietlanie Wyswietlanie = 0 Wyswietlono = 1 End If Return '************** LCD Koniec *********** '********** rejestracja DS ********* Ds_reg: Disable Interrupts 1wreset 1wwrite &H33 Ds(1) = 1wread(8): Enable Interrupts If Ds(1) <> 255 Or Ds(2) <> 255 Or Ds(3) <> 255 Or Ds(4) <> 255 Or Ds(5) <> 255 Or Ds(6) <> 255 Or Ds(7) <> 255 Or Ds(8) <> 255 Then Ds_ok = 1 For N = 1 To 8 Hbyte(1) = Ds_adr + N Writeeeprom Ds(n) , Hbyte(1) Next N Else Ds_ok = 0 End If Return '****** rejestracja DS Koniec ****** '************* Temperatura *********** Temperatura: Disable Interrupts 1wreset Select Case Ktory_ds Case 0: 1wwrite &HCC 1wwrite &H44 Case 1: 1wwrite &H55 1wwrite Ds1(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 2: 1wwrite &H55 1wwrite Ds2(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 3: 1wwrite &H55 1wwrite Ds3(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 4: 1wwrite &H55 1wwrite Ds4(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): End Select Enable Interrupts If Ktory_ds > 0 Then T(ktory_ds) = Msb * 256 T(ktory_ds) = T(ktory_ds) + Lsb Minusy.ktory_ds = Msb.7 If Minusy.ktory_ds = 1 Then T(ktory_ds) = Not T(ktory_ds) T(ktory_ds) = T(ktory_ds) + 1 End If T(ktory_ds) = T(ktory_ds) * 10 T(ktory_ds) = T(ktory_ds) / 16 Else If Poz_wysw = 1 And Wyswietlono = 1 Then Wyswietlanie = 1 End If Incr Ktory_ds If Ktory_ds = 5 Then Ktory_ds = 0 Return '********** Temperatura Koniec ********* '************ Sterowanie *************** '*********************************************** Sterowanie: If Tryb_letni = 1 Then If T(1) >= T_min Then Hword(1) = T(2) + 70 Hword(2) = T(2) + 30 If T(1) >= Hword(1) Then Pompa = 0 If T(1) <= Hword(2) Then Pompa = 1 Else Pompa = 1 End If Else If T(1) >= T_min Then Pompa = 0 Else Pompa = 1 End If End If Hist = T_went - 20 If T(1) >= T_went Then Went = 1 End If If T(1) <= Hist Then Went = 0 End If If T(1) >= T_alarm Or T(2) >= T_alarm Then If Buzz_en = 1 Then Buzz = Not Buzz Else Buzz = 1 Else Buzz = 1 Hword(1) = T_alarm - 50 If T(1) <= Hword(1) And T(2) <= Hword(1) Then Buzz_en = 1 End If Return KOD 3'************* Konfiguracja uC ***************** '*********************************************** $regfile = "m8def.dat" $crystal = 16000000 Config Portb = &B11111000 : Portb = &B11111111 Config Portc = &B11111111 : Portc = &B11111111 Config Portd = &B00011111 : Portd = &B11111111 Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 'mirley UPT M16 Config Lcd = 16 * 2 Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'stopien Deflcdchar 1 , 3 , 2 , 2 , 2 , 2 , 2 , 2 , 3 'nawias[ Deflcdchar 2 , 24 , 8 , 8 , 8 , 8 , 8 , 8 , 24 'nawias] Cls Cursor Off Noblink Config 1wire = Pind.2 Sw_port Alias Pinb 'nazwa portu Pompa Alias Portd.3 Went Alias Portd.4 Buzz Alias Portd.1 Ds1r Alias Pind.7 Ds2r Alias Pind.6 Led_a Alias Portb.5 Led_p Alias Portb.3 Led_w Alias Portb.4 Config Timer0 = Timer , Prescale = 256 Enable Timer0 : On Timer0 Prztimer0 Enable Interrupts '********** Konfiguracja uC Koniec ************ '****************** Zmienne ******************* '*********************************************** Dim Stan_sw As Byte , Sw As Byte , Licznik_sw As Byte 'sw Dim Wyswietlanie As Byte , Poz_wysw As Byte , Wyswietlono As Bit 'Lcd Dim Mig As Bit , Poz_ust As Byte Dim Autosave As Byte , Autopowrot As Byte Dim Ds1(8) As Byte , Ds2(8) As Byte , Ds(8) As Byte , Ds_adr As Byte , Ds_ok As Bit 'DS18B20 Dim Ktory_ds As Byte , Lsb As Byte , Msb As Byte , Minusy As Byte Dim T(4) As Word Dim T_min As Word , T_alarm As Word 'menu Dim Dmuch As Byte , Przerwa As Word Dim T_minw As Word , Hist As Word Dim Dzielnik(2) As Byte 'dzielniki timera Dim Flaga_4ms As Bit , Flaga_500ms As Bit , Flaga_1s As Bit , Flaga_120s As Bit 'flagi przerwań Dim Hbyte(2) As Byte , Hword(3) As Word , N As Byte , Hbit As Bit , M As Byte Dim Buzz_en As Bit Dim Tryb_letni As Bit '0- tryb zimowy, 1- tryb letni Dim Wygaszenie As Bit , Praca_przerwa As Bit Dim Licznik_went As Word , Tryb_pracy As Bit 'przerywany czy ciagly Dim Wygasz_licz As Byte , Off_licz As Byte , Oldt1 As Word ' wygaszanie pieca '************* Zmienne Koniec **************** '************ Warunki Poczatkowe *************** '*********************************************** Lcd " Sterownik C.O." Lowerline Lcd " Wersja 2.0.0 " Wait 1 If Ds1r = 1 And Ds2r = 0 Then 'programowaniew czujnikow Ds_adr = 30 Gosub Ds_reg Cls Lcd "Ds Piec" End If If Ds1r = 0 And Ds2r = 1 Then Ds_adr = 40 Gosub Ds_reg Cls Lcd "Ds Bojler" End If For N = 1 To 8 Hbyte(1) = 30 + N Readeeprom Ds1(n) , Hbyte(1) Hbyte(1) = 40 + N Readeeprom Ds2(n) , Hbyte(1) Next N Readeeprom T_minw , 0 Readeeprom T_min , 2 Readeeprom T_alarm , 4 Readeeprom Hbyte(1) , 6 Readeeprom Dmuch , 7 Readeeprom Przerwa , 8 Tryb_letni = Hbyte(1).0 If T_minw < 100 Or T_minw > 950 Then T_minw = 400 If T_min < 100 Or T_min > 950 Then T_min = 400 If T_alarm < 100 Or T_alarm > 950 Then T_alarm = 850 If Dmuch < 2 Or Dmuch > 99 Then Dmuch = 10 If Przerwa < 60 Or Przerwa > 5940 Then Przerwa = 600 Hword(1) = Przerwa / 60 Hword(1) = Hword(1) * 60 If Przerwa <> Hword(1) Then Przerwa = 600 Wait 1 'start watch dog Wygaszenie = 1 'standardowo wentylator nie pracuje Wyswietlono = 1 Wyswietlanie = 1 Autosave = 5 '******* Warunki Poczatkowe Koniec *********** '************** Petla glowna ****************** '*********************************************** Do '*********************************************** co 4ms If Flaga_4ms = 1 Then Flaga_4ms = 0 Gosub Przyciski If Wyswietlono = 1 Then Gosub Wysw_lcd End If '*********************************************** '*********************************************** co 500ms If Flaga_500ms = 1 Then Flaga_500ms = 0 Mig = Not Mig If Pompa = 0 Then Led_p = Mig Else Led_p = 1 If Went = 0 Then Led_w = Mig Else Led_w = 1 Led_a = Buzz Wyswietlanie = Poz_wysw End If '*********************************************** '*********************************************** co 1s If Flaga_1s = 1 Then Flaga_1s = 0 If Poz_wysw <> 1 Then Incr Autopowrot If Autopowrot = 6 Then 'Poz_wysw = 1 Wyswietlanie = 1 Poz_ust = 0 End If Else Autopowrot = 0 End If If Autosave < 6 Then Incr Autosave If Autosave = 6 Then 'tu zapis do eeprom Writeeeprom T_minw , 0 Writeeeprom T_min , 2 '2 bajty Writeeeprom T_alarm , 4 '2 bajty Hbyte(1) = 0 Hbyte(1).0 = Tryb_letni Writeeeprom Hbyte(1) , 6 'bajt Writeeeprom Dmuch , 7 'bajt Writeeeprom Przerwa , 8 '2 bajty Poz_ust = 0 End If End If Gosub Temperatura Gosub Sterowanie End If '*********************************************** Loop End '************ Petla glowna Koniec ************** '************ Przerwanie timer 0 *************** '*********************************************** Prztimer0: Timer0 = 5 Set Flaga_4ms Incr Dzielnik(1) If Dzielnik(1) = 125 Then Dzielnik(1) = 0 Set Flaga_500ms Incr Dzielnik(2) If Dzielnik(2) = 2 Then Dzielnik(2) = 0 Set Flaga_1s End If End If Return '******** Przerwanie timer 0 Koniec ************ '*********************************************** '***************** Przyciski ************** Przyciski: Sw = Sw_port And &B00000111 'maska na piny nieużywane jako sw If Sw <> &B00000111 And Stan_sw = Sw Then Incr Licznik_sw If Licznik_sw = 68 Then Licznik_sw = 0 Select Case Stan_sw Case &B00000011: 'incr '*********************************************************** Select Case Poz_wysw Case 2: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_minw < 950 Then T_minw = T_minw + 10 End Select Autosave = 0 Case 3: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_min < 950 Then T_min = T_min + 10 Case 2: If T_alarm < 950 Then T_alarm = T_alarm + 10 End Select Autosave = 0 Case 4: If Poz_ust = 0 Then Poz_ust = 1 Else Tryb_letni = Not Tryb_letni Autosave = 0 Case 5: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If Dmuch < 99 Then Dmuch = Dmuch + 1 Case 2: If Przerwa < 5940 Then Przerwa = Przerwa + 60 End Select Autosave = 0 End Select If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Case &B00000101: 'ustaw next '*********************************************************** If Poz_ust = 0 Then Wyswietlanie = Poz_wysw + 1 If Wyswietlanie = 6 Then Wyswietlanie = 1 Else Select Case Poz_wysw Case 2: Incr Poz_ust If Poz_ust = 2 Then Poz_ust = 0 Case 3: Incr Poz_ust If Poz_ust = 3 Then Poz_ust = 0 Case 4: Incr Poz_ust If Poz_ust = 2 Then Poz_ust = 0 Case 5: Incr Poz_ust If Poz_ust = 3 Then Poz_ust = 0 End Select End If If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 Case &B00000110: 'decr '*********************************************************** Select Case Poz_wysw Case 1: Off_licz = 0 Tryb_pracy = 0 Wygaszenie = Not Wygaszenie Case 2: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_minw > 100 Then T_minw = T_minw - 10 End Select Autosave = 0 Case 3: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If T_min > 100 Then T_min = T_min - 10 Case 2: If T_alarm > 100 Then T_alarm = T_alarm - 10 End Select Autosave = 0 Case 4: If Poz_ust = 0 Then Poz_ust = 1 Else Tryb_letni = Not Tryb_letni Autosave = 0 Case 5: Select Case Poz_ust Case 0: Poz_ust = 1 Case 1: If Dmuch > 2 Then Dmuch = Dmuch - 1 Case 2: If Przerwa > 60 Then Przerwa = Przerwa - 60 End Select Autosave = 0 End Select If Buzz = 0 Then Buzz_en = 0 Autopowrot = 0 End Select End If Else Stan_sw = Sw Licznik_sw = 60 End If Return '*********************************************** '*********************************************** '************** LCD *********** Wysw_lcd: If Wyswietlanie <> 0 Then Wyswietlono = 0 Select Case Wyswietlanie Case 1: 'temp piec bojler '************************************************************** If Poz_wysw <> 1 Then Cls Lcd "Piec :" Lowerline Lcd "Bojler:" End If For N = 1 To 2 Hword(1) = T(n) / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) If Minusy.n = 1 Then Decr Hword(2) Locate N , Hword(2) Hword(2) = T(n) Mod 10 If Minusy.n = 1 Then Lcd "-" Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" Next N Case 2: 'temb banka,dom '************************************************************** If Poz_wysw <> 2 Then Cls Lcd "T.Minw:" End If If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else 't wyłączenia wentylatora Hword(1) = T_minw / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 1 , Hword(2) Hword(2) = T_minw Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C " End If Case 3: '************************************************************** If Poz_wysw <> 3 Then Cls Lcd "T.Min:" Lowerline Lcd "T.Alarm:" End If If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else 't minimalna Hword(1) = T_min / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 1 , Hword(2) Hword(2) = T_min Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C " End If If Poz_ust = 2 And Mig = 1 Then Locate 2 , 10 Lcd " " Else 't alarmowa Hword(1) = T_alarm / 10 Hword(2) = 12 If Hword(1) >= 10 Then Decr Hword(2) If Hword(1) >= 100 Then Decr Hword(2) Locate 2 , Hword(2) Hword(2) = T_alarm Mod 10 Lcd Hword(1) ; "." ; Hword(2) ; Chr(0) ; "C" End If Case 4: '************************************************************** If Poz_wysw <> 4 Then Cls Lcd "Tryb: " End If Locate 1 , 7 If Poz_ust = 1 And Mig = 1 Then Lcd " " Else If Tryb_letni = 1 Then Lcd "Letni" Else Lcd "Zimowy" End If Case 5: '************************************************************** If Poz_wysw <> 5 Then Cls Lcd "Nadmuch:" Lowerline Lcd "Przerwa:" End If 'dmuch If Poz_ust = 1 And Mig = 1 Then Locate 1 , 10 Lcd " " Else Hword(2) = 11 If Dmuch >= 10 Then Decr Hword(2) Locate 1 , Hword(2) Lcd Dmuch ; Chr(1) ; "s" ; Chr(2) End If 'Przerwa If Poz_ust = 2 And Mig = 1 Then Locate 2 , 10 Lcd " " Else Hword(2) = 11 Hword(1) = Przerwa / 60 If Hword(1) >= 10 Then Decr Hword(2) Locate 2 , Hword(2) Lcd Hword(1) ; Chr(1) ; "min" ; Chr(2) End If End Select Poz_wysw = Wyswietlanie Wyswietlanie = 0 Wyswietlono = 1 End If Return '************** LCD Koniec *********** '********** rejestracja DS ********* Ds_reg: Disable Interrupts 1wreset 1wwrite &H33 Ds(1) = 1wread(8): Enable Interrupts If Ds(1) <> 255 Or Ds(2) <> 255 Or Ds(3) <> 255 Then Ds_ok = 1 For N = 1 To 8 Hbyte(1) = Ds_adr + N Writeeeprom Ds(n) , Hbyte(1) Next N Else Ds_ok = 0 End If Return '****** rejestracja DS Koniec ****** '************* Temperatura *********** Temperatura: Disable Interrupts 1wreset Select Case Ktory_ds Case 0: 1wwrite &HCC 1wwrite &H44 Case 1: 1wwrite &H55 1wwrite Ds1(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Case 2: 1wwrite &H55 1wwrite Ds2(1) , 8 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): End Select Enable Interrupts If Ktory_ds > 0 Then T(ktory_ds) = Msb * 256 T(ktory_ds) = T(ktory_ds) + Lsb Minusy.ktory_ds = Msb.7 If Minusy.ktory_ds = 1 Then T(ktory_ds) = Not T(ktory_ds) T(ktory_ds) = T(ktory_ds) + 1 End If T(ktory_ds) = T(ktory_ds) * 10 T(ktory_ds) = T(ktory_ds) / 16 Else If Poz_wysw = 1 And Wyswietlono = 1 Then Wyswietlanie = 1 End If Incr Ktory_ds If Ktory_ds = 5 Then Ktory_ds = 0 Return '********** Temperatura Koniec ********* '************ Sterowanie *************** '*********************************************** Sterowanie: 'pompa If Tryb_letni = 1 Then 'letni If T(1) >= T_min Then 'wlacza sie przy t_min Hword(1) = T(2) + 70 Hword(2) = T(2) + 30 If T(1) >= Hword(1) Then Pompa = 0 'wlacza sie pompa jesli na piecu t większe o 7 stopni niz bojler If T(1) <= Hword(2) Then Pompa = 1 'wylacza kiedy gdy na piecu t większe o mniej niż 3 stopnie Else Hword(1) = T_min - 30 If T(1) < Hword(1) Then Pompa = 1 End If Else 'zimowy If T(1) >= T_min Then Pompa = 0 Else Hword(1) = T_min - 30 If T(1) < Hword(1) Then Pompa = 1 End If End If 'alarm If T(1) >= T_alarm Or T(2) >= T_alarm Then If Buzz_en = 1 Then Buzz = Not Buzz Else Buzz = 1 Else Buzz = 1 Hword(1) = T_alarm - 50 If T(1) <= Hword(1) And T(2) <= Hword(1) Then Buzz_en = 1 End If 'wentylator If T(1) >= T_minw Then If Tryb_pracy = 0 Then 'je?li był ciagly to zmien tryb na przerywany i resetuj zmienne Tryb_pracy = 1 Licznik_went = 0 Praca_przerwa = 0 End If Else Hword(1) = T_minw - 30 If T(1) < Hword(1) Then If Tryb_pracy = 1 Then Tryb_pracy = 0 Off_licz = 0 End If End If End If If Wygaszenie = 0 Then If Tryb_pracy = 0 Then Went = 0 Incr Wygasz_licz If Wygasz_licz = 250 Then '250 Wygasz_licz = 0 'co okolo 4min If Oldt1 >= T(1) Then Incr Off_licz If Off_licz = 8 Then Wygaszenie = 1 Else If Off_licz > 0 Then Decr Off_licz End If Oldt1 = T(1) End If Else If Praca_przerwa = 0 Then 'przerwa Went = 1 Incr Licznik_went If Licznik_went >= Przerwa Then Licznik_went = 0 Praca_przerwa = 1 End If Else Went = 0 Incr Licznik_went If Licznik_went >= Dmuch Then Licznik_went = 0 Praca_przerwa = 0 End If End If End If Else Went = 1 End If Return '******** Sterowanie Koniec ***
|
|||
mój sterownik piecz co
Witam !!
opracowałem sterownik pieca co i bojlera , działa od kilku lat ale czasem wyskakuje jakiś problem np.brak histerezy przy równaniu temperatur,i nie potrafię przypisać numerów fabrycznych do czujników tak aby odczytywany był konkretny czujnik.
Nie potrafię załączyć pliku.
Program opracowałem w baskomie.
z poważaniem Bronislaw
mój sterownik pieca co
Witam!!
Przepraszam za błąd w tytule
tylko w takiej formie udało mi się wkleić program.
$regfile = "M168def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.1 , Rs = Portb.3
Cls
Lcd "ATM168_13_01_8"
Lowerline
Lcd "Boniu" '
Wait 2
Config Watchdog = 2048
Start Watchdog
Config Portc.0 = Output 'wyjscia otwary colektor przekaznikowe ppompaco
Config Portc.1 = Output 'wyjscia przekaznikowe klapa
Config Portc.2 = Output 'wyjscia przekaznikowe pp cyrkulacyjna
Config Portc.3 = Output 'wyjscia przekaznikowe
Config Portc.4 = Output '
Config Portb.2 = Output 'wyjscia przekaznikowe
Config Portb.0 = Output 'podswietlenie LCD
Config Portd.0 = Output 'grzałki w bojlerze
Config Portd.1 = Output 'zawbojler
Config Portd.5 = Output 'alarm
Config Portd.2 = Input 'przycisk OK
Config Portd.3 = Input 'przycisk PRAWO
Config Portd.4 = Input 'przycisk GORA
Config Portd.6 = Input 'przycisk DOL
Config Portd.7 = Input 'przycisk LEWO
Config 1wire = Portc.5 '1wire
Portd.2 = 1
Portd.3 = 1
Portd.4 = 1
Portd.6 = 1
Portd.7 = 1
Portb.0 = 0
Dim Pom As Bit 'zmienna pomocnicza do włączania pompy
Dim Plicznik As Byte 'licznik zmienna pomocnicza do włączania pompy
Dim Plicz As Bit
Dim Licznik As Byte 'licznik obiegów pętli
Dim X As Bit 'zmenna pomocnicza do alarmu
Dim Ppp As Byte 'zmienna pomocnicza do zmiany programów
Dim Ppp_eep As Eram Byte 'zmienna pomocnicza do zmiany programów
Dim Al As Bit 'zmienna pomocnicza do alarmu
Dim Escap As Bit
Dim Escape As Bit
Dim Esc As Bit
Dim Zmiana As Bit
Dim Li As Bit
Dim Pozycja As Byte
Dim Tpg_eep As Eram Integer
Dim Tpg As Integer
Dim Tpgs As String * 6
Dim Tpd_eep As Eram Integer
Dim Tpd As Integer
Dim Tpds As String * 6
Dim Ta_eep As Eram Integer
Dim Ta As Integer
Dim Tas As String * 6
Dim Tkg1_eep As Eram Integer
Dim Tkg1 As Integer
Dim Tkg1s As String * 6
Dim Tkd1_eep As Eram Integer
Dim Tkd1 As Integer
Dim Tkd1s As String * 6
Dim Tzg_eep As Eram Integer
Dim Tzg As Integer
Dim Tzgs As String * 6
Dim Tzd_eep As Eram Integer
Dim Tzd As Integer
Dim Tzds As String * 6
Dim Tbg_eep As Eram Integer
Dim Tbg As Integer
Dim Tbgs As String * 6
Dim Tbd_eep As Eram Integer
Dim Tbd As Integer
Dim Tbds As String * 6
Dim Tsalon_eep As Eram Integer
Dim Tsalon As Integer
Dim Tsalons As String * 6
Dim Tsal As Integer
Dim T As Integer
Dim Ts As String * 6
Dim I1 As Integer 't piec
Dim I2 As Integer 't salon
Dim I3 As Integer
Dim I4 As Integer
Dim Izz As Integer
Dim P As Integer
Dim Bb As Integer
Dim G As Integer
Dim S As Integer 't bojler
Dim Ss1 As String * 6
Dim Ss2 As String * 6
Dim Ss3 As String * 6
Dim Ss4 As String * 6
Dim Dsid1(8) As Byte
Dim Dsid2(8) As Byte
Dim Dsid3(8) As Byte
Dim Dsid4(8) As Byte
Declare Sub Wyl_alarm
Declare Sub Odczyt_temp
Declare Sub Light
Declare Sub Pp
Declare Sub P1_co_we
Declare Sub P2_bo_we
Declare Sub P3_co_el_bo
Declare Sub P4_bo_el
Declare Sub P5_co_pzamarzaniu
Declare Sub P6_bo_priorytet
Declare Sub P7_co_priorytet
Declare Sub Setpositionmenu
Declare Sub Ustawt
Up Alias Pind.4 'prycisk zielony
Down Alias Pind.6 'przycisk zielony
Lewo Alias Pind.7 'przycisk czarny
Prawo Alias Pind.3 'przycisk czarny
Ok Alias Pind.2 'przycisk czerwony
Alarm Alias Portd.5 'dioda niebieska
Pompa Alias Portc.0 'dioda czerwona przezroczysta pompa co
Klapa Alias Portc.1 'diod abiała klapa pieca co
Ppcyrkul Alias Portc.2 'dioda niebieska pompa cyrkulacyjna
Zawor Alias Portc.3 'dioda zielona zawór na powrocie co 0=otwarty,1=zamknięty
Grz_co Alias Portb.2 'dioda żółta Grzałki co
Lamp Alias Portb.0 'podświetlenie LCD
Zawbojler Alias Portd.1 'dioda czerwon dyfuzyjna zawór w obiegu bojlera
Grz_bo Alias Portd.0 'dioda.czerwona dyfuzyjna.grzałki bo
Reset Watchdog
Enable Interrupts
Enable Int0
On Int0 Menu Nosave
Li = 0
Al = 1
X = 1
Licznik = 1
Plicz = 0
Plicznik = 1
Tpg = Tpg_eep 'T zalonczenia pompy Tzp
Tpd = Tpd_eep 'T wylonczenia pompy Twp
Tkg1 = Tkg1_eep 'T zamkniecia klapy w trybie 1 Tzk1
Tkd1 = Tkd1_eep 'T otwarcia klapy w trybie 1 Tok1
Tzg = Tzg_eep 'T otwazrcia zaworu powrotnego w trybie bojlera Toz
Tzd = Tzd_eep 'T zamkniecia zaworu powrotnego w trybie bojlera Tzz
Tbg = Tbg_eep 'T bojlera
Tbd = Tbd_eep 'T otwarcia klapy w trybie 2 Tok2
Ta = Ta_eep 'T wlaczenia alarmu Twa
Tsalon = Tsalon_eep 'T zadana w pokoju Tsalon
Ppp = Ppp_eep 'zmienna programowa
Dsid1(1) = 1wsearchfirst() 'znaajdz pierwszy czujnik podpiety do portu
Dsid2(1) = 1wsearchnext() 'Znajdź kolejny czujnik podpięty do portu
Dsid3(1) = 1wsearchnext() 'Znajdź kolejny czujnik podpięty do portu
Dsid4(1) = 1wsearchnext()
Reset Watchdog
Do
Call Odczyt_temp
Reset Watchdog
Cls
Lcd Ss1 ; " " ; Ss2 ; " " ; Ss3
Locate 2 , 13
Lcd Ss4
If I1 > Ta Then 'wlancznie alarmu TA'
If X = 1 Then
Alarm = 1
Al = 0
Cls
Lcd "ALARM " ; "temp=" ; Ss1
End If
Else
X = 1
End If
Reset Watchdog
Config Debounce = 30
If Al = 0 Then
Debounce Pind.3 , 0 , Wyl_alarm , Sub 'wylancza alarm
End If
Reset Watchdog
Config Debounce = 30
Debounce Pind.4 , 0 , Pp , Sub
Config Debounce = 30
Debounce Pind.6 , 0 , Pp , Sub
Config Debounce = 30
Debounce Pind.7 , 0 , Light , Sub
Reset Watchdog
If Ppp = 1 Then
Call P1_co_we
Locate 2 , 1
Lcd "P1 co_we"
End If
If Ppp = 2 Then
Call P2_bo_we
Locate 2 , 1
Lcd "P2 bo_we"
End If
If Ppp = 3 Then
Call P3_co_el_bo
Locate 2 , 1
Lcd "P3 co_el_bo"
Reset Watchdog
End If
If Ppp = 4 Then
Call P4_bo_el
Locate 2 , 1
Lcd "P4 bo_el"
End If
Reset Watchdog
If Ppp = 5 Then
Call P5_co_pzamarzaniu
Locate 2 , 1
Lcd "P5 -*-*-"
End If
If Ppp = 6 Then
Call P6_bo_priorytet
Locate 2 , 1
Lcd "P6 bo_prior"
End If
If Ppp = 7 Then
Call P7_co_priorytet
Locate 2 , 1
Lcd "P7 co_prior"
End If
If Li = 1 Then
Lamp = 1
End If
If Lamp = 1 Then
Incr Licznik
End If
If Licznik = 50 Then
Lamp = 0
Li = 0
Licznik = 1
End If
Reset Watchdog
Loop
Reset Watchdog
End
Sub Odczyt_temp
Reset Watchdog
1wreset
1wwrite &H55
1wverify Dsid1(1) 'wysyłamy adres pierwszego czujnika
1wwrite &HBE
S = 1wread(2)
'---------------------------------
Reset Watchdog
1wreset
1wwrite &H55
1wverify Dsid2(1) 'wysylam adres drugiego czujnika
1wwrite &HBE
P = 1wread(2)
'---------------------------------
Reset Watchdog
1wreset
1wwrite &H55
1wverify Dsid3(1) 'wysylam adres trzeciego czujnika
1wwrite &HBE
G = 1wread(2)
'---------------------------------
Reset Watchdog
1wreset
1wwrite &H55
1wverify Dsid4(1) 'wysylam adres trzeciego czujnika
1wwrite &HBE
Bb = 1wread(2)
'---------------------------------
Reset Watchdog
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 500
Reset Watchdog
I1 = P
I1 = I1 * 10 'temperatura pieca
I1 = I1 / 16
Ss1 = Str(i1)
Ss1 = Format(ss1 , "0.0")
Reset Watchdog
I2 = Bb
I2 = I2 * 10 'temperatura bojlera
I2 = I2 / 16
Ss2 = Str(i2)
Ss2 = Format(ss2 , "0.0")
Reset Watchdog
I3 = S
I3 = I3 * 10 'temperatura pokojowa
I3 = I3 / 16
Ss3 = Str(i3)
Ss3 = Format(ss3 , "0.0")
Reset Watchdog
I4 = G
I4 = I4 * 10 'temperatura grzałki
I4 = I4 / 16
Ss4 = Str(i4)
Ss4 = Format(ss4 , "0.0")
End Sub
Sub Pp 'wybor programu
Reset Watchdog
If Up = 0 Then
Waitms 30
If Up = 0 Then
Incr Ppp
If Ppp = 8 Then
Ppp = 1
End If
End If : End If
Ppp_eep = Ppp
If Down = 0 Then
Waitms 30
If Down = 0 Then
Decr Ppp
If Ppp = 0 Then
Ppp = 7
End If
End If : End If
Ppp_eep = Ppp
End Sub
Sub Wyl_alarm
Reset Watchdog 'wylanczanie alarmu TA'
X = 0
Alarm = 0
Al = 1
End Sub
Sub Light 'podświetlenie
Reset Watchdog
Toggle Li
End Sub
Sub P1_co_we 'program węglowego ogrzewania co
Reset Watchdog
Zawor = 0
Grz_bo = 0
Grz_co = 0
If I1 > Tpg Then 'pompa zalonczona TPG'
Pompa = 1
End If
If I1 < Tpd Then 'pompa wylonczona TPD'
Pompa = 0
End If
If I1 < Tkd1 Then
If I3 < Tsalon Then
Klapa = 1
End If
End If
If I1 > Tkg1 Then
Klapa = 0
End If
Tsal = Tsalon + 2
If I3 > Tsal Then
Klapa = 0
End If
Izz = I2 - 10
If I1 > Izz Then
Zawbojler = 0
Ppcyrkul = 1
End If
If I1 < Izz Then
Zawbojler = 1
Ppcyrkul = 0
End If
End Sub
Sub P2_bo_we 'program weglowego grzania bojlera
Reset Watchdog
Zawbojler = 0
Grz_co = 0
Grz_bo = 0
If I1 > I2 Then 'porównanie temp pic-bojler
Pompa = 1
End If
If I1 < I2 Then
Pompa = 0
End If
If I1 > Tzg Then 'zawor otwarty TZG'
Zawor = 0
End If
If I1 < Tzd Then 'zawor zamkniety TZD'
Zawor = 1
End If
If I1 < Tkd1 Then 'klapa otwarta TKDco'
Klapa = 1
End If
If I1 > Tkg1 Then
Klapa = 0
End If
Izz = I2 - 10
If I1 > Izz Then
Zawbojler = 0
End If
If I1 < Izz Then
Zawbojler = 1
End If
End Sub
Sub P3_co_el_bo 'program elektrycznego ogrzewania co
Reset Watchdog
Klapa = 0 'klapa=0 oznacza ze jest zamknieta
Zawor = 0 'zawor =0 oznacza że jest otwarty
If I3 < Tsalon Then
Grz_co = 1
Pompa = 1
End If
If I4 > 820 Then '820=82 st.C
Pompa = 1
End If
Tsal = Tsalon + 2
If I3 > Tsal Then
Grz_co = 0
Pompa = 0
End If
Zawbojler = 1
If I2 < Tbd Then
Grz_bo = 1
End If
If I2 > Tbg Then
Grz_bo = 0
End If
End Sub
Sub P4_bo_el 'program elektrycznego grzanaibojlera
Reset Watchdog
Grz_co = 0
Pompa = 0
Zawor = 1
Zawbojler = 1
Klapa = 0
If I2 < Tbd Then
Grz_bo = 1
End If
If I2 > Tbg Then
Grz_bo = 0
End If
End Sub
Sub P5_co_pzamarzaniu 'program przeciwzamrożeniowy
Reset Watchdog
Grz_bo = 0
Ppcyrkul = 0
Zawor = 0
Klapa = 0
If I4 > 820 Then '820=82 st.C
Pompa = 1
End If
If I3 < 50 Then
Grz_co = 1
Pompa = 1
End If
If I3 >= 70 Then
Grz_co = 0
Pompa = 0
End If
End Sub
Sub P6_bo_priorytet
Reset Watchdog
Zawbojler = 0
Grz_co = 0
Grz_bo = 0
If I1 > I2 Then 'porównanie temp pic-bojler
Pompa = 1
End If
If I1 < I2 Then
Pompa = 0
End If
If I1 > Tzg Then 'zawor otwarty TZG'
Zawor = 0
End If
If I1 < Tzd Then 'zawor zamkniety TZD'
Zawor = 1
End If
If I1 < Tkd1 Then 'klapa otwarta TKDco'
Klapa = 1
End If
If I1 > Tkg1 Then
Klapa = 0
End If
Izz = I2 + 10
If I1 > Izz Then
Zawbojler = 0 '0 oznacza zawor otwarty
End If
If I1 < Izz Then
Zawbojler = 1 '1-ozacza zawor zamkniety
End If
If I2 > Tbg Then
Ppp = 7
End If
End Sub
Sub P7_co_priorytet 'program węglowego ogrzewania co
Reset Watchdog
Zawor = 0
Grz_bo = 0
Grz_co = 0
If I1 > Tpg Then 'pompa zalonczona TPG'
Pompa = 1
End If
If I1 < Tpd Then 'pompa wylonczona TPD'
Pompa = 0
End If
If I1 < Tkd1 Then
If I3 < Tsalon Then
Klapa = 1
End If
End If
If I1 > Tkg1 Then
Klapa = 0
End If
Tsal = Tsalon + 2
If I3 > Tsal Then
Klapa = 0
End If
Izz = I2 + 10
If I1 > Izz Then
Zawbojler = 0
End If
If I1 < Izz Then
Zawbojler = 1
End If
If I2 < Tbd Then
Ppp = 6
End If
End Sub
Menu:
Reset Watchdog
Disable Int0
Escape = 1
Esc = 1
Pozycja = 0
While Escape = 1
Select Case Pozycja
Case 0:
Cls
Lcd "Wyjscie z Menu"
Waitms 200
Escap = 1
While Escap = 1
Waitms 200
Call Setpositionmenu
If Ok = 0 Then
Waitms 20
Escape = 0
Escap = 0
Waitms 500
End If
Wend
Case 1:
Reset Watchdog
Cls
T = Tpg_eep
Tpg = Tpg_eep
Tpgs = Str(tpg)
Tpgs = Format(tpgs , " 0.0")
Lcd "T zal pompy"
Lowerline
Lcd "Tpg =" ; Tpgs
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 30
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , " 0.0")
Lcd "Ustaw"
Lowerline
Lcd "Tzp =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tpg_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 2:
Reset Watchdog
Cls
T = Tpd_eep
Tpd = Tpd_eep
Tpds = Str(tpd)
Tpds = Format(tpds , " 0.0")
Lcd "T wyl pompy"
Lowerline
Lcd "Tpd =" ; Tpds
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 30
If Ok = 0 Then
Waitms 30
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "Ustaw"
Lowerline
Lcd "Tpd =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tpd_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 3:
Reset Watchdog
Cls
T = Tkg1_eep
Tkg1 = Tkg1_eep
Tkg1s = Str(tkg1)
Tkg1s = Format(tkg1s , "0.0")
Lcd "T zamk klapy"
Lowerline
Lcd "Tkg1 = " ; Tkg1s
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tkg1 =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tkg1_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 4:
Reset Watchdog
Cls
T = Tkd1_eep
Tkd1 = Tkd1_eep
Tkd1s = Str(tkd1)
Tkd1s = Format(tkd1s , "0.0")
Lcd "T otwacia klapy"
Lowerline
Lcd "Tkd1 = " ; Tkd1s
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tkd1 =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tkd1_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 5:
Reset Watchdog
Cls
T = Tbg_eep
Tbg = Tbg_eep
Tbgs = Str(tbg)
Tbgs = Format(tbgs , "0.0")
Lcd "T bojler gorna"
Lowerline
Lcd "Tbg = " ; Tbgs
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tbg =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tbg_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 6:
Reset Watchdog
Cls
T = Tbd_eep
Tbd = Tbd_eep
Tbds = Str(tbd)
Tbds = Format(tbds , "0.0")
Lcd "T bojler-dolna"
Lowerline
Lcd "Tbd = " ; Tbds
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tbd =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tbd_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 7:
Reset Watchdog
Cls
T = Tzg_eep
Tzg = Tzg_eep
Tzgs = Str(tzg)
Tzgs = Format(tzgs , "0.0")
Lcd "T otwarcia zaworu"
Lowerline
Lcd "Tzg = " ; Tzgs
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tzg =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tzg_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 8:
Reset Watchdog
Cls
T = Tzd_eep
Tzd = Tzd_eep
Tzds = Str(tzd)
Tzds = Format(tzds , "0.0")
Lcd "T zamk zaworu"
Lowerline
Lcd "Tzd = " ; Tzds
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tzd =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tzd_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 9:
Reset Watchdog
Cls
T = Ta_eep
Ta = Ta_eep
Tas = Str(ta)
Tas = Format(tas , "0.0")
Lcd "T alarmu"
Lowerline
Lcd "Ta = " ; Tas
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Ta =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Ta_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
Case 10:
Reset Watchdog
Cls
T = Tsalon_eep
Tsalon = Tsalon_eep
Tsalons = Str(tsalon)
Tsalons = Format(tsalons , "0.0")
Lcd "T pokoju "
Lowerline
Lcd "Tsalon = " ; Tsalons
Waitms 200
Escap = 1
While Escap = 1
If Ok = 0 Then
Waitms 20
If Ok = 0 Then
Esc = 1
While Esc = 1
Call Ustawt
Cls
Ts = Str(t)
Ts = Format(ts , "0.0")
Lcd "ustaw"
Lowerline
Lcd "Tsalon =" ; Ts
Waitms 200
If Ok = 0 Then
If Zmiana = 1 Then
Tsalon_eep = T 'zapis do EEPROMu
Zmiana = 0
End If
Esc = 0
Escap = 0
End If
Wend
End If
End If
Waitms 200
Call Setpositionmenu
Wend
End Select
Wend
Enable Int0
Return
Sub Setpositionmenu
Reset Watchdog
If Up = 0 Then
Waitms 20
If Up = 0 Then
Incr Pozycja
If Pozycja >= 11 Then
Pozycja = 0
End If
Escap = 0
End If
End If
If Down = 0 Then
Waitms 20
If Down = 0 Then
Decr Pozycja
If Pozycja = 255 Then
Pozycja = 10
End If
Escap = 0
End If
End If
End Sub
Sub Ustawt
Reset Watchdog
If Up = 0 Then
Waitms 20
End If
If Up = 0 Then
T = T + 10
Zmiana = 1
Waitms 20
End If
If Lewo = 0 Then
Waitms 20
End If
If Lewo = 0 Then
T = T + 1
Zmiana = 1
Waitms 20
End If
If Down = 0 Then
Waitms 20
End If
If Down = 0 Then
T = T - 10
Zmiana = 1
Waitms 20
End If
If Prawo = 0 Then
Waitms 20
End If
If Prawo = 0 Then
T = T - 1
Zmiana = 1
Waitms 20
End If
End Sub
z poważaniem Bronislaw
Do Szymon SQ3OPC
Według noty katalogowej Atmela nie powinno się używać tej komórki. Może ona zostać nadpisana przy operacji zerowania mikroprocesora.
chymmm
Jak dla mnie obsługa jakiejkolwiek magistrali w przerwaniu to nie jest szczęśliwy pomysł. Rozumiem że sensorów nie wymieniasz w trakcie pracy ?C. Jeśli masz problem z adresami sensorów proponuję rozwiązanie:
na wstępie, przed pętlą główną, odczytujesz adresy sensorów i umieszczasz je w tablicy/tablicach, (możesz też je zapisać do pamięci nieulotnej) ?C masz wielki więc nie powinno być z tym problemu.
Tak jak pisze przedmówca omijaj pierwszą komórkę EEPROM szerokim łukiem - a najlepiej kilka pierwszych.
"Cierpliwym być musisz, by wiedzę zgłębiać tajemną, gdyż ciemna strona mocy niszczącą i silną jest.".