Drive small DC motor directly from AVR port pin?

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Imagine a small two-wire DC motor driven off a single battery, so 1V to 1.5V. Think of those little pocket fans that people take to sproting events & picnics.

Running by itself directly off the battery, it draws 7mA to 9mA @1.5V on a fresh alkaline cell.

Now, I want to control this motor with an AVR with (say) 3.3V Vcc.

Given the rather modest current draw, is a MOSFET to do the switching necessary? Or am I asking for noise trouble if the motor is driven directly from the AVR port pin? Will back-EMF be a problem?

If I want to drive the motor directly with PWM to approximate the nominal 1.5V, should I run the "raw" PWM into the motor? Or RC filter it to more nearly approximate a DC level? Or maybe just a storage cap?

I'm thinking that with the modest current requirements we can skip the MOSFET to save the part, and PWM of the motor power from 3.xV will actually be more efficient than driving continually with the battery voltage.

For efficiency, will faster PWM be better?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not be optimistic !

I would try it, but protect the AVR in the first experiments:

Use a 100Ohm series resistance to limit current.
I think the current during sartup will be much higher, but AVR
outputs seem robust.

Use a 1A SCHOTTKY diode for BACK-emf protection.

See what happens and then reduce resistor to improve efficiency
(if necessary) and play around with PWM.

Goor luck !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, you should be able to run the "stepper" motors used for clocks. And they would use an actal PWM, I think.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are driving a motor directly from a port in, you shouldn't need any kind of flyback catch diode. The flyback current can't be greater than the drive current, so if it's safe to pass the drive current through the pin, it's safe to pass the flyback current.

Back EMF is not a problem, as it is simply the voltage generated by the motor's rotation when you aren't driving it (you see the back EMF after the flyback energy dissipates). Unless you grab the shaft and spin it yourself, the back EMF will always be between ground and your supply voltage.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Uouhh, your message left me dazzled Scott.
How about the voltage that the motor's coil (winding) will produce when you turn it ON/OFF? This is not the back EMF you're talking about.
I'm not on sound ground here, so I'll wait for the Gurus :)

Embedded Dreams
One day, knowledge will replace money.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How about the voltage that the motor's coil (winding) will produce when you turn it ON/OFF?

This appears to rest on the fact that the upper transistor is ON when the lower transistor is OFF. The upper transistor is located in the same place electrically as the flyback diode, and should conduct the flyback current safely.

But don't ever turn the motor off by changing DDR.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
But don't ever turn the motor off by changing DDR.

Good point - as the motor slows down, it will now be driving the port pin with back-EMF. This will be actively breaking the motor's speed, call it a feature?

Is there a way the "user" can drive the fan? And what is the MAXIMUM current draw in these states, as in user driving it the wrong direction, etc.

That would be my concern mainly. If you can always keep the AVR in a state that it is 'forcing' the fan's pins to be either shorted or connected to VCC (as PWM would), you'll never be using the AVR's over-voltage protection diodes... and then I'd go for it. As long as you're never exceeding current limits that is ;-)

-Colin

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As far as back EMF goes don't you have to worry about the inductor flyback? Sure the motor will never generate more voltage than it's driven with when it starts to float, but the inductance of the motor winding could possibly generate an over voltage when it switches off. The currents through a motor of this size will be pretty small and so the possible inductive kickback should be low, but you at the least should find out what the inductance of the motor is and simulate worse case scenarios in pspice before you actually try it.

-Curiosity may have killed the cat
-But that's why they have nine lives

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are two ways you can turn the motor off.

1) Drive the motor pin to ground. If you do this, the back EMF drains through the port pin's bottom transistor to ground. The current is no higher than when you were driving the motor from the top transistor in the port.

