The stepper motor now has a position control! It wasn't easy either, and it has a ways to go yet, but here's an update:
As you can see, it needs some more work yet, but it is really coming together nicely now. A few of the problems that I will try to fix are:
Jitter. It's not too bad anymore, but it's too much. I may have to use a digital potentiometer.
- Current draw. The motor is rated for 6 Amps @ 3 volts. I'm not sure that rating is right, but that was what it was specified as. The problem with that is that the transistors can't handle more than about an amp, so they are getting really hot. The other problem with the current draw is that the whole thing is running off of USB, so while this is great for testing, because it's current limited, to get the full torque out of this motor I'll need a good 3V supply and some higher current transistors. (I'm also not sure if the transistors are saturating all the way, so it might be that I just need lower voltage transistors)
- What to use for a proper enclosure.
- How to mount it to the rail system ( this is the easy one!)
Anyway, that's where I am currently. Here's the code I'm using:
---------------------------------------------------------------------------------------------------------------------
/*
* MotorKnob
*
* A stepper motor follows the turns of a potentiometer
* (or other sensor) on analog input 0.
*
* http://www.arduino.cc/en/Reference/Stepper
* This example code is in the public domain.
*/
#include
// change this to the number of steps on your motor
#define STEPS 200
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);
// the previous reading from the analog input
int previous = 0;
void setup()
{
// set the speed of the motor to 15 RPMs
stepper.setSpeed(15);
}
void loop()
{
delay(100);
// get the sensor value
int val = analogRead(0);
// move a number of steps equal to the change in the
// sensor reading
stepper.step(val - previous);
// remember the previous value of the sensor
previous = val;
}
---------------------------------------------------------------------------------------------------------------------
(I know that's probably not relevant to anyone else here, but I want a backup of the code online, and this is a good place to put it)