2009-07-09

DIY camera motion control

Hows about moving your HF100 like a pro?

DIY camera motion control from Martin Koch on Vimeo.
The system consists of a ready-made IGUS DryLin W rail system and a small stepping motor which is controlled by an Arduino interface board. Once the controller program is loaded the system works stand alone. It can be powered by a battery and can be controlled by a simple power switch because the programmed task starts automatically each time the Arduino board is powered on. It's possible to horizontally move loads (camera + mounting head) of up to 6 kg (13 lbs) with the system described below.
Here's what you need:

Slider

1000 mm long Igus DryLin WS 10-80 rail.
Costs: about 50 EUR / m
Ready-mounted Igus DryLin WW 10-80-15 sledge.
Costs: about 30 EUR
The maximal possible length of movement equals rail length minus slider length (the WW 10-80-15 sledge is 150 mm long) so the usable length will be 850 mm ( 1000 mm - 150 mm).

The Igus order number for a complete system with 1 meter long rail and 150 mm sledge is WK-10-80-15-01, 1000 (the first number is the rail diameter in millimeters, second is the rail width followed by length of sledge, number of sledges and rail length).
The DryLin-W railsystem is a maintainance free, self lubricating linear guide system. It is available in three rail diameters: 10, 16 and 20 mm.

Official Igus procedure for aligning the carriage (needs to be done once).
1. Loosen all carriage bolts - (don't remove - just loosen a few turns)
2. slide carriage back and forth to allow bearings to align themselves
3. Tap the center of the carriage to "bump" the bearings into place
4. With downward pressure on carriage tighten the bolts again a few turns at a time (alternating them - i.e. do NOT crank one down and then do the other ones)

Alternatively you could also use the narrower 10-40 system but the savings are minimal. Or for a super strong version for long rails or cameras that weigh more than 3 kg (1.5 lb) use the 16-60 system. Read this thread at dvxuser.com for more info and inspiration. (a 10-40 version is shown in post #336 on page 34). Post #475 shows how to move along an arc.
You can order directly from Igus. They have offices around the world. More info at Drylin-W.de
This is about all you need when you move the camera manually. You can also build a hand cranked version if you wish. I went a step further and motorized the whole assembly.

Controller board

Arduino Duemilanove (or Arduino Uno see update below) or Arduino Nano USB I/O controller board. Visit arduino.cc for more information and where to buy it.
Costs: Arduino about 25 EUR, Arduino Nano about 50 EUR.
The current (as of 2009) Arduino is called Duemilanove which is italian for "2009". It is meant to be used with a "shield", an interface board that sits on top of the Arduino.

I used the Arduino Nano. It offers the same features in a smaller 30 pin package that can be used just like an integrated circuit. You need an USB to USB mini cable to program it. Such a cable came much likely with your digital camera.

Software

Download and install the Arduino software for Windows, Mac OS X or Linux.
Costs: free.
Copy and paste the following Arduino sketch into the developing enviroment and download it to the board. Make sure to choose the correct board under Tools>Hardware. If you use an Arduino Nano replace the digital output numbers with the ones in the comment. Once downloaded the Arduino executes the sketch on its own. Every time power is turned on or the tiny reset button is pressed the sketch starts.
/*
Move an unipolar stepper motor
Version 2.0 with simpler, leaner code
2010, Martin Koch
http://canon-hf100.blogspot.com/
----------------------------------------

Use a 12 V, 0.16 A to 0.5 A unipolar (6 wires) stepper motor

If you use the Arduino Nano assign these digital output numbers:
#define D0 2
#define D1 3
#define D2 4
#define D3 5
*/

// Arduino digital output numbers
#define D0 13
#define D1 12
#define D2 11
#define D3 10

int rpm = 30; //revolutions per minute (keep below 100)

void setup() { 
 pinMode(D0, OUTPUT);
 pinMode(D1, OUTPUT);
 pinMode(D2, OUTPUT);
 pinMode(D3, OUTPUT);
 delay(1000);

//Choose number of steps by trial and error 
//so the slide runs the whole length of the DryLin W rail
 for (int step=0; step<9000; step++) {
   moveMotor(step); 
   delay (150 / rpm);
 }
 motorOff();
}

void loop() { 
// run again and again (not used)
}

void moveMotor(int step) {
 switch (step % 8) // Half steps (step modulo 8 ensures 0 to 7 cycles)
 {
  case 0:   //1000
  digitalWrite(D0, HIGH);
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  break;
  
  case 1:    //1100
  digitalWrite(D0, HIGH);
  digitalWrite(D1, HIGH);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  break;
  
  case 2:    //0100
  digitalWrite(D0, LOW);
  digitalWrite(D1, HIGH);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  break;
  
  case 3:    //0110
  digitalWrite(D0, LOW);
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, LOW);
  break;

  case 4:   //0010
  digitalWrite(D0, LOW);
  digitalWrite(D1, LOW);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, LOW);
  break;
  
  case 5:    //0011
  digitalWrite(D0, LOW);
  digitalWrite(D1, LOW);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  break;
  
  case 6:    //0001
  digitalWrite(D0, LOW);
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, HIGH);
  break;
  
  case 7:    //1001
  digitalWrite(D0, HIGH);
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, HIGH);
  break;
 } 
 return;
}

