Jeżeli nie odpowiedni dział to najmocniej przepraszam.
Napisałem program na uC i nie wiem czemu co chwilę na wyświetlaczu oprócz poprawnego wyniku wskakuje jakaś liczba nie związana z pomiarem.
$regfile = "m8def.dat"
$crystal = 16000000
Config Lcd = 16 * 2
Enable Interrupts
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5
Config Timer1 = Timer , Prescale = 64 'maks=0,261s, min=0,000004s
Enable Timer1
Config Int0 = Falling
On Int0 Poczatek
Enable Int0
Stop Timer1
Timer1 = 0
Dim Wynik As Word
Dim Flaga As Bit
Dim Wynikczas As Single
Cls
Cursor Off
Do
Locate 1 , 1
Lcd Wynikczas ; Spc(6)
Waitms 100
Loop
End
Poczatek:
If Flaga = 0 Then
Load Timer1 , 0
Start Timer1
Config Int0 = Rising
Else
Stop Timer1
Wynik = Timer1
Wynikczas = Wynik * 0.000004
Load Timer1 , 0
Config Int0 = Falling
End If
Toggle Flaga
Return
Do podawania stanu niskiego użyłem drugiego uC z takim programem:
$regfile = "m8def.dat"
$crystal = 4000000
Config Pinb.1 = Output
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Disconnect , Prescale = 8
Config Portd = Input
Dim Pom As Integer
Config Portd.0 = Output
Config Portd.1 = Output
Config Portd.2 = Output
Config Portd.3 = Output
Config Portd.4 = Output
Do
Set Portd.0
Set Portd.1
Set Portd.2
Set Portd.3
Set Portd.4
If Pind.0 = 0 Then
Pwm1a = 50
End If
If Pind.1 = 0 Then
Pwm1a = 100
End If
If Pind.2 = 0 Then
Pwm1a = 150
End If
If Pind.3 = 0 Then
Pwm1a = 200
End If
If Pind.4 = 0 Then
Pwm1a = 250
End If
Loop
End
Czy można prosić kogoś mądrzejszego ode mnie o poprawienie programu bo sam nie daje rady.