Comparator problem

Discussion in 'The Projects Forum' started by elex09, Apr 19, 2010.

  1. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    hi,

    gopikrissh, even i was using a comparator with my ir rxers...basically for the purpose of adc conversion before giving it to the uC..i suppose u are doing the same...

    however im experiencing something strange with lm339..for testing purpose i connected the high o/p of 1 ir rxer to pin 9 (non-inv) and gave Vref of 2.5V to pin 10...but im getting 0 output..any specific reason? of course i have given +5V to pin3 and gnd to pin 12..
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    I moved your post from the original - http://forum.allaboutcircuits.com/showthread.php?t=34013 as it was a topic hijack.

    For something more than a vague guess, post up your schematic. This part -
    - really needs further explanation to make sense.
     
  3. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    need a little help...i have scanned my schematic..how do i paste that here?...i have made it myself its not frm the net..how do i put it up here..i have .jpg and .pdf format of it..
     
  4. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    this is my schematic....

    hope its ok?
    not able to understand why comaprator gives 0 o/p inspite of showing correct values of Vref, and proper supply being given to it...
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    The LM339 quad comparator has open-collector outputs. This means that they can sink current, but cannot source current. You will need pull-up resistors to +V to source the current.

    The LM339 outputs cannot sink much current. 6mA is about the maximum. Calculate your pull-up resistors as:
    Rpullup = Vsupply/4mA
    In your case, you are using 5v for Vsupply, so:
    Rpullup = 5v/0.004A = 1250 Ohms. You could use 1.2k or 1.3k Ohm resistors.
     
  6. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    i have connected 10k pullups to the oututs of lm339...and then to the uC....
     
  7. shortbus

    AAC Fanatic!

    Sep 30, 2009
    4,004
    1,523

    The pull-up resistors would go from V+ to the 339 outputs, NOT, to the μC. Like SGT. said the 339 only sinks not source. With out a pull-up resistor to V+ there is no current.
     
  8. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    ok..done that but still no output...all other pins are giving a value like Vref or Vcc..only output is 0...
     
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Do you have a 0.1uF capacitor on the output of the 7805 regulator, and another across the Vcc/GND pins of the LM339 comparator? I do not see them on your schematic.

    If you do not have a capacitor at the output of the 7805 regulator, it may become unstable and oscillate at a high frequency.

    Your uC also needs to have a 0.1uF capacitor across its' Vcc/GND pins.

    I didn't pay attention to your IR LEDs before. Did you mean to connect them in reverse? If you are trying to detect light, then you did mean to do that.
     
  10. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    the ir leds are as transmitters and are forward whereas the ir receivers are photodiodes and are in reverse...

    the circuit worked satisfactorily before..this problem of comparator output not coming has happened now...i assumed the ic is ok, because its getting +5 v ..checked on DMM and all other Vref values are correct..

    connected 0.1uF after 7812 but not after 7805..but i checked the values on the multimeter..they're pretty accurate..so are 0.1uF still reqd?

    my head's spinning trying to figure out what the problem could be..though i really appreciate all u guys here trying to help me nail the problem..
     
  11. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    If you examine any datasheet for the 78xx series of regulators, you will see that they require an 0.33uF capacitor on the input, and an 0.1uF capacitor on the output. They should be as close to the regulator as possible.

    Without those capacitors, you can have very odd problems.

    Also, any IC that you use should always have at a minimum, a 0.1uF bypass capacitor across it's power supply pins. If it is a single supply, it normally just needs one from gnd to +V. If it is a dual supply IC, it needs two. You should always examine the datasheet for the ICs that you are using. They may require more than the 0.1uF cap; if so, they will indicate as much.

    Many datasheets don't talk about the bypass caps at all, but it is understood that they are required.
     
  12. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    its to avoid glitches, right?
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Yes - and to keep the power rails quiet.

    You don't show what you are using for a 2.5v reference. You should also have a small cap near the 339 to keep the reference voltage quiet/stable. Likely anywhere from 10nF to 100nF (0.1uF) should be fine.
     
  14. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    using a 10k pot...voltage adjusted to 2.5V..
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    It could not have worked before now, unless you had pull-up resistors on the outputs of the 339 comparator to Vcc, or had the uC's pins configured as outputs and had them held high.

    As far as Vref coming from a 10k pot; resistors make noise. Think of current flowing through the resistor as water coming through the nozzle of a garden hose. Hisssss... But if you put the nozzle in a bucket of water, the hiss goes away. Adding a capacitor does the same thing with the electrical noise.
     
  16. Norfindel

    Active Member

    Mar 6, 2008
    235
    9
    The datasheet of the LM339 says that the input common mode voltage range goes up to Vcc - 1.5v, doesn't that means that you cannot tie an input to Vcc?
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Good point, Norfindel.

    He could avoid that problem entirely by powering the LM339 from the 12v supply instead of the 5v supply.
     
Loading...