Controlling motor < 5 V

I am using a Baby Orangutan (168) to control a (stepper) motor, works like a charm.

The problem is that the motor that I now want to use handles a maximum of only 3.9 V. What is the best way to limit the current going through the motor given that the Orangutan voltage has to be above 5 V?

As far as I can see, the H bridge takes its supply voltages directly from the Orangutan’s input VCC which has to be above 5 V to feed the microcontroller. The “cleanest” solution would cutting the PCB wire going to the H bridge chip’s motor power supply pins and supply another voltage instead except that this is actually quite messy - I would prefer not to alter the Orangutan.

An appropriate number of power diodes with corresponding voltage drop could also be a solution but that’ll be a lot of diodes (8 in all). Similarly, PWM could probably help but could lead to possible toasting of the motor due to software failure.

Any help or just suggestions would be appreciated!

Oh, and great product by the way :slight_smile:

Hello,

What kind of currents are you expecting? If the stall current is more than a few hundred mA, the drop in the H-bridge transistors will give you right around what you’re looking for with an input around 5 or 6 V. Also, if your motor is somewhat matched to the motor driver, the motor driver will probably overheat (and turn off) faster than your motor will melt.

Another option is to use a slower clock on the mega168, allowing the whole board to run at a lower voltage.

- Jan

Hi Jan, thanks for responding.

It’s max 0.6 A per coil. My input is 5V.

The data sheet is here
nanotec.com/downloads/pdf/11 … 8S0604.pdf
Summary: Voltage 3.9. Amps/phase 0.6. Resistance/phase 6.5 ohms.

How much would the total drop over the H-bridge transistors be? The data sheet on the LB1836M says 0.4 V saturation voltage @ 400 mA. Maybe that’s enough… and maybe use PWM for the remaining drop.

Is it okay to supply just 3.8 V to the board, if I change the clock?

Thomas

I don’t have any info besides the same datasheet, but you can measure how much of a drop you get on your particular unit. The 0.4 V is typical, but the max is 0.6 V. And with a higher current, I think you could easily lose close to a volt in the transistors.

Everything can run on 3.8 V so it should be okay. You should probably bypass the reverse-protection diode and the voltage regulator to get the most out of your battery.

- Jan

Tried running the board on 5V just now. As you said, I lose at least a volt. To be exact, I’m down to 3.4 V when one motor coil is active and 3.0 V when both are active. Problem solved (in fact there wasn’t any to begin with :slight_smile: ).

My next problem is getting the stepper motor to run faster. According to specs it’s able to run much faster than what I can make it (I get max 300 rpm, the specs say 6000 rpm).

Have tried both full stepping and half stepping to no avail. I haven’t got a lot of experience with stepper motors but it looks like microstepping could make it go a bit faster. An alternative explanation could be that either the on/off switching of the H bridge is too slow or current is too limited somehow, although I don’t think either of the explanations sounds reasonable. Maybe a more powerful motor controller is needed.

Thomas

Can you post the code you’re using, and how you’re changing it to try to control the stepper motor speed? I’ve been interested in using a Baby-O as a stepper motor controller for a long time, at least until Pololu comes out with a serial stepper motor controller!

So I’m a little confused, are you saying that as you increase the step-frequency past what would generate 300 rpm the motor doesn’t keep up? The LB1836M data sheet doesn’t specify a maximum switching frequency, but it should be able to switch on the order of tens of KHz. Lets assume a worst-case scenario of 10KHz, or 10,000 steps/second when full or half-stepping. Your motor has 200 steps per revolution, so that would give you a maximum speed of 50 rps, or 3000 rpm. That’s a worst-case though, I’m almost certain the Baby-O could run your motor at its full speed!

Microstepping a stepper motor results in smoother motion, and reduces resonance problems, but also has less torque and lower maximum speed (both from the capabilities of your controller and the tendency of your motor to start skipping steps at lower holding torques). It’s generally meant more for higher positioning precision than for high-speed operation. I haven’t written a program to do it myself, but my understanding is that you use high-freqiency PWM to aproximate two 90-degree offset sinusoidal analog inputs to slowly shift the rotor between poles, so your motor driver has to be able to switch at much higher frequencies than your motor’s maximum stepping frequency. You might be able to microstep a little with the Baby-O, but full or half stepping will always give you a higher maximum speed with a given motor and control hardware.

-Adam

