Forum: Mikrocontroller und Digitale Elektronik Single Addierung


von Dirk (Gast)


Lesenswert?

Hi,

ich habe folgenes Prob: Ich wollte eine Single Variable per Tastendruck 
erhoehen. Es stellt eigentlich kein Problem da, wenn ich aber ueber 
Tasten mach stuertzt der Mikrocontroller ab. Er erhoeht von z.B. 1.03 
bis 1.43 (mal mehr mal weniger) und dann tut sich garnix mehr.

Automatiersiere ich den Vorgang (ich nehme die Tastenabfrage raus) 
funktioniert es einwandfrei.
Ich benutze ein 8535 und Bascom.

Programm 1 (Automatisiert) FUNKTIONIERT!
$regfile = "8535def.dat"
$crystal = 7372800                                          ' 
Taktfrequenz
$baud = 19200
Config Pinc.0 = Input
Config Pinc.2 = Input
Config Pinc.4 = Input
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , 
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Config Debounce = 20

Portc = &B00010101
Dim Spg1 As Single
Dim Spg2 As Single

Cls
Cursor Off
Spg1 = 1.03
Spg2 = 0.10

Tastenabfrage2:
Wait 1
Spg1 = Spg1 + Spg2
'Debounce Pinc.0 , 0 , Ab2 , Sub
'Debounce Pinc.2 , 0 , Auf2 , Sub
'Debounce Pinc.4 , 0 , Ok , Sub
Goto Lcdpri


Lcdpri:
Locate 1 , 1

Lcd Fusing(spg1 , "#.##") ; "V     Save"
Goto Tastenabfrage2


Ab2:
Spg1 = Spg1 + Spg2
Goto Tastenabfrage2

Auf2:
Spg1 = Spg1 + Spg2
Goto Tastenabfrage2


Programm 2 (mit Tastenabfrage Spg1 um 0.10 erhoehen)
FUNKTIONIERT NICHT!


$regfile = "8535def.dat"
$crystal = 7372800                                          ' 
Taktfrequenz
$baud = 19200
Config Pinc.0 = Input
Config Pinc.2 = Input
Config Pinc.4 = Input
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , 
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Config Debounce = 20

Portc = &B00010101
Dim Spg1 As Single
Dim Spg2 As Single

Cls
Cursor Off
Spg1 = 1.03
Spg2 = 0.10

Tastenabfrage2:
Wait 1
Debounce Pinc.0 , 0 , Ab2 , Sub
Debounce Pinc.2 , 0 , Auf2 , Sub
Goto Lcdpri


Lcdpri:
Locate 1 , 1

Lcd Fusing(spg1 , "#.##") ; "V     Save"
Goto Tastenabfrage2


Ab2:
Spg1 = Spg1 + Spg2
Goto Tastenabfrage2

Auf2:
Spg1 = Spg1 + Spg2
Goto Tastenabfrage2




Mfg Dirk

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.