Pages

Saturday, 10 November 2012

GoPro Hero2 Automatic Timelapse Circuit

This summer I purchased a GoPro Hero2 camera. Mostly so I could bore my friends and family with videos of my airplane related escapades:


Along with HD video, the camera will also take nice wide angle fish eye photographs, and has a timelapse mode.

I wanted to do a long timelapse video of the assembly of the next RC model aircraft I was going to build. The GoPro seemed like it could do the job well. The wide angle lens lets me get most of my workshop in the frame. The main problem was that I wanted a way to automatically start and stop the time-lapse. Here's what I came up with.

The requirements were that the GoPro had to start taking photos when I went into the shop, it had to stop taking the pictures when no one was in the shop, and it had to stay charged.

First thing was to do some research on the interfaces available on the GoPro. There's a mini-USB connector for charging and accessing the data in the camera, HDMI out, microphone jack, and a 30-pin connector on the back of the camera. The 30 pin connector looked like it had some possibilities.

I found a pin-out for the 30 pin connector here: http://chargeconverter.com/blog/?p=71

The pins that jumped out at me as looking useful were:
Pin 5 and 6: USB 5V power for charging the camera.
Pin 12: Power/Mode button (for turning the camera on and off).
Pin 24: GoPro battery power while the camera is turned on.

My plan was to trigger the whole thing off of the light switch in the basement. By doing the following:

Connect a regular USB wall charger to one of the light sockets.
Use the 5V from the USB charger to charge the GoPro.
Use the 5V from the USB charger to also power an Arduino.
The Arduino, once powered would check to see if the camera is on. If the camera wasn't on it would toggle the Power/Mode button (pin 10) to power the camera.

By putting  the GoPro into "One Button Mode" I could have the GoPro automatically start taking pictures as soon as it's powered.

When I'm not in the workshop, I would turn off the lights. When this happens:
The Arduino detects that it has lost 5V power from the wall charger.
The Arduino stays alive on the power provided by the GoPro on Pin 24.
The Arduino turns off the camera by toggling The Power/Mode button (Pin 12).
The GoPro powers down, and removes power from Pin 24. The Arduino, having lost power shuts down as well.

This all might seem complicated, but the result is that the camera is taking pictures whenever the lights in the room are turned on. You can see this in action in my breadboard prototype in the video below.




So here's the circuit that I ended up with.



The Arduino code is at the bottom of this post for those that are interested

Initially I tried to control the GoPro Power switch (Pin 12) directly from an output from the Arduino. However, I couldn't make it work. I think what was happening was the pull up on the GoPro pin 12 was enough to keep the Arduino alive, and the system went into an endless loop of powering on and off and on and off when I removed USB power. I ended up adding the FET to separate the GoPro switch pin from the Arduino. This seems to work much better.

Here's the circuit soldered onto some prototyping board:



The red connector from the left is 5V power coming from a USB wall wart. The connector on the right goes to the GoPro 30 pin connector.

Incidentally, soldering to the GoPro connector was a little tricky. For once the magnifying glass on my "Third Hand" came in useful.



Once the backshell is on the 30-pin connector though, it ALMOST looks professional:


Now that that was working, I just needed to connect it up to the light in the workshop.


The extension chord goes to a USB wall charger.


Which goes through the Arduino Circuit and then to the GoPro.


The final result is I don't have to remember to turn on the camera when I walk into the workshop and start building. Here's a teaser:


Here's the Arduino Code.



int ON_PIN = 9;
int WALL_POWER = 12;
int CAMERA_POWER = 11;


int wall_power_state = 0;
int camera_power_state = 0;



void setup() {              
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(ON_PIN, OUTPUT);
  digitalWrite(ON_PIN, HIGH);
 
  pinMode(WALL_POWER, INPUT);
  digitalWrite(WALL_POWER, LOW);
 
  pinMode(CAMERA_POWER, INPUT);
  digitalWrite(CAMERA_POWER, LOW);
 
 
Serial.begin(9600);
Serial.println("Arduino Boot");
 
  }

void loop() {
 
  wall_power_state = digitalRead(WALL_POWER);
  camera_power_state = digitalRead(CAMERA_POWER);
  Serial.print("WALL POWER:");
  Serial.print("\t");
  Serial.print(wall_power_state);
  Serial.print("\t");
  Serial.print("CAMERA POWER:");
  Serial.print("\t");
  Serial.print(camera_power_state);
 
  if (wall_power_state && !camera_power_state) {
    //turn on the camera
    digitalWrite(ON_PIN, HIGH);
    Serial.print("\t");
    Serial.println("Case 1");
  }
 
  if (!wall_power_state) {
    //turn off the camera
    digitalWrite(ON_PIN, HIGH);
    Serial.print("\t");
    Serial.println("Case 2");  
//    Power_Pin_Low_Z();
    delay(3000);
//    pinMode(ON_PIN, OUTPUT);
    digitalWrite(ON_PIN, LOW);
    delay(3000);
    //delay(10000);
   
  }
 
  if (wall_power_state && camera_power_state) {
    //bring the camera pin high-Z
    digitalWrite(ON_PIN, LOW);
    Serial.print("\t");
    Serial.println("Case 3");  
  }

}



Tuesday, 6 November 2012

Low Voltage Battery Warning Circuit

For my first post, a very simple circuit that I threw together in an evening. The reason for this circuit was that this aircraft happened to be on my building bench:


It's a Binary 900 Discus Launch Glider, which is available from different online sources. Anyways, the kit belongs to a friend who asked if I would build it for him. The build is pretty simple and there are plenty of links where it is detailed. What I'll describe here is an extra feature I added to the glider. The feature is a low voltage warning circuit to tell you if you need to charge the glider before you toss it into the air again.

On most electric powered RC aircraft, you have a motor, which sucks a majority of the on board electrical power. RC speed controllers have a cut-off circuit which serves to warn you when the battery is getting towards empty. There are two reasons this is useful. First because it isn't much fun being airborne when your battery drains completely (ask me how I know), and second the lithium polymer batteries used in RC aircraft don't like being discharged below about 3 volts per cell.

Anyways, the motor controller typically either pulses or cuts off the motor completely when it's time to land. On  a glider, however, not having a motor means that it doesn't have an easy way to tell if the battery still has enough juice for another toss. The radio and servos will continue to work well below a voltage that would result in damage to the battery.

What I needed was something light and simple that you could glance at before tossing the glider back into the air for another flight.

Some researching and I found an op-amp circuit that was just simple and light enough that I could add to a 150g glider without hurting the performance too much:

http://www.reuk.co.uk/LM741-OpAmp-Voltage-Indicator.htm

Here's the schematic I sketched up:




Op amps are a surprisingly simple circuit element, but one that can be incredibly useful. Here I'm using the op amp in probably it's simplest form - a comparator. The basic operation of an op-amp is that when one input (the one with a "+") is at a higher voltage than the other (the one with a "-") the output is high. Otherwise, the output is low. Add a light to this output and you can have an indicator to tell you if your voltage is above or below a certain range.

In the circuit above, I am using a zener diode , D1, to set the voltage at the non-inverting input (pin 3) to a constant voltage of roughly 1.8V. The inverting input of the op amp (Pin 2) is fed by the wiper of a variable resistor. This variable resistor forms a voltage divider and allows me to set the trip point of the circuit by adjusting the variable resistor. When the voltage at pin 3 is greater than the 1.8V from the Zener Diode, the output, LED1, will be OFF. When the voltage at pin 3 is lower than the 1.8V at pin 2, the output will be ON.

I ordered some LM741 Op-Amps from Digikey so I could do some bread boarding and validate my design. It wasn't long before I had something working on the breadboard.


The circuit is near the bottom of the picture above. The LM741 is the 8 pin DIP package.

To test the circuit, I used my giant rheostat to load the battery down. This is nothing more than a large 3 ohm variable resistor that is rated up to 12.9Amps continuous current. I connected it across the battery in the circuit and adjusted it to get whatever battery voltage I wanted.



The aircraft is powered by a 2-cell Lithium Polymer battery. This battery is fully charged at 8.4V, nominally operates at 7.4V, and shouldn't be drained below 6V. I chose 7.0V as my desired trip point to prevent from discharging the battery too much during normal use. 

With the battery just below 7V, I adjusted the variable resistor in the circuit until the LED just turned on. At this point there's nothing more to do. The low battery warning light will stay off until the battery voltage drops below the 7V point. In the image below you can see the input is 6.77V, and the LED is on. 



Once I had the circuit working on the breadboard, it was time to squeeze it onto the smalled piece of circuit board I could find. Here is the final result soldered onto some prototyping circuit board.



A quick final test and adjustment of the pot was all that was needed before sealing up the circuit board. 

Here's the circuit with a battery level of 6.9V, the LED is off. 

Here it is with the battery voltage slightly lower (although the Power Analyzer is still showing 6.90V due to round-off error). The LED is now on. 

With this circuit on board, all you need to do is glance at the LED and wiggle the controls on the glider. If the LED stays off, you're good for another flight. If the LED flickers ON when you wiggle the controls, you might want to think about calling it a day and charging the battery inside the glider.

Here's the circuit squeezed into the fuselage of the Binary 900. It is the small black backage between the silver metal wing mounts in the left area of the picture below. You can just make out the wire going to the LED glued into the side of the fuselage.

Finally, here's the final product in action. Can't wait to play with it when there are some thermals in the area.