simple relay circuit - improvements? - Page 1
Forum section: electronics / beginners

author: snailFury
author_rank: Contributor
timestamp: February 01, 2014, 07:19:49 pm
content: Hi All, I've been working on a simple relay circuit. I've attached a block diagram I did in google draw. I've built the circuit and it works. I drew it afterwards by looking at my (ghastly) prototype board I soldered up, so hopefully I got it right! So what I am wondering is, am I missing anything essential like a capacitor to smooth things out, or something else to promote longevity of the components. The arduino and 12V supply are coming from wallwart transformers.My understanding of this circuit is:arduino triggers the npn which triggers the relay which controls "current"the diode is there for flyback protectionthe led is just and indicator for when the relay switch is closedBasically, does this circuit need to be improved?Can it be replicated on a single board?Other considerations?thanks!

author: Hideki
author_rank: Frequent Contributor
timestamp: February 01, 2014, 07:38:03 pm
content: No, you don't need anything else, but the 100 ohm LED resistor seems rather low if you're driving a normal led from 12V.You do however need a common ground connection to the Arduino, which I assume you have, since it works. It is however not drawn in, so we have to use our psychic powers to guess what you're really doing

author: mariush
author_rank: Super Contributor
timestamp: February 01, 2014, 07:42:53 pm
content: The 22kohm seems quite high to me - make sure the transistor opens enough.For example, let's say the relay needs 100mA to work, and the npn transistor has a minimum hFe of 80 and an average of 100. You need the transistor to let 100mA flow.If the transistor has hFe of 80-100, then be conservative and assume the hFe could be as low as 70 in some cases so that means that to have 100mA pass from collector to emmiter, you would need about 1.5mA at the base (1.5 x 70 = 105mA)To get the resistor value ... you have ohm's law V = I x R but don't forget there's a 0.6v drop on the npn transistor so 5v arduino - 0.6v drop = 0.0015 x R => R = 4.4 / 0.0015 = 2933 ohm. I would just go with a 2700 ohm resistor and allow up to about 2mA on the base.The pdf is not clear about how that diode is connected. The protection for the relay voltage is like this:If you want the led to light up when relay works, connect +beforeafter relay at 12v and the negative after relay, before npn transistor. 12v ---> resistor ---> + led - ---> after npn. Choose a resistor accordingly. Led has about 2-3v, and you want to let about 20mA go through the led so again v = i x r = > 12v -3v = 0.002 x R => R = 9/0.020 = 450 ohm so you can pick 470 ohm or something around that value, whatever is convenient. 10-20mA will be plenty bright, so no need to be super exact with the resistor, but 100 ohm will allow too much current (maybe about 70-100mA through the led) and will burn it.edit : corrected the led paragraph, i wrote something stupid before.

author: snailFury
author_rank: Contributor
timestamp: February 01, 2014, 08:00:54 pm
content: Yes mariush, you are right, I mistyped that - it is actually a 2.2K resistor.And the bar on the diode is facing back toward 12V.And regarding the LED, the 100ohm resistor is what was recommended for lighting an LED via an arduino tutorial so I just went with it. It looks nice and bright, but maybe too bright,...I'll look into that...

author: Fabiusp98
author_rank: Contributor
timestamp: February 01, 2014, 08:02:59 pm
content: It won't be better if you simplify the circuit by getting rid of the transistor and use a 5v relay?

author: snailFury
author_rank: Contributor
timestamp: February 01, 2014, 08:25:39 pm
content: Yes I think that it might be a possibility to use a 5V relay. I guess I didn't because I wanted to practice using transistors. Also, is a 5V relay limited by the amount to current you can pass? Might be a design limitation down the road as far adaptability

author: IO390
author_rank: Regular Contributor
timestamp: February 01, 2014, 10:14:01 pm
content: I would always use a transistor to drive anything much more than a LED with an arduino. 20mA from the o/p pins is about the max it can do.

author: electronics man
author_rank: Frequent Contributor
timestamp: February 01, 2014, 10:31:00 pm
content: I think it would be better to use a MOSFET than an npn as you won't need any resistors on the gate. And it thing you should start to draw schematics Instaid of. Block diagrams for this sot of thing

author: Psi
author_rank: Super Contributor
timestamp: February 01, 2014, 10:34:41 pm
content: Quote from: snailFury on February 01, 2014, 08:00:54 pmThe arduino tutorial is recommending 100ohm for driving a typicalLEDfrom the arduinowhich is 5 Volts.5 volts and a typical 3V led = 2V left. 2V / 100R = 20mA, which is a normal amount of current for an LED12V and typical 3V LED = 9V left. 9V / 100R = 90mASo to keep the LED from exploding you should use a 470ohm resistor.(Or you could use a bigger LED rated for 90mA and keep the 100R)

author: snailFury
author_rank: Contributor
timestamp: February 01, 2014, 11:23:54 pm
content: Electronics man - what free schematic program would you recommend I use? And thank you for the mosfet suggestionPsi - I stand corrected. I think my power supply is putting out a little less than 12V, but I take your suggestion regarding the resistor

author: Rerouter
author_rank: Super Contributor
timestamp: February 02, 2014, 12:00:59 am
content: If you want to get boards made i would say kicad, (its library editor is not the most obvious thing in the world to start using, but its good once you get the hang of it)

author: sdg
author_rank: Regular Contributor
timestamp: February 02, 2014, 11:31:41 am
content: Quote from: electronics man on February 01, 2014, 10:31:00 pmA MOSFET gate will draw I=Ciss*dVDG/dt. That can be enough to fry the output stage of a CMOS IC.Besides, a current-limiting resistor on the gate also offers some protection against ESD. Might be of some benefit if the MOSFET is on an Arduino shield and the shield is left unconnected.