Pages: [1]   Go Down
Author Topic: Arduino relay control - Why the resistor and transistor?  (Read 1408 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am a complete beginner to electronics and microprocessors and am designing a project that uses an Arduino to switch a kitchen appliance on/off and also to control a linear actuator.

I've got a big SSR to switch the appliance and a small one for the actuator which operates on 12 VDC at 50mA.

I've been looking at some schematics for circuits that feature Arduinos controlling things like solenoids and have notices that the circuits always seem to include a resistor and a transistor.

I thought the whole point of using a relay was that it allowed you to switch relatively large currents using small control voltages so I'm surprised that a transistor would be necessary. So why can't you just control the relay directly with the Arduino?

Also, in the attached schematic there is also a resistor - what is its purpose?

Will I need to design separate circuits like this to control both of my relays?

Thanks.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Some relays can be controlled with 5V and <35mA of current so the arduino pin can drive them directly.

Other relays need more current, or a higher voltage, so  a transistor is needed to switch that higher current.

The base of an NPN transistor looks like a diode to ground. The resistor limits the current to keep the arduino pin from being damaged.

(5V - 0.7V)/35mA = 123 ohm, so use something like a standard 150 ohm resistor to turn the transistor on full, and protect the arduino output pin.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Crossroads.

So the Arduino is limited to an output of 5V @ 35mA?
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5594
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Crossroads.

So the Arduino is limited to an output of 5V @ 35mA?

Technically, individual pins of the ATMega328 are limited to 40mA @ 5V (HIGH), but you never want to hit this "absolute maximum" amount; so you should limit to something lower than this. 35mA to me seems like cutting it close; I would actually limit things to something even lower in a design (especially if you are using more than one pin; more on this in a moment) - maybe 20-25mA. If you are using more than one pin, though, the ATMega328 (IIRC) is limited to a total output of 200mA @ 5V (thus, if you limited your current draw on all pins to 20mA each, you could "turn on"/"set HIGH" up to 10 of them at one time).
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1616
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Well a lot my Seniors CrossRoads and Crosh have defined  already.
but on following:

Quote
So the Arduino is limited to an output of 5V @ 35mA?

I want to say that it's a lot(the current), always the Micro-ontrollers which ever you take up whether they are picaxe(another nice forum backed microcontroller) also the many others like PIC, Parallel Propeller etc all supply current nearby this level only, The thing they are there to process the code made by you and then achieve the final result via. supporting circuitry the same you are doing now giving resistance and diode and a relay to handle high current stuff.
                                                      Not only Microcontroller/Microprocessor's work like this other sort of IC's also call for supporting circuitry to achieve a goal.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So the Arduino is limited to an output of 5V @ 35mA?

I think one reason begineers have difficulty understanding about output pin current 'limits' is the very use of the word limit. I think many think the output pin can (or should) self 'limit' itself to it's 40ma max value, which of course it can't. The word limit as used by the specification, is a value the user must insure that their external circuitry does not attempt to draw more then that specified current 'limit' as doing so will cause higher then rated current to flow and thus subject the pin and chip to damage.

Lefty

 
Logged

0
Offline Offline
Shannon Member
****
Karma: 214
Posts: 12443
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's a good point - often bad names persist for historical reasons, abs. max limits are really "thresholds of permanent damage", and are the counterpart of parameters like "breaking strain" in physical components (and not "safe working loads").
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
God Member
*****
Karma: 4
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The recommended/safe current draw for each Arduino pin is rated at 20 mA IIRC.

I typically use a 220 Ohm resistor driving the gate of a BS170 MOSFET as a low end switch for switching purposes. It works great when the load is <= 500 mA. I love the BS170 -- I bought a hundred for a pittance at Digi-Key and it's almost time to re-order :-)

Once turned on (or off,) there will be almost no current draw out of the BS170, so you never have to worry about pin limits or trying to saturate a device, like you would for a bipolar transistor.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, 20mA is the max a pin can sink or source and still meet it rated output voltage levels.
Above that current, the voltage may start to rise (sinking current) or droop (sourcing current).
And above 40, good chance the output pin will fail.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Most of my design, I prefer using a transistor switch circuit to control multitud of led's, relays, etc.  My raison is this question :

Which parts you prefer to fail ?

A ... Microcontroller
B... transistor

If you choose A. You have money & time to burn.  smiley-evil  If you choose B. You are wise.  smiley-mr-green

That is my raisoning.

 
Logged

Pages: [1]   Go Up
Jump to: