# Arduino Forum

## Using Arduino => Motors, Mechanics, and Power => Topic started by: 168gr on Oct 31, 2015, 09:27 pm

Title: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Oct 31, 2015, 09:27 pm

I'm powering a tiny DC motor with an external power supply. I control the speed of it with PWM and am draining into digital I/O pin 11 on an Arduino Uno.

Using PWM I vary the voltage between about 1.3 and 2.5 V, and control the speed of the tiny motor. Project works fine, exactly as expected.

I've measured the current draw with this tiny motor simply wired to a battery, and it's about 30 mA.

I thought I'd swap the tiny DC motor out for one that is slightly larger. This one draws about 150 mA (again measured with it wired directly to a battery).

But when I wire it into the actual project, the motor doesn't turn, and the Arduino makes a non-reassuring humming sound, so I turned it off.

Is 150 mA (again, from an external power supply) too much to drain into an I/O pin?
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Oct 31, 2015, 09:45 pm
The absolute MAX for an I/O pin is 40mA but 20mA would be more sensible. Read the Atmel datasheet.

Do not try to power any motor from an I/O pin - you risk damaging your Arduino.

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: CrossRoads on Oct 31, 2015, 09:49 pm
150mA, yes way too much!
Add in a N-Channel MOSFET, let the Arduino drive PWM into its gate thru a 250 ohm resistor.
AOI514 would be great, almost the same as having a relay to connect the motor '-' to Gnd.
http://www.digikey.com/product-search/en?keywords=aoi514 (http://www.digikey.com/product-search/en?keywords=aoi514)
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Oct 31, 2015, 10:22 pm
Wait, I'm not powering the motor from the Arduino. I know I can't pull much off an Arduino powered by USB.

I have an external power supply. 5V --> motor --> Arduino. Common ground. Am I still really limited to 20 mA?

I'm using the digital I/O pin as a drain. When it's PWM'ing to 5 V, there's no potential and nothing happens; when it's 3 V, there's a 2 V potential and the motor moves.

Unless I'm fundamentally misunderstanding something here.
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: jack wp on Nov 01, 2015, 02:17 am
"I'm using the digital I/O pin as a drain. When it's PWM'ing to 5 V,"
There is not a yes/no answer here.
Whether source or drain, it's not much difference. When PWM comes into the calculation, it adds more.
In general terms, a pin can produce ABOUT 40 ma. If you push the limits, you should have a backup/spare arduino available.
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Nov 01, 2015, 02:31 am
OK, thanks. It appears I have fundamentally misunderstood this subject. I thought that since I was using an external power source, I could control motors with larger current demands this way.

What is the proper, safe way to use an Arduino to vary the voltage applied to a motor that needs more than 20 mA? If I want to be able to drive the 150 mA motor with 1.5 V one moment, 2.3 V the next, 3.9 V the next, etc to vary its speed. I'm looking for smooth, precise, fine control.

I'm sure there's a simple howto explanation, but my previous searches led me to what apparently was the wrong answer.  :)
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: jack wp on Nov 01, 2015, 02:41 am
You need more current than the arduino pin can supply. There are several ways to do that. Transistors, FET, etc.
I  prefer to use  KISS, SSR (solid state relay). Maybe a bit more expensive, but KISS.
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Nov 01, 2015, 10:12 am
I'm using the digital I/O pin as a drain.
Without seeing a wiring schematic it is impossible to know what you are doing.

However the 40mA limit and 20mA guidance values apply whether the current is flowing into or out of an I/O pin.

Just think about it - how tiny are the circuits inside the Atmega328 chip?

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Nov 01, 2015, 08:10 pm
Without seeing a wiring schematic it is impossible to know what you are doing.

However the 40mA limit and 20mA guidance values apply whether the current is flowing into or out of an I/O pin.

Just think about it - how tiny are the circuits inside the Atmega328 chip?

...R
Pretty tiny. Guess I can't expect to send a lot of current through it in either direction.

Attached are a couple of pictures of the actual project, and my crude attempt at a wiring diagram schematic.

The project uses the Arduino to control two motors:
1) A servo that moves from position A to B. This needs lots of torque so I'm using a fairly strong servo that's running at 7 V. It's spec sheet says 4.8 A at 6 V but I haven't measured what it uses at 7. Whatever it is, it's getting it and it's working fine.
2) A much smaller DC vibratory motor, like what makes cell phones vibrate. This requires very fine control that varies from moment to moment. One second it may need 1.05 V, the next it might need 2.3 V.

