Comparator problem

Thread Starter

elex09

Joined Mar 17, 2010
39
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..
 

Thread Starter

elex09

Joined Mar 17, 2010
39
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..
 

Thread Starter

elex09

Joined Mar 17, 2010
39
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...
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

shortbus

Joined Sep 30, 2009
10,045
i have connected 10k pullups to the outputs of lm339...and then to the uC....

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.
 

Thread Starter

elex09

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

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Thread Starter

elex09

Joined Mar 17, 2010
39
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..
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
its to avoid glitches, right?
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
the circuit worked satisfactorily before..this problem of comparator output not coming has happened now...
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.
 

Norfindel

Joined Mar 6, 2008
326
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?
 

SgtWookie

Joined Jul 17, 2007
22,230
Good point, Norfindel.

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