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

Picture of 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.

Picture of 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

Picture of 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....

Picture of 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


Comments

JonnyMac made it! (author)2014-04-13

I just developed a LANC driver for the Parallax Propeller which has the ability to write commands as well as read back the stream and data from it. The driver can also detect a loss of signal (camera sleeping or unplugged) and can wake a sleeping camera with the standard interface.

Demo code here:
http://forums.parallax.com/showthread.php/148752-L...

Small micros like the PIC are great for control-only projects, but when you want to take LANC to the next level, the Propeller is a great solution.

luckysdb (author)2013-04-18

Why i become the message "Warning HEX File loaded is larger than device"
Asm = 13 kb
HEx = 24Kb
I download the Zip file, and with MPlab Ide Vers 8.89 i export .
Who can help me

rtaneja (author)2011-07-14

Thanks again... I have another doubt.
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 (author)rtaneja2011-07-15

After the 8 bytes have been processed, it checks to see if the camera is recording so it can put on the record LED. When it jumps back to Start2, it checks to see if the record button or stop button have been pressed.

rtaneja (author)2011-07-06

hey , thanks for posting this. I have a question... Can you describe how you interfaced PIC with the the single data wire of LANC signal. You must have used SPI right..? but how exactly do we control those timings for LANC...?

portreathbeach (author)rtaneja2011-07-06

Hi,

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 (author)2011-06-10

do i just copy paste the code to the programming software

etechtim (author)2010-12-01

Great tool you've designed ! Can IRIS control be isolated in a remote LANC control? Thanks EtechTim

Coco Sapone (author)2010-10-20

I've made a LANC controler using a PIC16F628A for a SONY camera and it worked ok. For more information and other interesting technical things go to the link:
http://sites.google.com/site/telepicdata/

anglekissbbq (author)2010-02-28

Will the LANC protocol can provide do?

jpghiena (author)2010-02-01

Fantastic. That's just what I need, but no idea how to build it (I never made any electronic tools) : could you give a few hints on how to begin, or could this remote control be bought from you ?
Thanks for your answer

moonstruckman (author)2009-05-15

Just curious as to why you decided to use two seperate buttons for starting and stopping the device? Why not use 1 button?

Good question. 1 button probably would have been better, but I decided on 2 buttons. The record button takes little force to make contact and the stop button must have a stronger spring in it, because it takes a little more force to press. So it doesn't accidentally get knocked when using the camera.

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.

That makes sense. I just wanted to make sure it was possible to use 1button. I have been researching this topic for 2 months and getting no where, mostly because no one has used the 16F690. I am ecstatic to have found your post! It has been a huge help. It's the cleanest and most comprehensive code I have found yet. And the footage actually looks really good. Thanks again for posting this!

alexfagundes (author)2009-03-29

This is fantastic!! I've been trying to get any info I could reguarding a homemade controller for the LANC protocol and you are the first I've seen. All I want is a simple shutter release remote for my sony R1 camera. The RM-DR1 remote has more features than I need besides being impossible to find and not worth the price. portreathbeach, if you read this and think you could help me further in building this remote, let me know. The LANC logic and how it works in actually building a crcuit DIY style is alittle confusing to me. Great post

pau.cc (author)2009-02-01

Great! Thanks for posting!!

robhlee (author)2008-09-06

pic16f690? I have that same one; I have been searching for information on how to power my pic mirco (current,power). Is it generally the same for all pic micros?

portreathbeach (author)robhlee2008-09-06

I think all the cameras give out anything between 5 and 8 v dc. My camera gives out about 5 volts, so I connected it directly to the PIC. If you have more than 5 volts, you could always use a small 5 volt regulator.

Dorkfish92 (author)2008-08-28

pretty cool. P.S. I have the same monitor as you. 19 in.?

It's a 22 inch widescreen