RaspberryPi: Using the GPIO pins

Thread Starter

Alec_t

Joined Sep 17, 2013
12,149
I've recently been given a RaspberryPi 3 B+ and have made some measurements, the results of which may be of use/interest to fellow users (since info on GPIO pin characteristics seems rather thin on the ground):-
1) With a GPIO pin configured simply as an input via the RPi.GPIO library (pull-up/down state unaltered from its default value) the pin shows slight hysteresis with thresholds at 1.16V and 1.27V, as measured at DC.
2) In the PYTHON interpreter, an intruction to change the state of an output pin in response to a change in state of an input pin takes only about 5 nanoseconds to do its thing.
 

danadak

Joined Mar 10, 2018
4,057
2) In the PYTHON interpreter, an intruction to change the state of an output pin in response to a change in state of an input pin takes only about 5 nanoseconds to do its thing.
Are you sure about this ? Code to test an input pin and then write
to an output would take a lot longer than that. Something does not
add up, that's effectively a 200 Mhz pin rate code test to code output valid.

Regards, Dana.
 

Thread Starter

Alec_t

Joined Sep 17, 2013
12,149
Are you sure about this ?
No. I deduced it from my'scope display of the 100MHz noisy triangle wave signal I was seeing on the input pin. I agree it seems impossibly short a response/execution time. It's possible the triangle wave was a consequence of something other than the intended port pin switching, particularly as the test set-up involved a breadboard and unscreened twisted-pair wiring.
Here's the Python script I used for the test:
Code:
try:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(16, GPIO.IN)
while True:
  if GPIO.input(16) :
    GPIO.output(12, 0)
  else:
    GPIO.output(12, 1)
except KeyboardInterrupt:
  GPIO.cleanup()
Here's the test circuit:
Pi-pins.PNG
For the threshold test, R1 and C1 were replaced by a pot fed from 3.3V.
what is the dafault value?
I've no idea. It's whatever Raspbian and the RPi.GPIO library leave/set it at when I call "GPIO.setup(16, GPIO.IN)"
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
You can get at the actual response time by looking at the
compiler output in assembly, and count instruction clock
cycles from input detection to output state write.

Regards, Dana.
 
Top