Sure, I’ve posted a condensed version of the code. This is halfstepping code. Leave out the “b”-steps and you have full stepping. Bear in mind that it’s a prototype, so no optimizations yet. Also, the delay code is kind of crude. What you want is of course some kind of timer interrupt. Speed is controlled by changing the value of w. The value 7 works for me and sometimes 6 but below this, the stepper just stands still. The stepper motor is bipolar just to get that straight.

Yes, what I’m saying is that when the step frequency is increased, the motor doesn’t keep up. I don’t have an oscilloscope or similar but I’m pretty sure the bridge outputs do keep up. So the LB1836M is likely not the problem. As you mention it is quite capable of keeping up.

However, I’ve been reading up on stepper motors, and it seems that you really want to be able to supply the motor with higher voltage that its specification tell you. Of course, in order to avoid damaging the motor, you need some kind of current limitation. See cs.uiowa.edu/~jones/step/current.html . Sounds reasonable.

Unfortunately, LB1836M doesn’t support smart current limitation but the A3967 does. It also supports microstepping. I’m thinking about getting hold of one of these and trying it out.

Thanks for the input.

Thomas

(code follows)

void step1() {
PORTB |= 1 << PB1;
PORTD &= ~(1 << PD5);
PORTB |= 1 << PB2;
PORTD &= ~(1 << PD6);
}
void step1b() {
PORTB &= ~(1 << PB1);
PORTD &= ~(1 << PD5);
PORTB |= 1 << PB2;
PORTD &= ~(1 << PD6);
}
void step2() {
PORTB &= ~(1 << PB1);
PORTD |= 1 << PD5;
PORTB |= 1 << PB2;
PORTD &= ~(1 << PD6);
}
void step2b() {
PORTB &= ~(1 << PB1);
PORTD |= 1 << PD5;
PORTB &= ~(1 << PB2);
PORTD &= ~(1 << PD6);
}
void step3() {
PORTB &= ~(1 << PB1);
PORTD |= 1 << PD5;
PORTB &= ~(1 << PB2);
PORTD |= 1 << PD6;
}
void step3b() {
PORTB &= ~(1 << PB1);
PORTD &= ~(1 << PD5);
PORTB &= ~(1 << PB2);
PORTD |= 1 << PD6;
}
void step4() {
PORTB |= 1 << PB1;
PORTD &= ~(1 << PD5);
PORTB &= ~(1 << PB2);
PORTD |= 1 << PD6;
}
void step4b() {
PORTB |= 1 << PB1;
PORTD &= ~(1 << PD5);
PORTB &= ~(1 << PB2);
PORTD &= ~(1 << PD6);
}
void alloff() {
PORTB &= ~(1 << PB1);
PORTD &= ~(1 << PD5);
PORTB &= ~(1 << PB2);
PORTD &= ~(1 << PD6);
}
void delay_100us(int d) {
for(int i=0; i<d; i++) {
for(int j=0; j<10; j++) {
_delay_loop_1(67); // apprx 10us
}
}
}
int main(void) {
// Init code left out
int numsteps = 200; // One full turn
itn w = 7;
for(int i=0; i<numsteps; i++) {
step1(); delay_100us(w);
step1b(); delay_100us(w);
step2(); delay_100us(w);
step2b(); delay_100us(w);
step3(); delay_100us(w);
step3b(); delay_100us(w);
step4(); delay_100us(w);
step4b(); delay_100us(w);
}
alloff();
return 0;
}

I might take a stab at a timer-based stepping code after I finish my dynamics homework (boo dynamics homework!). Since you’re missing steps you might try “two-phase-on” full stepping as described in this document.

Basically you always have both phases energized, and switch polarity one at a time. The rotor poles actually step in between the stator poles, but the step size remains the same. It uses twice the power of normal “one-phase-on” full stepping, but you get 41.4% more torque, and thus you should get a higher top speed with the same hardware.

-Adam

My code actually does “two-phase-on” full stepping when you remove the calls to step1b…step4b. I started out without these calls, but added them later because I thought they would help :slight_smile: It didn’t change anything speed-wise, though.

Dynamics! Don’t boo it. I used to do dynamics all day long for several years, simulating interactively how people fall down staircases, over tables and such under various impacts. That was a great deal of fun. My next step in this direction will be a dynamically walking biped. Still need a pair of gyros and accelerometers… But first! Mastering the secrets of the stepper motor.

