I got a unipolar 5 wire motor stepper from a printer: NMB pm55L-048. It's characteristics are: 24V, 30 Ohm coil resistance. I'm using an arduino UNO.
I'm trying the program StepperTest, present in the AFMotor library examples, to make the stepper rotate, but in result the motor oscillates erratically.
I've already tried making a piggyback with another L293D with the same result, because the motor needs 0.8 A.
what i'm doing wrong?
Motor shield+stepper problem
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Motor shield+stepper problem
Are you sure you have the motor coils connected correctly?
-
- Posts: 7
- Joined: Tue Aug 23, 2011 9:51 am
Re: Motor shield+stepper problem
well, I have another shield, DFRobot, and the stepper works fine with it. So i guess the wiring is not the problem. Nevertheless, i tried to switch the wires and the result was the same.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motor shield+stepper problem
Post some photos of the front & back of the board and we'll take a look for any assembly problems.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motor shield+stepper problem
From the photo, there are a couple of solder joints that look a little rough, and a few that have not flowed well onto the pad.
Touch up anything that is not smooth and shiny or has not flowed well.
Beyond that, you can test each of the motor channels (M1-M4) to see that they are all switching current.
Touch up anything that is not smooth and shiny or has not flowed well.
Beyond that, you can test each of the motor channels (M1-M4) to see that they are all switching current.
-
- Posts: 7
- Joined: Tue Aug 23, 2011 9:51 am
Re: Motor shield+stepper problem
I'm sorry for the late reply, but i wasn't able to pay attention to this problem in these last few days due work. I tried your suggestion and i was able to put the lines M1 and M2 working, but not M3 and M4. In these, the stepper still oscillate erratically.
I tried to remake the connections of the L293 connected to M3 and M4 and some of the connections of the 10 line resistor because i didn't liked their appearance. As a result, now i'm back to square one. Both steppers oscillate erratically.
Any help please?
I tried to remake the connections of the L293 connected to M3 and M4 and some of the connections of the 10 line resistor because i didn't liked their appearance. As a result, now i'm back to square one. Both steppers oscillate erratically.
Any help please?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motor shield+stepper problem
I don't see any obvious soldering problems there. Make sure that your L293D chips are firmly seated in the sockets.
-
- Posts: 7
- Joined: Tue Aug 23, 2011 9:51 am
Re: Motor shield+stepper problem
The L293D are firmly seated in the sockets. i've also confirmed that there is current flowing in the M1-M4 lines. The typical values were 0.6A. There is one thing i don't understand: when, for example, measuring M3, i see 0.6A, but when it switches to M1 to the other stepper, M3 switches it current value to 0.72A, why? it shouldn't be 0 A?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motor shield+stepper problem
0.6A is the maximum rated current for the L293D's. If you exceed that for more than a few seconds you will either trip the thermal overload protection, or fry the chip.
How exactly are you measuring the current? Is this with your stepper motor as a load?
How exactly are you measuring the current? Is this with your stepper motor as a load?
Are you doing these tests with the piggy-backed chips?I've already tried making a piggyback with another L293D with the same result, because the motor needs 0.8 A
- cgapeart
- Posts: 2
- Joined: Tue Sep 27, 2011 2:12 pm
Re: Motor shield+stepper problem
I had something similar going on last night.
In my case, what was happening was that the stepper I was using was a low voltage one, and I had nothing in there to control the current draw. My arduino and the shield were browning out, and therefore resetting very quickly.
Of course, I tried the tool-time approach: more power. The result was frying one of the l293d's.
The blue smoke coming out being a good motivation to do more research, I started poking around a bit.
You can stack more l293's to increase the current they can handle, but your power supply would still need to be able provide the current needed for the motor.
So, the motor is going to draw as much as needed to satisfy I = V/R. To get mine running I am looking at two options:
The simplest option is to add a large power resistor in series with each coil. I have to do the calculations still, but it's probably going to be in the 2 ohms/6-10 watts range (and should be the non-inductive type)
The other option would be to adjust the driver software to PWM the enable line to cut back the current. I don't know how that's going to work, and if it is not cut back enough, I will blow a chip to find out.
In my case, what was happening was that the stepper I was using was a low voltage one, and I had nothing in there to control the current draw. My arduino and the shield were browning out, and therefore resetting very quickly.
Of course, I tried the tool-time approach: more power. The result was frying one of the l293d's.
The blue smoke coming out being a good motivation to do more research, I started poking around a bit.
You can stack more l293's to increase the current they can handle, but your power supply would still need to be able provide the current needed for the motor.
So, the motor is going to draw as much as needed to satisfy I = V/R. To get mine running I am looking at two options:
The simplest option is to add a large power resistor in series with each coil. I have to do the calculations still, but it's probably going to be in the 2 ohms/6-10 watts range (and should be the non-inductive type)
The other option would be to adjust the driver software to PWM the enable line to cut back the current. I don't know how that's going to work, and if it is not cut back enough, I will blow a chip to find out.
- cgapeart
- Posts: 2
- Joined: Tue Sep 27, 2011 2:12 pm
Re: Motor shield+stepper problem
Here are some code snippets from what I was thinking as a simple added feature to put in some open-loop current limiting:
AFMotor.h:
AFMotor.cpp:
AFMotor.cpp:
I haven't tested it yet -- it's just an idea, but maybe it will be useful to someone else. Let me know if you see anything that might make it break.
AFMotor.h:
Code: Select all
//...
class AF_Stepper {
public:
AF_Stepper(uint16_t steps, uint8_t num, uint8_t max = 255);
void step(uint16_t steps, uint8_t dir, uint8_t style = SINGLE);
void setSpeed(uint16_t);
uint8_t onestep(uint8_t dir, uint8_t style);
void release(void);
uint16_t revsteps; // # steps per revolution
uint8_t steppernum;
uint32_t usperstep, steppingcounter;
uint8_t BANNED;
private:
uint8_t currentstep;
};
//...
Code: Select all
//...
AF_Stepper::AF_Stepper(uint16_t steps, uint8_t num, uint8_t max) {
MC.enable();
revsteps = steps;
steppernum = num;
currentstep = 0;
BANNED = max;
if (steppernum == 1) {
latch_state &= ~_BV(MOTOR1_A) & ~_BV(MOTOR1_B) &
~_BV(MOTOR2_A) & ~_BV(MOTOR2_B); // all motor pins to 0
MC.latch_tx();
// enable both H bridges
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(11, HIGH);
digitalWrite(3, HIGH);
// use PWM for microstepping support
initPWM1(MOTOR12_64KHZ);
initPWM2(MOTOR12_64KHZ);
setPWM1(BANNED);
setPWM2(BANNED);
} else if (steppernum == 2) {
latch_state &= ~_BV(MOTOR3_A) & ~_BV(MOTOR3_B) &
~_BV(MOTOR4_A) & ~_BV(MOTOR4_B); // all motor pins to 0
MC.latch_tx();
// enable both H bridges
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
// use PWM for microstepping support
// use PWM for microstepping support
initPWM3(1);
initPWM4(1);
setPWM3(BANNED);
setPWM4(BANNED);
}
}
void AF_Stepper::setSpeed(uint16_t rpm) {
usperstep = 60000000 / ((uint32_t)revsteps * (uint32_t)rpm);
steppingcounter = 0;
}
//...
Code: Select all
//...
uint8_t AF_Stepper::onestep(uint8_t dir, uint8_t style) {
uint8_t a, b, c, d;
uint8_t ocrb, ocra;
ocra = ocrb = BANNED;
if (steppernum == 1) {
a = _BV(MOTOR1_A);
b = _BV(MOTOR2_A);
c = _BV(MOTOR1_B);
d = _BV(MOTOR2_B);
} else if (steppernum == 2) {
a = _BV(MOTOR3_A);
b = _BV(MOTOR4_A);
c = _BV(MOTOR3_B);
d = _BV(MOTOR4_B);
} else {
return 0;
}
// next determine what sort of stepping procedure we're up to
if (style == SINGLE) {
if ((currentstep/(MICROSTEPS/2)) % 2) { // we're at an odd step, weird
if (dir == FORWARD) {
currentstep += MICROSTEPS/2;
}
else {
currentstep -= MICROSTEPS/2;
}
} else { // go to the next even step
if (dir == FORWARD) {
currentstep += MICROSTEPS;
}
else {
currentstep -= MICROSTEPS;
}
}
} else if (style == DOUBLE) {
if (! (currentstep/(MICROSTEPS/2) % 2)) { // we're at an even step, weird
if (dir == FORWARD) {
currentstep += MICROSTEPS/2;
} else {
currentstep -= MICROSTEPS/2;
}
} else { // go to the next odd step
if (dir == FORWARD) {
currentstep += MICROSTEPS;
} else {
currentstep -= MICROSTEPS;
}
}
} else if (style == INTERLEAVE) {
if (dir == FORWARD) {
currentstep += MICROSTEPS/2;
} else {
currentstep -= MICROSTEPS/2;
}
}
if (style == MICROSTEP) {
if (dir == FORWARD) {
currentstep++;
} else {
// BACKWARDS
currentstep--;
}
currentstep += MICROSTEPS*4;
currentstep %= MICROSTEPS*4;
ocra = ocrb = 0;
if ( (currentstep >= 0) && (currentstep < MICROSTEPS)) {
ocra = microstepcurve[MICROSTEPS - currentstep];
ocrb = microstepcurve[currentstep];
} else if ( (currentstep >= MICROSTEPS) && (currentstep < MICROSTEPS*2)) {
ocra = microstepcurve[currentstep - MICROSTEPS];
ocrb = microstepcurve[MICROSTEPS*2 - currentstep];
} else if ( (currentstep >= MICROSTEPS*2) && (currentstep < MICROSTEPS*3)) {
ocra = microstepcurve[MICROSTEPS*3 - currentstep];
ocrb = microstepcurve[currentstep - MICROSTEPS*2];
} else if ( (currentstep >= MICROSTEPS*3) && (currentstep < MICROSTEPS*4)) {
ocra = microstepcurve[currentstep - MICROSTEPS*3];
ocrb = microstepcurve[MICROSTEPS*4 - currentstep];
}
}
currentstep += MICROSTEPS*4;
currentstep %= MICROSTEPS*4;
//CGAP Map the value to max power
ocra = map(ocra, 0, 255, 0, BANNED);
ocrb = map(ocrb, 0, 255, 0, BANNED);
#ifdef MOTORDEBUG
Serial.print("current step: "); Serial.println(currentstep, DEC);
Serial.print(" Max: "); Serial.println(BANNED, DEC);
Serial.print(" pwmA = "); Serial.print(ocra, DEC);
Serial.print(" pwmB = "); Serial.println(ocrb, DEC);
#endif
if (steppernum == 1) {
setPWM1(ocra);
setPWM2(ocrb);
} else if (steppernum == 2) {
setPWM3(ocra);
setPWM4(ocrb);
}
// release all
latch_state &= ~a & ~b & ~c & ~d; // all motor pins to 0
//Serial.println(step, DEC);
if (style == MICROSTEP) {
if ((currentstep >= 0) && (currentstep < MICROSTEPS))
latch_state |= a | b;
if ((currentstep >= MICROSTEPS) && (currentstep < MICROSTEPS*2))
latch_state |= b | c;
if ((currentstep >= MICROSTEPS*2) && (currentstep < MICROSTEPS*3))
latch_state |= c | d;
if ((currentstep >= MICROSTEPS*3) && (currentstep < MICROSTEPS*4))
latch_state |= d | a;
} else {
switch (currentstep/(MICROSTEPS/2)) {
case 0:
latch_state |= a; // energize coil 1 only
break;
case 1:
latch_state |= a | b; // energize coil 1+2
break;
case 2:
latch_state |= b; // energize coil 2 only
break;
case 3:
latch_state |= b | c; // energize coil 2+3
break;
case 4:
latch_state |= c; // energize coil 3 only
break;
case 5:
latch_state |= c | d; // energize coil 3+4
break;
case 6:
latch_state |= d; // energize coil 4 only
break;
case 7:
latch_state |= d | a; // energize coil 1+4
break;
}
}
MC.latch_tx();
return currentstep;
}
//...
-
- Posts: 7
- Joined: Tue Aug 23, 2011 9:51 am
Re: Motor shield+stepper problem
well, I put my hands on a new stepper: philips ID31, 12V, 60 Ohm. He worked just fine with the shield. So the problem isn't the shield itself.
I've tried again the stepper NMB PM35L-048 (60 Ohm), now measuring the current flowing to the coils and using a 9V source supply. I've measured 130 mA, which it was the expected value. But the erratic behavior of the stepper remains. I've tried this same configuration with the DFROBOT shield and worked just fine.
Is there a incompatability with the frequency signal, generated by the AFMOTOR library, with the stepper shaft inertia? It's possible to change the frequency signal generated by the arduino that's is reaching the stepper coils?
I've tried again the stepper NMB PM35L-048 (60 Ohm), now measuring the current flowing to the coils and using a 9V source supply. I've measured 130 mA, which it was the expected value. But the erratic behavior of the stepper remains. I've tried this same configuration with the DFROBOT shield and worked just fine.
Is there a incompatability with the frequency signal, generated by the AFMOTOR library, with the stepper shaft inertia? It's possible to change the frequency signal generated by the arduino that's is reaching the stepper coils?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motor shield+stepper problem
Does it work differently on M1/M2 vs M3/M4? M1/M2 PWM at 64KHz. M3/M4 are at 1KHz.
-
- Posts: 7
- Joined: Tue Aug 23, 2011 9:51 am
Re: Motor shield+stepper problem
I've tried in both M3/M4, M1/M2 and the result is the same.
Please be positive and constructive with your questions and comments.