Cheap PIC Controlled Helmet Camera Using Sony LANC (Good for Extreme Sports)
Intro: 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
18 Comments
luckysdb 11 years ago
Asm = 13 kb
HEx = 24Kb
I download the Zip file, and with MPlab Ide Vers 8.89 i export .
Who can help me
rtaneja 12 years ago
In the code, when the 8 bytes have been processed, you check whether the camera is recording or not and after that you jump back to '_Start2'.
Isn't that wrong as the subroutine '_Start2' again checks which button is being pressed even though in between the program has already checked whether the button has been released or not....!!! I mean, we should not be pressing 'Stop' button multiple times to execute the command.....
Please let me know....
portreathbeach 12 years ago
rtaneja 12 years ago
portreathbeach 12 years ago
It was a long time ago when I made this. I used this website for reference
http://www.boehmel.de/lanc.htm
Basically, my program waits for the long gap. When it sees the first bit change of byte 0, the program waits 1/2 a bit length (then you know you are in the middle of the bit) it then reads it, waits a whole bit length and the reads again etc. etc.
To write on the LANC, you simply wait for the long gap, and when it sees the first bit, simply output your byte, bit at a time at the correct bit length.
If you download the .asm file you should be able to see how it works. I have documented nearly every line of code.
robot1398 12 years ago
etechtim 13 years ago
Coco Sapone 13 years ago
http://sites.google.com/site/telepicdata/
jpghiena 14 years ago
Thanks for your answer
moonstruckman 14 years ago
portreathbeach 14 years ago
Also I didn't want to always be looking down at the LEDs to check if I was recording, so using two buttons, I would be sure that when I press the record button, it would start recording. With 1 button, it would toggle start and stop.
Using 1 button would look neater I think.
Here are a couple of youtube links of a dangerous pathway we walked in 'El Chorro', Spain. Most of the footage of the second part was filmed with the head cam, but unfortunately youtube has removed the sound due to copyright infringements!
Part 1: http://www.youtube.com/watch?v=_PDOQkvvpIw
Part 2: http://www.youtube.com/watch?v=47YwybKu74Q
The quality of the camera is actually pretty good, but due to compression on youtube it doesn't look as good.
moonstruckman 14 years ago
alexfagundes 15 years ago
pau.cc 15 years ago
robhlee 15 years ago
portreathbeach 15 years ago
Dorkfish92 15 years ago
portreathbeach 15 years ago