Introduction: Cheap PIC Controlled Helmet Camera Using Sony LANC (Good for Extreme Sports)


This Instructable will show you how to make a cheap Helmet Camera which can be controlled via a remote so your main camera can stay safely in your ruck sack.

The controller can be attatched to one of the shoulder straps of you ruck sack, and will allow you to Record and Stop the camera as well as being able to switch the 'bullet' camera on and off also.

This is perfect for people who want to film extreme sports such as bmxing, snowboarding, skateboarding etc. from a first person perspective.

The picture below shows the bullet camera and remote controller along with the main camera adn battery pack.

Step 1: How It Works.


It is fairly simple to connect a small 'bullet' style camera to your camcorder and get the camcorder to film what the mini camera is 'seeing', but I wanted to be able to control the record and stop fuctions of the camcorder without taking out of my bag everytime.

After a little investigation, I found that Sony camera have a LANC connection on them which can be used to control the camera and also give information about the what the camera is doing. This is great, becasue when you remotely press the Record button, you can read the data from the LANC cable to find out if the camera is actually started recording, and have a record LED illuminate on your controller.

The mini camera cost only 15 pounds from ebay
The 2.5mm stero jack was about 1 pound
and the other bits and pieces were less than 5 pounds

So for about 20 pounds, you can have a a fully working, remote control helmet cam.


My controller is very simple. It has a Record button, a Stop button, a power switch for the mini cam and 3 LEDs. (Minicam power, Main camera power and a record indicator). This is all I needed for my project, but the source code I have supplied is pretty straight forward and can be adapted to allow you to control anything on the camera.


---
I have added another step, Step 4, it is an update that gives an indication of low battery and end of tape)
---


Pictures:

Picture 1 - The prototype (with 8 LEDs to help debug my program)
Picture 2 - A close up of the 'bullet' camera and controller

Step 2: The Circuit Diagram


The circuit is very basic.


- The PIC is powered directly from the LANC cable.

- The Minicam is powered from a 12 volt battery pack via a switch

- There are 2 push buttons for Record and Stop

- 3 LEDs are used to show you the status of the camera


PIC connections:

RA0 - LANC from the camera
RB7 - Record LED
RB4 - Record button
RB5 - Stop button


(Please note, Step 4 is an update to this circuit, the power LED is connected to RA5 and there is a different source code)

Step 3: What Is LANC and How Does the Program Work?


If you visit this link, it will tell you how the Sony LANC protocol works, and all the commands and camera data available on the LANC protocol:

http://www.boehmel.de/lanc.htm

As you can see, you can get a lot of information from the camera as well as controlling every function of the camera via the LANC communication port.

My code is very basic and the .asm file can be loaded into MPLAB (free from Micochip.com) and programmed using the PicKit2 quite easily.

How the code works:

If you download the source code, it is documented all the way through telling you what is happening, but I'll give a brief expanation here also.

There are 8 bytes on the LANC port every 20ms (16,6ms for NTSC). Each byte has a Start Bit followed by 8 bits, each at a length of 104uS. There is a gap of about 200uS - 400uS between bytes. After all 8 bytes have 'appeared' on the LANC line, there is a long gap (5 - 8 ms) where the LANC line is 'held' high, and then the same 8 bytes 'appear' again.

- When the program starts, it keeps checking the LANC input until it 'sees' it high for a period longer than 1000uS, this means that we are in the gap between the 8th byte and the first byte.

- Next the program waits to see the Start Bit (logic 0) on the line. When this happens the program waits for 52uS (half a bit length) and checks again to make sure there is still a logic 0 on the LANC line. If so, we know we have a valid Start Bit and are ready to read the byte.

-We now wait for 104uS (the length of 1 bit), so we will be right in the middle of the next bit on the LANC line. We read this bit, wait 104uS and read again. This continues for all 8 bits. We now have Byte 0.

-The program then waits for the next Start Bit and carries out the same task to get Byte 1, 2, 3, 4, 5, 6 and 7.

Byte 4 is the one I use in the program to get the information about the record status of the camera, but as you can see in the link I provided, there is loads of information available!

Right, that is the reading the LANC line discussed, what about writing to it to control the camera?

- When a button is pressed, 2 registers are loaded with the bytes needed to carry out the specific operation and a register called 'Sender' is loaded with the number 5 (I'll explain why later). When the program gets to the 'ready to read the bytes' part, if the register 'Sender' is not 0 it changes the RA0 pin to an output and starts outputing the first byte. Then it looks for the next Start bit and outputs the next byte. The register 'Sender' is decremented by 1 and RA0 is changed back to an input to read the last 6 bytes.

The reason the register 'Sender' is used is because for the camera to accept a command, it needs to see the command for a few cycles. Some sites say only 3 are necessary, but as 1 cycle only takes 20ms, sending it 5 times (to be on the safe side) only takes 100ms to complete.

I hope this brief Instructable makes sense and you are able to make your own DIY helmet cams. Feel free adapt my code to suit your needs, but please credit me for the code if you publish it anywhere else.

Step 4: Update....


I updated the program in the PIC to flash the power LED when the battery on the main camera is low and to flash the record LED if the tape is at the end.

I have added a newer wiring diagram and source code.

The only difference in the wiring diagram is that the Status LED (was power led) is now connected to RA5 instead of +5v