OV7670 Camera + mbed LPC1768 over USB
The ethernet version is ready and you can find it in my new notebook page: HERE.
Last year I searched some camera module to connect to the mbed and finally I found on ebay this module: OV7670 Camera Module with FIFO AL422.
I searched some information and I found these interesting notebooks that given me a big help: Martin Smith notebook and Fuyuno Sakura notebook
This camera is based on a CMOS Sensor OV7670 made by Omnivision and a FIFO buffer AL422.
- Array Size: 640x480
- 8bit Output Format (YUV/ YCbCr 4:2:2/RGB565-555-444/RAW RGB Data)
- Serial Camera Control Bus (SCCB)
- Rolling shutter
- 3Mbit of DRAM
- Read/write cycle time: 20ns
There are two versions of this camera.
The difference is that in the model V2 the VSYNC from the OV7670 is connected directly to the AL422’s write reset (WRST).
The schematic is here: /media/uploads/edodm85/ov7670_fifo_sch_v2.pdf
In the back of my camera there is this code: CF7670C-V2.
|Name||OV7670 pin||MBED pin|
Note: you need a pull-up resistor on sda and scl.
|Name||OV7670 pin||MBED MASK: 0x7878000||MBED MASK: 0x78600C0|
|D0||13||P13 (p0.15)||P8 (p0.6)|
|D1||14||P14 (p0.16)||P7 (p0.7)|
|D2||15||P12 (p0.17)||P12 (p0.17)|
|D3||16||P11 (p0.18)||P11 (p0.18)|
|D4||17||P15 (p0.23)||P15 (p0.23)|
|D5||18||P16 (p0.24)||P16 (p0.24)|
|D6||19||P17 (p0.25)||P17 (p0.25)|
|D7||20||P18 (p0.26)||P18 (p0.26)|
This camera supports various formats, but I will comment only the three that I used:
- YUV 4:2:2
The YUV model defines a color space. The Y component determines the brightness of the color, while the U and V components determine the color itself (the chroma). Y ranges from 0 to 255 in digital formats, while U and V range from -128 to 127.
One neat aspect of YUV is that you can throw out the U and V components and get a grey-scale image.
In the YUV 4:2:2 format the U and V channels are shared between two consecutive pixels. Therefore two pixels are composed from 4 bytes, this means that in average each pixel is stored as 2 bytes.
- RGB 565
RGB Colorspace is one of the most common colorspaces used today. It is used for many uncompressed image formats and computer displays. In RGB, there are 3 channels, each one indicating how much of a given color the final color has. These channels indicate Redness (R channel), Blueness (B channel), and Greeness (G Channel). Combining these components allows us to make almost any color humans can see.
The RGB565 color format is composed by 5 bits for the red and blue value and 6 bits for the green value.
- RAW Bayer
This type of format doesn't have any image processing.
Test Code for mbed
I wrote a C# program that snap a image and send it to the pc.
You can download the program here: OV7670 Grabber USB V1.5
Is required Microsoft .NET Framework 3.5 or above.
First you need to set the correct COM Port (only the first time) and press the "Connect" button (1). You can reset the mbed with the "Reset ARM" button.
There is the possible to change the priority of the program to real time with the "Real Time" button.
Then you can select the type of image format (8bit black&white or 16bit RGB or 24bit RGB or RAW) (2), press the "INIT" button (3) for initialize the camera and in the end press the "SNAP" button (4) for SNAP a image.
In this version of the software there is a possibility to decide to save or not of the images grabbed with the checkbox "Save Image" (5).
- U6: Updated OV7670 Grabber USB to V1.5
- U5: Updated OV7670 Grabber USB
- U4: Fixed 640x480 resolution
- U3: Added RAW to RGB888 conversion
- U2: Added YUV422 to RGB888 conversion
- U1: Added 320x240 and 640x480 resolutions
45 comments on OV7670 Camera + mbed LPC1768 over USB:
Please log in to post comments.