Limiting Current Output Of Arduino pins

Hi,

I have an Arduino Micro. For my project, I need to use many outputs, but I'm worried I may overshoot the maximum current output of 200mA and thus damage the Arduino Micro I'm using. I'm a noob in terms of Arduino, though know a fair deal about electronics in general.

The Arduino Micro I'm using is outputting as follows:

4 output pins connected to an L293D driver chip, with 2K2 Ohm Resistors - this is to drive a bipolar stepper motor.

3 output pins connected to 3 input pins of a PICAXE 28X2 microcontroller for interfacing easily.

3 output pins connected to 3 input pins of a GENIE E18 microcontroller, again for interfacing.

1 output pin connecting to a loudspeaker (using the full 40mA which is amplified using a Darlington BDW 93C transistor to roughly 200mA).

Just to clarify, the Arduino Micro is the main microcontroller, which does the "heavy lifting" processing, while the PICAXE and GENIE microcontrollers control subsystems of the circuit.

At any one time, these outputs could all be on, i.e. being used. I am conscious that having 11 outputs at once means that I could damage the microcontroller if I go past 200mA. However, the only way I am able to solve this is through limiting the current outputted - reducing the number of outputs used at a time is out of the question, to make things clear.

The input pins of the GENIE and PICAXE microcontrollers are high impedance, so I would like to limit the current to as little as possible, the inputs just need a 5V input when the output goes high. I would like as little current to flow to these pins, just enough for the 5V output to be registered by the input pins of the said microcontrollers.

I would prefer to only limit the current of the 6 outputs going to the microcontroller, though if not possible I could limit the current for the 4 pins going to the L293D (again, this is a last resort situation).

Is it possible to limit the output current through programming or through hardware?

P.S. Sorry about the length of this post - this is my first time posting a question on the forum and I wanted to make sure I gave enough detail about the project.

s it possible to limit the output current through programming

No.

or through hardware

Yes, use a resistor.

However nothing in that lot is going to draw anything significant so there is no problem.
There is no need to limit the current from pins driving other ICs. The only problem will happen if you are trying to drive lots of current like driving lost of LEDs.

using the full 40mA which is amplified using a Darlington BDW 93C transistor to roughly 200mA).

But that is not coming from the processor is it?

TechWiz123:
1 output pin connecting to a loudspeaker (using the full 40mA which is amplified using a Darlington BDW 93C transistor to roughly 200mA).

You most certainly do not want "the full 40mA" (even if that were sensible) to drive a Darlington - one mA would be just fine, obviously you must have a resistor in series with the base - 3k3 would suit. You really do not need a Darlington anyway, if it is only 200mA a general-purpose transistor fed with 5 mA (1k resistor) should suffice.

It should be kept in mind that Darlingtons do not switch efficiently at all and especially at low (logic) voltages - you have to have a really good and well thought out reason to use one.

Thanks for the speedy replies.

Grumpy_Mike:
Yes, use a resistor.

However nothing in that lot is going to draw anything significant so there is no problem.
There is no need to limit the current from pins driving other ICs. The only problem will happen if you are trying to drive lots of current like driving lost of LEDs.
But that is not coming from the processor is it?

Sorry, I’m not quite sure I understand.

Let me get things straight.

  1. What is the normal output of an Arduino pin? I was under the impression it was 40mA unless you used a resistor in series with the output. Again, I don’t know much about Arduinos, so do correct me.

  2. Regarding the pins to other ICs, why wouldn’t you need to limit the current? How much current is actually outputted to the pins?

  3. I will explain my reasoning behind the loudspeaker circuit. So in essence, the Arduino output is amplified using a non-inverting op amp circuit to 16V [5*(1+2.2)]
    This output is fed into the BDW 93C. I have used this transistor as it can handle a large load, and has a high gain (of 750). I use a 150 Ohm resistor in series with the transistor to power a loudspeaker.

I have attached my circuit. The tuner part of the circuit works fine, but I would be more than happy for you to critique the amplifier circuit and improve if necessary.

@Grumpy_Mike - So there are no issues regarding damaging the Arduino with too much current?

Just to be clear, could you fully explain any replies, sorry about the hassle, but it would really help.

  1. What is the normal output of an Arduino pin?

It is 5V or 0V.

was under the impression it was 40mA unless you used a resistor in series with the output

No. the 40mA is a limit on the current that you can draw from a pin. This depends on what you are driving with the pin. If it is another input then the current is determined by the input impedance of what you are driving. Things like other chips have a high input impedance. Things like LEDs and speakers need the current controlling and one simple way to do this is with a resistor.

  1. Regarding the pins to other ICs, why wouldn't you need to limit the current? How much current is actually outputted to the pins?

In technical terms it is sod all. The input impedance of a chip it typically 10M so with 5V that would be a current of 0.5 uA, it's a long way off 40mA.

That circuit is not going to work. There is no source of power for the output. All a transistor can do is to control the flow of current from a source of power. The transistor is not connected to any source of power. If you want it to work then remove the ground connection from the speaker and replace it with a connection to one of the + supplies.

So there are no issues regarding damaging the Arduino with too much current?

There is only an issue when you are driving things that have a low impedance and so then you have to consider the current situation.

I am afraid that circuit is a total disaster!

You need to forget it and start again. Perhaps you should carefully explain to us just what - and exactly what various functions you wish to execute.

Your first op-amp has a 100 nF capacitor across its output. That is wrong. What were you attempting to do with this?

Your second op-amp and everything following it is complete rubbish - makes no sense at all. If you want a modest audio amplifier, you want a LM386 module, though if you seriously want 5W - which I doubt - you will need something more again.

If you have an 8 ohm speaker, and drive it directly with 0-5V source then the max current that would flow is
5V/8ohm = 625mA,
and the max wattage seen would be
P=IV = .625A x 5V = 3.125W.

If you want 5W than you need a higher voltage source, like 9V or 12V.
What you can do is use a transistor to sink current thru a speaker.
I can't seem to "reply" so I can't attach any diagrams (only Quick Reply seems to be working).
If you google "one transistor amplifier" you can see several examples:
https://www.google.com/search?q=one+transistor+amplifier&biw=1680&bih=929&tbm=isch&imgil=hQeSFu8MfJiFhM%3A%3Bgz7078xVI-uZbM%3Bhttp%253A%252F%252Fpzwart3.wdka.hro.nl%252Fwiki%252FUser%253ALieven_Van_Speybroeck%252FElectronics%252F1_Transistor_Amplifier&source=iu&pf=m&fir=hQeSFu8MfJiFhM%3A%2Cgz7078xVI-uZbM%2C_&usg=_1MoFdr6o07tWTrJhe7hYpFVNdE%3D&ved=0CCkQyjc&ei=tFWYVOCcM8OjNpvhgagI#facrc=&imgdii=&imgrc=hQeSFu8MfJiFhM%253A%3Bgz7078xVI-uZbM%3Bhttp%253A%252F%252Fpzwart3.wdka.hro.nl%252Fmediawiki%252Fimages%252F3%252F37%252F1_Transistor_Amplifier.jpg%3Bhttp%253A%252F%252Fpzwart3.wdka.hro.nl%252Fwiki%252FUser%253ALieven_Van_Speybroeck%252FElectronics%252F1_Transistor_Amplifier%3B652%3B372

Okay, thanks for the brutally honest feedback, it helps if you are surrounded by critics.

Paul__B:
Perhaps you should carefully explain to us just what - and exactly what various functions you wish to execute.

I ought to explain my project in its entirety. It is a tuner, metronome and amplifier.

So the first op amp circuit - that is a pre-amplifying circuit. It takes the input from the guitar lead jack, and amplifies it to about 2.5V, and offsets it by 2.5 so the Arduino ADC input can read it. This is for the tuner.

