User Tools

Site Tools


ms:camera_controller

MakerSlide Camera Motor Control Program

Introduction

This is an open source project for a simple Arduino based camera slider control program. It goal was to produce a low cost and easy to operate controller that can be pre programmed for simple field use. It allows a series of moves and dwells, each with their own distance, speed and acceleration.

It was programmed for the Arduino Uno hardware.

Warning this is free, DIY, open source software that may include bugs and errors. Use at your own risk. Many things could cause the system run on its own potencially damaging the slider, your camera or yourself. Use at your own risk.

Driver Shield

Note: Never do any wiring changes or disconnect any parts with power on.

Users Guide Schematic

If you use my Arduino shield, the standard location to put the motor driver is in the X Axis position. Be sure to orient the driver correctly or the voltage will be applied incorrectly and it will be destroyed. See the image. The adjustment pot goes above the capacitor on this version of the the PCB. You can get complete details on the shield in this document.

The motor needs to wire to the shield. It uses the 4 position terminal block right near the driver. Wire it using the colors shown in the image. If the motors goes backwards from what you think it should do when you move it reverse green and black.

You need to power the shield on two position terminal block as shown below. Do not apply the voltage backwards or the drivers will be destroyed. The shield also needs 5V from the Arduino or the drivers will not operate. This means the shield will not operate on its own.

The Arduino also needs power. You can power it either from the USB cable or via it's power connector. See the documentation for the Arduino for information on that. You can power both parts with the same power supply.

The Pololu A4988 drivers can run on voltages from 8-35V and currents up to 2 amps per coil. They will only run at full voltage and current if you can keep them cool which will require a heatsink and fan. The stepper motors are way more powerful than you need. I typically run my setup at about 12V and 0.2 amps. They run quieter at these levels and do not get hot at all. To adjust the current see the Pololu web site or my user guide.

The setup shown below has push button switch in one of the driver slots. This switch allows you to start a saved move program without a PC. The switch is connected to pin 11 on the Arduino. Change this statement in the code if you want to use a different pin.

#define PIN_START_SWITCH 11  // this is the switch used to run the sotred program (high = run)

In the current version, pin 11 is pulled low and switched to 5V. This means, if you do not use the switch, you must either add a 10K resistor from pin 11 to ground or change the code to remove the function. If pin 11 does not have the resistor, it could go high on it's own at any time and start the program. The code chages in the main loop would be like this.

Change

// look for start switch
    if (digitalRead(PIN_START_SWITCH))

To

// look for start switch
    if (false) // never enter this section
    

Future changes will trigger on the pin 11 going low and use the built in pull up resistor of the pin 11 to make the design work with or without the switch circuit.

Change in setup function

pinMode(PIN_START_SWITCH, INPUT);

To

pinMode(PIN_START_SWITCH, INPUT);
digitalWrite(PIN_START_SWITCH, HIGH);  // turn on pull up resistor

And change

if (digitalRead(PIN_START_SWITCH))

to

if (!digitalRead(PIN_START_SWITCH))

Controller Setup

This assumes you have some experience with Arduino. If you are not familiar with then spend some time to play with the examples that come with it.

  • Download the Arduino 1.0 IDE from Arduino.cc.
  • Launch the Arduino program.
  • Open the Camera control program
  • Upload the software to the Arduino
  • Open the Serial Monitor

The serial monitor should now present the menu to you.

I strongly suggest practicing with the setup before you mount a heavy and expensive camera. An easy power off switch might be handy too.

The user interface is a interactive menu system. All commands and parameters are separated with a single space.

  • 0 : This sets the 0 point or home position to the current location. Once you move the carriage to the position you want to be the 0 point, use this command to set it to 0
  • S = Stop now! This is an immediate stop. If the carriage is moving fast, this could cause a violent shake in the system and even knock a tripod mounted setup over. Only use it to prevent the carriage from crashing into the end.
  • D = Disable Motor This disables the motor driver if you driver and setup supports this feature. This lowers the power draw to almost nothing and also allows you to manually move the carriage
  • E = Enable Motor This enables the motor driver if your setup sorrts the feature. All motion command will automatically do this before each moove.
  • H = Home (Move to 0) This moves the carriage to the 0 postion. The 0 position is either where the carriage was at system turn on or at the point you zeroed the carriage.
  • M = Move to ..
  • J = Jog until stopped Jogging is moving the camera without a predefined end point. To jog forward use any positive number after the J, like “J 1”. The value of the number does not matter, so I suggest using 1 and -1. You can also provide the speed of jogging by adding a second parameter. “J 1 3000”, would jog forward at 3000 steps per second. Type J with no parameters to stop jogging. It will smoothly decelerate to a stop. If you need to stop immediately, use the S command, but it will be a more violent stop.
  • I = Info This will return the current info on the position max speed and max acceleration. It is good do do this before running a program to make sure you at at the zero location before you start. This can be entered even while the carriage is moving to see where you are.
  • G = Go Run the current program
  • P = Show Program This will display the move program that is currently in memory.
  • C = Clear Program This basically sets the program as zero lines long.
  • L = Edit Line. This allows to edits lines of the move program. The format is “L N X S A”. Where
    • L is the command (required)
    • N is the line number (required)
    • X is the postion you want to move to (required)
    • S is the speed (optional)
    • A is the acceleration (optional)
      • If you set X and S to zero it makes that line the end of the move file. (L 4 0 0) would make line four the end of the program.
      • If you set X to zero and S to a value, it becomes a dwell or pause for the duration of X in milliseconds. (L 3 5000 0) would do a 5 second dwell.
  • R = Set Max Speed This sets a max speed and will override move commands that request a higher speed.
  • A = Set Max Accel This sets a max accel. You should determine how fast your carriage and camera setup can accelerate before the motor stalls. A heavy camera or running uphill can limit the acceleration.
  • V = SaVe to EEPROM This saves the max speed, max accel and the move program to EEPROM memory. If you do not do this, the those value will revert to the last saved values when the system is restarted.
  • ? = Redisplay this menu

Initial Test

  1. Assemble Arduino, Shield, Driver and Switch (or modify code without switch)
  2. Make sure all pins are aligned and not shifted. Make sure driver is oriented correctly.
  3. Connect the motor to the shield. It might be easier to initially test without a belt installed to prevent unwanted movement.
  4. Connect Arduino to computer using a USB cable (watch for lights on Arduino)
  5. Upload the controller program.
  6. Turn on the serial monitor of the Arduino and watch for controller menu to appear.
  7. Double check polarity one more time and apply power to to the shield.
  8. You should be able to manually spin the motor because the drivers come on in a disabled state.
  9. Type “E” and enter on the computer keyboard. The drivers should enable and lock the motors in position.
  10. Type “M 1000 2000 2000”. This should spin the motors 1000 steps.
ms/camera_controller.txt · Last modified: 2011/12/31 09:32 by bdring