6

Are there any microcontollers on the market that would be able to drive this relay directly?

If not, what is the most cost effective way to have a microcontroller control 5 relays?

Federico Russo
  • 9,658
  • 17
  • 68
  • 117
Alexis K
  • 2,719
  • 8
  • 30
  • 33
  • 2
    your relay needs 12 V to drive its coil, so you're not likely to find a microcontroller to drive it directly. I think this question addresses the rest of your question: http://electronics.stackexchange.com/questions/15960/need-advice-on-microcontroler-to-switch-relay-on-off – The Photon Jan 25 '12 at 23:41
  • you may also refer that they explain very clean with c code. Complete tutorial project " Interfacing Relay with PIC Microcontroller" @ http://www.nbcafe.in/interfacing-relay-with-pic-microcontroller/ – user3220494 Feb 06 '14 at 07:23
  • Personally I'd describe that tutorial as "very low quality" instead of "very clean". But either way link-only answers are discouraged because they become useless if the link dies, instead you should include essential parts of the answer here. – PeterJ Feb 06 '14 at 07:45
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – alexan_e Feb 06 '14 at 10:02

2 Answers2

9

No uC (microcontroller) operates from 12V (except for 1 pin per uC for very niche application pins in a very few cases).

30 mA is more than the rated current from any uC

Drivers are easy and cheap.

  • 1 x ULN2803 or similar
    8 lines. $US0.89/1 pricing and datasheet.
    uC drives one input per relay. Relays connect output to +12V. No diodes or resistors etc needed. ie 1 IC and nothing else needed.
    Note that pin 10 (com) should also connect to V+ (12V here).
    Also note other family members (ULN280X).

Hundreds of related web pages


Circuit below same for FET or bipolar EXCEPT FET does not need base resistor.

enter image description here


Relay driving basics

Transistor relay driver

And again

MANY ICs made for the job

Russell McMahon
  • 147,325
  • 18
  • 210
  • 386
  • How is using a relay driver different than using a transistor and diode or are they the same? – Alexis K Jan 26 '12 at 00:54
  • @AlexisK they are the same, the IC just integrates the transistors and diodes into a single package. The IC drivers will also often employ a darlington pair for more current drive capability. – vicatcu Jan 26 '12 at 01:39
  • I have been trying everything out! One quick thing is I switched to a 5V relay. At first I did it the 5 x Mosfet way, like in the picture. It works! Then I wanted to see if I could simplify it a little so I used the ULN2803. However, this chip seems to work, but after about 5 seconds causes the mC to freeze. Any idea? With the mC I am connecting the output pin directly to pin 1,2,3... of the ULN2803. ULN2803 is grounded on pin 9 and at 5V on pin 18. One side of each relay is connected to 5V and the other side is connected to pin 10, 11, 12... – Alexis K Jul 26 '12 at 21:48
  • Do I need a resistor between the output pin of the mC and the ULN2803? Any idea about what could be happening? – Alexis K Jul 26 '12 at 21:49
  • @AlexisK - No resistor needed usually as ULN2803 has a 2k7 input resistor. Adding an external resistor of a few k ohm will redcue drive loading but too high will cause operating problems due to lack of drice. – Russell McMahon Jul 27 '12 at 05:59
  • @AlexisK - re lockup using ULN2803. Did you note my note and do it?: -> "Note that pin 10 (com) should also connect to V+ (12V here)." Failure to do this can be fatal. This places diodes across the coill - not needed IF you have external diodes. (Does no harm). – Russell McMahon Jul 27 '12 at 06:00
  • Yes. Pin 10 is connected to V+ – Alexis K Jul 27 '12 at 09:47
  • @RussellMcMahon "*30 mA is more than the rated current from any uC*" - At least some, perhaps all, in the Atmel atMEGA family source and sink 40 mA per GPIO, limited by total current at Vcc / Gnd. – Anindo Ghosh Feb 06 '14 at 09:25
  • @AnindoGhosh -Maybe downhill with the wind behind them :-). ie if you are happy for output voltage to be pulled very substantially by the load (say more than a volt at 5V Vdd) then you may indeed manage that. As far as I know Atmel tend to be somewhat quiet on the maximum operating IO currents you CAN achieve. They typically rate ATMega I/O at 40 mA absolute maximum, and graph of Vout versus Iout may stop at about 20 mA, with probably 0.5 V to 1V range pulling by the load. One can infer that they may get all the way to 40 mA if loaded hard enough but I don't think it's certain. I may be wrong. – Russell McMahon Feb 06 '14 at 09:43
  • ... What's achievable will also vary with temperature - if the processor can be air cooled or formally heat-sunk it should help somewhat. In this case, with a 12V relay he is of course out of luck (I know you know that). Even a 5V coil relay would often be 'at risk' re pulling in at coil voltages below 4V (holding would usually be OK if 4V can be maintained). Paralleling pins helps of course. – Russell McMahon Feb 06 '14 at 09:48
  • @Russell "***rated** current*". Also, I've just checked on an Arduino Nano clone (atMEGA328), sustained 35 mA into a Chinese sugar cube relay with no other loaded GPIO, just a bit warm and 4.35 V output. So you are right that the voltage drop is significant, but it kind of scrapes through. Not a solution I would recommend. Any case, I'm just being pedantic with you, don't concern yourself with my curmudgeonly remarks ;-) – Anindo Ghosh Feb 06 '14 at 11:10
  • @AnindoGhosh - I don't imagine that we disagree substantively once we are on the same page (data sheet or other :-) ). We can discuss it over a beer some time (or a Coke [tm] in my case). Microchip PIC long ago used to have higher than most I/O drive which AFAIR was typically 20 mA and actually specified numerically in the data sheet (as opposed to Atmel's graphs that "just stop". – Russell McMahon Feb 06 '14 at 13:54
4

No, none operate at 12V. Use five suitable BJTs.

Leon Heller
  • 38,774
  • 2
  • 60
  • 96