Is my LM339N Broken?

Discussion in 'General Electronics Chat' started by hellohellosharp, Nov 16, 2012.

  1. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    I am trying to use an op amp in this chip and it seems to be dysfunctional. Is there a simple way to test this?

    Here is an image:

    [​IMG]

    I tried hooking pin 3 (VCC) to six volts, pin 12 to ground, pin 4 to ground, and pin 5 to 1.5 volts, and pin 2 to an LED. But the LED won't turn on. Shouldnt there be 6 volts coming from pin 2?
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,345
    1,028
    The 339 is a comparator with an OPEN COLLECTOR output. Its intended that the output be pulled up to +V (or in your case, an LED and resistor) for proper operation.

    With the + input higher then the - the output will be OFF, allowing the presumed pullup to make the output high. The 339 does not source any current itself.

    You'll want to connect the cathode of the LED to the output and the anode through a resistor to +V. The LED will turn on when the output is low i.e. the - input is > the + input.
     
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Consult several datasheets for this part and you will see what member JohnInTx is explaining.

    hgmjr
     
  4. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    Thanks for the help guys. I got it working like John said, i put the annode in 7.5 volts and the cathode on the out for the op-amp :)

    I now need to use this op-amp to trigger the clock on the 4013BE flip flop. Any ideas how to do this?
     
  5. crutschow

    Expert

    Mar 14, 2008
    13,011
    3,233
    The LM339 is a comparator, not an op amp. They both use the same schematic symbol but a comparator is like an op amp without feedback compensation, so it can't be readily used in typical op amp feedback circuits. It's normally used open loop to give a digital (2-state) output signal.

    If you connect the LM339 output to the 4013BE clock input, it should trigger the FF if you configure the LM330 to generate a clean pulse (typically this requires the addition of some positive feedback to provide hysteresis and prevent oscillations at the trip point). Also the LM339 output resistor should connect to the 4013BE power.
     
  6. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    [​IMG]

    Here is a diagram of my Comparator circuit. When I shine light on the photoresistor, the LED turns on.

    So instead of the LED turning on, I need to simulate a clock pulse to my D Flip Flop.
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Now replace the LED with a 10kΩ resistor.
     
  8. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
  9. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Yes.

    Put a resistor (270Ω to 470Ω) in series with all your LEDs.
    Eventually, you should connect all unused inputs to GND.
     
  10. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    I tried this...the 2nd LED (connected to the D Flip Flop) instantly turned on. Unfortunately though, shining light on the photoresistor or putting it in darkness does not change the state of the LED or D Flip-Flop.

    New diagram just to be sure I got your right:

    [​IMG]
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    No.

    Connect Pin2 of LM339 to Pin3 of CD4013.
    Connect R5 from 7.5V to either of these two pins.
     
  12. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    That kind of worked :) Thanks!

    The LED turns off when I flash a light on the photoresistor, and turns back off with another flash of light...

    The problem is that its a bit unstable. Sometimes it needs three or four flashes of light to turn the LED on and vice versa. Is there anything I can do it make it more stable?

    Thanks again for your help :)
     
  13. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    Where is your schematic?? Maybe its voltage thresholds are wrong.
    Am LM339 can switch many times very quickly. Maybe the switch on your flashlight is dirty and it turns on and off many times when it is turned on (but it switches so quickly that you cannot see it switching).

    Your flashlight needs a "debounce circuit" or the comparator circuit must be slowed down.
     
  14. JohnInTX

    Moderator

    Jun 26, 2012
    2,345
    1,028
    With the changes suggested by Mr Chips, add something like 330K between pin 2 (output) and 5 (+input) of the 339 to add hysteresis i.e. slightly different on and off voltages. Without it, the 339 will likely oscillate during switching making many clocks as it does.

    Smaller values of the R will increase hysteresis making it less likely to oscillate. Too small and it will switch and stay that way. Find a good value in between. The LM397 datasheet has a section on hysteresis that would apply to the 339 as well.
     
    Last edited: Nov 20, 2012
  15. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    A 330k resistor?
     
  16. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    Thanks a bunch bro :) I added a high resistor and it seems much more stable!

    Thanks to everyone who has helped so far!

    A video of my completed circuit.

    I still want to add what Audioguru was talking about though with the debounce.

    Would like to personally thank Austin Clark, Mr. Chips,JohnInTX and Audioguru for their contributions.
     
    Last edited: Nov 20, 2012
  17. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    The link to your video does not open. EDIT: It took a long time to open. It shows extremely dangerous wiring.
    Where is your schematic?
     
  18. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
  19. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    Your relay coil is an inductor that generates a very high voltage when it turns off. A diode is needed parallel with its coil to dump the high voltage into the power supply.

    Hee, hee. Hold the relay coil terminals in ONE hand. Power the coil from a 9V battery then while still holding the coil terminals, disconnect the battery. ZAP!
    The diode parallel to the coil protects the transistor or your hand from being zapped by a high voltage.

    Your relay has no spec's and no part number so we don't know its coil voltage and current.

    The transistor needs a resistor in series with its base that is determined by the unknown relay current.

    The +7.5V supply needs a bypass capacitor to ground of 10uF to 100uF.

    I didn't look at the CD4013 IC.
     
  20. hellohellosharp

    Thread Starter New Member

    Apr 19, 2011
    27
    0
    Thanks for your reply. Which way should the diode face...?

    I am not sure what relay it is at its part of a board I am using right now.

    I also have a mini one that I will be switching over to soon. it's a blue mini-relay from Radioshack by Tyco Electronics....I can't find the part # or anything though.

    What would the capacitor do?

    Sorry for the nooby questions.
     
Loading...