Optoisolator on Relay control - Page 1
Forum section: electronics / projects

author: dan3460
author_rank: Frequent Contributor
timestamp: December 20, 2016, 04:45:05 pm
content: Please excuse this novice question. I'm working on a project where a current is monitored by a microcontroller and if exceeds certain amperage a couple of relays a triggered to shut down the mains connection. I have been working with eBay arduino parts for the concept and I'm building a prototype board to continue testing. The relay board that I'm using has an optoisolator separating the relay from the connection to the controller.The relay that i'm considering for the final product, based basically on the coil power consumption, has a several thousands volts of isolation, do I need to add the optoisolator on the final product? I think the controller can be tied directly to the coil side of the relay. I would put a diode across the coil to protect the controller from any spike on voltage as the coil changes state.Suggestions?

author: Brutte
author_rank: Frequent Contributor
timestamp: December 20, 2016, 04:57:51 pm
content: No need for extra optoisolation. Just do not drive a relay directly from IO pin. Relay coils are typically powered from 12VDC or 24VDC (most popular) so just use ULN2003 or similar transistor to drive that. Back EMF protection diode is a must.Also make sure that after you power up the board and before the uC ends booting up (which can take several ms) the relay has to be unenergized.

author: ajb
author_rank: Super Contributor
timestamp: December 20, 2016, 05:56:34 pm
content: If the microcontroller and the relay coils are powered from a common supply then there's no point in including isolation between them. If the supplies are separate, then isolation could be required (or at least a good idea).

author: dan3460
author_rank: Frequent Contributor
timestamp: December 20, 2016, 06:17:56 pm
content: Understand, the relays that i'm considering are driven by 5V.

author: Dave_PT
author_rank: Frequent Contributor
timestamp: December 20, 2016, 06:43:19 pm
content: Use a MOSFET to activate the relay and is done.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 20, 2016, 07:26:38 pm
content: The circuit is in principle ok, but the choice of FET is bad: Suitable fets are small low level MOSFETs, so more like 2N7000 or BSS138. One can also drive a relay with a NPN transistor, especially if you get some with integrated base resistor.

author: Seekonk
author_rank: Super Contributor
timestamp: December 20, 2016, 10:10:32 pm
content: Not a fan of using 5V for relays. Pretty easy to get into trouble with voltage dips if the supply is minimal. Assume there is a higher unregulated voltage. You can still use that higher voltage to drive a 5V relay though. I generally PWM relays to save current anyway to lower hold in voltage. Operating a 5V relay off 8-12V is easy and minimal heat. Just pull in at 255 and count down each loop till 150.

author: dan3460
author_rank: Frequent Contributor
timestamp: December 21, 2016, 12:31:42 pm
content: Understand, but there is a space restriction on the final product, reason why I'm sticking to a single voltage regulated power supply.I'm at work now so I don't have the specs of the relay but I think the amperage used was only 40mA which I though will be ok for one of the digital ports to take. I will look on the suggestion of a FET or BJT to drive the relay.I'm using a digital instead of a PWM because I don't want the controller spending time calculating other parameters, it uses several clock cycles just figuring out what the amperage is and if it should react or not.Thanks for the help.

author: Seekonk
author_rank: Super Contributor
timestamp: December 21, 2016, 03:26:27 pm
content: I don't buy any of those excuses.

author: Siwastaja
author_rank: Super Contributor
timestamp: December 21, 2016, 03:43:20 pm
content: Quote from: dan3460 on December 21, 2016, 12:31:42 pmThe bypass caps that are absolutely required near the relay supply are eating up the space anyway, so you are, in principle, having "separate supplies", separated by trace inductance and bypass capacitance, anyway. Using 12V relays and a 5V regulator off this same 12V supply in fact may make the complete circuit footprint smaller, or at least more robust, since now you have the regulator PSRR in your advantage, you are allowed several volts of ripple in the 12V line, and the coil currents are smaller, generating less ripple.5V relays off the shared 5V MCU supply is a recipe for a disaster for a beginner. Handling it properly takes the same PCB room and design skills it takes to do it with a "separate supply", but the "separate supply" strategy kind of forces you to do it right, so I'd recommended it for a beginner.tldr: If you have 12V available, use 12V relays, use elcaps near the relays on the 12V line. Regulate down with a 5V reg for the MCU, with proper local caps both before and after the regulator.

author: dan3460
author_rank: Frequent Contributor
timestamp: December 21, 2016, 05:14:00 pm
content: oh guys, you are tough.Will take your advice and look at my design again.I really appreciate your help.