I got a motorized linear stage off eBay a while ago, that came with nice Vexta stepper motor:
I also got a Centent CN0162 driver (manual here: http://www.centent.com/Manuals/cn0162.pdf) to go with it. These drivers, while old, are supposedly pretty robust, have all sorts of protection circuits and their current rating far exceeds the 0.85A/phase of the Vexta motor (disclosure: first, I got a BigEasyDriver but quickly fried it for some unknown reason).
I quickly hacked together some basic code and got the motor moving nicely (powered by two 12V SLA batteries in series and the step pulses provided by an Arduino UNO). So far so good. The next few months I spend putting together a sketch for more fancy control of the stage movement.
At various time points, I tested my code and the motor kept moving. But now - after a longer period of coding - that I have finished the sketch, the stepper is not moving any more - and I have no idea why and I need some ideas for troubleshooting.
When power is supplied to the driver, the motor still makes its characteristic high-pitched noise. Initially, the driver doesn't supply any current to the motor (according to the manual), so the motor can be moved freely by hand. When the motor sees the first single step pulse (provided by powering up the Arduino), current is supplied and I cannot move it by hand anymore. So far, still the expected behavior. But when I now send step pulses to the motor, nothing happens anymore.
I measured the voltage across the driver terminals for the motor windings and they measure ~25V when no current is provided. This drops to about 1.5V, however, when current is supplied. I have no idea, if that is in the right ball park and I'm not sure, where to go from here. How do I troubleshoot the driver or stepper motor? Or should I simply try a new driver?
pipetman:
At various time points, I tested my code and the motor kept moving. But now - after a longer period of coding - that I have finished the sketch, the stepper is not moving any more - and I have no idea why and I need some ideas for troubleshooting.
First thing I would do is write a short sketch that does nothing except make the motor move. If the motor driver just needs step and direction signals this code should work
// 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 = 6;
byte stepPin = 5;
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);
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()
{
}
Thanks for this very helpful tip - I didn't want to believe my code was at fault, but that's exactly what was the culprit. One thing I did later on in my sketch, was to put the commands for the step pulse in a little function I called TakeStep(). But when referencing the function, I wrote "TakeStep;" instead of "TakeStep()," (face palm) -- But why doesn't the compiler complain about the former?
pipetman:
But when referencing the function, I wrote "TakeStep;" instead of "TakeStep()," (face palm) -- But why doesn't the compiler complain about the former?
It does if you turn on warnings (select verbose mode during compilation in the preferences),
you get warning like this:
test.ino:56: warning: statement is a reference, not call, to function ‘enable’
test.ino:56: warning: statement has no effect