Pages: 1 ... 24 25 [26] 27 28   Go Down
Author Topic: ov7670 with both arduino uno and now mega  (Read 77025 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's on my hardrive. The code is very messy. I actually posted an earlier version in 2013 you can find it on the first page. I was planning on making a new one but have not got to it yet.
Logged

Melbourne. Australia
Offline Offline
Edison Member
*
Karma: 30
Posts: 1138
Freelance software and hardware development based in Melbourne Australia
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

messy code would be better than none, but I understand why you've not released it.
It takes me ages to tidy up code that I want to make public ;-)
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I already posted a similar version on page one but here is my up to date code.
http://pastebin.com/f2pShvZB
The issue is that I wrote a bulk of the code almost two years ago. Back then I was not as good of a programmer. I just hacked on some recent changes as I anticipated this to be a quick way to test stuff for personal use only. The program is now posix only (such as linux and bsd).
I am planning to write a new application that grabs frames but is cleaner both code wise and user interface wise. It will also let you edit registers from pc.
« Last Edit: July 11, 2014, 09:32:42 pm by Mr_arduino » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very sorry to double post but this is important.
Previously I have told you all that you would need either external spi ram or the fifo version to get data. For the most part that is true.
Today I decided to get out the 0v7670 module (I admit I haven't done anything with it for a while) and write some code that only uses only the ov7670 and the buffer for 5v to 3.3v conversion.
What the code does is it will send the data from the ov7670 to uart and you can receive it using your pc.
https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno
It also generates a 8mhz clock on pin 11 that you get from 5v to 3.3v and plug into the ov7670.
I called it no-ram but I just mean external ram.
This should be a simpler example of the ov7670 using newer register functions.
Tell me what you think. One thing I think people seem to be forgetting is that I am always open to pull requests.

This looks like a great place to start for me i have both the fifo and non fifo. I am using a resistor voltage divider for pin 11
5v<-----------Arduino
220r
3.3v---------->Pin 11
220r
220r
GND<---------Arduino
will let you know how i go, I dont have much coding experience but can muddle my way though
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright good to hear that my new program seems more viable for people.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you use OV7670 grabber usb v1.5?
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No. I just looked it up and I have not used it. The arduino is not true usb, it just uses microcontroller programmed to do serial<->usb.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,
Firstly I'd like to thank you all since, having read the whole 26 pages, I have learnt quite a lot.
Nevertheless, I still appear to be having a tough time at getting my OV7670 without FIFO running on my Arduino Mega2560.
Here ares my issues that hope someone will be able to guide me through :

1) I have read that a buffer is needed in order to lower the voltage of the pin that is to be wired to XCLK. Can't we use a resistor ?
(I might have not understood what is the whole problem here therefore I would very much appreciate to have someone pointing me the direction a good explanation of the whole problem with regards to resistors use/pull up use/buffer telnet and use.)

2) I have spent a lot of time trying to communicate with registers without the XCLK wired or any resistors wired to the  SCCB related pins. It was way before I encountered this topic... Is it probable for my module to be damaged ? if yes, how can I assess it ?

3) During my journey to communication with registers, the only thing that would appears weird was that during the 2-phase read transmission cycle, more especially the first phase of it : the writing of 0x43, I read the last bit as a logical 0 and thus encountered any expected error : here's "my"(I've mostly concatenate some code that I've encountered, mostly here : https://gist.github.com/freespace/2585921 ) code :
https://gist.github.com/Near32/225cdca19ad55c6d8306
See Line 318.

