I want to read the output of OV7670 camera module that produces 8-bit output at a very high frequency. The output pixel clock frequency is around 8MHz. I have to sample those 8-bit data at raspberry pi's GPIO at every falling edge of pixel clock. I am coding the same in python. can anyone can say at what speed raspberry pi samples at GPIO?
-
1Why don't you just run your script and find out? – joan Mar 08 '20 at 17:28
-
I tried counting the number of pixel clock rising/falling clocks per second by enabling interrupt, but it didn't count the exact number. The pulses it counted is way more less than what it should be! – HEMASAI KUMAR Mar 08 '20 at 17:37
-
So you already know the answer. You might be able to optimise your script slightly but you will never achieve your aim with Python on the Pi. – joan Mar 08 '20 at 17:42
-
So raspberry pi isn't suitable for this application?or I can achieve this with raspberry pi using scripts other than python? – HEMASAI KUMAR Mar 08 '20 at 17:45
-
I doubt it. I have seen claims that it can be done in C but those claims are unsupported by evidence. – joan Mar 08 '20 at 17:55
-
With interrupt callbacks, you probably won't be able to be faster than about 5Khz - that's what I've found during some measurements. By polling the pin, you might be faster, but then you still need to move the data somewhere (i.e. store it). I suggest you look for some extra digitizer hardware. – PMF Mar 08 '20 at 20:50
-
1Does this answer your question? How fast can GPIO pins toggle? – Dmitry Grigoryev Jan 29 '21 at 10:35
3 Answers
If you want to work with video on a Pi, you can get a USB VGA webcam for almost the same price as the OV7670 module, and get the video stream via v4l interface ("/dev/video") which will work faster and be easier to use.
If you want to play with low-level video acquisition, get a fast microcontroller with a dedicated data port (1 pins which can be read at once in a single byte). The Pi is not really suitable for this.

- 27,928
- 6
- 53
- 144
We have recently tested the read speed for two python libraries, PIGPIO and RPi.GPIO, by simulating on the raspberry an 8-bit sipo register with an 8-bit D flip flop connected on it's parallel output.
The test was performed on a Raspberry Pi 3b.
Both libraries perform well for frequencies of up to 5 KHz, with accuracy above 99%. The accuracy of the Rpi.GPIO library deteriorates over 5 KHz and at 50 KHz it is incapable of performing this task.
The PIGPIO library performs comparably better, with its accuracy being above 99% for frequencies up to 20 KHz. Above that frequency, its performance gradually deteriorates and at 110 KHz it cannot read correctly any phrase at all.
You can find the exact test setup and results on this this post: https://atman-iot.com/blog/raspberry-pi-benchmark/

- 51
- 3
I'm facing a similar issue. I want to read clock signal of 10Mhz. I'm able to read only up to 7MHz clock signal.
However, in my code, the GPLEV0 reading speed is about 40M times a second. Even with this reading speed, the clock is not able to read. [Makes no sense to say reading at 40MSPS yet not able to catch the clock at 10MHZ. But it is happening with me]
Anyways, the code to read GPLEV0 in a tight loop 30M times a second has been posted in the links below. To read at 40M times a second, you'll have to run the code in a service and add a start/stop triggering mechanism.
Here is my detailed issue with the code:

- 109
- 3