Jump to content

What is the maximum current input on an Arduino?

AndrewCam100

Hello!

 

I have an Arduino Mega. I am using it to control a bunch of relays, and none of my power supplies will get all of those relays powered successfully. Would using the 12v, 19amp computer power supply that is used for the things I am powering with the relays cause harm to my Arduino?

 

Thanks in advance!

if day == Friday:

  Celebrate()

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you for the advice. I am using relays to power on a few 12 volt LED strips around my bedroom. There is going to be 7 relays that need to all be powered once everything is wired. I do not have access to MOSFET's as of right now, so would using some transistors help?

if day == Friday:

  Celebrate()

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, AndrewCam100 said:

Thank you for the advice. I am using relays to power on a few 12 volt LED strips around my bedroom. There is going to be 7 relays that need to all be powered once everything is wired. I do not have access to MOSFET's as of right now, so would using some transistors help?

You could use the transistors to switch your relays. They won't be able to switch the LED strips directly, but you can use an NPN transistor or even a Darlington pair to easily switch on and off the relay, just make sure to use a flyback diode. 

 

Quote

The only reason to use relays is because you might want to have your grounds isolated, like switching on and off 120v AC. If you can, try to use N-Channel mosfets configured on the low-side of your load since they are cheaper, will switch much faster, and aren't prone to mechanical wear.

+1. Using a MOSFET would also allow you to control the brightness of the LEDs using pwm signals. 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Most relays pull more current than a single GPIO pin can supply on a microcontroller. Generally what you need to do is have a transistor control a larger supply of current into the coil of the relay. Almost like having a relay control a relay controlled by your arduino. I ran into the same problem on my first semester engineering project, had to bodge in a 2n2222 at 3am lol.

ASU

Link to comment
Share on other sites

Link to post
Share on other sites

 

The Arduino chip can output something like 150 mA throughout all its pins, but only around 10-15 mA through each of its i/o pins.

This information is listed in the datasheet ... just look on what chip is on your Arduino (Atmega328 or something like that), download the datasheet, and then go to "Electric specifications" or something like that.

 

You can absolutely control 7 or even more solenoids or whatever using an arduino, as long as you use the proper transistors or mosfets.

Find some transistors with high hFe or Beta ... that's the ratio between how much current has to be supplied on the base of the transistor for it to open and conduct electricity (work like an on/off switch)

There are transistors with very small hFe of around 50-100 and there's transistors that go up to 200-500 or Darlington pair transistors that go to 1000 or higher.

 

For example, there's cheap generic through hole transistors like 2n3904 *see page 4, hFe section, on 100mA row) which have a minimum gain of only around 30 , so if you need it to open for at least 100mA you need at least 3-5mA of current on the base pin which is a lot.

There's also relatively cheap transistors like MMBT4401 with minimum gains of 100 (typical 300) at 150mA so these would need around 1-2mA on base pin to work fine with your solenoids or whatever you use

 

Darlington transistors would have a higher gain, but there's bigger voltage drop between collector and emitter (not really a big issue with relays, which can work with a wide input voltage (for example 12v relays will start working from around 10v)

 

A very popular part for use with relays, solenoids, even led segment digit displays is ULN2003A (and others in the series) ... it's a chip that has 7 darlington transistors in the package with the base resistors built in, so you don't have to put resistors (to limit current going into the bases of each darlington transistor) and the current is limited to some very low figure like 1mA or less

There's versions with resistors inside (the ones ending with A usually) and there's some models that are designed to get 12v or more on the base pins and won't work well with microcontrollers.

ULN2003A has the resistors on base pins chosen to work well with 3.3v ...6v so it works fine with microcontrollers, and has a hFe of around 1000, so less than 1mA per base pin is needed

See:

ULN2003A STMicroelectronics | Discrete Semiconductor Products | DigiKey

ULN2003AN Texas Instruments | Discrete Semiconductor Products | DigiKey

 

Here's the internal of each transistor in the package : http://www.ti.com/lit/ds/symlink/uln2003a.pdf (page 12)

 

image.png.e185aa5a17569b5b62a00324656d427e.png

 

