ov7670 camera sensor success!

The ov7670 camera sensor, cheaply available from ebay, has been the bane of my existence during my short electronics hobby career. I bought my first ov7670 sensor maybe a year ago, and have been tearing my hair out trying to get it to respond. It seemed completely dead. It didn’t respond to any form of i2c communication, and showed no signs of life in the oscilloscope.

Every now and then, I tried to get it to work using various approaches, but to no avail, and was ready to completely give up. However, now after seeing some recent success stories with the ov7670 here and here, I decided to give it one more go.

I’m pretty new to electronics, and I’m learning new stuff every day. On my most recent attempt at breathing life into the wretched thing, my attention got directed towards a feature I had not even considered before – the XCLK pin. This pin labeled “external clock”, always seemed to me like it was something optional, as I’ve gotten used to all my other toys having internal RC oscillators, or no need for oscillators. But no, in this case it’s not optional, and my oversight seems so obvious now!

I’ve read pretty much every document available on the internet about the ov7670 sensor, but to this day, I’m not sure it’s clearly stated anywhere that feeding the XCLK is an important step  to getting the ov7670 up and running. It’s probably listed in every schematic out there, but my newbie mind ignored it.

So, to feed the camera some clockage, I used the CLKOUT feature of the LPCXpresso  to generate a frequency of ~10Mhz, and lo and behold, it’s alive! Alive!

From this point on, working with the camera was pretty straightforward. Analyzing the sync signals and reading the digital color signals with the aid of the provided pixel clock was easy as a pie. Some minor headaches with the clock running so fast, but that was possible to tune down to more workable levels.

The smallest resolution the camera supports is QQVGA (160×120), and with rgb565 color space, that fits quite neatly in the 64K of memory that LPC1769 has.

To pump out the image to my computer for viewing, I initially used the semihosting feature of LPCXpresso –  just for testing. Printing out the full image with printf’s took nearly an hour! But after a few attempts I managed to conjure a sensible image out of the data, crowning my success with a picture of my stupid face.

My good friend Oona. The colors could use some tuning, but I quite like the result already.

Next step was to output the data via UART at more convenient speeds. Initially I didn’t seem to be able to pump the data to my computer at speeds more than ~57600. Somewhere the data got buffered, and when it buffered enough, it went nuts. So I adjusted the serial protocol a little, so the client sends commands to request lines one at a time, and the lpcxpresso responds with data. This keeps both parties happy about the rate of data flowing, and I was able to increase the baudrate to 921600.

Now I was able to view a new image from the camera every 1-2 seconds. This almost feels like watching a video instead of a slideshow :) I could do some tricks to get faster framerates, but actually I won’t bother. My initial thoughts with the camera were to use it for still images taken on request, and to transfer them wirelessly via XBee, so in future I’ll use the camera at a much slower pace.

In case someone reads this page one day, looking for advise with the ov7670, I’ll list some notes here that might be useful:

  • Needs a clock source
  • i2c is dodgy, I had to add some delay to read routines
  • different versions exist on ebay, some take 2.8V instead of 3.3V, and some have FIFO

I’ve dumped the project source to github at https://github.com/desaster/ov7670test. At the time of writing, the pygame + pyserial client isn’t there, but I might add it later after I work on it a bit.