void  motorOff() {
   digitalWrite(D0, LOW);
   digitalWrite(D1, LOW);
   digitalWrite(D2, LOW);
   digitalWrite(D3, LOW);
}
There's also an Arduino stepper motor class available but I prefered to write my own stepping motor control code just for fun. To cut noise the motor is operated in half step mode so it doesn't offer the full torque but the ULN2803A interface allows to connect twice as strong motors.

Stepping motor

Small 12V unipolar (6 wires) stepping motor with maximal 0.5 A per winding.
Costs: about 30 EUR.

My stepping motor needs just 0.16 A per winding and offers a force of just 70 mNm (0.070 Nm = 0.62 Pound-force inches). Nonetheless it is still able to horizontally pull loads up to 6 kg (3 lb). I bought it from RS-Components. The part number is 440-436. In order to fit my interface I had to rearrange the wires. To loosen a wire in the type of connector shown above use a needle to press in the latch from the front then pull out the wire. The wire easily clicks in place at the new location. If you use the same motor the wire arrangement in the plug should be B brown, E brown, A white, F blue, C red, D yellow.

Interface

1 ULN2803A integrated circuit, prototyping board, connection pins, wire
Costs: A few Euros.
The interface is as simple as it can get. Make sure to connect the stepping motor wires as shown in the schematic.
Schematic for Arduino board

Schematic for Arduino Nano board


This board also shows a 5 V relais (orange part) that is used to trigger a still camera.

Battery

A small maintainance-free 12 V lead battery with about 2 Ah is inexpensive and sufficient for hours of continuous operation.
Costs: about 20 EUR.

You'll also need a lead battery charger

Assembly

The most silent solution is to use a nylon rope to pull the sledge across the track. It works in one direction only but by turning the whole assembly by 180° its easily possible to move in the opposite direction.
The usual camera move is from left to right just as we read. It tells the viewer that everything is alright. If you want to disturb the viewer move the camera from right to left.

The rope bobbin can be made on a lathe.

The whole assembly is not completly silent but silent enough to be usable. The noise of the stepper motor is cut significantly by using rubber mounting bolts.

Ideas

If you don't mind the noise (e.g. music video) you can also use a d.c. motor with gear assembly. The Arduino board offers pulse width modulation (PWM) control to set different speeds.
The Arduino board also offers analog and digital inputs so you can wire a potentiometer or switches to set different speeds.
The possibilities are endless and it's fun to play with the Arduino system. I recommend the book "Getting started with Arduino" for an easy start.
Here's an example video: vimeo.com/5535135

Update March 9, 2010: I updated the Arduino sketch above with a simpler and leaner version that does the same.
Update November 20, 2010: There's a new Arduino UNO available which replaces the Arduino Duemilanove and works the same.
Update February 15, 2011: If you use the Arduino UNO it's best to built the interface circuit on a ProtoShield that can be plugged directly into the Arduino.
Update June 19, 2011: As far as I know Igus doesn't sell directly to individuals any longer but they offer ready-made sliders with predrilled 3/8" hole at Amazon.com.

The image from Amazon above shows that you need 8 bolts to properly fasten the plate to the four linear bearings.

Do you want an even leaner code? Well I recently learned how to use the Arduino stepper library with an unipolar stepper motor. It's way simpler to use than I thought and although I haven't tested the code below I post it to give you an idea how little code is neccessary using the Stepper.h library included with the Arduino software download:
#include <Stepper.h> //include the function library
#define STEPS 200 //1.8 deg motor (200 steps per revolution)
#define D0 13 // Arduino digital output numbers
#define D1 12
#define D2 11
#define D3 10
Stepper stepper(STEPS, D0, D1, D2, D3); //create the stepper

void setup() 
{
  stepper.setSpeed(30); //set speed to 30 rpm
  delay(1000); 
  stepper.step(200); //move 200 steps = 360 deg in one direction
  delay(1000); 
  stepper.step(-200); //move 200 steps = 360 deg in the opposite direction
}

void loop() 
{}