What I'm wondering what is the update rate of each GPIO when used as inputs. What I'm actually doing with the Raspberry PI 3 is a pulse counter. I basically have 7 GPIOs set up as inputs and registered a callback to the Rising Edge with python and the RPi.GPIO module, using the following:
GPIO.add_event_detect(x, GPIO.RISING, callback=self.on_pulse_received, bouncetime=5)
Where x is the GPIO pin number. With this setup I'm having some problem on some specific pins: for example, the GPIO pin 4 seems to lose some pulses now and then, while the 26 doesn't. I repeated a lot of tests with more than 3000 pulses and almost every pin had a very low error percentage (about 1.2%), while the GPIO 4 went up to 15-20%.
The pulses I'm reading have a frequency of 1-2 pulse per second and the signal width is 100ms.
What I'm wondering is if there's some pin "internal" priority which makes some GPIOs slower and less reliable the others. If there is I can adapt my code and use different pins to get better performance.
EDIT: I don't know if it matters or not, but my pulses happen at the same time on all 7 GPIOs (just for testing purposes, in real cases it won't happen).
I also have a piece of code which I made to prevent false detection (which happened a lot in the beginning). When the
add_event_detect fires its event, I make a double check in the callback just to be sure I detected a real pulse.
What I do is the following:
def on_pulse_received(self, channel): time.sleep(0.001) if GPIO.input(channel) == GPIO.HIGH: # Code to handle the pulse
This way, if the event fires for a false pulse, it's not registered. May this code break the pulse detection ?