Go Down

### Topic: Listening to 12V Signals with Optocouplers? (Read 2924 times)previous topic - next topic

#### sgtpepperaut

##### Feb 14, 2013, 10:41 pm
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.

#### retrolefty

#1
##### Feb 14, 2013, 10:45 pm
Quote
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

#### sgtpepperaut

#2
##### Feb 14, 2013, 10:45 pm
this is the alternative and would save a couple of resistors... (need to listen to more than 3 inputs...)

#### retrolefty

#3
##### Feb 14, 2013, 10:47 pm
Quote
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

#### sgtpepperaut

#4
##### Feb 14, 2013, 10:52 pm
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?

#### sgtpepperaut

#5
##### Feb 14, 2013, 10:56 pm

Quote
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

#### Nick Gammon

#6
##### Feb 14, 2013, 10:57 pm
Judging by the table on page 3, 10 to 20 mA should be plenty.
Please post technical questions on the forum, not by personal message. Thanks!

http://www.gammon.com.au/electronics

#### Nick Gammon

#7
##### Feb 14, 2013, 10:58 pm
Their test conditions quote 10 mA, not 60. I think 60 is the absolute maximum.
Please post technical questions on the forum, not by personal message. Thanks!

http://www.gammon.com.au/electronics

#### retrolefty

#8
##### Feb 14, 2013, 10:58 pm

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.

Lefty

#### Nick Gammon

#9
##### Feb 14, 2013, 10:59 pm
Quote
... so my guess at 1K ohm resistors was right on ...

And that's experience for you! I would have reached for the calculator.
Please post technical questions on the forum, not by personal message. Thanks!

http://www.gammon.com.au/electronics

#### retrolefty

#10
##### Feb 14, 2013, 11:00 pmLast Edit: Feb 14, 2013, 11:58 pm by retrolefty Reason: 1

Quote
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

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

#### sgtpepperaut

#11
##### Feb 14, 2013, 11:12 pm

Quote
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

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

#### pwillard

#12
##### Feb 14, 2013, 11:56 pm
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". http://en.wikipedia.org/wiki/Node_(circuits)

#### MarkT

#13
##### Feb 15, 2013, 12:44 am
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).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### vasquo

#14
##### Feb 15, 2013, 01:03 am
Quote
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.

Go Up

Please enter a valid email to subscribe