Thomas

Very cool, what exactly is your job?

I’m not booing dynamics in general (well, maybe Lagrangian dynamics just a little, but it has its place), but rather I’m booing this particular homework, and this class in general.

More specifically I’m booing a textbook and a professor, both of whom are very equation-derivation oriented, without principle explanations or clear examples. The professor’s small sloppy handwriting really doesn’t help (I can barely tell his psi from his phi).

Oh well, it’s the last homework.

-Adam

Yeah, purpose-built chips are always the best. I’ve considered picking up one of the EasyDriver stepper motor boards from Sparkfun, which are based on the A3967, but I keep getting scared off by the warning on the website:

“Caution: Do not connect or disconnect a motor while the driver is energized. This will cause permanent damage to the A3967 IC.”

Yikes! I don’t see that warning on the chip’s data sheet, which makes me even more concerned about using one. It’s totally the sort of thing I would do, I’m cruel to my electronics. Although, that doesn’t quite beat this warning that came to my lab with a multi-thousand dollar IMU:

Anyway, I just looked through your code a little more seriously, and it looks like correct half-stepping to me.

One little question though, you said that this was the condensed version of your code. At some part of the non-condensed version, do you set your four output pins (PB1, PB2, PD5, PD6) as actual outputs in DDRB and DDRD?

If not, when you try to set a pin high your commands are attaching internal pull-up resistors to the output pins, and I could see that slowing down the H-Bridge response a little. More importantly, when you try to set a pin low, you’re actually setting it to a high-impedance floating state, so who knows how long it will take the input charge to dissipate and drop low.

Anyway, you probably set them to outputs somewhere and just didn’t copy that part, right?

-Adam

Yes, I did setup PB1, PB2, PD5 and PD6 as output pins, I just left out the code from the message (there was a lot of other initialization, e.g., of a serial connection to the PC). But I’m going to double check just to be sure (haven’t got the code at my current location). Anyway, the motor driver chip reacts to the outputs from the chip, so it ought to work.

As for my dynamics job, it’s several years ago: elecplay.com/reviews_article … ticle=4769 . It was great fun, and even recently turned into a major box office movie hit. So, dynamics can get you to many interesting places. I’m now on to something completely different. But I agree that uninspired professors and textbooks can be a drag :slight_smile:

As for your IMU warning, wow! If it’s going to be used by many people in different circuits, it would probably be a good idea to build protection circuitry around it right from the start. Same thing could be done with the A3967 but at least its price is not in the thousands.

Thomas

On closer inspection of the ATMega168 datasheet, there doesn’t seem to be a really great way to use hardware PWM for microstepping (not with just one counter anyway). I know at least some of the ATTinys are configurable to have four pins PWM controlled by the same timer, OCR1A, !OCR1A, OCR1B, !ORC1B, which would make microstepping pretty simple. It’s also great for controlling two-color LEDs!

I wrote a quickie interrupt based code and tested it out on a 200-step motor I yanked out of a printer years ago (so I have no clue what the specs are). Playing with it I was reminded of another quirk of stepper motors I forgot about earlier, they have two maximum speeds. There is the max startup speed, and a higher maximum speed that can be reached only by accelerating slowly towards it.

You probably knew that already, but your current code may not be able to accelerate in small enough increments to reach the max speed, since as your W variable gets smaller, the jump in speed between two values of W gets larger! When your motor is sitting there sputtering away, you can try to give your motor a twist with your hand and see if it can keep up once it’s going.

I also found that full stepping had a higher maximum speed, but half stepping could jump to a higher speed from a dead stop without skipping steps. The discrete speeds I can set in my code right now jump logarithmically like yours, and the speeds were close enough that I can’t absolutely make that claim, but my overall max speed was 451 RPM.

Anyway, I’d be interested to hear how the A3967 compares on the same motor. What are your plans for these steppers anyway?

-Adam

P.S. Yeah, videogame physics is getting pretty amazing these days. I only ever played Hitman as a demo, and the (free) demo was easily worth more than the really REALLY crappy VR glove it came packaged with.

Yes, that a good observation! I will try speeding up gradually and see where that gets me but I’m pretty certain we’re not talking about a 10-fold speed-up. I have already observed a behavior where I can help the motor to get running by hand if I give it a nudge but that is only possible with w=6. With w=5 already, the approach doesn’t work.