2) Open the drive pin by setting the pin to an input. When you do this, there will be a short negative inductive spike. Once again, the current in this spike will be no higher than the current you were driving into the motor. The pin protection diode will catch this current and return it to ground. Those who say you need a large clamp diode may be forgetting that spike current will always be less than the current you were driving into the motor. If the port pin was able to source that current when you were driving the motor, it can also source that current for a short period as the inductive spike decays. When the inductive spike has decayed, you will see the residual back EMF, which is directly proportional to the motor's coasting speed.

While there are motors that can run on the output current of a port pin, they are tiny and are not likely to drive a fan, at least not fast enough to cool you ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In theory there is no difference between theory an practice, but in practice...

Thats my own favourite in making faults. My brain is not good enough to imagine all the things possible in reality !

A high starting current (only limited by DC-Motor-resistance).
A user pushing the reset-button in the vulnarable moment
(when current is high).

A high-side MOSFET not turned on or having an on resistancs so high that the current may drive the AVR protection diodes into conduction.

A current so high, that the protection-diode are not sufficient to prevent LATCHUP.

I like protection circuitry, its often cheap simple and bullet-proof.
With the protection circuitry you can sefely evaluate the performance under different conditions, even under extreme ones.

In this case its probably not the steady-state operation that will kill something.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"A high starting current (only limited by DC-Motor-resistance)."

No, also limited by the pin driver resistance. You'll already violate the maximum pin current just by driving the motor at startup. ESD events will push an Amp through a port pin without latching up the device. The issue here is power dissipation, not dielectric breakdown. If both the motor stall (startup) current and the inductive spike are transient events there isn't much danger of blowing out a pin.

Robot builders have been driving little motors from HCMOS logic for years, depending on the clamp diodes to catch any inductive kickback when they float the drivers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ossi wrote:

Use a 1A SCHOTTKY diode for BACK-emf protection.

I am not sure about motors, but for an inductive load like a relay coil that would be a bit overkill. If the motor is running at around 10mA, I'd put a fast 100mA diode like 1N4148 there, instead of a slow 1A diode. Schottky will be better than normal diodes, I don't know about speed but for protection. Usually diodes with small current ratings are faster than the ones with high current ratings. And "small-signal" diodes are faster than "rectifying" ones.

My point comes from the fact, that inductance wants to maintain the same current it was used to. So at least in relay coils, if there is a 50mA current flowing in the steady state, the maximum current ever going through the diode is 50mA when the relay is turned off, and then decreases to zero. Same happens when powering the coil, when turned on, the coil current starts from zero and goes to 50mA.

- Jani

Edit: turn on -> turn off

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Quote:
instead of a slow 1A diode

A schottky usually is very fast. Therfore good here. Additionally the low ON-voltage.

I dont like to use the AVR internal diodes, they are not built for that.

1A might be a bit overkill.

My recommendation is a BAT54S. 100mA double schottky diode in series connection. K to VCC; A to GND; COM to AVR port and motor.

Port = out_high: accelerates, runs the motor
Port = out_low: breakes the motor
port = input: lets the motor run free

when you swith the port out_low / out_high (with enough frequency to use the motor´s internal inductive to store a little energy) you will get speed control with (relatively) high torque.
when you swith the port input / out_high (with enough frequency to use the motor´s internal inductive to store a little energy) you will get torque control (relatively) independent of speed.

Try it, also try different frequencies.

With the second motor wire connected to a second port you can change motor direction.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Imagine a small two-wire DC motor .....

Imagine an ant-house, where it can get very hot in summer .... or a home for home-less mice .... producing a lot of heat as they are playing and tumbling over each other ....

What application has Lee in mind ?
No, don't tell !!! Not yet. Let's imagine ....

I assume fttb that this has to do with the same project as the low-cost dc-dc-converter. So let's see if it's possible to reduce the number of parts as much as we can ... and cut on costs as well. (note: although they work hard, the income of ants is not very high, and mice ? They just play)

About direct driving from avr-pin: the protection-diodes aren't meant to be used for inductive-load-drive protection, but they can do that job very well at the rated currents and voltages. From personal experience: they are very forgiving. Humans could learn from them.

Although the motorcurrent is just 7 - 9 mA when running, measure the current when you block the motor: if it's more than 40 mA, a mosfet will be necessary, IMO.

Then about running the motor from 3V or 1.5V. When driven directly from avr, there is not much choice: it runs from 3V as the avr is running @ 3V. Assuming pwm from avr-timer is used. Is it efficient from power-point-of-view ? No. It's better to run from 1.5V directly. Mind that the dc-dc-converter has an efficiency of less than 100% as well. An inductor-less converter gets up to 70-80% max. Might be even less at these low voltages (alkaline cell)

About the capacitor acroos the motor: when doing pwm, keep it as low as acceptable in terms of noise. 22nF is a good start (Cm in the picture). Mind that with each pwm-pulse, the cap needs to be charged, and the energy of that in-rush-current has to be dissipated by the driving fet. The avr.

Putting all together:

If max_current_minifan_motor < 40 mA, then the suggestion in the picture would be a good approach: low cost, minimal # of parts, efficient and flexible.

In software, normal operation:
portx.y=0
ddrx.y=1 // motor on
ddrx.y=0 // motor off

In software, with fresh battery, and too much air-flow:
use soft pwm to control ddrx.y
But you might get complaints from the animals that it's beeeeeping ...

And if you need reverse:
ddrx.y=1
portx.y=1 // reverse
portx.y=0 // forward

We defenitely need a section on this forum called: interfacing

Plons

Attachment(s): 

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Addendum: an RC-combination between AVR-pin and motor is not recommendable: it will cause great losses (relatively speaking, of course)

Or is the project for Barbie ? Or even Ken ? :P

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks all for the thoughts. I wasn't much worried about limiting starting current; I figured that either the AVR port pin would limit nicely, or drop in an appropriate series R.

The efficiency points are valid as the step-up certainly does not approach 100%. It will be interesting to play on the bench and see what duty cycle is needed to keep an approapriate RPM. If low enough, then it is a win; if not, ...

I hadn't thought of the hookup from plons's picture. Not as simple a PWM. ;) Run normal PWM but switch a MOSFET on the low side?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I still have no clue about the application ... still in imagine-phase .... I don't know how much CPU-resource (time) is available. Soft PWM, I did it for 13 channels, 32 steps, with 1600 Hz update on a tiny2313@8MHz internal clock. The big advantage of using softPWM over HW-PWM is the ability to control ddrx.y. And that saves you a mosfet. But yes, you could add a mosfet at the low-side of the motor, and use HW-PWM. All a matter of choices.

PM me Lee, if it has to stay a secret.

regards

Plons

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The C across the motor doesn't cause so much trouble if the motor isn't being PWM'ed. It simply trades reduction of the inductive spike current for increased startup current. I agree that there isn't enough power available from a port pin to cool much more than an ant, bee, or mouse, and that's why I'm not terribly concerned about clamp current if the motor can be driven within the AVR's port pin current limits.

I just powered several small motors at 1.5V, all no load. The intended coil drive voltage is in ();

8mm dia (4.5V) 81mA.
6mm pager (3V) 96mA
coin pager (3V) 77mA
Walkman cassette drive motor (6V) 52mA
Maxon coreless, ball bearing (6V) 10mA

The Maxon motor has significantly lower running current for several reasons:
Ball bearings
6V windings, and so is turning low RPMs on 1.5V
Low friction brushes

Remember, none of these motors is driving a load. I'm skeptical about a 7mA motor, but my entire proposal was based on the presumption the original poster had something that operated on the sort of current available from an AVR port pin.

Last Edited: Thu. May 18, 2006 - 04:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are interested in maintaining a regulated speed under PWM, use AVR pins that are also available to the ADC. After the kickback dies, measure the back EMF with the ADC and correct the next cycle of PWM to maintain RPMs where you want them.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Agree with Scott: if no pwm, Cm's value isn't critical. But I understood from Lee that he wants to do pwm. Nice idea, Scott, reading EMF.

Plons

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips