Hi Searcher,
das gefällt mir, weniger Zeilen und damit auch übersichtlicher. Es funktioniert mit einer kleinen Änderung, da ich an den Foto-LEDs mit einem Transistor die Polung invertiere bedarf es eine 1 bei "opto_1 = 0..." oder die Transistoren wieder entfernen. Die Namen der Variablen werde ich im fertigen Programm so umbennenen das ich sie in X Jahren noch wiedererkenne
.
Was ich noch nicht verstehe:
* ocr0a = 78 --- Wer oder was ist das?
* compare0a --- Wer oder was ist das, warum nicht timer0?
Das kleine Testprogramm sieht dann so aus:
Grüßle, HermannCode:' --- Mikrocontroler Daten... ---------------------------------------------------------------------------------- $regfile = "attiny44.dat" $crystal = 8000000 $hwstack = 40 ' $hwstack = 34 $swstack = 40 ' $swstack = 20 $framesize = 40 ' $framesize = 24 ' --- Deklarationen... ----------------------------------------------------------------------------------------- enable interrupts ocr0a = 78 config timer0 = timer , prescale = 1024 , CLEAR_TIMER = 1 ' about 10 milliseconds compare0A interrupt on compare0a isr_deadtime ' enable COMPARE0A config porta = output config portb = input config lcdpin = pin , Db4 = porta.2 , Db5 = porta.3 , Db6 = porta.4 , Db7 = porta.5 , E = porta.0 , Rs = porta.1 config lcd = 20 * 4 cursor off : cls opto_1 alias pinb.1 ' light barrier track 1 opto_2 alias pinb.2 ' light barrier track 2 ' --- Variablen... --------------------------------------------------------------------------------------------- const deadtime = 100 ' 100 * 10ms of copmare0a interrupt dim monoflop_1 as byte dim monoflop_2 as byte dim round_1 as byte ' round counter dim round_2 as byte ' round counter dim Z_formatiert as string * 2 : Z_formatiert = "" ' Zahlen rechtsbündige formatieren ' --- Programm Anfang ------------------------------------------------------------------------------------------ locate 1,1 : lcd "Formel X 20 Runden" locate 2,1 : lcd "--------------------" locate 3,1 : lcd "Spur 1 ---- Runde 0" locate 4,1 : lcd "Spur 2 ---- Runde 0" do if opto_1 = 1 and monoflop_1 = 0 then incr round_1 Z_formatiert = str(round_1) locate 3,1 : lcd "Spur 1 ---- Runde" ; format(Z_formatiert , " ") monoflop_1 = deadtime endif if opto_2 = 1 and monoflop_2 = 0 then incr round_2 Z_formatiert = str(round_2) locate 4,1 : lcd "Spur 1 ---- Runde" ; format(Z_formatiert , " ") monoflop_2 = deadtime endif loop ' --- Prozeduren, Funktionen... -------------------------------------------------------------------------------- isr_deadtime: if monoflop_1 > 0 then decr monoflop_1 if monoflop_2 > 0 then decr monoflop_2 return ' --- Programm Ende -------------------------------------------------------------------------------------------- end







Zitieren

Lesezeichen