Listening to 12V Signals with Optocouplers?

hi guys,

i am currently trying to figure out if i am doing this correctly or if i am missing something. Goal is to safely listen to various ~12V DC signals in my car. As most people know this voltage can vary quite a bit and i wanted to protect the arduino from any damage with some optocouplers:

I will use Arduinos Input_Pullup function which basically sets the digital PIN to high and put a 22k resistor in line.

my first draft:
the question is if i need indivual Resistors on the 12V side? or if i could simply use a single 10K (or other value?) to limit the current from the 12V lines.

the question is if i need indivual Resistors on the 12V side? or if i could simply use a single 10K (or other value?) to limit the current from the 12V lines.

Each individual opto needs it's own input current limiting resistor. By the way I would think 1k ohm resistors would be closer to the correct value Vs 10K ohms, but check the opto's datasheet for recommended led forward current operation.

Nice drawing by the way.

Lefty

this is the alternative and would save a couple of resistors... (need to listen to more than 3 inputs...)

this is the alternative and would save a couple of resistors... (need to listen to more than 3 inputs...)

No, that way would suck.

Lefty

i have received some fast replies but never one in between my two post of asking one question lol.

the datasheet says:
Forward current IF 60 mA

i am assuming the goal is here to undershoot a little bit? and take into account the voltage fluctuations as well? so lets say for a car maxV = 16 and that should give me about 50mA?
so V = IR
16/0.05 = 320Ohms?

i must say 60mA sure seems high for a tiny little led in an IC?

retrolefty:

this is the alternative and would save a couple of resistors... (need to listen to more than 3 inputs...)

No, that way would suck.

Lefty

figured as much....could you give me some input as to why "it would suck" ..just trying to get my EE straight :slight_smile:

Judging by the table on page 3, 10 to 20 mA should be plenty.

Their test conditions quote 10 mA, not 60. I think 60 is the absolute maximum.

sgtpepperaut:
i have received some fast replies but never one in between my two post of asking one question lol.

the datasheet says:
Forward current IF 60 mA
http://www.vishay.com/docs/83606/cny17.pdf

i am assuming the goal is here to undershoot a little bit? and take into account the voltage fluctuations as well? so lets say for a car maxV = 16 and that should give me about 50mA?
so V = IR
16/0.05 = 320Ohms?

i must say 60mA sure seems high for a tiny little led in an IC?

No, that 60 ma listed in the absolute maximum rating section and is the value if exceeded would destroy the device. Later in the datasheet showing typical operating conditions it states 'test condition', IF = 10 mA. So that is a good target value to shoot for. So at a nominal 12volt supply voltage resistor would equal to (12-1.4) / .01 = 1,060 ohms, so my guess at 1K ohm resistors was right on. :wink:

Lefty

... so my guess at 1K ohm resistors was right on ...

And that's experience for you! I would have reached for the calculator. :wink:

sgtpepperaut:

retrolefty:

this is the alternative and would save a couple of resistors... (need to listen to more than 3 inputs...)

No, that way would suck.

Lefty

figured as much....could you give me some input as to why "it would suck" ..just trying to get my EE straight :slight_smile:

Current would not be controlled evenly through each individual led, but rather hogged by some and starved from others. It's simply an invalid circuit. A single resistor sets the value of current that is allowed to flow and there is no way to make sure it's divided evenly among the optos that are switched on and even if there was magic balancing somehow, the number of optos active at any time is subject to the users switches so the individual leds would see a different current value depending on how many other optos were switched on, but again leds in parallel don't share nicely anyway so that is kind of mute.

Lefty

retrolefty:

sgtpepperaut:

retrolefty:

this is the alternative and would save a couple of resistors... (need to listen to more than 3 inputs...)

No, that way would suck.

Lefty

figured as much....could you give me some input as to why "it would suck" ..just trying to get my EE straight :slight_smile:

It's simply an invalid circuit.

Lefty

this kinda felt like:

this is one lively forum! Thank you. Ill get on soldering that up and report back with some pictures :slight_smile:

Yes Virginia, it really is possible to design a circuit that basically works and is also a sucky bad design at the same time. I can make a bicycle wheel out of wood... and it would work, ( HA! audible pun), but that doesn't make it a good solution.

I basically see that there are few very regular discussions here... one of them is... "Why can't I use fewer resistors?". I'm not going to answer... I'm just going to say that I am regularly surprised at how much effort is expended to want to pull out a part that costs $0.25 and will make a circuit behave reliably and predictably. (which should always be the goal of a design)

For the curious: This web page will start to explain why "so many resistors". Node (circuits) - Wikipedia

Before omitting pull-up resistors on the Arduino side of the opto coupler you need to be aware of several issues:

Internal pullups are poorly specified - could be anything from 20k to 50k

opto isolator photo-transistor will have a leakage current specification

If you multiply the worst-case dark-current leakage by the max internal pull-up value you'll
find out how many volts will be across the pull-up worst case for "off". If that is a problem (could be
read as a logic LOW) then adding lower value physical pull-ups would be necessary
(in fact I'd add 10k pull ups anyhow, then I could test the opto couplers in situ with a multimeter
whether or not the code remembers to enable pull-ups).

a part that costs $0.25

Where do you buy your resistors? That's expensive.

1/4w, 1% metal film, $0.02 at Mouser
or $0.07 for 1 Watt.

I was referring to COMMON VENDOR pricing for roughly a worst case scenario (besides Radio Shack)... but my point is resistors are only pennies. Personally, I buy my resistors from places like Tayda at $0.03 each

well i certainly didn't mind the cents that the resistor cost more the soldering of the board. anyways i agree with whats being said here i just wanted to understand the fundamentals behind it.

thx for all the input.

anyways circuit is done and its right on the sweetspot:
10mA a Pop for a total of 60mA draw at 12V...woho :slight_smile:


still have to get some experience soldering but it worked out okay..

and the updated schematic for people to reference:

I got these zero-ohm resistors for $4 for a batch of 500: