Witam
Mam problem z prostym programem
Poniższy program działa tak jak powinien
Natomiast w poniższym gdzie dodałem pomiar ADC
nie działają przyciski
Czy to może być spowodowane zbyt dużą ilością zmiennych word i single i string ?
Mam problem z prostym programem
Poniższy program działa tak jak powinien
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 1
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portb.3 , Db7 = Portb.2 , E = Portc.4 , Rs = Portc.5
Cls
Config Pind.3 = Input
Config Pind.2 = Input
Config Pind.4 = Input
Config Pinb.1 = Output
Set Portd.2
Set Portd.3
Set Portd.4
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Disconnect , Prescale = 64
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Up Alias Pind.3
Down Alias Pind.2
Enter Alias Pind.4
'zmienne pomiaru prądu
Dim Odczyt0 As Word
Dim A As Single
Dim Amper As String * 3
'zmienne pomiaru napięcia
Dim Odczyt1 As Word
Dim V As Single
Dim Volt As String * 3
'zmienna do regulacji Pwm pin B.1 początkowa wartość 10
Dim P As Word
P = 10
Start Adc
'-----------PROGRAM--------------
Do
Pwm1a = P
Gosub Wyswietlanie
If P > 630 Then
P = 630
End If
If Down = 0 Then
P = P - 10
End If
If Up = 0 Then
P = P + 20
End If
waitms 300
'-----------------------------
Loop
End
Wyswietlanie:
Cls
Locate 2 , 3 : Lcd "P=" ; P
Cursor Off
Return
'---------------------------
Natomiast w poniższym gdzie dodałem pomiar ADC
nie działają przyciski
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 1
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portb.3 , Db7 = Portb.2 , E = Portc.4 , Rs = Portc.5
Cls
Config Pind.3 = Input
Config Pind.2 = Input
Config Pind.4 = Input
Config Pinb.1 = Output
Set Portd.2
Set Portd.3
Set Portd.4
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Disconnect , Prescale = 64
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Up Alias Pind.3
Down Alias Pind.2
Enter Alias Pind.4
'zmienne pomiaru prądu
Dim Odczyt0 As Word
Dim A As Single
Dim Amper As String * 3
'zmienne pomiaru napięcia
Dim Odczyt1 As Word
Dim V As Single
Dim Volt As String * 3
'zmienna do regulacji Pwm pin B.1 początkowa wartość 10
Dim P As Word
P = 10
Start Adc
'-----------PROGRAM--------------
Do
Pwm1a = P
Gosub Wyswietlanie
If P > 630 Then
P = 630
End If
If Down = 0 Then
P = P - 10
End If
If Up = 0 Then
P = P + 20
End If
'---------POMIAR--------
'Pomiar Prądu
Odczyt0 = Getadc(1)
A = Odczyt0 * 0.0455
Amper = Fusing(a , "#.$$")
'Pomiar Napięcia
Odczyt1 = Getadc(0)
V = Odczyt1 * 0.0225
Volt = Fusing(v , "#.$$")
Waitms 300
'-----------------------------
Loop
End
Wyswietlanie:
Cls
Locate 1 , 1 : Lcd "V=" ; Volt
Locate 2 , 3 : Lcd "P=" ; P
Cursor Off
Return
'---------------------------
Czy to może być spowodowane zbyt dużą ilością zmiennych word i single i string ?