Może ma ktos z was gotowy program do wyswietlania cyfr na dwóch wyswietlaczach? Może w przerwaniu. Mam cos takiego ale wyswietlacz mruga.
Moderowany przez McRancor:Używaj znaczników "code" jak wklejasz kod. Poprawiłem
$regfile = "m8def.dat"
$crystal = 8000000
Config Portd = Output
Config Pinb.0 = Output
Config Pinb.1 = Output
Config Pinb.2 = Output
Config Pinb.3 = Output
Config Pinb.4 = Input
Config Pinb.5 = Input
Config Pinb.6 = Input
Config Pinb.7 = Input
Config Portc = Output
Set Pinb.5
Set Pinb.6
Set Pinb.7
Dim A As Integer , Licznik As Byte , T As Integer ,
Dim Setki As Byte , Dziesiatki As Byte , Jednostki As Byte ,
Dim Mux As Byte ,
Swstart Alias Pinb.5
Swstop Alias Pinb.6
Funk Alias Pinb.7
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Disconnect , Prescale = 64
Dim Wart_ac As Word
Dim P As Byte 'pozycja 'x temperatura
Dim X As Single 'temperatura z czujnika
Dim Z As Byte 'czas przedmuchu
Dim J As Byte 'czas pomiedzy przedmuch
Dim I As Byte 'obr min
Dim S As Single 'temperatura w pamieci
Dim U As Byte
Config Timer0 = Timer , Prescale = 64
Enable Interrupts
Enable Timer0
On Timer0 Co4ms
Dmuchawa Alias Pinb.2
Pompa Alias Pinb.3
Cz_temp Alias Pinb.4
Declare Sub Temp
Declare Sub Przedmuch
Declare Sub Czas_m_przedmuch
Declare Sub Obr_min
Declare Sub Obr_max
Declare Sub Temperatura
Declare Sub Pompa
Declare Sub Dmuchawa_sub
Declare Sub Praca
Declare Sub Wyswietl
Declare Sub Obroty_max_sub
Declare Sub Obroty_min_sub 'end program
P = 1
Do
If Funk = 0 Then
Waitms 200
Incr P
End If
If P = 5 Then
P = 0
End If
If P = 0 Then
Portc = &B11111110
Waitms 100
If Swstart = 0 Then
Gosub Praca
End If
End If
If P = 1 Then
Portc = &B11111101
Gosub Temp
End If
If P = 2 Then
Portc = &B11111011
Gosub Przedmuch
End If
If P = 3 Then
Gosub Czas_m_przedmuch
Portc = &B11110111
End If
If P = 4 Then
Gosub Obr_min
Portc = &B11101111
End If
If P = 5 Then
Gosub Obr_max
Portc = &B11011111
End If
Loop
Sub Temp
Readeeprom X , 1
If Swstart = 0 Then
Waitms 10
If Swstart = 0 Then
Incr X
T = X
Waitms 20
If X = 91 Then X = 35
End If
End If
If Swstop = 0 Then
Waitms 10
If Swstop = 0 Then
Decr X
T = X
Waitms 20
If X = 35 Then X = 90
End If
End If
Writeeeprom X , 1
End Sub
Sub Przedmuch
If Swstart = 0 Then
Waitms 50
If Swstart = 0 Then
Incr Z
If Z = 25 Then Z = 1
End If
End If
If Swstop = 0 Then
Waitms 50
If Swstop = 0 Then
Decr Z
If Z = 0 Then Z = 25
End If
End If
Writeeeprom Z , 2
End Sub
Sub Czas_m_przedmuch
If Swstart = 0 Then
Waitms 50
If Swstart = 0 Then
Incr J
If J = 99 Then J = 1
End If
End If
If Swstop = 0 Then
Waitms 50
If Swstop = 0 Then
Decr J
If J = 0 Then J = 99
End If
End If
Writeeeprom J , 3
End Sub
Sub Obr_min
If Swstart = 0 Then
Waitms 50
If Swstart = 0 Then
Incr I
If I = 12 Then I = 1
End If
End If
If Swstop = 0 Then
Waitms 50
If Swstop = 0 Then
Decr I
If I = 1 Then I = 11
End If
End If
Writeeeprom I , 4
End Sub
Sub Obr_max
If Swstart = 0 Then
Waitms 50
If Swstart = 0 Then
Incr U
If U = 11 Then U = 1
End If
End If
If Swstop = 0 Then
Waitms 50
If Swstop = 0 Then
Decr U
If U = 1 Then U = 11
End If
End If
Writeeeprom U , 5
End Sub
Sub Temperatura
Start Adc
Wart_ac = Getadc(3)
S = Wart_ac / 10
End Sub
Sub Praca
Do
Gosub Temperatura
If S < X Then
Gosub Obroty_max_sub
Set Pompa
End If
If S > X Then
Gosub Obroty_min_sub
End If
If S > 90 Then
Pwm1a = 1
End If
Loop
End Sub
Sub Obroty_max_sub
Readeeprom U , 5
Pwm1a = U * 93
End Sub
Sub Obroty_min_sub
Readeeprom I , 4
Pwm1a = I * 93
End Sub
'end program 'end program
Co4ms:
'Standardowa konwersja binarna 0...255 na trzycyfrową BCD
A = T
If A > 100 Then
Setki = 1
A = A - 100
Else
Setki = 10
End If
A = Makebcd(a)
Jednostki = A And 15
Dziesiatki = A
Shift Dziesiatki , Right , 4
'Standardowa obsługa wyświetlaczy
Incr Mux
If Mux = 3 Then Mux = 0
Portb = 127
Select Case Mux
Case 0
Portd = Lookup(jednostki , Tabela)
Portb.1 = 0
Case 1
Portd = Lookup(dziesiatki , Tabela)
Portb.0 = 0
End Select
Return
Tabela:
Data &B00111111 , &B00000110 , &B01011011 , &B01001111 , &B01100110,
Data &B01101101 , &B01111101 , &B00000111 , &B01111111 , &B01101111