kod programu
Kod:
$regfile = "m8def.dat" 'informuje kompilator o pliku
'dyrektyw mikrokontrolera
$crystal = 8000000 'informuje kompilator
'o czŕstotliwoťci oscylatora
'taktuj¦cego mikrokontroler
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 Adc = Single , Prescaler = Auto , Reference = Internal
Config Watchdog = 2048 'reset wystąpi po 8192 ms
'Start Watchdog
Deflcdchar 1 , 4 , 10 , 4 , 32 , 32 , 32 , 32 , 32 'znak stopnia
Declare Sub Odcz_temp
' Config Portc.1 = Output
Config Portb.2 = Output 'wyjścia przekazników
Config Portb.1 = Output 'wyjścia przekazników
Config Portd.0 = Output 'wyjścia przekazników
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
Dim Wart_nap As Word
Dim Wart_nap1 As Word
Dim Wart_nap2 As String *
Dim Wart_nap22 As Word
Dim T As Single
Dim T1 As Single
Dim T2 As Single
Dim Wart_ac As Word
Dim Wart_ac1 As Word
Dim Wart_ac2 As Word
Dim V As Single
Dim V1 As Single
Dim V2 As Single
Dim Kasownik As Byte
Dim Pomocnicza As Word
Dim Pomocnicza2 As Word
Dim Licz As Byte
Kasownik = 0
Pomocnicza = 0
Dim Pokuj_on As Byte
Dim Pokuj_of As Byte
'Pokuj_on = 21 'temperatura minimalna w pokoju
'Pokuj_of = Pokuj_on + 2 'temperatura max w pokoju
Config Rc5 = Pind.1
Dim Adres As Byte , Command As Byte
Enable Interrupts
' Set Portb.3 = Input
Start Adc
Do
Cls
Lcd "Solar Lato"
Waitms 2900
Readeeprom Licz , 5
If Licz > 50 Then Licz = 21
Pokuj_on = Wart_nap + 10
Pokuj_of = Wart_nap + 6
'Portd.0 = 0
Start Watchdog
Cls
Do
Pokuj_on = Wart_nap + 10
Pokuj_of = Wart_nap + 6
If Kasownik = 1 Then
Pomocnicza = Pomocnicza + 1
If Pomocnicza > 300 Then Pomocnicza = 1
End If
Getrc5(adres , Command)
Command = Command And &B01111111
Waitms 20
'Reset Watchdog
Debounce Pinb.3 , 0 , Kasowanie , Sub 'czyta swicze
'Start Watchdog
'czytam pierwszy czujnik BOJLER
'waitms 20
Wart_ac = Getadc(0)
V = Wart_ac * 0.0026
T = V * 100
' Reset Watchdog
'czytam drugi czujnik PIEC
'Waitms 20
Wart_ac1 = Getadc(1)
V1 = Wart_ac1 * 0.0026
T1 = V1 * 100
Reset Watchdog
'czytam 3 czujnik DOM
'Waitms 20
Wart_ac2 = Getadc(2)
V2 = Wart_ac2 * 0.0026
T2 = V2 * 100
Cls
Locate 1 , 10
Wart_nap = Int(t )
Lcd "pow:" ; Wart_nap
Reset Watchdog
Locate 1 , 1
Wart_nap1 = Int(t1 )
Lcd "solar:" ; Wart_nap1
Reset Watchdog
Locate 2 , 1
Wart_nap2 = Fusing(t2 , "#.&")
Lcd "boj:" ; Wart_nap2 ; Chr(1) ; "C "
Wart_nap22 = Int(t2 )
Reset Watchdog
If Kasownik = 1 Then
Locate 2 , 13
Lcd Pomocnicza
Reset Watchdog
End If
' Reset Watchdog
' Lowerline
'Lcd Wart_nap
Stop Watchdog
Waitms 1000
Start Watchdog
Reset Watchdog
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'obsługa przekazników
If Portd.0 = 0 Then
If T2 > 40 Then Portd.2 = 0
If Kasownik = 1 Then Portd.2 = 1
If Pomocnicza = 300 Then Kasownik = 0
Reset Watchdog
End If
If Kasownik = 0 Then
If Wart_nap1 < 40 Then Portd.0 = 0
If Wart_nap1 > 40 Then
If Wart_nap1 > Pokuj_on Then Portd.0 = 1
If Wart_nap1 < Pokuj_of Then Portd.0 = 0
'End If
End If
End If
'od kasownika =0
Reset Watchdog
'koniec obsługoi przekazników
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx odsługa rc5
If Adres = 0 Then
Stop Watchdog
If Command = 12 Then 'power załanczam odliczanie
Cls
Lcd "załonczenie zdalne"
Waitms 1000
Start Watchdog
Reset Watchdog
Gosub Kasowanie
End If
Getrc5(adres , Command)
Command = Command And &B01111111
If Command = 13 Then
For Pomocnicza2 = 1 To 5000
Pokuj_on = Wart_nap
Pokuj_of = Pokuj_on + 2
Cls
Locate 1 , 1
Lcd "PROGRAMOWANIE"
Lowerline
Lcd "zal. przy:" ; Pokuj_on ; Chr(1) ; "C "
Locate 2 , 1
Command = 0
Getrc5(adres , Command)
Command = Command And &B01111111
If Command = 13 Then
'Getrc5(adres , Command)
Waitms 100
'Cls
'wchodze w programowanie
Lcd "programowanie "
Waitms 1000
'Cls
End If
'End If
If Command = 32 Then
'Cls
Licz = Licz + 1 'wchodze w p+
Lcd "zw. temp-" ; Pokuj_on ; Chr(1) ; "C "
Waitms 1000
'Cls
End If
If Command = 33 Then
'Cls
'wchodze p-
Licz = Licz - 1 'wchodze w p+
Lcd "zmn. temp-" ; Pokuj_on ; Chr(1) ; "C "
Waitms 1000
'Cls
End If
If Command = 12 Then 'zapamiętuje zmiany
' Cls
Pokuj_on = Wart_nap
Pokuj_of = Pokuj_on + 2
Lcd " zapamietuje "
Waitms 1000
Writeeeprom Licz , 5
Cls
'Reset Watchdog
Start Watchdog
Reset Watchdog
Goto Koniecrc
End If
Next Pomocnicza2
Start Watchdog
Reset Watchdog
End If
End If
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Koniecrc:
Loop
Loop
Kasowanie:
Reset Watchdog
If Kasownik = 1 Then
Kasownik = 0
Goto Ra
End If
Kasownik = 1
Pomocnicza = 0
Ra:
Return
'end sub
schemat połączenia programatora z procekiem zgodyny z
Cytuj:
http://obrazki.elektroda.pl/7162847700_1324675664.png
próbowałem programować zgodnie z waszymi sugestiami zmieniajc teaktowanie oscylatora z 1 MHz na 8MHz, niestety to nie przyniosło rezultatu