SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By bdemers
#118590
I need to check when a dirty 9V signal goes high.
Any ideas on the best way to do this?
By esklar81
#118881
How about one of these with its input fed your "dirty" 9V line through a current-limitting resistor?

You'll need to pick your resistor so that the current at the minimum condition you expect is enough to turn on the optoisolator and the current at the maximum condition you expect is not enough to burn out the optoisolator's LED. As the datasheet indicates there's an order of magnitude range that will turn this device on, that shouldn't be impossible. For example:
The current through the LED is found thusly:
Iresistor = (Vsignal-Vled)/R, so R = (Vsignal-Vled)/Iresistor
Vsignal is nominally 9 V,
Vled is nominally 1.2V,
Iled is nominally 20 mA, and
Iresistor = Iled.
Combining these gives us: R = (9 V - 1.2 V)/20 mA = 390 ohms.

To check the range over which this should work, we rearrange
Iresistor = (Vsignal-Vled)/R
to
Vsignal = (R*I) + Vled

At the maximum current the LED will tolerate:
Imax = 50 mA,
Vsignal = (R*I) + Vled = (390 ohms * 50 mA) + 1.2 V = 20.7 V

At the minimum current at which the optoisolator will turn on:
Imax = 5 mA,
Vsignal = (R*I) + Vled = (390 ohms * 5 mA) + 1.4 V = 3.35 V
(I used 1.4 V for Vled, as that's the maximum value shown on the datasheet).

So, such a circuit should turn on if your "9 V" is anywhere from 3.35 to 20.7 V.

Have Fun,
Eric
By bdemers
#118908
Thanks a lot! I was thinking about an opto isolator but was unsure, its been a while since my digital classes.

I appreciate your break down of the formulas, ( I admit I had forgot the E, I, R triangle the other day)

I think this will help clean out the cobwebs!

Thanks again!
By esklar81
#118941
bdemers,

You're welcome!

There are lots of different optoisolators in the world; I picked that one because it has the lowest piece price among what I found in the SparkFun catalog.

If you need a bit more noise tolerance or more than one channel of such inputs, though, you might be better off with this one. It's a 4-channel package and appears to be operable from 5 mA to 80 mA input current, so you could tolerate a broader range of "9 V" signals.

You didn't say what sort of noise you're expecting on the "9 V". If the signal ever goes negative (such as the flyback from shutting off an inductive load) or above the maximum voltage calculated as tolerable by the optoisolator, I suggest you consider using diodes to clamp the "9 V" into a more reasonable range, then use an optoisolator to produce a clean digital signal from the clamped input.

Eric