Paul__B:
Your first op-amp has a 100 nF capacitor across its output. That is wrong. What were you attempting to do with this?

To clarify, the 100nF going to ground is a bypass capacitor, helping to filter out AC noise.

This circuit definitely works. I personally have breadboarded it, and the tuner works satisfactorily. There is no issue with this circuit; I have correctly got the frequency readings for the tuner, contrary to your beliefs.
I will admit I was sceptical about it working when I first came across it at http://www.instructables.com/id/Arduino-Guitar-Tuner/?ALLSTEPS
However, when using an LM741, it works fine.

The circuit could be adapted so the SPDT switch choosing between the tuner and amp goes before the tuner preamplification circuit, and then the amplifier is dealt separately.

Regarding the second op amp circuit, I will further clarify. The guitar jack input needs to be amplified to 5W, the Arduino output does not need to operate the speaker at 5W. The Arduino output is simply for the metronome - it does not need to be quite as loud, just reasonable, like say 1W, so I suppose that circuit could be altered.

To make myself as clear as possible,

i) The guitar jack input is used for a tuner, hence the first op amp circuit
ii) The Arduino output is used for the metronome, it does not need to be 5W, just a reasonably loud output.
iii) The guitar jack input is also used for the amplifier - this, I would like to be 5W, it does not have to be that loud, I am perfectly happy with the 3.125W output suggested.

I only have LM741 op amps, I am looking for something that functions well, I do not want the absolute most efficient amplifier.

One question, I do not see where the second op amp circuit fails, it is the standard op amp non-inverting gain circuit. The method of amplifying the current, I will admit using the Darlington may not have been the best option. And yes, I should have connected the speaker to +V not to 0V, but I think although there might be better ways of designing the circuit, I think this is perfectly functional. I shall breadboard the circuit with the speaker alteration mentioned above and feedback, (it may very well be the case that I was utterly wrong, I will be the first to admit it).

If you have better suggestions, please do feel free to post schematics and links to schematics.

Thank you for your guidance, it really does help to have experienced people critiquing.

I will try and be as clear as possible in future, I can understand it may not be easy to garner all the key details from a post in the forum.

If you guys have any alternative circuits for the guitar jack amplification circuit please do post, I don't have much expertise there so would love feedback, that would be really appreciated. I wasn't too sure on the specifics when designing the circuit, that is not an area I know a great deal about, I just tried to design a circuit using "known unknowns".

I will redesign the circuit so the guitar amplifier is entirely independent of the tuner, aside from a switch to choose between the two. Could you guys give pointers/ post circuits that should work?

Thanks again for your time and feedback.

Hey guys,

So as you may have realised, my knowledge of guitar amplification circuits isn't too great. Would anybody be able to guide me in redesigning a circuit for guitar amp to 5W, with a +/- 18V power supply and volume control. All help would be really appreciated, please could you post schematics and a detailed explanation of what the circuit does. Sorry, it's just this avoids future misunderstandings.

I can only use LM741s though if there is a significant advantage to using other op amps, this would be appreciated, though I can only get stuff from rapidonline.com

Thanks

TechWiz123:
a circuit for guitar amp to 5W, with a +/- 18V power supply and volume control.

I can only use LM741s ...

The 5 Watt output line and the LM741 line do not intersect.
You should walk that over to "google".
The final output of your dwg., the resistor in series with an 8ohm spkr, terrible - and not a 5W winner.
The LM386 is a workhorse, it's been done to death; "crude" but effective.

Given your present design skills, you need to forget about constructing a 5W amplifier. I would not try to do it, other than in kit form. Go get a module to do it. Let me see, try eBay, what can we find?.

Here we are! Looks like the very thing.

So you have some LM741s? Fine, keep them in case you need them for some project. This most certainly is not it!

Not sure what your fondness for Rapidonline is, but they simply do not seem to offer anything relevant.