I'm working on a project and am wondering if it is possible to run a 17PM-K845-00VS stepper motor with an Arduino Mega 2560. I have tried to hook it up using a ULN2004A according to the examples in the stepper motor library, but the shaft on the stepper didn't actually move (I used the example "stepper_onerevolution" to attempt to move it). Please let me know if you have any advice.
Um in the description on the website I bought it from (digikey) it says it is unipolar, but what makes you say its bipolar? And it has 6 wires. I also tried hooking it up with a ULN2067B driver (it can handle more amperage) and that got the motor moving, but it still isn't really doing what it is supposed to. It doesnt go as far as it should (for example if I progam it to do a full revolution it only goes about a 5th of the way around). Thanks for taking the time to help me!
mandy_coutu7:
Um in the description on the website I bought it from (digikey) it says it is unipolar, but what makes you say its bipolar? And it has 6 wires. I also tried hooking it up with a ULN2067B driver (it can handle more amperage) and that got the motor moving, but it still isn't really doing what it is supposed to. It doesnt go as far as it should (for example if I progam it to do a full revolution it only goes about a 5th of the way around). Thanks for taking the time to help me!
Have you connected all the grounds together? 2 from the motor, the grounds on the ULN2067B and the ground on the Arduino?
Are you certain that you're energising the correct motor coils at the correct time? Do you know that you have to energise two coils at once?
mandy_coutu7:
Um in the description on the website I bought it from (digikey) it says it is unipolar, but what makes you say its bipolar? And it has 6 wires. I also tried hooking it up with a ULN2067B driver (it can handle more amperage) and that got the motor moving, but it still isn't really doing what it is supposed to. It doesnt go as far as it should (for example if I progam it to do a full revolution it only goes about a 5th of the way around). Thanks for taking the time to help me!
Have you connected all the grounds together? 2 from the motor, the grounds on the ULN2067B and the ground on the Arduino?
Are you certain that you're energising the correct motor coils at the correct time? Do you know that you have to energise two coils at once?
Are you using microstepping mode?
Hey,
I know I've connected the grounds on the ULN2067B and the one on the Arduino, but I wasn't aware that there are grounds on the motor (I thought it was four wires for the four coils, and two common coils that you connect to power).
I'm pretty sure I'm energizing the coils in the right order, and yes I'm aware that I'm supposed to energize two at a time, but I'm not sure if the program I'm using is doing that. I used the step() function to try to get it to move. Is there anywhere I can look to find out what the step() function actually does? (ie. see what the code behind the step() function is?) It is definitely possible that the code is the issue, so maybe I should just write my own.
And finally, I don't know if I am in microstepping mode. Is there a way of determining that?
I know I've connected the grounds on the ULN2067B and the one on the Arduino, but I wasn't aware that there are grounds on the motor (I thought it was four wires for the four coils, and two common coils that you connect to power).
The two common connections are the ground connections to all four coils, one pair on each. Try connecting them to ground before you go looking for other problems.
Henry_Best:
The two common connections are the ground connections to all four coils, one pair on each. Try connecting them to ground before you go looking for other problems.
Ok I tried that but the motor doesn't move at all anymore. Are you sure they are supposed to be ground connections? If you look at the circuit drawing for the ULN2004A (http://arduino.cc/en/uploads/Tutorial/Unipolar_sch.jpeg) the common connections go to a seperate power source, not a ground. (I know it's a different chip, but that's all I have to base my new circuit off of. Unfortunately, I don't have very much electrical knowledge.) Could you post a circuit drawing for what you think I should be doing? It doesn't have to be pretty and would be very greatly appreciated!! I've attached the wiring drawing for the motor.
Hi, is the ground of the arduino and the ground of the stepper motor supply connected together and to the gnd pin8 on the 2004?
Also make sure you are not pulsing the outputs too quickly, to begin put a 250mS delay between each pin change so that you know that the windings are getting a decent pulse. This will produce a stepped motion but will ensure that you have the phasing right.
Tom
PS "one revolution" program assumes a fixed number of pulses per revolution, your motor might have a different number of pulses per rev, but don't worry about that at the moment, just try and get it to turn.
TomGeorge:
Hi, is the ground of the arduino and the ground of the stepper motor supply connected together and to the gnd pin8 on the 2004?
Also make sure you are not pulsing the outputs too quickly, to begin put a 250mS delay between each pin change so that you know that the windings are getting a decent pulse. This will produce a stepped motion but will ensure that you have the phasing right.
Tom
PS "one revolution" program assumes a fixed number of pulses per revolution, your motor might have a different number of pulses per rev, but don't worry about that at the moment, just try and get it to turn.
Hi Tom,
I've actually got the motor turning if I use a driver chip that can handle more amperage (ULN2067B) and yes I've connected all the grounds together. The motor is just not going as far as it should be. For example, when set to take 200 steps at 60 rpm, it goes about 1/16 of the way around. (It's takes 200 steps per rev) Do you know if it is possible to take a look at the code that makes up the step() function? And how would I find out how many pulses per rev that my motor needs?
I do love that instruction leaflet. Such a fine example of Chinglish.
What the heck's a "Motor intuition hole"? Does the motor sense our moods?
23KM and 32KM screws? You'd be all week doing those up, not to mention the RSI to your wrist.
TomGeorge:
Hi, is the ground of the arduino and the ground of the stepper motor supply connected together and to the gnd pin8 on the 2004?
Also make sure you are not pulsing the outputs too quickly, to begin put a 250mS delay between each pin change so that you know that the windings are getting a decent pulse. This will produce a stepped motion but will ensure that you have the phasing right.
Tom
PS "one revolution" program assumes a fixed number of pulses per revolution, your motor might have a different number of pulses per rev, but don't worry about that at the moment, just try and get it to turn.
Hi Tom,
I've actually got the motor turning if I use a driver chip that can handle more amperage (ULN2067B) and yes I've connected all the grounds together. The motor is just not going as far as it should be. For example, when set to take 200 steps at 60 rpm, it goes about 1/16 of the way around. (It's takes 200 steps per rev) Do you know if it is possible to take a look at the code that makes up the step() function? And how would I find out how many pulses per rev that my motor needs?
Take Tom's advice and slow your motor speed down to 1 or 2 RPM to see if that works correctly. If so, you can increase the speed gradually to find the max. speed it will work at.
At 60RPM you're sending the motor 200 pulses a second. If we assume a 50/50 mark space ratio then the power will only be on for 2.5 milliseconds in each pulse, maybe not enough time to overcome the reluctance of the coils and produce sufficient magnetic field to move the motor fully.
Reply #6 stated "The two common connections are the ground connections to all four coils, one pair on each. Try connecting them to ground before you go looking for other problems."
This is not correct. For a unipolar motor and four terminal unipolar driver, the coil center taps go to motor power (as the OP understood).
Henry_Best:
I do love that instruction leaflet. Such a fine example of Chinglish.
What the heck's a "Motor intuition hole"? Does the motor sense our moods?
23KM and 32KM screws? You'd be all week doing those up, not to mention the RSI to your wrist.
Haha sorry, I just posted it for the wiring diagram. The rest of it is mounting instructions
Take Tom's advice and slow your motor speed down to 1 or 2 RPM to see if that works correctly. If so, you can increase the speed gradually to find the max. speed it will work at.
At 60RPM you're sending the motor 200 pulses a second. If we assume a 50/50 mark space ratio then the power will only be on for 2.5 milliseconds in each pulse, maybe not enough time to overcome the reluctance of the coils and produce sufficient magnetic field to move the motor fully.
[/quote]
Hi,
So I tried slowing down the motor and that worked, but only for very slow speeds. I tried running it with a second between each step, and that worked, but as soon as I tried to go any faster than that, the motor did weird things (eg. it changed direction after about 12 steps when it is programmed to rotate continuously in only one direction). Is it possible that the motor actually can't go faster than that? Or is it possible that something else is causing the motor to malfunction? There is nothing attached to the shaft yet so there shouldn't be a loading issue. I've attached the sketch I used to run the motor. It is an adaptation of the code posted by Iain Portalupi here: How To Control A Stepper Motor With An Arduino Uno - YouTube.
Robin2:
Can you post the actual code you are using and a drawing (or a photo of a drawing) of how you have everything wired up?
...R
Hi,
So the code I actually used is attached to reply #14 (the attachment is called stepper_motor.ino) and I've attached a picture of the wiring that I drew by hand. Let me know if it is too messy and I'll try to draw it better. The columns of 5 squares each to the left and right of the ULN2067B represent the part of the circuit board that are connected in columns. The data sheet for the ULN2067B can be found here: http://www.st.com/web/en/resource/technical/document/datasheet/CD00000178.pdf
void step_cw(int steps, int off_time)
{
for(i = 0; i < steps; i++) //counts steps
{
a = a++; //adds 1 to the total number of steps
//steps are counted as +1 for clockwise
//decides which coil to turn on
b = 1 + (abs(a) % 4); //b is always 1 through 4
if(a < 0) //check to see if a is a negative number
{
//if a is negative make coils continue to go from 1 to 4
b = 5 - b;
}
if(b == 1) //rotor now alined with coil 1
{
//always turn off unneeded coils before turning others on
digitalWrite(c2, LOW);
digitalWrite(c4, LOW);
digitalWrite(c1, HIGH);
digitalWrite(c3, HIGH);
}
if(b == 2) //rotor now alined with coil 2
{
//always turn off unneeded coils before turning others on
digitalWrite(c1, LOW);
digitalWrite(c4, LOW);
digitalWrite(c2, HIGH);
digitalWrite(c3, HIGH);
}
if(b == 3) //rotor now alined with coil 3
{
digitalWrite(c1, LOW);
digitalWrite(c3, LOW);
digitalWrite(c2, HIGH);
digitalWrite(c4, HIGH);
}
if(b == 4) //rotor now alined with coil 4
{
digitalWrite(c2, LOW);
digitalWrite(c3, LOW);
digitalWrite(c1, HIGH);
digitalWrite(c4, HIGH);
}
delay(off_time); //wait this long between steps
}
}
Hi I am finding it hard to work out what order you are applying signal to the windings of the stepper.
If I make a table of your possible output.
C1 C2 C3 C4
b=1 H L H L
b=2 L H H L
b=3 L H L H
b=4 H L L H
I cannot see the logic that will make the motor turn, if you are trying to half step drive the motor then you need 8 steps.
I would try first this pattern which is single step.
C1 C2 C3 C4
b=1 H L L L
b=2 L H L L
b=3 L L H L
b=4 L L L H
This will make your stepper move one pole at a time, which from the comments in your program you are trying to do.
This comment has nothing to do with @TomGeorge's comments which may be very useful.
Your drawing is fine as a piece of art but it's not much use for microcontroller diagnostics as you haven't labeled any of the motor connections or any of the Arduino connections (presuming it is the thing on the right).
{
for(i = 0; i < steps; i++) //counts steps
{
a = a++; //adds 1 to the total number of steps
//steps are counted as +1 for clockwise
//decides which coil to turn on
b = 1 + (abs(a) % 4); //b is always 1 through 4
if(a < 0) //check to see if a is a negative number
{
//if a is negative make coils continue to go from 1 to 4
b = 5 - b;
}
if(b == 1) //rotor now alined with coil 1
{
//always turn off unneeded coils before turning others on
digitalWrite(c2, LOW);
digitalWrite(c4, LOW);
digitalWrite(c1, HIGH);
digitalWrite(c3, HIGH);
}
if(b == 2) //rotor now alined with coil 2
{
//always turn off unneeded coils before turning others on
digitalWrite(c1, LOW);
digitalWrite(c4, LOW);
digitalWrite(c2, HIGH);
digitalWrite(c3, HIGH);
}
if(b == 3) //rotor now alined with coil 3
{
digitalWrite(c1, LOW);
digitalWrite(c3, LOW);
digitalWrite(c2, HIGH);
digitalWrite(c4, HIGH);
}
if(b == 4) //rotor now alined with coil 4
{
digitalWrite(c2, LOW);
digitalWrite(c3, LOW);
digitalWrite(c1, HIGH);
digitalWrite(c4, HIGH);
}
delay(off_time); //wait this long between steps
}
}
Hi I am finding it hard to work out what order you are applying signal to the windings of the stepper.
If I make a table of your possible output.
C1 C2 C3 C4
b=1 H L H L
b=2 L H H L
b=3 L H L H
b=4 H L L H
I cannot see the logic that will make the motor turn, if you are trying to half step drive the motor then you need 8 steps.
I would try first this pattern which is single step.
C1 C2 C3 C4
b=1 H L L L
b=2 L H L L
b=3 L L H L
b=4 L L L H
This will make your stepper move one pole at a time, which from the comments in your program you are trying to do.
It may make a big difference.
Tom
Hi Tom,
The second pattern you posted in your reply (the one that excites one pole at a time) is what I had originally, but when I had the program doing that, the motor didn't move. The reason I changed it in the first place was to get the motor moving. I changed it after I read this page: http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/ . As you can see, my pattern corresponds to the pattern in the table in the link. I know that this pattern works, as I have tried both patterns by manually switching the wires. Please let me know if you think of anything else though.