(I've done the same with Wire (with and without the internal pull-up resistors of the arduino....) and I could read things that was pretty weird.....)

I hope that someone will be able to help me. I can already thank you for having made it through this post ^^" !
Best Regards,
Near32
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To answer your questions.
1. You could try a voltage resistor divider. I have not tested it myself but it won't hurt to try. Also you need pulls ups for i2c. The resistor value does matter. I have found 10k to work just fine, I also remember testing 4.7k and that worked fine too. However using a resistor that has too much or too little does not work for example when I tried a 1k it would not work. The two resistors will be a pull  up resistor to 3.3v. The way this works is you plug in the i2c pins to 3.3v using the resistor and then plug that into the ov7670 all wired up together. Another thing is to disable the internal pull up resistors, they are off by default however the arduino wiring library enables them please follow my instructions on how to disable the internal pull up resistors if using the wiring library.
2. When I first got the ov7670 I also made that mistake and it works just fine. I do not think this will cause any damage I am more concerned about the internal pullup resistors causing damage however when I first got the module (if I remember right) I did not disable the internal pull resistors and the ov7670 still works but when enabled I do not remember having any luck with writing and reading resistors. However just because I got lucky does not mean you will.
3. Why are you bitbanging? Use the hardware i2c peripheral. Try my code, it uses hardware i2c and it works fine for me. Also the ov7670's i2c address is 0x42 the LSB (bit 0) is set to 0 when writing and 1 when reading so yes you do use 0x43 to read. Also when using the wiring library you must specify the 7bit address so use 0x21.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Firstly, thank you for your answer smiley.

To answer your questions.
1. You could try a voltage resistor divider. I have not tested it myself but it won't hurt to try. Also you need pulls ups for i2c. The resistor value does matter. I have found 10k to work just fine, I also remember testing 4.7k and that worked fine too. However using a resistor that has too much or too little does not work for example when I tried a 1k it would not work. The two resistors will be a pull  up resistor to 3.3v. The way this works is you plug in the i2c pins to 3.3v using the resistor and then plug that into the ov7670 all wired up together. Another thing is to disable the internal pull up resistors, they are off by default however the arduino wiring library enables them please follow my instructions on how to disable the internal pull up resistors if using the wiring library.

Sure, I'll try using a voltage resistor divider if I manage to find the materials I need. I'll give feedback about that maybe at the end of this week...

2. When I first got the ov7670 I also made that mistake and it works just fine. I do not think this will cause any damage I am more concerned about the internal pullup resistors causing damage however when I first got the module (if I remember right) I did not disable the internal pull resistors and the ov7670 still works but when enabled I do not remember having any luck with writing and reading resistors. However just because I got lucky does not mean you will.

Thank you, I hope I will be lucky too then...


3. Why are you bitbanging? Use the hardware i2c peripheral. Try my code, it uses hardware i2c and it works fine for me. Also the ov7670's i2c address is 0x42 the LSB (bit 0) is set to 0 when writing and 1 when reading so yes you do use 0x43 to read. Also when using the wiring library you must specify the 7bit address so use 0x21.

The bitbanged implementation was the one that I understood at first and thus I thought I could give it a try.
I do want to try your code and using the hardware i2c peripheral but the fact is that I appear to be unsuccessfull in my quest to use the correct registers on the arduino MEGA2560 that I am using, or, I should put it that way : I am currently browsing the datasheet but the use of the hardware i2c peripheral and the associated registers is not as plain as a pikestaff...

I am currently waiting for resistors and other materials to arrive...
Thank you for your help, I'll give feedback if there is any progress.
Logged

Monte Colombo - Rn
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To all good afternoon and thanks for this nice thread.

I'm a newbie and I've buyed an OV7670 (buffered or not? don't know) and would like to use it with an arduino MEGA 2560.

Firstly I need only to save some image into a microSD regardless tips to speedup the fps.

I've quickly browsed  the pages of this thread and maybe I've lost some useful link, so I need a simple schematic (I would like to try with resistors to pull-up the pins and to match the 3,3 V level  inputs of OV7670) to connect the camera to arduino.

The code I've seen on github is C or C++ (objective C) : can I copy that code and paste into the editor of arduino IDE?

Thanks for replies.
Claudio.

 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Claudio :
I've quickly browsed  the pages of this thread and maybe I've lost some useful link, so I need a simple schematic (I would like to try with resistors to pull-up the pins and to match the 3,3 V level  inputs of OV7670) to connect the camera to arduino.

Firstly, you have to figuring out if your version is the fifo or the non-fifo one, otherwise the schematic might change.
The non-fifo version have 18 pins :

    D0..D7 - for data (pixel) connected to arduino digital pins as INPUT on arduino board
    XCLK - for camera clock connected to arduino digital pin as OUTPUT from arduino board : you have to generate a clock
(I am lost on this part : the documentation that I have found on oscillators/PWN/timers/interruptions is non-specific to the arduino MEGA2560 and haven't been able to replicate it....)
    PCLK - for pixel clock connected to arduino digital pin as INPUT on arduino board
    HREF - to define when a line starts / ends connected to arduino digital pin as INPUT on arduino board
    VSYCH - to define when a frame starts / ends connected to arduino digital pin as INPUT on 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
    SIOC - to communicate on the SCCB/i2c : the user, through the arduino, as to drive it in order to assert the data that are being written/read through SIOD : you have to connect it to a digital pin if you use a bitbanged implementation of SCCB/i2c or to the SCL pin of the MEGA2560 if you use the hardware i2c ; unless I am mistaken... Anyway, it's an OUTPUT.
    SIOD - to communicate on the SCCB/i2c : alternativaly, the user may drive in order to write (OUTPUT), or it's the OV7670 which drives it whenever there is a data that is being read.

If you happen to have the fifo version, you'll find a schematic here :
http://nicolasfley.fast-page.org/?page_id=35


The code I've seen on github is C or C++ (objective C) : can I copy that code and paste into the editor of arduino IDE?

The code you have seen is written in C, mostly, and you cannot copy/paste it directly into the arduino IDE editor.
You may want to consider this :
http://www.vascop.com/compiling-and-uploading-arduino-programs-without-the-ide.html
Nevertheless, you may copy/paste some parts directly into the arduino IDE editor but be careful since the code you may have seen deals with registers directly and it can be very tricky sometimes if you do not know what you're doing...

Good luck smiley-wink!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo,

I'm a nooby and need some help.

How must i wire the ov7670  to an UNO or MEGA?

And where can i find a code to test if the camera is wired properly (working).


Raduen
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello for all. I have camera CF7670 v3 (with FIFO). And I tried to connect it to my arduino uno board. But it seems that something is wrong.
Can you help me with this moment? I used next pins connection:

1.      3.3v    - 1. VCC
2.      GND -   2. GND
3.      A5   - 3. SCL (SIO_C)
4.      A4   - 4. SDA (SIO_D)
5.      D7   - 20. D7
6.      D6    - 19. D6
7.      D5   - 18. D5
8.      D4   - 17. D4
9.      A3   - 16. D3
10.      A2   - 15. D2
11.      A1   - 14. D1
12.      A0   - 13. D0
13.      D3 - 5. VSYNC
14.      GND - 12. GND
15.      D2   - 6. HREF
16.      D8   - 7. WEN
17.      D9   - 8. NC/XCLK
18.      D10   - 9. RRST
19.      D11   - 10. OE/CS
20.      D12   - 11. RCLK/WR
__________________________
for connecting SIO_C and SIO_D I used 10k resistor for each one.
Please tell me. Is it correct connection and do I use 10k resistors right ?

« Last Edit: August 17, 2014, 09:52:40 am by WASJA1991 » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am trying to get Arduino Uno with the OV7670 w/o FIFO to run https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno. I am sending data at 1mbs to the serial port, for vga I get 30720 bytes(taking out the "RDY") statement. I have also tried the other resolutions and get a consistent amount of bytes. Clock is on pin 11, running at 8 mhz, output voltage 3V (going thru a 74HC244..also tried 74LVC245). A4 (SDA) and A5 (SCL) have a 4.7kohm pullup resistor to 3.3V. I also removed the pullups in the twi library. I verified that PLCK has an output signal. All the rest of the connections look good. I am using Realterm to capture the serial data. It writes this data directly to a file. I have tried converting over a "useQvga" image like so:
ffmpeg -f rawvideo -s 320*240 -pix_fmt yuvj422p -i frame0.yuv -f image2 -vcodec png img.png
I get a green screen, nothing that looks like a picture image. I have also used a couple other utilities that I found, but they do not produce an image either. One of which converted the image into grayscale, looks similar to static on tv . So, I am not sure what I am doing wrong here. If anybody can provide some insight I would be interested. By the way, I also tried another camera, similar results.

Also, Mr Arduino, you posted below about your data-converter, I would like the windows binary if you could post it? I am having trouble getting the data-converter to compile on my win 7 machine. I think it is related to a problem with the libpng library. Perhaps your converter would help me produce a good image.

"Yes it is here https://github.com/ComputerNerd/RawCamera-data-converter one thing I was wondering should I release windows binaries with it or not? How many people here use windows here?

Thanks,

-diesel
« Last Edit: August 15, 2014, 12:19:13 am by diesel » Logged

Pages: 1 ... 24 25 [26] 27 28   Go Up
Jump to: