I'm building a 3D printer and I'm a little over my head. Right now I'm trying to make sure most of my components play nice with each other with some simple code and only one motor. Here's my set-up:
I have a seeeduino mega. More on the pinouts later. It's being powered via USB and I don't know if that's okay.
I have some of these cheap stepper motors, 95 cents each and with basically no specifications at all. They have four leads, so they're definitely bipolar. I don't really have to use these, but I would prefer to, since, you know, I have them.
Then, I have a pololu stepper motor driver with soldered-on header pins. If I get one of these to work I'm gonna buy more, but I don't want to spend the money without proof-of-concept.
I think I have the stepper motor correctly hooked up to pins 1a-2b, but I might be wrong. VMOT and GRD are connected to a 12V PC power supply. VDD and GND are connected to the 5V output on the same power supply and, of course, the ground. MS1, MS2, MS3 (which are used to control microstepping - all of them off means a full step according to pololu), RESET, SLEEP, STEP, and DIR all go to the arduino.
Here is my arduino code:
int enable = 22;
int MS2 = 23;
int MS2 = 24;
int MS3 = 25;
int reset = 26;
int sleep = 27;
int stp = 28;
int direct = 29;
void setup() {
pinMode(enable, OUTPUT);
pinMode(MS1, OUTPUT);
pinMode(MS2, OUTPUT);
pinMode(MS3, OUTPUT);
pinMode(reset, OUTPUT);
pinMode(sleep, OUTPUT);
pinMode(stp, OUTPUT);
pinMode(direct, OUTPUT);
digitalWrite(enable, LOW);
digitalWrite(sleep, HIGH);
digitalWrite(reset, HIGH);
}
void loop()
{
delay(10);
digitalWrite(direct, HIGH);
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(1000);
digitalWrite(direct, LOW);
digitalWrite(stp, HIGH);
delay(100);
digitalWrite(stp, LOW);
delay(900);
}
All good, right? Well, the problem is that this produces a spectacular display of nothing. I have a couple of problems here but don't know how valid they are.
1) Is it okay to have the arduino powered by USB but the motor controller powered by the power supply?
2) How should I proceed testing the motors? There is a current-limiting potentiometer on the stepper driver and they can drive up to 2A. Again, I have no specs on the motors. Should I just turn it up until I see something?
3) Is my code okay? The datasheet says STEP is triggered by a high to low change, so that seems like it should work. But then again, I'm a little inexperienced with stepper motors.
I would just tinker with these, but I'm not very experienced with high voltage/current power supplies and I don't want to ruin something or kill myself.
Also, if nothing else works, I'm totally fine with ditching the surplus steppers and buying new, specification-laden ones. But you know.
All help is really appreciated. Really. Thanks!