How to Connect an Optocoupler

Discussion in 'The Projects Forum' started by JDR04, Dec 3, 2011.

  1. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    How can I connect an optocoupler SFH618-2 to the output (PIN 2)of the LM339 comparator?(Datasheet Attached)

    I'm hoping to to connect my camera remote cable to the circuit (Attached) so it is totally isolated from the circuitry to protect it. The circuit I have attached makes the output on pin 2 go high 7.64Vdc when light is obstructed from falling onto the LDR.

    As a thought, would it be better to use a phototransistor circuit for this sort of thing?

    Any help or ideas will be greatly appreciated. Many thanks - JDR04
     
  2. Adjuster

    Well-Known Member

    Dec 26, 2010
    2,147
    300
    The LM339 would require a pull-up resistor to go high, as it has an open-collector output. None is shown on your diagram, but with a reasonable resistor value fitted, you might expect the output to go up virtually to the supply unless loaded with something heavier than a DMM. 7.64V sounds low then, unless your battery is fairly run down.

    The LED in the coupler seems to be specified for currents of 5mA or less, although the maximum is higher. The worst-case output sink current of the LM339 is 6mA. Since you are running this from a 9V battery, 5mA seems like a good limit, but do you know how much current is needed from the output end of the coupler?

    If 5mA input is OK, you need a series resistor to drop the difference between the supply voltage, and the LED. A few hundred mV will be dropped across the transistor when it is on, but this may not be very significant.

    If the LED forward voltage is 1.5V, the resistor drops 7.5V on a 9V supply, so a resistor of 7.5V/5mA = 1.5kΩ would be required. That is, if the LED is required on when the comparator output goes high: The resistor is wired to supply, and the LED is wired pin 2 to ground.

    If the LED is required on when the comparator output is low, then the LED has to go in series with the resistor, the two connected between the supply and pin 2. In this case, the transistor drop subtracts from the resistor voltage so we might take the resistor as say 7.2V/5mA = 1.4kΩ.
     
  3. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks for the prompt reply Adjuster. I'm a newbie so will have to ask you a few questions if you dont mind. First one I need to understand is the "pull up resistor" for the LM339. One of the other forum members told me this as well and I thought it meant from the power pin (3) to the power line. It seems I got that wrong so could you explain what the "pull up resistor" means and where do I insert it in my circuit.

    I'll try and digest all your other info while waiting for your response. Many thanks for your time - JDR04
     
  4. Adjuster

    Well-Known Member

    Dec 26, 2010
    2,147
    300
    The pull-up resistor normally goes from the positive supply to the output pin, e.g. pin 2 in your diagram. I thought that would be clear from my last posting?

    Depending which input condition you require to make the LED shine, either the LED goes in series with the pull-up resistor, or the pull-up goes straight to the output, and the LED goes from output to ground.
     
  5. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Thanks, is my diagram for the pull up resistor and optocoupler connections correct? Have I calculated the resistor value correctly as well?

    Thanks again - JDR04
     
  6. Adjuster

    Well-Known Member

    Dec 26, 2010
    2,147
    300
    That should work, provided that this gives the right sense of switching for your purpose.

    Do you know the requirements of the camera remote input?
     
  7. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Hi Adjuster, your suggestion worked, thanks very much.

    The camera has three connections/cables. Ground,shutter and focus.

    If you short the shutter cable to ground cable it triggers the shutter and a photo is taken. The normal sequence when using a proper remote module is first short focus to ground and then short shutter to ground. As I'm using the camera in manual mode I only need to short the shutter to ground.

    This has now been achieved by connecting the ground cable to pin 3 and the shutter cable to pin 4. It works!!!!

    I was wondering if you coud tell me of a better way of detecting a break in a laser beam. At the moment I'm using a LDR and it does not seem to be able to register any very fast moving objects.

    Thanks for your help anyway. - JDR04
     
  8. T.Jackson

    New Member

    Nov 22, 2011
    328
    14
    The LM339 Quad Comparator is active low. You should be connecting its output to the cathode side of the LED inside the opto. Connect the 'anode' side to VCC through an appropriate current limiting resistor. See datasheet of opto for vf to determine the value of R.
     
  9. Adjuster

    Well-Known Member

    Dec 26, 2010
    2,147
    300
    I was rather afraid that you might find LDRs rather slow for triggering a camera, as their response time can be slow even on the millisecond scale normally appropriate to this sort of situation. You would probably do much better to replace the LDR with a photo-transistor, as I think you may have alluded to earlier.

    Depending how quickly the camera responds to triggering, you might also need something like a 555 timer to "stretch" the trigger pulse out longer if the beam is only broken for an instant, e.g. by a small fast-moving object.
     
  10. T.Jackson

    New Member

    Nov 22, 2011
    328
    14
    You can actually stretch out a pulse using one of the LM339's comparators.
     
  11. JDR04

    Thread Starter Active Member

    May 5, 2011
    339
    4
    Hi Guys, thanks to Adjuster and T.Jackson for their info. I was away for a while so was not prompt in answering.

    The problem of "stretching out" the signal by using a 555 circuit has me thinking. Would I use the output from the LM339 to trigger the 555 and then have the optocoupler connected to the output of the 555? Will I still need to have the pull up resistor in place on pin 2 of the LM339 as well as the 555 output?

    I'm curious on T.UJackson suggestion of using the LM339 tro "stretch out" the pulse. How would I do that?

    Thanks for time guys. - JDR04
     
Loading...