This project, as shown, works exactly as intended. I've been using it for the better part of a year now. Using digital I/O pin 11, the Arduino has been able to vary the voltage applied to the little 3V, 30 mA motor from 0-3 V with very fine control. No problem.

My objective at this point is to replace the little 3V, 30 mA motor with one that's rated for 1.5 - 6 V, 150 mA, and continue to use the Arduino to vary the voltage applied to the slightly bigger motor from 0-5 V with similarly fine control.

I had thought I could just swap one motor for the other, but apparently the Arduino won't sink 150 mA into digital I/O pin 11 without frying ...

Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Nov 01, 2015, 08:27 pm
Here, I'll try to inline the circuit schematic:

(http://www.pggweb.com/bbimg/schematic-circuit.jpg)
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Nov 01, 2015, 09:11 pm
Your diagram in Reply #9 does not show where the Arduino gets its power.

I would never connect a motor directly to an Arduino I/O pin because, in addition to too much current, motors can generate very high voltage spikes - far in excess of 5v.

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Nov 01, 2015, 09:32 pm
Your diagram in Reply #9 does not show where the Arduino gets its power.
It's plugged into a USB port on a computer, where the control software runs and communicates with the Arduino.

I would never connect a motor directly to an Arduino I/O pin because, in addition to too much current, motors can generate very high voltage spikes - far in excess of 5v.
What's the correct way to do this?
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Nov 02, 2015, 10:16 am
What's the correct way to do this?
There are several circuit ideas on this website (http://www.pighixxx.com/test/) if you cannot follow the advice already given in earlier replies.

(Circuits are not my strong point so I will not give advice myself).

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: 168gr on Nov 02, 2015, 11:48 pm
Thank you -

I guess I just got lucky that my original functioning project didn't cook the Arduino, because the motor happened to be such a low current device. This circuit diagram was on pighixxx.com:

Would this design, which shows how to turn a motor off/on by setting an IO pin low/high, allow variable speed control of a motor by using PWM on that same IO pin?

It says "recommended only for switch or low frequency applications" which makes me question that.

Thanks for your patience. I started off with some misconceptions and it's hard to overcome errors you thought you were getting right all along ... after all, the project worked for months with the little motor. :)
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Nov 03, 2015, 10:54 am

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: jack wp on Nov 04, 2015, 02:37 am
I see no problem with your schematic in post #13. "Low frequency" is ambiguous, but I think the 500hz from the PWM would qualify.
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: amirf on Mar 27, 2019, 12:47 pm
I have tried drawing current from more than one pin and it goes close to 200mA. Still it didnt work for me as Fona 3G board needs closer to 500mA occasionally.
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Mar 27, 2019, 01:16 pm
I have tried drawing current from more than one pin and it goes close to 200mA.
That's crazy. I/O pins should not be used as an energy source.

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: MarkT on Mar 27, 2019, 03:02 pm
Thank you -

I guess I just got lucky that my original functioning project didn't cook the Arduino, because the motor happened to be such a low current device.
Luckier than you think, the low current won't protect you from inductive kick-back.

If you switch inductive loads (motors are highly inductive, like relays, solenoids), then you _need_
to protect against kick back, typically with a free-wheel diode (in a DC circuit).

What was happening with the 30mA motor (which BTW probably drew much more than that
at stall), was the ATmega's input anti-static protection diodes were taking the current pulses
and acting as free-wheel diodes, despite them being rated for more like 1mA than 30mA.

If a protection diode were to fail, the inductive pulse voltage would be enough to blow away
the output driver for the pin, and perhaps the whole chip.

This sort of abuse typically leads to seeming random failure at some point in the future, and
is likely to bite back one day when least expected!

The pins on any logic chip like a microcontroller are for signalling, not for powering.  For convenience
the ATmega pins can drive very high currents (for a logic device), to make it convenient to
shine LEDs, drive opto-couplers, etc.  In general a logic signal might be rated for 5mA or so,
sometimes more, sometimes less.
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: Robin2 on Mar 27, 2019, 05:26 pm
Luckier than you think,
Sorry to say that was 3.5 years ago :)

...R
Title: Re: How much current can I drain to an Uno digital I/O pin?
Post by: MarkT on Mar 27, 2019, 06:43 pm