josh ingram

mas.863 how to make

camera, cmos style

this week i decided to use the cmos cameras. I am hoping to take advantage of this work for the idea i have with my final project, adjusting lamps based on the feedback of a camera.

before i get started I want to thank Moritz. he spent a lot of time working with me this week.

this week can be broken down into a few steps

datasheets back to top

so the first step was to dive into the datasheet and see what this little camera was capable of. After and little research and understanding how the camera receives and outputs data we decided to pair it up with the atmega168. it had enough pins and, hopefully, enough memory to support the camera.

the way the camera works is, basically, you give it a series of start up operations which include telling in it output formats, framerates, and auto focus settings for example. after you have given it all the required parameters. it will start streaming the data. the data is sent in horizontal rows where each color is sent as 2 bytes. the first byte contains 5 bit representation of red and the first 3 bits of a 6 bit representation of green. The second byte contains the next 3 green bits followed by a 5 bit representation of blue. so it is essentially 16 bit color when the output format is set to rgb, which is what i focused on.

schematic back to top

there was a lot to consider when deciding on port use for the atmega168. for one there in only 1 full port we were able to use for data capture from the camera. problem is that port contains the hardware serial communication pins. We decided, for now to do serial communication in software. I have a strong feeling thought that we will change the camera data to come in on 2 partial ports and and then 'or' the data into a single register. but for now we are still reading it all on a single port. also there were a lot of other consideration we had to make, including using a 20mhz crystal, using an external bootloader, where the camera inputs would come from, and wiring in a few LEDs for debugging and visual checks. the other thing we had to do was feed the camera with 2 separate power sources. one 2.8 volts and one 1.5volts. we used a couple opamps wired as followers after the voltage dividers to guarantee consistent power.

board design back to top

after putting all of these components into the schematic, we realized based on a few of the connection that one or two zero ohm resistors would not be enough. So we decided to for go the jumpers and just do a 2 layer board. we did a few things to ensure this would work. one created a ground plane and routed all ground to the back. two, we fattened all routes on the back it ensure success with some margin of error from front to back. and last, we made the vias very large to make it easy to solder them together afterwards. we had a few tricks for milling as well. first, we used a 1/100" bit because the pads on the chips were very close together. using the smaller bit we were able to get into all the small crevasses. and second, we knew that flipping the board would only have alignment error in one axis so we laid the vias out in a way that allowed us to manually modify the traces to increase the pad dimension in that axis. if you notice the pads on the back of the board, they are rectangular instead of square.

programming back to top

we decided to do the programming in C. i install avr studio 5 on my machine which integrates directly into visual studio. it is amazing nice to use. within a few minutes we were able to verify the board was working. as well as set and adjust the clock speed. we have essentially done as much as possible without actually having the camera. I hope to have the camera Monday to add it to the board and finish programming it. crossing my fingers.