Driving a stepper motor with a mini-Rambo controller

Hi everyone,

I am trying to do a similar thing as this post but for some reason my stepper motor won't spin. To summarize the problem-space, I am programming a mini-Rambo controller (basically a souped up Atmega2560) to control three NEMA 17 stepper motors. Right now, I am attempting to just drive on of them for testing. My sketch uploads just fine, but there is no movement from the motor. Below is the code I am uploading:

#include "AccelStepper.h"
#include "Wire.h"

#define ELECTRONICS "RAMBo13a"

#define X_STEP_PIN             37
#define X_DIR_PIN              48
#define X_MIN_PIN              12
#define X_MAX_PIN              -1
#define X_ENABLE_PIN           29
#define X_MS1_PIN              40
#define X_MS2_PIN              41

AccelStepper stepper(1, X_STEP_PIN, X_DIR_PIN); // 1 = Driver

void setup()
{  
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);	
}

void loop()
{  
   stepper.runSpeed();
}

Where am I going wrong, and what things can I try to trouble-shoot my situation? Thanks in advance for your help :slight_smile:

ordo1234:
Where am I going wrong, and what things can I try to trouble-shoot my situation? Thanks in advance for your help :slight_smile:

You have done nothing with the enable pin

Try adding in setup()

pinMode(X_ENABLE_PIN, OUTPUT);
digitalWrite(X_ENABLE_PIN, HIGH);

and if that does not work, try LOW

...R

You have done nothing with the enable pin

Ah, duh. So I tried three flavors of enable pin code. First I tried with the digitalWrite HIGH.

void setup()
{  
   pinMode(X_ENABLE_PIN, OUTPUT);
   digitalWrite(X_ENABLE_PIN, HIGH);
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);	
}

Then I tried setting it to LOW.

void setup()
{  
   pinMode(X_ENABLE_PIN, OUTPUT);
   digitalWrite(X_ENABLE_PIN, LOW);
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);	
}

Finally, I tried using two methods from the AccelStepper library.

void setup()
{  
   stepper.setEnablePin(X_ENABLE_PIN); 
   stepper.enableOutputs();
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);	
}

From the docs:

void AccelStepper::setEnablePin ( uint8_t enablePin = 0xff )
Sets the enable pin number for stepper drivers. 0xFF indicates unused (default). Otherwise, if a pin is set, the pin will be turned on when enableOutputs() is called and switched off when disableOutputs() is called.

void AccelStepper::enableOutputs ( )
Enable motor pin outputs by setting the motor pins to OUTPUT mode. Called automatically by the constructor. If the enable Pin is defined, sets it to OUTPUT mode and sets the pin to enabled.

This second one I call for sanity as it is called by the constructor by default.

I thought I saw/hear the stepper motor wiggle once when I went from setting the pin from HIGH to LOW, but I can't replicate the movement. I still seem to be stuck.

You should never be relying on code in a constructor to work driving pins, constructors are often called before the Arduino runtime itself is initialized. Constructors can initialize the value of instance variables, but not much more.

Try this Simple Stepper Code - with suitable adjustments for the pin numbers and the code for the enable pin.

Are you sure your stepper driver is not damaged. They are easily destroyed if the wire between the driver and the motor is disconnected even briefly while the driver is powered.

...R
Stepper Motor Basics

Unfortunately the simple stepper code did not work. I tried some of the code from Controlling stepper motors with Mini RAMBo 1.3 - Motors, Mechanics, Power and CNC - Arduino Forum which did something; it made the motor click loudly and then became unresponsive, and I can't get the click to happen again.

How can I test if my driver/motor is damaged?

ordo1234:
Unfortunately the simple stepper code did not work. I tried some of the code from

That is what I call the scatter-gun approach to debugging. It doesn't work.

My simple stepper code works. If it doesn't work for you then trying another program just adds confusion without making any effort to pinpoint the problem.

How can I test if my driver/motor is damaged?

Try a different driver.

The motor is much less likely to be damaged.

...R

I only have this single driver. Are there any tests I can do with just this driver?

ordo1234:
I only have this single driver. Are there any tests I can do with just this driver?

Not that I am aware of.

Buy a few more. And if the one you have is an A4988 I suggest you get DRV8825 drivers as they are plug compatible and can handle a bit more motor current for much the same price.

...R