??? 02/25/09 15:38 Modified: 02/25/09 15:41 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#162822 - Give this a try... Responding to: ???'s previous message |
Hi Aamir,
learning electronics is really hard, isn't it? But don't give up, it's worth the trouble... ![]() A voltage divider is needed to produce a reference voltage of about 9V / 220k x 100k = 4.09V at the inverting ("-") input of LM339. Because the input voltage at non-inverting ("+") input can rise up to 7V you need to power the LM339 by a supply voltage of 9V. Then, input voltages up to 9V - 1,5V = 7.5V are allowed, according to datasheet. Take care, the output of LM339 is not a push-pull, but an open collector. So, you need a pull-up resistor to produce high state! This pull-up resistor can be connected to the +5V supply of micro or to the +9V supply of LM339. If you want to connect the comparator output to any of the micros' pins, then hook the pull-up to +5V. There's another feature shown in the scheme, which is important when driving a counter, the Schmitt-trigger hysteresis provided by the 1M resistor. When the input signal at non-inverting input is near the reference voltage, the comparator output can oscillate due to noise on the input signal. The positive feedback (because the 1M resistor is connected from the output to the positive (non-inverting) input) helps to traverse this critical point faster and steeper, by additionally increasing the input voltage when rising above the reference voltage and by additionally decreasing the input voltage when going under the reference voltage. So, the feedback stabilizes the performance of LM339 arround the reference voltage. The hysteresis is about 50mV which should be enough in your application. Don't forget proper supply voltage decoupling at the LM339. Connect 100n X7R directly across the supply pins. In very noisy systems it can be of benefit to add a small ceramic cap of 1...100nF from inverting input of LM339 to ground. Good luck my friend, Kai |