switching using a 4n 25

Thread Starter

jonisonvespa

Joined Mar 25, 2012
49
hi
im trying to switch a +5 to a pin on a auduino project, the switch circuit is in a very noisy environment hence i using an opto isolator, first time ive used one

have i got my circuit correct? ive limited both led and current to the ic pin to 10ma

thank you
 

Attachments

#12

Joined Nov 30, 2010
18,224
The way you have that laid out, the "+5 volt to pin" is always at +5 volts. I think you need to move the 560r to the top of the transistor, not the bottom.

The result would be a reversal of the logic. If this is not good, explain your wishes better and we can work something out.
 

Thread Starter

jonisonvespa

Joined Mar 25, 2012
49
ok i think ive got it now ive revised my circuit

just wondering if there is any way i could use the + and gnd in my circuit, for the (opto part switch)

and isolate that from the rest of the circuit?

thank you
 

Attachments

Last edited:

KrisBlueNZ

Joined Oct 17, 2012
111
I'd suggest increasing the pullup resistor on the collector. A 560 ohm resistor will draw nearly 10 mA from the 5V rail when the optocoupler is activated, which is a bit wasteful. A more typical value would be 10k.

If you want to interface to an electrically noisy environment, I would suggest using series resistors of 1~10k in both of the wires that go out to the switch (which I assume is in the noisy environment) and a capacitor of say 10~100 nF from the microcontroller input to ground. You will lose the electrical isolation, so there's no reason to use an optocoupler.
 
Top