Hallo, ich hab mir eine Platine aufgebaut mit einem Atmega 8 und 3 relaiskarten. Ziel des ganzen ist es insgesamt 2 Endgeräte jeweils mit einem Taster an- und aus zu schalten. Die dritte Relaiskarte soll auf Tastenkombination reagieren. Mir stellen sich aber bis jetzt 2 Probleme auf: 1. Tastenkombination 2. Entprellung Ich habe das mit den an- und ausschalten per taster schon realisiert. Ich programmieren anbei mit Bascom :-) ###################################### Hier mein momentaner Code: ###################################### $crystal = 1000000 $regfile = "m8def.dat" Portd = &H0C ' Pullup Config Pind.0 = Input ' Taster 1 Portd.0 = 1 Config Pind.1 = Input ' Taster 2 Portd.1 = 1 Config Portc.0 = Output ' Relaiskarte 1 Config Portc.1 = Output ' Relaiskarte 2 Config Portc.2 = Output ' Relaiskarte 3 Config Portc.3 = Output ' Status-LED Config Portc.4 = Output ' Power.ON-LED Config Debounce = 30 Dim I As Integer ' Variable I Dim P As Integer ' Variable P Dim X As Integer ' Variable X Dim Y As Integer ' Variable Y '_____________________________ Portc.4 = 1 ' Power-LED -> ein I = 0 ' Variable I auf 0 P = 0 ' Variable P auf 0 X = 0 ' Variable X auf 0 Y = 0 ' Variable Y auf 0 '_____________________________ Do Portc.2 = 1 ' Relaiskarte 3 -> ein If Pind.0 = 0 Then ' Taster 1 Portc.0 = 1 ' Relaiskarte 1 -> ein Portc.3 = 1 ' Status-LED -> ein I = 1 ' Variable I auf 1 If Pind.0 = 0 And I = 1 Then Portc.0 = 0 ' Relaiskarte 1 -> aus I = 0 If I = 0 And P = 0 Then ' Status-LED erst aus Portc.3 = 0 wenn Relaisk 1+2 aus End If ' Variable I auf 0 End If End If If Pind.1 = 0 Then ' Taster 2 Portc.1 = 1 ' Relaiskarte 2 -> ein Portc.3 = 1 ' Status-LED -> ein P = 1 ' Variable P auf 1 If Pind.1 = 0 And P = 1 Then Portc.1 = 0 ' Relaiskarte 2 -> aus P = 0 If I = 0 And P = 0 Then ' Status-LED erst aus Portc.3 = 0 wenn Relaisk 1+2 aus End If ' Variable P auf 0 End If End If '____________________________ 'Tastenkombination: If Pind.0 = 0 Then ' Taster 1 X = 1 ' Variable X auf 1´ Waitms 50 ' Zeitabstand zwischen Tastendruck If Pind.0 = 0 Then ' Taster 1 Y = X + 1 If Y = 2 Then Portc.2 = 0 ' Relaiskarte 3 -> aus End If End If End If Loop ###################################### Die dritte Relaiskarte ist mit absicht permanent an und soll auf tastenkombi erst aus gehen ;-) ###################################### Des Weiteren reagieren die Taster trotz Debounce total schlecht und irgendwie kriege ich das nicht in den Griff dass sie sauber durchschalten.. Evtl. auch ein Programmierfehler (?) (Taster: http://www.pollin.de/shop/dt/MzM0OTc1OTk-/Bauelemente_Bauteile/Mechanische_Bauelemente/Schalter_Taster/Drucktaster_PBS_28B.html)
Hallo User, du configurierst die Zeit für Debounce mit Config Debounce = 30 verwendest im Quellcode den Debounce-Befehl nicht, sondern liest selbst die Ports. Das könnte aber der Debounce-Befehl für dich übernehmen( Siehe Hife zu BASCOM). z.B. Debounce T_start_stop , 1 , Setstartstop , Sub Als Hinweis : a) Kommentare sind hilfreich, aber nicht immer nötig Y = 0 ' Variable Y auf 0 ist sebsterklärend b) Verwende zur besseren Lesbarkeit für Portpins doch einfach den ALIAS-Befehl z.B. Config Pind.0 = Input ' Taster 1 Portd.0 = 1 T_start_stop Alias Pind.0 Gruss Frank
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.