So the negative lead of the relay goes into C and E is connected to ground.. when the microcontroller sends some current on the base pin, transistor is turned on and connects C to E, therefore creating a connection between them and the negative of the relay gets connected to ground through the transistor and relay gets power flowing through it.

The 2.7k resistor limits the current so you don't need extra resistor on the base pin. 

As an added bonus, you also get the flyback diode which otherwise has to be used with relays to protect a switching transistor or mosfet from the rising energy that occurs when the magnetic field inside the relay/solenoid coil collapses (as it's turned off) ... so that COM you can connect to your 12v input (or whatever you use to power the relays)

 

These ULN2003A are rated for up to 500mA but not continuously... there's charts in the datasheet... if you have to keep several relays turned on for long periods of time, it's recommended to not use all 7 transistors inside (or to pair transistors together and use a chip to power only 3 relays for example, pairing 2 transistors at a time and leaving one unused)

Basically see how much current each relay uses, and assume you can safely do 100-150mA 24/7 ... so for example if a single relay consumes 20mA, if wouldn't use more than 4 or 5 on a single uln2003a

 

image.png.6e850cd6ee6cdefb214cbb3bf13e06f5.png

 

This is why these are often used for 7 segment led digits ... let's say you have 4 digits each with 8 segments so you have 4 common anodes or 4 common cathodes, and use 8 pins from micro to turn on or off the segments of one digit at a time.

With 10mA per segment, you're looking at maximum 80mA per digit on the led display, and if you use a uln2003A to quickly switch between those 4 digits that means you have a 25% duty cycle  and in the graph above your N is 4 because only 4 transistors are used... so at 25% duty cycle and 4 transistors, the uln2003A can do up to around 400-450mA in total, or a bit more than 100mA per transistor/digit.

 

A 12v relay shouldn't need more than around 40-50mA, should be around 20mA or less. 5v relays would use a bit more current.

 

Also see this very good video explaining how to use npn transistors with solenoids (relays is same thing) :

 

Tutorial: How to design a transistor circuit that controls low-power devices - YouTube

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Minimalist Manta Ray said:

Using a MOSFET would also allow you to control the brightness of the LEDs using pwm signals. 

That's somewhat of a too broad blanket statement. MOSFET's have a gate capacitance which must be charged each time you want to turn it on and discharged each time you want to turn it off. Depending on the MOSFET in question, this gate capacitance can be significant and require large currents to switch the MOSFET on and off quickly. Gate drivers are used to mitigate this problem.

 

So you can't just choose any MOSFET. You need one with a low enough gate capacitance so that the arduino can drive it fast enough for PWM.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Unimportant said:

That's somewhat of a too broad blanket statement. MOSFET's have a gate capacitance which must be charged each time you want to turn it on and discharged each time you want to turn it off. Depending on the MOSFET in question, this gate capacitance can be significant and require large currents to switch the MOSFET on and off quickly. Gate drivers are used to mitigate this problem.

 

So you can't just choose any MOSFET. You need one with a low enough gate capacitance so that the arduino can drive it fast enough for PWM.

I agree. While not optimal, some MOSFETs can be switched directly with an Arduino. Using a MOSFET driver is certainly better in most cases.

Link to comment
Share on other sites

Link to post
Share on other sites

Depending on what you want to delve into and how much you want to learn there are a few options.

 

Discrete components is better for learning. Can also learn about things like biasing, pull up or pull down resistors and protection diodes/zeners.

 

As @mariushm has pointed out you can get ICs that simplify things as they incorporate it all in the package. Can get even more expensive types like ones with a serial interface, higher current and protection specifically for inductive loads.

 

Lastly there is the option of cheating and going for an off the shelf shield or module with it all ready to go.

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you so much for the help! Because I have some bad experiences with frying transistors, I used two power supplies and connected the positive rails of both, and now it works much more reliably. I never would have guessed that the issue was just powering relays from pins. 

Thanks again!

if day == Friday:

  Celebrate()

Link to comment
Share on other sites

Link to post
Share on other sites

20 milliamps. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×