Arduino + OV7670 - No FIFO - Read Snapshot

I know that there is a lot on the Internet ( http://forum.arduino.cc/index.php?topic=159557.0 ) about OV7670, and I read a lot about it, but it seems that something is missing.

First of all, I looked at how we can read pixel pixels from a camera to create a rectangular image of 600 X 480, and this was pretty easy to understand, given that HREF, VSYNCH and PCLOCK are described here in the documentation: http: // www. voti.nl/docs/OV7670.pdf . I understand that XCLOCK as input I need to give OV7670 as a kind of loop controller, and RESET is something like RESET it.

So, at this moment I thought that the functionality of such a camera would be covered by the wiring of the following contacts:

  • D0..D7 - for data (pixels) connected to arduino digital pins from 0 to 7, like INPUT on an arduino board.
  • XCLK - for camera clocks connected to arduino digital output 8, like OUTPUT from an arduino board.
  • PCLK - for pixel clocks connected to arduino digital pin 9, like INPUT on an arduino board.
  • HREF - determine when the line starts / ends, connected to the arduino digital output 10, as INPUT on the arduino board.
  • VSYCH - determine when the frame starts / ends, connects to the arduino digital output 11 as INPUT on the arduino board.
  • GRD - groud connected to arduino GRD
  • 3V3 - 3.3 INPUT connected to arduino 3.3v
  • RESET - connected to arduino RESET
  • PWDN - connected to arduino GRD

The implementation of this approach from my point of view will be something like this: Code:

for each loop function do write high to XCLK if VSYNCH is HIGH return; if HREF is LOW return; if lastPCLOCK was HIGH and currentPCLOCK is LOW readPixelFromDataPins(); end for 

My readPixelFromDataPins() basically reads only the first byte (since I'm just testing if I can even read something from the camera), and it is written as follows:

the code:

 byte readPixelFromDataPins() { byte result = 0; for (int i = 0; i < 8; i++) { result = result << 1 | digitalRead(data_p[i]); } return result; } 

To check that something is being read from the camera, I just print it on the Serial 9600, the byte is read from the data contacts as a number. But at the moment I am only getting null values. The code I use to get the image is stored here: https://gist.github.com/franciscospaeth/8503747 .

Does someone who makes an OV7670 work with Arduino already figure out what I'm doing wrong? I suppose I'm using XCLOCK incorrectly? What should I do to make it work?

I searched a lot and I did not find any SSCCE ( http://sscce.org/ ) for this camera using arduino, if anyone has it please let me know.


This question is present on the arduino forum ( http://forum.arduino.cc/index.php?topic=211741.0 ).

+7
camera clock arduino
source share
3 answers

Your idea is not bad, but ... xclock should be a clock (in your program there is only a transition from 0 to 1 and it freezes there) you also need to use I2C with SIOC and SIOD to configure the camera (or you can use the default settings, but I not sure if this is the correct output format for you, 30F / s, VGA, YUV format ....)

execution of your code is slower using sequential output in the same loop with read data. I recommend that you switch the output of xclock and transfer the print of the pixel to if (). You can also read data only at a very precise time, if you want to read only one byte, and after switching from 0 to 1 from HREF you need to wait for a new transition from 0 to 1 from PCLK (you can see only one transition from HREF after the transition by 784x2 to PCLK (640 active pixels + 144 dead times for each line) x 2 (for YUV or RGB 2 bytes received for each pixel))

+5
source share

Hi, I'm Mr_Arduino from the arduino forums. Your problem is that you read pixels too slowly, please do not use digital reading to do such a thing. Also, if you insist on using a separate byte-read-only function, make sure the function is built-in. You can do this by declaring your function static inline. Also as mentioned above, how do you generate a watch. You can generate XCLK using PWM on arduino.

I created a working example here:

https://github.com/ComputerNerd/arduino-camera-tft/blob/master/captureimage.c

Edit: a third-party copied part , but not all of the code from the link above in response here. However, the link should remain, as the code below requires that additional files from this source actually work. Edit 2: Remote irrelevant code. You will need to change what you do with the data.

 void capImg(void){ cli(); uint8_t w,ww; uint8_t h; w=160; h=240; tft_setXY(0,0); CS_LOW; RS_HIGH; RD_HIGH; DDRA=0xFF; //DDRC=0; #ifdef MT9D111 while (PINE&32){}//wait for low while (!(PINE&32)){}//wait for high #else while (!(PINE&32)){}//wait for high while (PINE&32){}//wait for low #endif while (h--){ ww=w; while (ww--){ WR_LOW; while (PINE&16){}//wait for low PORTA=PINC; WR_HIGH; while (!(PINE&16)){}//wait for high WR_LOW; while (PINE&16){}//wait for low PORTA=PINC; WR_HIGH; while (!(PINE&16)){}//wait for high WR_LOW; while (PINE&16){}//wait for low PORTA=PINC; WR_HIGH; while (!(PINE&16)){}//wait for high WR_LOW; while (PINE&16){}//wait for low PORTA=PINC; WR_HIGH; while (!(PINE&16)){}//wait for high } } CS_HIGH; sei(); } 

You can also find it on github .

+2
source share

You can use my instruction: how to get an image from ov7670 It contains all the necessary steps. There is also the option to install FrameGrabber: how to start framegrabber

-one
source share

All Articles