I am aware of the nonlinear relationship with w. I’ll probably change the code to support linear speed in order to do a proper gradual speed-up.

I’ll order the A3967 for sure, just don’t know when, yet. It’s really inconvenient the way it works with customs here in Denmark when I order something from the US, so I tend to wait until I have a bunch of stuff that I need, or try to find a European distributor. But I’ll let you know when I have some results.

As for the steppers, my current plan is using them to wind up a piece of thread attached to a spool. Actually, I realized in the last couple of days that a brushless motor with Hall sensors could be better suited for that purpose but it’s really difficult finding prices for these, except some really high power ones that are used in R/C hobbying. Maxon Motors have them but they look a bit on the expensive side. So I’m still hoping that a stepper motor will be able to do the job but it will need to run faster than in the current situation.

Thomas

Hi, Thomas:

I’m puzzled by your assertion that this motor should be capable of 6000 rpm. This is very fast–a few hundred rpm is the fastest I’ve ever seen for a stepper and so I’m very interested. I couldn’t find any rotational speed spec in the data sheet whose link you posted. Can you elaborate, and where did you get the motor?

Thanks, Jim

Folks:

I should have googled first and asked questions later.
The 6000 rpm spec is posted on the manufacturer’s web site at

nanotec.de/page_product__st2018__en.html

However, for that spec the motor is running at 48 volts, which requires a current limiting resistor that will dissipate an enormous amount of power. Alternatively you need active current limiting (current sense combined with PWM) to limit the motor current to 0.6 A.

To run this motor at 48 volts using a current limiting resistor you need a series resistor R = 45v /0.6A = about 75 ohms, which will dissipate P = I^2 R or about 27 watts. Oh, and there is one for each coil!

Perhaps you use this to heat water for tea while the motor is running?

Cheers, Jim

Hi Jim,

Yep, it has to be a pretty high power resistor for that approach to work, so I think that is out of the question (and for many other reasons besides efficiency, too). Instead, I’m thinking of limiting the current by chopping it up with an appropriate controller. The A3967 can handle up to 30 V and 0.75 A, so that would probably bring me closer a lot closer. I’ll settle for less than 6000 rpms but I do need more than the 300 rpms I’m getting presently.

I haven’t worked with steppers before and therefore was a bit puzzled by the fact that you run a 3.9 V motor on 48 volts. But I believe I get it now; it’s the current you have to watch, the 3.9 V’s are merely a guide calculated using the resistance of the coil and the max ampere rating. Right?

Thomas

Hi,Thomas:

The voltage rating is given for running the motor without a series resistor. As you surmise, the current rating and the winding inductance and resistance are more important factors. The higher the driving voltage, the faster the motor will run, but you still need to observe power dissipation limits of the motor winding. If you don’t want to waste power in resistors you must use current chopping to control the power dissipation.

A quick search revealed the following guide to stepping motor characteristics and driving methods, courtesy of ST Microelectronics. There are lots of others but a glance through this one suggests that it is reasonably complete:

st.com/stonline/books/pdf/docs/1679.pdf

A reasonably priced 35V driver board is available and does current chopping at 200 kHz. It appears to be suitable for this motor:

nanotec.de/page_product__smc11__en.html

Good luck and let us know how the project develops!

BTW did you get a good deal on these motors? They do look pretty nice for robotics.

Jim

Hi Jim,

Thanks for the explanations and the link to the ST guide, great. I think I understand now what’s going on.

I can see that Nanotec can also provide several nice controller chips and full circuit boards that support chopping and high voltage + current limits. Just didn’t think I needed them until now but will look into their capabilities right after this.

The deal I got was just the one advertised on the web site, i.e., 33.81€ = 49.05$. If you buy more than 25, you can get them for 34.34$ a piece. I’ve seen cheaper offers but as you mention, the steppers seem pretty nice in several ways, fast, compact and high torque. I also bought an integrated encoder. I need some more for the project later, and if I’m happy with the motor I have now and don’t find a more promising candidate, I’ll probably acquire some more.

As mentioned, another possibility that seems promising would be a brushless motor with Hall effect sensors. They can reach an insane amount of RPMs (50000+). But I have a hard time finding good offers online (or in fact any offers with available prices, except for R/C hobbyists). I did get an offer from Maxon Motors when I inquired, but it was rather expensive ($250 for a similarly specced 22 mm motor).

I’ll keep you posted on my findings!

Best regards,
Thomas