My son asked me if I could make him a camera slider. Of course the answer was yes, what father in his right mind would admit to being beaten at this stage?
Long story short, after much research, I decided to use the vee track made by Openbuilds, a carriage, nema17 stepper motor and G2 belt.
To power it all up I've settled on a Ardinuo uno R3 board piggy backed with an Adafruit stepper motor shield.
This is all over kill but sets me on a learning curve with much excitement. I'm hoping I can power the whole setup with a 12v lead acid battery.
Q1. Can some kind member send me some code so that I can control motor speed and direction.
Q2. How best to implement stops at each end, limit switches or software?
I am not familiar with the Adafruit Stepper Motor Shield. If it just needs step and direction signals you can provide a single step with these two lines of code
You might also want to consider the AccelStepper library.
If you know how many steps are required to traverse the track you may only need a limit switch at one end to allow you to zero the position at startup.
You can use a microswitch or an optical detector for the limit switch. Assuming the mechanism can go a little way past the switch a common procedure is to move quickly towards the switch until it is triggered. Then go back a short distance beyond the switch and approach it slowly until the switch triggers and marks the Zero point.
Nema 17 only defines the size of the front face of the motor - it says nothing about its electrical requirement. You must ensure that the stepper driver can comfortably supply the current required by the motor. And be aware that stepper motors draw the full current even when stationary - so you may need a big battery.
If the Adafruit shield just takes step and direction signals this simple test code should make the motor move. Because it uses the delay() function it is almost certainly not suitable for actual use in a project. Just make sure that it is using the correct pins.
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0
byte directionPin = 9;
byte stepPin = 8;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 25; // milliseconds
void setup()
{
Serial.begin(9600);
Serial.println("Starting StepperTest");
digitalWrite(ledPin, LOW);
delay(2000);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(directionPin, HIGH);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
// delayMicroseconds(pulseWidthMicros); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
delay(3000);
digitalWrite(directionPin, LOW);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void loop()
{
}