0
\$\begingroup\$

I have already done research on how to turn on a relay with an optocoupler but I am still confused on some aspects. My diagram works great even though I am doing things incorrectly.

schematic

simulate this circuit – Schematic created using CircuitLab

Diagram explanation:

  • On the right side:

I have an atmega328p chip (arduino) running on 3.3V instead of just a 3.3 battery. I drew it that way to make it simple to illustrate. Arduino datasheet states that it should run on 5V but it runs fine on 3.3V. That circuit uses 40 mA.

  • On the left side:

I have a relay connected to a 6V battery. That circuit uses 112 mA.

Questions

  1. I first used 100 Ohms on the right side of the diagram instead of 50 because that used 20mA of current. Arduino states that you should not use more than 20mA of current per pin. My question is why is it that it does not work with a 100 Ohm resistor? Here is a picture of what I had to do in order to make it work:

enter image description here

as you can see on the image I had to solder another 100 Ohm resistor in parallel in order to make it 50 Ohms because it was not triggering the relay. So now I know I am braking the rule and the pin of Arduino is outputting more than 20mA.

  1. If it works now with 50 Ohms resistor how long could it run without breaking?

  2. Let's say I use another microcontroller where I am able to output as many amps I want per pin. Or just to make it simple I have a battery connected just like on the diagram instead of having a microcontroller like Arduino. How can I know if 40mA is to much current for that optocoupler running at 3.3V? Moreover, on the left side of the diagram how can I know if 112mA is to much current? I been trying to find the datasheet for that optocoupler and I cannot find those specs.

  3. Let's say I decide to buy a different optocoupler because I cannot find the datasheet of that one. Let's say I decide to buy this one:

enter image description here enter image description here

I can see on those specs that it can take up to 20mA so I will have to use 100Ohm resistor assuming I still use 3.3V. Where is the info on what is the max current it can take in and what is the max current it can output? For example will 112mA will be a lot of current for that optocoupler? Where can I find that info on the datasheet? I know I can make use more components in order to follow the specs but it will be nice if I could understand what are the maximum values I can use

\$\endgroup\$
2
  • \$\begingroup\$ My diagram works great - not for me it doesn't - it's confusing and you appear to have the input supply connected incorrectly. The output transistor connections are unfathomable. \$\endgroup\$
    – Andy aka
    Aug 5, 2021 at 13:58
  • \$\begingroup\$ LED polarity is backwards. Opto-transistor is backwards too if it is an NPN. \$\endgroup\$
    – Transistor
    Aug 5, 2021 at 14:54

1 Answer 1

1
\$\begingroup\$

The 4N35 optocoupler input is tested at 10mA so the input from AVR to LED should work just fine with a 100 ohm resistor.

But the 4N35 output has an absolute maximum current limit of 50mA, so it can't be used to directly drive a relay that requires more than 100mA.

There is also no diode over the relay coil to protect the optocoupler transistor from inductive kickback so the optocoupler transistor may be damaged.

Those might be the reasons it needs excessive input current to operate the relay.

\$\endgroup\$
1
  • \$\begingroup\$ Justme thanks for the help. Where do you find those values on the datasheet? \$\endgroup\$
    – Tono Nam
    Aug 5, 2021 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.