Timelapse

 

after playing a bit with a webcam on a tripod:

I wanted to move the cam slowly over like 180° to get a nice pan effekt.

For the first try the webcam was attached to a stepper motor in half step, but with 0.9° steps it looks like crap.

 

so a small gearbox went between the stepper and the webcam, with a ratio off 1:1000, so the steps are now 0.018° as i move in fullstep.

Here is the final video with nice motion:

 

 

The Hardware:

The arduino controls the Stepper with a L293D, like shown on the arduino website: http://arduino.cc/en/Reference/Stepper

 

The Webcam Software:

I used HandyAvi, what makes the video directly from the webcamstream, perfect tool for things like this {#emotions_dlg.smile}

HandyAvi: http://www.azcendant.com/

 

The Arduino Code:

 

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 200
#define WaitMS 200

char val; // Data received from the serial port
 
unsigned long time;

Stepper stepper(STEPS, 3, 5, 6, 9); //This is the new one with PWM

 
void setup()
{
  stepper.setSpeed(500);
  Serial.begin(57600);
}

void loop()
{

 if (Serial.available()) { // If data is available to read,
   val = Serial.read(); // read it and store it in val

   if (val == 'R') {
     stepper.step(1);
     time = millis() + WaitMS;
   }
   if (val == 'L') {
     stepper.step(-1);
     time = millis() + WaitMS;
   } 
 }

if(millis() > time){
 
 stepper.SetCurrent(125);
 
 time = millis() + 20000;
 
}

}

There is a added Function in the stepper.cpp, what enables you to reduce the motorcurrent, so the motor does not heat up so much.

 

void Stepper::SetCurrent(int Current)
{
      switch (this->step_number % 4) {
      case 0: // 1010
      analogWrite(motor_pin_1, Current);
      digitalWrite(motor_pin_2, LOW);
      analogWrite(motor_pin_3, Current);
      digitalWrite(motor_pin_4, LOW);
      break;
      case 1: // 0110
      digitalWrite(motor_pin_1, LOW);
      analogWrite(motor_pin_2, Current);
      analogWrite(motor_pin_3, Current);
      digitalWrite(motor_pin_4, LOW);
      break;
      case 2: //0101
      digitalWrite(motor_pin_1, LOW);
      analogWrite(motor_pin_2, Current);
      digitalWrite(motor_pin_3, LOW);
      analogWrite(motor_pin_4, Current);
      break;
      case 3: //1001
      analogWrite(motor_pin_1, Current);
      digitalWrite(motor_pin_2, LOW);
      digitalWrite(motor_pin_3, LOW);
      analogWrite(motor_pin_4, Current);
      break;
    } 

}

The Processing Code:

 
/**
 * TimeLapse Coding
 * 
 * Check if the mouse is over a rectangle and writes the status to the serial port. 
 * This example works with the Wiring / Arduino program that follows below.
 */


import processing.serial.*;

Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
int Time; // Next trigger Time
int TimeBase; // The Increment for the rotation
int Steps; // How many steps are made
int Stepsize; // How big are the steps?
int Count; // For the Counter

void setup()
{
  size(200, 200);
  // I know that the first port in the serial list on my mac
  // is always my FTDI adaptor, so I open Serial.list()[0].
  // On Windows machines, this generally opens COM1.
  // Open whatever port is the one you're using.
  String portName = Serial.list()[1];
  
  myPort = new Serial(this, portName, 57600);
 
  TimeBase = 500;
  Steps = 100;
  Stepsize = 0;
  
  Time = 0;
  
  Count = 0;
  
}

void draw() {
    background(255);
    fill(0, 0, 255, 255);
  rect(5, 5, 190, 190);         // Draw a square

  
    PFont font;
    font = loadFont("Arial-Black-15.vlw");
    fill(255, 255, 255);
    textFont(font,15);
    text("TimeBase: " + TimeBase + " QW",10,25);
    text("Steps: " + Steps + " AS",10,50);
    text("Stepsize: " + Stepsize + " YX",10,75);
    text("Motor Move with +-",10,100);
    int RunT = (Steps * TimeBase) / 1000;
    text("Time: " + RunT + "sec",10,125);
    RunT = RunT /60;
    text("Time: " + RunT + "min",10,150);
    
    if(Stepsize!=0){
     if(Steps>0){
      
       //Check the Time:
       
       if(Time<millis()){
         
         if(Stepsize>0){
           myPort.write('R');
         }
         if(Stepsize<0){
           myPort.write('L');
         }
                           
         Steps--;
         Time = millis() + TimeBase;
       } else {
         int ToTime = int((Time - millis())/10);
         text("NextMove " + ToTime,10,175);
       }
       
     } else {
       Stepsize = 0;
     }
   }



}


void keyPressed() {
  if( key == '+'){
    myPort.write('R');
    delay(5);
    
    Count++;
    println(Count);
    
  }
  if( key == '-'){
    myPort.write('L');
    delay(5);
  }
  
  if(key == 'q'){
    TimeBase = TimeBase + 100;
  }
  
  if(key == 'w'){
    TimeBase = TimeBase - 100;
  }

  if(key == 'a'){
    Steps = Steps + 100;
  }
  
  if(key == 's'){
    Steps = Steps - 100;
  }
  
    if(key == 'y'){
    Stepsize = Stepsize + 1;
  }
  
  if(key == 'x'){
    Stepsize = Stepsize - 1;
  }

}

For Questions, please visit the Arduino Forum in this Thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252182542

Featured on Hackaday!!!



Comments powered by CComment