Habe mit einem B+ das Problem, dass eine interrupt abfrage langsamer abgefragt wird als eine Routine im Hauptprogramm.
100ms Pulse wird von GPIO4 erkannt.
Abfragen ob er wirklich 100ms lang ist.
Wenn 100ms lang dann wird ein Wert addiert.
Anfang des Programms:
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import sys, os
GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers
GPIO.setwarnings (False)
GPIO.setup((4),GPIO.IN, pull_up_down=GPIO.PUD_UP) # Münzprüfer Pulse 0,5
Folgende Routine Hauptprogramm funktioniert.
-------
while True:
if GPIO.input(4) == True:
Sta = time.time()
while GPIO.input(4) == True:
En = time.time()
Diff = En-Sta
if Diff > 0.9:
A = A + B
------
wenn ich das jetzt als Interrupt laufen lasse ist schon die Abfrage
while GPIO.input(4) == False:
nicht mehr aktuell. GPIO4 ist schon wieder True
Hier die Interrupt Routine
-------
def summe(self):
Sta = time.time()
while GPIO.input(4) == True:
En = time.time()
else:
Diff = En-Sta
if Diff > 0.9:
A = A + B
GPIO.add_event_detect(4, GPIO.RISING, callback=summe, bouncetime = 30)
while True:
time.sleep(0.0001)
-------
Hat jemand eine Idee wie ich per interrupt einen 100 ms langen Puls abfragen kann ?
Ich muß insgesamt 5 GPIO#s abfragen und um "verschlucker zu vermeiden ist eine Interrupt Abfrage notwendig
Danke für konstruktive Hilfe.
Detkor