4N25 Optocoupler (Optoisolator)

Discussion in 'The Projects Forum' started by chumarkrch, Mar 15, 2010.

  1. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    This is my first time positing to the forums and I am simply trying to use the 4N25 optoisolator to electrically isolate a DC voltage so it can be sensed by a microprocessor on the output side. Here is the basic circuit I am using:

    [​IMG]


    This is the same circuit I've seen on other websites describing how to use the 4N25. I have varied the R1 and R2 values from 100 Ohms up to 10 KOhms and varied the input V1 from 0 to 10 V but the output either remains at some constant value in the mV or it is equal to V2. However, it never is equal to V1 which is what it should do.

    Somebody please let me know what I am doing wrong.
  2. SgtWookie

    SgtWookie Expert

    Joined:
    Jul 17, 2007
    Messages:
    22,096
    Location:
    In the vast midwest of the USA; CST
    They're designed to be used as optically isolated logic switches, not as linear devices.

    Your circuit is wrong. R2 needs to be in the wire that goes to +5v instead of between pin 5 and Vout. Wired the way it is, you would always read 5v on the output.

    The pin numbers for 4 and 6 are in the wrong place; exchange them.

    The emitter side (on the left) has a Vf of around 1.2v @10mA. Calculate your current limiting resistor R1 as:
    Rlimit = (Vsupply - 1.2v)/10mA
    So, if your V1 is either 5v or 0v, then:
    Rlimit = (5v-1.2v)/10mA = 3.8/0.01 = 380 Ohms. Use the closest standard value, or use resistors in series or parallel to get 380 Ohms.

    The 4N25 has a current transfer ratio of 20%
    Don't expect the output to sink much current. Use a 2.5k to 3k resistor for R2.
  3. BMorse

    BMorse Senior Member

    Joined:
    Sep 26, 2009
    Messages:
    2,673
    Location:
    Vermontville, Michigan (GMT -5)

    VOut should also be connected between the pin and the resistor, not where you have it on the circuit or else you will always be reading the value of V2....

    B. Morse
  4. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    I tried your solution with the following circuit:

    [​IMG]

    Maybe I'm not understanding something. By an optically isolated switch, does that mean it requires some signal to go high or low to start? How exactly does this start? Also, will it simply output the same DC voltage on V1 on the output?

    Thank You.
  5. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    Here is a link to the wikipedia section the topic of opto-isolators. This material will help provide you with a bit more background on the subject. Hopefully it will answer you main questions. Anything that is not clear you can come back here and ask for clarification.

    hgmjr
  6. BMorse

    BMorse Senior Member

    Joined:
    Sep 26, 2009
    Messages:
    2,673
    Location:
    Vermontville, Michigan (GMT -5)

    With the circuit above, you should read V2 on Vout.

    If you disconnect V1, then you should read almost 0 volts on Vout.

    You "activate" the opto coupler by turning the LED side on or off to control the state of the output phototransistor...

    B. Morse
  7. SgtWookie

    SgtWookie Expert

    Joined:
    Jul 17, 2007
    Messages:
    22,096
    Location:
    In the vast midwest of the USA; CST
    You misunderstood me when I said the pin numbers were swapped.

    You also misunderstood me when I said the resistor needed to be moved to the wire going to Vcc.

    You have likely destroyed the optocoupler, but here is how you should have connected it. Note the corrections in red.

    [​IMG]

    Attached Files:

  8. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    Thanks for all your help.

    I still can't seem to get it working so I think the optocoupler may not be the right solution for what I'm trying to do.

    I'm trying to isolate the DC voltage of a battery so I can send it to the analog input of a microprocessor. Can anyone offer up a type of circuit or solution that would do this.
  9. retched

    retched AAC Fanatic!

    Joined:
    Dec 5, 2009
    Messages:
    5,198
    Location:
    Baltimore, MD
    Why do you want to isolate it? And you were right that the optocoupler was wrong for the job.

    If you want to isolate something from its power source, you should use an isolation transformer. Isolation transformers have the same number of windings on the primary and secondary windings so they do not raise or lower the voltage, just physically isolate it.

    You may want to put it out there and just tell us what your trying to do. That will help save time with the wild goose chases.
  10. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    It's a battery management system that will be a part of a Formula Hybrid vehicle. The rules say that the high voltage circuit must be isolated from the low voltage circuit. However, we have to sense the battery voltages for the battery management system to work. It is also to protect the microprocessor.
  11. SgtWookie

    SgtWookie Expert

    Joined:
    Jul 17, 2007
    Messages:
    22,096
    Location:
    In the vast midwest of the USA; CST
    You might use a linear Hall-effect sensor to detect current flow through a known resistance. The Hall-effect sensor would provide the isolation as well as giving an output corresponding to the current.
    I=E/R (Current = Voltage/Resistance)
    So if you know both R and I, you can derive E.

    One problem with that is the electrical noise. You will need very good filtering and shielding.
    chumarkrch likes this.
  12. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    I have been reading about analog optocouplers, would this work and could anybody recommend a type? Again, the voltage of the batteries being sensed is from 0 to 5 V.
  13. retched

    retched AAC Fanatic!

    Joined:
    Dec 5, 2009
    Messages:
    5,198
    Location:
    Baltimore, MD
    Are you using one for each cell?
  14. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    They are packs of cells. Each pack has nominal voltage of 18.5 V which is reduced with a voltage divider to 5 V. 24 packs in total.
  15. chumarkrch

    chumarkrch Thread Starter New Member

    Joined:
    Nov 2, 2009
    Messages:
    7
    I have heard from our project adviser that there are optocoupler/optoisolator ICs that have D/A and A/D converters built in so an analog voltage can be relayed linearly while isolating the inputs and outputs. Does anyone know of any ICs like this?

    Thanks
  16. bertus

    bertus Administrator Staff Member

    Joined:
    Apr 5, 2008
    Messages:
    12,855
    Location:
    Amsterdam,Holland (GMT + 1)
  17. BMorse

    BMorse Senior Member

    Joined:
    Sep 26, 2009
    Messages:
    2,673
    Location:
    Vermontville, Michigan (GMT -5)
Similar Threads
Forum Title Date
The Projects Forum Optocoupler 4n25 relay circuit Oct 12, 2010
The Projects Forum 4N25 help Jul 20, 2014
The Projects Forum opto isolator 4n25 connections Apr 8, 2012
The Projects Forum Para Port - 4N25 - Stepper Driver? Apr 26, 2011
The Projects Forum Optocoupler Circuit Dec 5, 2014

Related Site Pages

Section Title
Textbook Electrical isolation : Transformers

Share This Page