4N25 input?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Deuset
 
Posts: 3
Joined: Sun Jun 24, 2012 8:20 am

4N25 input?

Post by Deuset »

There seem to be many examples of optocouplers being used on the "output" side of a circuit from the Arduino family, but only a few (and usually conflicting ) information about using them on as input - The Aduino being able to sense the presence of an external voltage other than <5v. Can anyone point me to, or be kind enough to upload the circuit diagrams for using a 4N25 to sense say 12, 30, or 75 volts? I'm sure that it would be a potentially useful circuit for all kinds of applications.

Many thanks

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: 4N25 input?

Post by floresta »

You would feed the voltage that you are sensing, through a current limiting resistor, to the LED that is essentially the 'input' side of your optocoupler (pins 1 and 2). The size of the resistor depends on the voltage as with any LED.

You would connect pin 4, which is the emitter of the output transistor, to the Arduino GND. Pin 5, which is the collector of the output transistor, would connect to the Arduino +5 V through a 'pull-up' resistor (try 10K Ohms). Pin 5 would also connect to the digital input pin of your Arduino.

Don

Deuset
 
Posts: 3
Joined: Sun Jun 24, 2012 8:20 am

Re: 4N25 input?

Post by Deuset »

Thanks Don, most helpful.
Any suggestions on what values to use for 12, 30 or 75 volts? Am I right in thinking that a 1/4w resistor isn't going to be up to it??

As you can probably deduce from the questions, I'm rather new to this!

:-)

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: 4N25 input?

Post by floresta »

Any suggestions on what values to use for 12, 30 or 75 volts?
According to the data sheet the input diode will typically drop 1.3 V when the current is 50 mA. That means for 75 volts the resistor will drop the rest of the voltage (73.7 V) and it will have the same 50 mA current. The resistance should therefore be at least 73.7/0.05 or 1474 ohms. A 1500 ohm resistor will work here.
Am I right in thinking that a 1/4w resistor isn't going to be up to it??
Yes. The power dissipated in the resistor will be approximately (73.7)(0.05) or 3.7 watts. Back to the drawing board. Are you sure you can't find a smaller voltage to monitor?

Don

User avatar
john444
 
Posts: 443
Joined: Sun Mar 04, 2012 2:42 pm

Re: 4N25 input?

Post by john444 »

Hi Deuset,

There are lots of beginners here. If you have questions, I bet there are many others with the same ones.
My advise is to check out Wikipedia: http://en.wikipedia.org/wiki/LED_circuit and the spec sheet: http://www.vishay.com/docs/83725/4n25.pdf

While Floresta was quickly answering your question, here is the long-version explaining how to determine values yourself. BTW, Floresta is not wrong in using 50-mA for the LED current, it is just that I am more conservative. You may choose different values for reasons that are important to you. Also, these calculations are presuming that the sensed voltage is either full-on or fully off, no in between voltages are considered.

The idea is to use Ohm's Law to calculate the resistor needed to set the required LED current.
Subtract the LED voltage drop from the supply voltage. (12-1=11) and divide by the LED current (11/.01=1.1k-ohm). The result is the value in ohms (k-ohms if you divide by mA) for the LED current limiting resistor.
The other voltages are just a easy: (30-V - 1-V = 29-V, 29-V / 10-mA = 2.9k-ohm) and (75-1=74, 74/.01=7.4k-ohm).
The heat (power) the resistor will dissipate is Volts * Current = Power (W).
11-V * .01-A = 0.11-W, 29-V * 10-mA = 290-mW, 74-V * 0.1-A = 0.74-W.

The hard part for beginners is figuring out the LED's forward voltage-drop and operating-current.
Check out the graph on the spec sheet under 'Typical Characteristics', Forward Voltage vs Forward Current. You can see that at room temp the voltage drop is about 1.1-V @ 10-mA. It is higher when cold or lower when hot.
Also, there are a range of possible operating currents that vary from 60-mA (absolute max) to 0.05-mA.
In general, stay away from the absolute max value as well as the minimum. The LED current has an effect on the transistor's ability to fully turn-on at a particular collector current. Fully turning on the transistor is know as 'saturation'. Again, looking at the graphs, most show that 10-mA is well within the maximum and can saturate the transistor if the emitter current is below 5 or 6-mA (Fig. 6 - Collector Emitter Current vs. Temperature and LED Current).

So there you have it. You can half or double the LED current as long as you allow for the saturation current of the transistor.
Your next question will be “How do you make sure that you allowed for the transistor saturation current?”

I don’t want to leave you hanging so here is how to calculate the transistor's collector resistor:
In the typical circuit, the opto's pin-3 and pin-6 are not connected to anything. Connect the transistor’s emitter to ground (opto's pin-4), the collector (opto's pin-5) to a resistor and the other side of the resistor to the Arduino’s 5-V supply. (The Arduino's input pin connects to the transistor's collector & resistor junction - pin-5). At saturation, the transistor will drop about 0.5-V. If we want 5-mA to flow then: 5-V – 0.5-V = 4.5-V. 4.5-V / 0.005-A = 900-ohm. (a common resistor value would be 1k).
Why wouldn’t you want to operate the opto at as low of a current as possible? Speed.
Consider the LED’s light shining on the transistor as the transistor’s base current. When you don’t project very many photons onto the transistor’s base, it cannot turn on as fast as when there are lots of photos (higher LED current).

After you have gone through the exercise a few times, you see that you can take shortcuts. For example:
There will be about a volt dropped across the LED. (this is not true for other LEDs)
At 12-V and less you can use ¼-W LED resistors.
10 or 20-mA is a good general LED operating current.
Keep the transistor’s collector current to about 5-mA or less.

Good Luck on your project.
John

Deuset
 
Posts: 3
Joined: Sun Jun 24, 2012 8:20 am

Re: 4N25 input?

Post by Deuset »

THANK YOU for your time John, that is a great explanation.

A few minutes with Excel and I had all the values from 5 to 80 volts and within 30 minutes I had it working on a bread board with no signs of the smoke escaping! :-)

Thanks to Don too for the circuit explanation!

Now I just got to make them! lol

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”