81 thoughts on “ov7670 camera sensor success!

    1. desaster

      Well I’ve taken apart the stuff long time ago already.. but I think the connections should be pretty self explanatory at least on the camera side. And on on the MCU side, it’s really up to you.

      I think the source code also has most of the pins explained.

      If you’re working on the camera yourself, I’d be very interested in hearing about your experiences with it! :)

      Reply
  1. diego

    hello, good information. But indon know how i will can see the captures images in pc, sended with uart, can you help me?

    Regards

    Reply
    1. desaster

      For my application, I wrote a python app using pyserial that reads the raw data by using a simple command/response protocol, and then displays the data by using pygame. You can see an example of how I did it in my github repository.

      Reply
      1. diego

        Thank you,
        Pytom it,s a stranger for me:) i will seach about this in google..

        In a week i will receibe my camera, :)

        Thanks, and regards from spain

        Reply
  2. diego

    Hello,
    the last friday receibed the camera and today i,m test comonication with sccb bus, with any dificults, but work i think…

    Can you help me any more with how to use your aplication for pythom?

    Best regards

    Reply
  3. JS

    Hello! I am new to lpc1769 and i have been trying to get the ov7670 camera working. I followed your instructions and used your project source from github. However, when i debug and run the code, I realised that the code doesnt run beyond “while (I2CEngine() == I2CSTATE_SLA_NACK);” under the ov7670_get function. Would appreciate it if you can assist me with the troubleshooting.
    Thanks!
    Best Regards

    Reply
    1. desaster

      I spent a *lot* of time trying to get the i2c working using various microcontrollers, timings, etc. In the end however it wasn’t really the fault of the i2c code, but the way the camera was connected and powered.

      Like I wrote in the blog, my biggest obstacle was that I wasn’t providing a clock to the camera (non-FIFO verison that is). Without it, even i2c will not work. However there could be many more reasons, like the i2c connections themselves (pullup resistors).

      Maybe if you provided a schematic of your setup, I could see if there’s some obvious fault.

      Also, for me, it was very important to have a simpler i2c device to verify that my i2c code and the bus was working properly. I used a simple foolproof i2c eeprom for that.

      Reply
      1. JS

        Thank you for your prompt reply! I have tried figuring out for the past few days but to no avail.

        This is the link to the schematic of my setup: https://docs.google.com/document/d/1htmgQO7R7Ofnz7y8e_Dm-VtTWBKdlKjJUCyPvKx6RB8/edit?pli=1

        This is the eeprom I am using (24lc512) :
        http://sg.element14.com/microchip/24lc512-i-p/eeprom-serial-512k-24lc512-dip8/dp/9758020

        This is the camera which I am using(VGA OV7670):
        http://www.ebay.com/itm/-/230684824130?item=230684824130&ViewItem=#ht_6726wt_1053

        Thank you again for assisting with my troubleshooting. Look forward to your reply soon.

        Reply
        1. desaster

          Hey,

          I don’t see SIOC and SIOD from the camera connected to the lpc1769. They are the i2c bus that you were having problems with. Or did I misinterpret the drawing?

          Your eeprom seems to be connected, but is lacking pullup resistors? Also seems the SCL and SDA should be swapped around (but check this from the lpc1769 datasheet). Did you have your EEPROM working, though?

          Reply
  4. JS

    Thanks! you didnt misinterpret. I forgot to connect those pins! May I know where should SIOC and SIOD be connected to?

    What values should I put for my pull-up resistors? I would need to place pull up resistors for both SDA and SCL pins of the eeprom right?

    I think I connected the SCL and SDA properly but I drew it wrongly. Sorry about that! I am new to lpc1769, hence thank you for the patience.

    Thanks!

    Reply
    1. desaster

      I suggest you look up i2c bus on wikipedia for example to learn some basics about what it is about. In ov7670 you use it to modify settings of the camera, an on eeprom you use it to write and read data.

      Ov7670 calls the i2c bus “SCCB”.

      Your i2c bus should have a pull-up on both wires, and they can be something like 2.2k. I used 10k myself.

      i2c bus has two wires: clock and data.

      on eeprom: SCL = clock, SDA = data.
      on ov7670: SIOC = clock, SIOD = data.

      You can connect both these devices to the same i2c bus, and to the same connections in your lpc1769.

      Reply
      1. JS

        Heyy. Thanks for assisting me with the camera! Cam test is working fine now.

        For the python code, I installed python 2.7.3 and the dependencies as required. When I run the code, i was shown with this error.

        —————————————————————————————————————

        Traceback (most recent call last):
        File “C:UsersacerDesktopdesaster-ov7670test-14756aautilscamview.py”, line 148, in
        Application()
        File “C:UsersacerDesktopdesaster-ov7670test-14756aautilscamview.py”, line 108, in __init__
        self.serial = SerialPort(self.ov7670, 5, reactor, baudrate=921600)
        File “C:Python27libsite-packagestwistedinternet_win32serialport.py”, line 35, in __init__
        xonxoff=xonxoff, rtscts=rtscts)
        File “C:Python27libsite-packagesserialserialwin32.py”, line 30, in __init__
        SerialBase.__init__(self, *args, **kwargs)
        File “C:Python27libsite-packagesserialserialutil.py”, line 260, in __init__
        self.open()
        File “C:Python27libsite-packagesserialserialwin32.py”, line 56, in open
        raise SerialException(“could not open port %s: %s” % (self.portstr, ctypes.WinError()))
        SerialException: could not open port COM6: [Error 2] The system cannot find the file specified.
        >>>

        ————————————————————————————————————–

        Would appreciate if you can assist me with this error, perhaps letting me know where I have gone wrong. Appreciate your help so far! Thanks alot!!

        Reply
  5. geo

    Hi!

    I have followed the above entries and your correspondence with JS to fix up my camera. I have installed python and the various dependencies needed in your source code. However, I have experienced this even after reinstalling twisted and pyserial. Did you encounter any of this during your troubleshooting? The link has the image of the error after running the python code.

    https://docs.google.com/document/d/1Po1i0hg2q1ypGkwjbADxnX3686LGtpxnF9uCBeDVALk/edit

    I have installed the .egg and other packages from .exe files smoothly but just can’t get the python code that you’ve supplied to run. It would be good if you could shed some light on the error.

    Thanks for the help!

    Reply
      1. geo

        Hi there! Thanks alot for the help. Does it matter if I am using Windows 7 64bit version? Could that be the source of the problem?

        Reply
  6. haris

    hi. nice blog to see. i am using ov7690 with stm32f4. i have manage to read write register settings.
    i am using hardware sync.
    but the problem is with image data output. I am receiving continuously 0x02.
    what can be the problem? it may be clk polarity settings of vsync,hsync, pclk or what?
    thanks

    Reply
  7. haris

    there is dedicated data register in STM32F4 i.e DCMI_DR and dedicated pins for digital output DATA from camera.
    I can read and write register settings of camera.and SCCB works fine.

    I am continously transmitting the DCMI_DR register every after some micro seconds through USART to PC. (i know i would lost lot of data by this method and I have to use DMA… but the for checking purposes I am directly transmitting the DCMI_DR)

    I have checked by manually pull-up and pull-down the different data PINS at STM32F4 . and I got the correct results on my serial. and I got the change in run-time.

    but when I connect these PINS to data output of camera, it contnously gives 0x02 on my serial.

    may be i am setting the camera register incorrectly OR there is difference between clock polarity settings (vsync,hsync, pclk) of camera and STM32F4?

    even if am not setting the register correctly, i think there should be some DATA at least variable DATA on data output PORT of the camera. not only constant 0x02.

    => stm32F4 has bulit-in FIFO.
    => (if i would use DMA ) DMA picks up data from DCMI_DR in STM32F4.

    thanks. help required.

    if u say i can send main routines of my code.

    Reply
  8. JS

    Hey thanks for the reply. COM6 is not the port I want to read the values from. Instead, its COM4. Hence, i change your camview.py code at line 108 to self.serial = SerialPort(self.ov7670, 3, reactor, baudrate=921600) as I realised that it will always +1 to the number i put in the line of the code and open the corresponding port. Eg: I put in 3 it will open port 4 which is (3+1). Having successfully open my desired port of which the uart serial usb cable is connected to, I am however still unable to get any image. I am not sure what I miss out, Perhaps asking python to read another port requires more changes to the code than just that line? All it shows is a blank/black pygame screen. You can go to this link to view the pictorial image of what I see.

    https://docs.google.com/document/d/1htmgQO7R7Ofnz7y8e_Dm-VtTWBKdlKjJUCyPvKx6RB8/edit?pli=1

    I am not sure what could be the problem now, as I have gotten the camtest successful stage as seen in the pic in the link above.

    For my uart transfer, I am using a FT232R chip of which I only two connections beside the usb cable to my laptop: I connect TXD of the chip to RXD0/P0.3/(J6-22) of the lpc1769 and RXD of the chip to TXD0/P0.2/(J6-21) of the lpc1769.

    I got a feeling my uart0 is not transmitting, hence receiving a blank image. Maybe I miss out on something. Appreciate your help if you can help me spot any obvious errors or let me know what might have gone wrong.

    Thank you so much!

    Reply
    1. desaster

      Not sure if it matters, but I ran my lpc1769 at 120mhz, while yours seems to be running at 100mhz. Search google for how to change the clock speed, IIRC it requires a small change to system_LPC17xx.c.

      Anyways, before even touching the python script, you should verify that the UART communication is working properly by using a serial console manually. Study main.c to learn how the commands work (getimage, getline, regr, regw).

      Also, it sounds wrong that your serial chip only has two connections – GND should be connected too!

      Reply
      1. JS

        Heyy thanks for all your help!! I managed to get the image on the pygame display and I have been studying the source code and lpc1769 for the past week to help me understand more about how it works. My camera is getting a new image every 2-3 seconds and I was wondering if you are able to advise if there is any way to increase the frame rate to lets say maybe to the extent of like when you are watching a video/less than 1second per frame? Just wondering if that is possible as I am with limited knowledge and was thinking about whether this is possible or not. Thanks again!!

        Reply
        1. desaster

          Well, I increased the FPS by bumping up the UART speed, however at some point you are bound to hit a limit on that.

          Generally UART is not the best way to transfer video, though, and I’ve only used it for testing purposes. For a real life application you’d want to use some high speed interface.

          Reply
  9. Peter

    Hi. nice blog to see. I am using OV7670 moudle(AL422 FIFO witj LD0) with Arduino Mega2560

    I just want my camera taken photo and save in registers

    I search from net from very long time I can’t found the ans i wanted

    Could you help me to solve my problem

    THX

    Reply
    1. desaster

      Hi Peter,

      I now have a FIFO version too, but unfortunately I haven’t gotten around to trying it yet.

      Maybe sometime in future I will try it and write a small blog entry about it.. these cameras seem to have gotten really popular lately.

      Reply
    1. desaster

      For camera like mine, I don’t think any atmega will run fast enough to be able to process the signals. However, I’m not sure how slow the camera clock can be driven..

      Reply
  10. ycmoh

    Hi. I’m YC and I’m from spain.

    I was inspired by your blog and I went ahead to purchase one from ebay to try it out with the lpc1769 that I have lying around. Fortunately (unfortunately), the version I bought came with the FIFO. (Whats the difference btw the FIFO and non-FIFO version? What is the FIFO used for??????????)

    I shall try to figure it out too. Looking forward to your future post!

    Reply
  11. Peter

    hi there did you found the way to conquer the question ,yet

    if you found the way to solved the question please must be that us know

    I really desperate to konw

    THX for the helping

    I will very greatful

    Reply
  12. Pingback: OV7670-FIFO + MSP430 Launchpad | qrfnfgre'f oybt

  13. tml

    Hello, I have used your project on my lpc1769 board (no eeprom).However, when I run the program it stops at
    while (I2CEngine () == I2CSTATE_SLA_NACK). .I did follow the instructions as above add pull-up resistors on but it still fails?
    This error is due to non-eeprom?
    Please help me solve this problem
    thanks.

    Reply
    1. desaster

      Hi, the EEPROM I only used as a certainly working i2c example, to rule out other problems with the camera module. Sounds like this would be a great idea in your case as well :)

      Unfortunately without a full schematic or illustration of your setup, it’s hard for me to make guesses on what might be wrong…

      Reply
  14. tml

    Thank you for your reply
    I used this camera ov7670 module .
    http://banlinhkien.vn/goods-1091-camera-ov7670-no-fifo.html.
    The schematic of my setup similar to your project I just change the uart speed = 115200 and
    it is up FLASH MAGIC TERMINAL to check when I checked it out up “Initializing ov7670 … reset …settings ” then it stops
    it stops at ” while (I2CMasterState < 0x100)" in I2CEngine.
    THANKS.

    Reply
  15. M. YILDIRIM

    Congrats :) It is a real annoying challenge to get this camera work. Actually I ruined a camera before communicating over I2C :) Your article is quite beneficial for those who are confronted by ov7670.

    Reply
  16. sharethl

    A question here, It seems those 8 data pins are not used?
    Only I2C communication?

    /* use these to check if pin is high */
    #define ST_D0 (LPC_GPIO2->FIOPIN & (1 <FIOPIN & (1 <FIOPIN & (1 <FIOPIN & (1 <FIOPIN & (1 <FIOPIN & (1 <FIOPIN & (1 <FIOPIN & (1 << 7))

    Reply
    1. desaster

      Those definitions may not be used in the code, but the data is certainly read from the GPIO2 port, but it’s done in one single command:

      qqvgaframe1[i] = LPC_GPIO2->FIOPIN;

      Since qqvgaframe1 is uint8_t (8 bits), only the first 8 pins from FIOPIN will be saved. This is faster than individually reading each pin, and speed is quite important when trying to keep up with the frames.

      That said, there may more ways to optimize the reading part, but I didn’t tweak the code much after I got the basic functionality working.

      Reply
  17. sharethl

    Cannot edit my comment, is I2C used to setup camera, DataPins for image?
    Why not just use I2C or data pins?

    Reply
  18. Karl

    Could you please help me wiring the OV7670 Camera Module to my MCU ?
    By now, I have taken the information from your text
    http://s14.directupload.net/images/130204/xjwrrge2.png
    I have no idea where (on which Pin of the OV7670) *the date arrives* ?
    Does everything work with 3.3 volts, because the V_in pin is labelled 3v3 or is there an other voltage to supply to the data pins?

    Reply
      1. karl

        Hello, thank you for the reply.
        However, I think my MCU (ATmega328) is not able to create such a high frequency clock (10MHz, T=100ns)
        For the clock I am thinking of some procedure like
        – set high
        – wait 100ns
        – set low
        – wait 100ns

        There is XCLK (system clock input) ,CLK , and PCLK – are the frequencies the same?
        How can I create such a high frequency clock signal? Datasheet page 6 states 10MHz minimum!

        Reply
        1. desaster

          On an AVR, I would probably look into using the CKOUT fuse for generating a fast clock.

          However, with a low speed MCU like an atmega, I think you might have some bigger problems.

          I was using a pretty powerful MCU at 120mhz, and still keeping up with the data wasn’t easy.

          Another issue, where will you store the image data? AFAIK atmegas don’t have a whole lot of memory.

          If I were you, I would probably try using one of the FIFO equipped versions of the ov7670 module instead. I’ve written another blog entry on those here: http://www.rpg.fi/desaster/blog/2012/10/20/ov7670-fifo-msp430-launchpad/

          Reply
      2. karl

        Thank you for your help!
        ok, I haven’t thought about that issue yet
        now I found a way: Using assembler NOP (=> 1 clock cycle on 16mhz = 6.25ns) So I would repeat that 16 times (16*6.25ns=100ns)
        Maybe it isn’t even possible with an AVR because of small buffer and relatively low clock speed.
        And how do I TRIGGER the camera, I think it is either supplying voltage to some trigger pin or sending some code on an input.

        Reply
  19. ALfian Fortrandyka

    hello, i need help
    how configuration ATmega128 microcontroller OV7670 to be displayed to the PC
    Do you have his AVR coding?
    please help me

    Reply
  20. Pingback: OV7670-FIFO + MSP430 Launchpad | desaster's blog

  21. ashkan

    hi. tnx for the great pst.
    for some time i am trying to communicate with ov7670+FIFO using lpc1768.
    I can write 0x80 to register 0x12(to reset the registers) but after that i can’t read any registers.
    my code for reading registers:

    u8 rdOV7660Reg(u8 regID, u8 *regDat)
    {
    startSCCB();
    if(0==SCCBwriteByte(0x42))
    {
    stopSCCB();
    return(0);
    }
    DelaySCCB(100);
    if(0==SCCBwriteByte(regID))
    {
    stopSCCB();
    return(0);
    }
    stopSCCB();

    DelaySCCB(300);

    startSCCB();
    if(0==SCCBwriteByte(0x43))
    {
    stopSCCB();
    return(0);
    }
    DelaySCCB(100);
    *regDat=SCCBreadByte();
    noAck();
    stopSCCB();
    return(1);
    }

    DelaySCCB generate 1us delay.
    i have pull up SCL but not SDA (because it is pull-up on the pcb )

    Reply
  22. Sherry

    Hi, i just got the ov7670 camera module without a FIFO. I also have an eprom M27C512. how do i connect these to the arduino (arduino uno rev3)? and could i just connect the camera pins to a 3g shield (SIM5216E ITEAD 3G shield)?
    i want to be able to stream video using the camera. How do i go about connecting and writing code to achieve this.
    I have never worked with this camera before and am having a hard time figuring it out.How do i connect the camera, eprom and arduino together to give me an image or video?
    please help.

    Reply
  23. EMMA

    hi.in this source i changed format to QVGA using regiter COM7 and accordingly some numbers in lpc code,but my image is not ever clear and i am sure that the changes are true.do have any idea about the problem?
    tnx u a lot…

    Reply
  24. tincho andrade

    Hi desaster!, I am a last year student of Technical High School from Argentina, and I need to make a final project.

    I have a OV7670 camera without FIFO. In order to test it, before try to get an image, I wish to read valid pixel data and print them trough the serial port.

    I have connected output pins d0 to d7, href, vsync, to digital input pines of ARDUINO MEGA 2560 board, and the camera is powered by 3.3 V from ARDUINO board.

    For clock signals (XCLK) I use a 24.8 MHz external oscillator which is powered with 5 V from ARDUINO board.

    I have written a program to read data when vsync changes from low to high but I have get only zeroes.

    I assume that camera is OK because when I read d0-d7 pines directly I see that bytes change their values under illumination changes

    I need some help to control this camera, if you know any way to view images (don’t care the format, I’m not changing registers, I use the default configuration) only with arduino mega board and a PC it will be great, and useful to my project.

    Thank you for help me,

    Martín

    This is the program:

    #define href 21
    #define vsync 20
    #define d0 24
    #define d1 25
    #define d2 26
    #define d3 27
    #define d4 28
    #define d5 29
    #define d6 30
    #define d7 31

    void setup(){

    pinMode(href, INPUT);
    pinMode(vsync, INPUT);

    Serial.begin(9600);

    pinMode(d0, INPUT);
    pinMode(d1, INPUT);
    pinMode(d2, INPUT);
    pinMode(d3, INPUT);
    pinMode(d4, INPUT);
    pinMode(d5, INPUT);
    pinMode(d6, INPUT);
    pinMode(d7, INPUT);

    attachInterrupt (3, empiezabarrer, RISING);

    }

    void empiezabarrer(){

    // read 8 bits (1 byte) and print to serial

    int Bit1;
    int Bit2;
    int Bit3;
    int Bit4;
    int Bit5;
    int Bit6;
    int Bit7;
    int Bit8;

    Bit1= digitalRead(d0);
    Bit2= digitalRead(d1);
    Bit3= digitalRead(d2);
    Bit4= digitalRead(d3);
    Bit5= digitalRead(d4);
    Bit6= digitalRead(d5);
    Bit7= digitalRead(d6);
    Bit8= digitalRead(d7);

    Serial.print(Bit1);
    Serial.print(Bit2);
    Serial.print(Bit3);
    Serial.print(Bit4);
    Serial.print(Bit5);
    Serial.print(Bit6);
    Serial.print(Bit7);
    Serial.print(Bit8);
    Serial.println(” “);

    //detachInterrupt(3);

    }

    void loop(){

    // the flowing lines captures d0 to d7 directly (all the time)

    /*
    int Bit1;
    int Bit2;
    int Bit3;
    int Bit4;
    int Bit5;
    int Bit6;
    int Bit7;
    int Bit8;

    Bit1= digitalRead(d0);
    Bit2= digitalRead(d1);
    Bit3= digitalRead(d2);
    Bit4= digitalRead(d3);
    Bit5= digitalRead(d4);
    Bit6= digitalRead(d5);
    Bit7= digitalRead(d6);
    Bit8= digitalRead(d7);

    Serial.print(Bit1);
    Serial.print(Bit2);
    Serial.print(Bit3);
    Serial.print(Bit4);
    Serial.print(Bit5);
    Serial.print(Bit6);
    Serial.print(Bit7);
    Serial.print(Bit8);
    Serial.println(” “);
    */
    }

    PD: i need send pictures (1fps or more) via RF (modules nrf24l01). and print it to PC. im running out of time to do mi project. thanks!!!!!!

    Reply
  25. samer

    Olá meu amigo tudo bem?
    muito bom seu projeto!
    eu moro no Brasil e estou tentando fazer um projeto que usa uma câmera USB para liga-la ao PC
    e essa câmera identifica características de rosto, e é movida por servos, na horizontal e vertical.
    ainda sou inexperiente em Arduíno! esse projeto é para apresentar dia 10 de fevereiro de 2014.
    por favor poderia me ajudar?
    muito obrigado!
    me ajudando, darei seu nome e o cite seu para alunos conferirem, filmarei e enviarei para você.

    Reply
  26. samer

    Hello my friend how are you?
    very good your project!
    I live in Brazil and I’m trying to do a project that uses a USB camera to connect it to your PC
    and identifies features of this camera face, and is moved by servants, both horizontally and vertically.
    ‘m still inexperienced in Arduino! this project is to present the 10th February 2014.
    please help me?
    thank you!
    helping me, I will give your name and quote your students to confer, will film and send to you.

    Reply
  27. bruce

    Hello,
    Is there any tutorial witch can help me to make connection Arduino and OV6770 camera and the ode?.
    Thank You very much..

    Reply
  28. anhdung88

    Hi Desaster,
    I’ve seen your code here
    void ov7670_readframe(void)
    {
    while (ST_VSYNC); /* wait for the old frame to end */
    while (!ST_VSYNC); /* wait for a new frame to start */

    uint32_t i = 0;

    while (ST_VSYNC) {
    //if (y >= (QQVGA_HEIGHT / 2)) break;
    while (ST_VSYNC && !ST_HREF); /* wait for a line to start */
    if (!ST_VSYNC) break; /* line didn’t start, but frame ended */
    while (ST_HREF) { /* wait for a line to end */
    /* first byte */
    while (!ST_PCLK); /* wait for clock to go high */
    /* no time to do anything fancy here! */
    /* this grabs the first 8 bits, rest gets chopped off */
    qqvgaframe1[i] = LPC_GPIO2->FIOPIN;
    while (ST_PCLK); /* wait for clock to go back low */

    /* second byte */
    while (!ST_PCLK); /* wait for clock to go high */
    qqvgaframe2[i] = LPC_GPIO2->FIOPIN;
    while (ST_PCLK); /* wait for clock to go back low */
    i ++;
    }
    }
    }
    While comparing this code with OV7670 VGA timing, I’ve bothered that the value of HREF when logic state changes, what value of variable ST_HREF is. When a line not starts, the HREF signal is low and so the ST_HREF will be 1 and when a line does start, the HREF signal is high-active and ST_HREF will be 0. So that, does your above code have some troubles with ST_HREF?
    PS: I deducts this fact of ST_HREF while comparing other signals with corresponding variables in your same code above.

    Reply
    1. desaster

      Hi,

      No, I didn’t have problems with the code, I think it should be functional.

      Unfortunately It’s been a long time since I did this, so I don’t remember much of the details. Having taken a quick look at the datasheet, I dont’ see a problem here.

      However, it’s of course best not to trust my code, and start from scratch by experimenting with the signals.

      Reply
      1. anhdung88

        Okay desaster,
        Could you tell me which logic state corresponds to which bit value? (I mean that when VSYNC is logic high/low, what value of ST_VSYNC and the same question with HREF,PCLK).
        PS: I’ve search all the datasheet of the LPC1769 but dont see anywhere amends to this fact.

        Reply
          1. anhdung88

            Thanks desaster,
            So in your above code, while reading a frame, VSYNC is high, right? But in the OV7670 datasheet, I see that while data is valid, the VSYNC is low and so that there is something wrong in the datasheet or I am misunderstanding something?
            Here is my datasheet http://www.voti.nl/docs/OV7670.pdf.
            PS: I’m a newbie so sorry for some ugly questions. Thank you so much for answering.

    2. murgesh

      i am using STm32F429 DISC0 eval controller board interfacing with ov7670
      in this controller i have LQFP144 pin package so i am stuck in pin configuration can anyone guide me how to do in this controller i am new bee in this controller

      still now i got std peripheral lib for my “KEIL MDK V5.18A” and i am stuck in pin configuration for DCMI DMA SDRAM

      can you help me out resolve this issue?

      thank you!!

      murugesh@emelitetechsolutions.in

      Reply
  29. Alejandro

    I am very happy for the information of your project. I already have the captured image but I do not represent my pc. Can you help?
    Thanks

    Reply
  30. parsa

    Hi desaster, I use your code for ov7670 without FIFO and lpc1768 but I have problem with I2CStart( void )
    this function becomes timeout and stop the progarm. The problem is in startup file.
    I need your advice.
    thanks

    Reply
  31. Sandesh Mukartihal

    I am interfacing OV2640 module to MSP30 LaunchPad.

    I have got the module from:
    http://www.ledsee.com/index.php/new-products/ov2640-camera-module-detail

    I am trying to talk to module using SCCB interface but not receiving any response from the module. I am using 3.3V supply voltage and 3.3V SCL and SDA lines from the MSP430. the datasheet mentions these are 1.8V lines. Will this create any issue?

    When the module is not connected, the SCL and SDA lines are properly driven to 3.3V and 0V, but when the module is connected, some bits will make the SDA line latched up at 2.8V instead of 3.3V. any ideas? is this because I am using 3.3V SCL and SDA pull up lines?

    Reply
  32. pharoah als

    Did you happen to try any other external crystals? Your scope looked pretty decent @10mhz. I was wondering about using a 8 or 16mhz ext crystal, thoughts?

    Reply
  33. murgesh

    i am using STm32F429 DISC0 eval controller board interfacing with ov7670
    in this controller i have LQFP144 pin package so i am stuck in pin configuration can anyone guide me how to do in this controller i am new bee in this controller

    still now i got std peripheral lib for my “KEIL MDK V5.18A” and i am stuck in pin configuration for DCMI DMA SDRAM

    can you help me out resolve this issue?

    thank you!!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *