Opto Isolator Circuit

Discussion in 'Embedded Systems and Microcontrollers' started by skusku, Jul 22, 2015.

  1. skusku

    Thread Starter Active Member

    Aug 9, 2009

    I would like to make a microcontroller circuit that switches a relay to switch a 220V load on/off.
    I want to add opto-isolator because previously I tried to do exactly the same with a 220V solenoid
    and my Arduino received some nasty feedback and just restarted the program every now and then.
    I have yet to solve it.
    I just need a bit of help with the opto-isolation part of the design.
    Connecting the relay ground and the ground to the PIC makes the opto- isolation useless in my opinion.
    Do I need two separate power supplies or can someone help in adjusting the circuit correctly?
    The second power supply would obviously go to the output side of the optocoupler and the grounds not connected.
    Thus 2 separate VCC's and 2x GND.
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    Buy an opto-isolated SSR.

    In your schematic; you obviate the benefits of opto-isolation by connecting the 0V side of the "isolated" side supply to the 0V of the Arduino supply. If you do that, why bother opto-isolating?...
    Last edited: Jul 22, 2015
  3. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    Depending on what type of load the relay is switching power to, a purchased SSR probably is the least effort on your part. You are correct, tying the relay gnd to the systen gnd defeats the purpose of the opto. If you want to stay with your current arrangement, then you do indeed need isolated power for the output side of the opto.

    Also, D1 is not needed and D2 is in backwards.

  4. ebeowulf17

    Well-Known Member

    Aug 12, 2014
    Did you have the flyback/freewheeling diode on the coil of your relay when you tried this previously without the opto? I would expect that diode to eliminate most kickback from the relay coil.

    In the last attempt, was the relay coil being powered directly by the Arduino, or was there a transistor in between? Because most relays draw more current than Arduinos like to handle, especially when first activated.

    As for this circuit, you would definitely need separate VCCs for this to provide any isolation. I'm less certain about sharing grounds. Seems ok to me, but I'm still learning and make lots of mistakes!

    Also, the LED is shown backwards. It would never light as drawn.

    For complete isolation without two separate low voltage sources, you might want to look into triacs and triac-based opto isolators. With those, everything on the far side of the Arduino is high voltage. Of course that means doing more work with components at high voltage, which may be a bad idea depending on your experience and comfort level.

    Better still, just pick up a pre-made SSR (essentially what the last paragraph described anyway) to replace both opto and relay.

    EDIT: Oops, took too long typing. Everyone beat me to it!
  5. crutschow


    Mar 14, 2008
    In your original circuit make sure you have a diode across the relay coil.
    Also run the relay driver ground and relay power directly back to the power supply, not connected through the Arduino circuit.
    That may solve your problem.
  6. skusku

    Thread Starter Active Member

    Aug 9, 2009
    My original circuit had a flyback diode in, and there was a transistor connected in between. However it wasn't a darlington pair opto isolator and then required the transistor otherwise the relay would not switch. With the darlington pair the relay switches just fine. Previously it was connected to a PC to handle the I/O through RS232. But for some reason it just reset my MCU after a few minutes every time the 220V solenoid was connected. When I disconnected the 220V plug, the MCU ran 100% with no problem.

    I fixed the LED, just drew it opposite side accidentally. The diode D1 I saw from another circuit yesterday and did not include it previously.
    Was just hoping that diode could stop some unwanted noise.
    The circuit is supposed to measure voltage across a set of batteries, 400aH 24V. So the charger is going to be a 20amp or 30amp, otherwise I would have just connected the charger output through the relay and that would be +-28V. But since the current is so big, I was thinking of rather just turning the battery charger on through the relay (as a on/off switch) instead.

    So my options are SSR and Triacs?
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    If your Arduino is measuring the battery bank, then there must be a common ground between the battery bank, charger, and the Arduino. Are you powering the Arduino from the battery bank being measured?
  8. skusku

    Thread Starter Active Member

    Aug 9, 2009
    Mike. The Arduino was a previously designed circuit to power two 220V solenoids. The circuit I have attached now is for the battery charger circuit using PIC IC.
    I would not prefer to power the IC from the battery bank that needs to be monitored and charged. Would you advise to use those batteries to power the circuit as well?