RPi Projects/serialJpegCam

From eLinux.org
< RPi Projects
Revision as of 15:07, 16 July 2012 by Dirkx (Talk | contribs) (Wiring things up)

Jump to: navigation, search

Serial JPEG camera (TTL, µCAM)

This project is about attaching the "Serial JPEG µCAM" (UK) to the GPIO pins and take pictures on command.

<img1>

Requirements

You will need the following:

  • A Raspberry PI, any model
  • A µCAM (see above). Ideally one which comes with the connector and wires already pre-soldered. Most do.
  • A 26pin IDC (female) socket that fits onto the GPIO connector of your Pi. ({http://uk.rs-online.com/web/p/headers-pcb-receptacles/6935353/%7CRS} or any electronics supplier).
  • Some flat pliers or, better a small vice.
  • A recent raspberry linux SD images.

About the camera

Consult the [1] for full details - but the short of it is that the camera is connected to your Pi by a '3.3v TTL serial connection'. One talks to the camera using a simple serial command protocol. Such as 'get started', 'measure the light', 'take an image NOW' and ultimately 'give me the image'. The camera (mostly) expects a simple master/slave model. Where the Pi is the master and the camera the slave. The master then gives commands and the slave reacts with things such as 'Ok, done that', 'Error' or 'here is what you asked for'.

Serial Connections

Serial connections are relatively simple affairs. They consists of two wires; one which goes from the Pi to the camera. The Pi then 'transmits (Yx)' on this wire to the camera its receive wire 'Rx'. And a second wire going from the camera to the Pi where the Camera Transmits and the receiver listens. The only issue is the voltage.

There are various voltages in common use: from 15 volt (the old RS232) all the way down to the more modern 5 and 3.3 volt digital. Your Pi supports 3.3 volt digital TTL. As does above camera (it also supports 5 volt; but we won't be using that).

<img2>

Wiring things up

We need to wire up 4 things:

  • The Tx pin of the GPIO to the RX wire of the camera.
  • The Rx wire of the GPIO to the TX wire of the camera.
  • The ground of the Pi to the ground of the camera (as otherwise above Tx and Rx signals would not have any common ground).
  • And, as the camera needs power, we need to wire the 3.3volt wire up to the 3.3volt of the PI.

We can find the various pins of the GPIO socket in the documentation of the PI. On the {http://elinux.org/Rpi_Low-level_peripherals%7Cdetailed} documentation page you will find this image:

!http://elinux.org/images/2/2a/GPIOs.png!

and what we now need to find are the 4 pins:

pin function
8 Tx - serial transmission to the camera
10 Rx - serial information from camera to PI
6 GND - 0 volt, or common ground
1 3.3 volt power

Now we do the same for the camera. Page 5 and 6 of the {http://www.coolcomponents.co.uk/catalog/camera-module-serial-jpeg-p-369.html%7Cdatasheet} tell you that on the camera the wiring is as follows:

function
5 Rx - serial information inbound from the PI
4 Tx - serial transmission outbound back to the Pi
3 GND - 0 volt, or common ground
2 3.3 volt power

So combing this we get the wiring diagram.

PI Camera function
8 5 Pi to Camera
10 4 Camera to PI
6 3 GND - 0 volt, or common ground
1 2 3.3 volt power

<img 3>

The next step is to wire this up on the IDC connector. There are some good video's on the web on how to do {http://wiki.makerbot.com/stepstruder-mk6-electronics-assembly%7Cthis} or {http://mechatronics.mech.northwestern.edu/stack.htm%7Cthat}.

The connector comes in 3 parts. We'll start with the connector itself and the bit which clicks straight on top of it - with the 26 grooves and the tiny slots for the metal knifes of the connector. Leave the smooth wire-tensioning loop for now.

The numbering is from the small triangle; the notch or groove at that side is number 1; the next one 2 until you hit 26.

In our case we'll be skipping a few of the holes as shown below in the photograph. So at the far end (where the notch is) we have the first wire (to pin 2 of the camera, the VCC wire). We then skip 4 notches until we are at position 6. There we insert the ground wire (to pin 3 of the camera). We then skip another notch and insert the serial transmit wire from Pi to Camera (pin 5 on the camera, notch 8 on the connector). And we then skip one more notch for the last cable, pin 5 on the camera to notch 10 on the GPI connector.

If you are doing this for the first time - it is a good idea to use a pencil or similar to make a small marking on the strip with the notches at position 1, 6, 8 and 10. And check and double check that you got those at the right place. Counting down from what you think is position 26 on the far end is a good way to do this.

You may want to make a small diagram on a piece of paper with the colours of the wire on it. That helps in the next step.

Once you've marked things - you gently click the small strip with the notches on top of the connector. But do *NOT* press them together. They should click once - but not more (if you press to hard - they'll click twice and you will have to use a small screwdriver or needed to dis-assemble them). You should now have a small grove between the connector and the top strip.

Gently insert the first wire (pin 2 on the camera, pin 1 on the GPIO connector) in the 1st slot of the GPIO connector; the one all the way to wards the triangle. It should come out on the other side; still in groove 1. If you cannot push it through - loosen the strip a bit. Once inserted you'll find it will stay in place thanks to the small metal knives. Check and double check it is exactly in the first grove (and not in the second one or diagonal).

Continue doing this for the other 3 wires. The end result should look like

<img 5>

Once done - check things a final time and squeeze the two halves together 'hand tight'. You will probably find that the thing does not properly snap together. This is good - as this gives you the all important chance to check it one final time. If things are wrong - gently pry the connector loose and try again. If the wire is damaged; cut the wire(s) and try again.

If things are right - then use a small vice or some pliers to really 'click' the connector together. Once that is done - loop the cable back and put the tension-relief bar over top. This will generally also lock the strips in place.

If you have a multi-meter - you can now check your wires; simply insert a thin wire or needed into pin 1, 6, 8 and 10 and check where they connect to. It is easy to get pin 1 and 2 confused; so keep checking where the triangle is. Consider putting a bit of red inkt on it.

The final assembly should look like

<img 6>

== Connecting it to the PI

Next up - ensure the pi is unplugged and insert the connector. Make sure your pin one (the triangle) is next to the P1 and notch marking near the edge of the board.

If you have a multi-meter you can check your wiring a final time.

== Software

Download the zip file from