Comparators give me headaches!

Status
Not open for further replies.

Electroman987

New Member
I'm pretty new at electronics but I have some experience. I am using LM339 to determine whether or not certain voltages are 5v or not. I was thinking to connect 5v to the reference (+) side and the measured voltage (-) to the other side. Then as the Vdd, I am connecting 5v again. All of this is going to a basic stamp to be determined as high or low. Do I still need a pull up resistor to have the microcontroller detect it? And if I do, what ohm dose it need to be? Help would be greatly appreciated.

Sincerely,
A student
 
Since you're a student... *grin*

Download the datasheet: **broken link removed**

Go to page 15, look at the schematic of the parts inside the comparator. Where does the current flow when the comparator is supposed to indicate "true" -> what's the current through the transistor, what's the voltage across the transistor?

Now that you've done that and figured what size resistor is required, can you tell me why the comparator is going to be outputting garbage? Hint: page 2, there are some characteristics labeled "Input offset voltage" "Input bias current" "Input bias voltage"...
 

Something seems odd about this setup. Your supply voltage is 5V on the 339, yet you want it to tell you when the input is at 5V or not? This doesn't make sense. What range of voltages will be coming into the 339 in the first place? I guess that would be a start.
 
At least one input needs to be within the common mode range of the LM339. Look at the data sheet to see that for single supply operation the input common mode rangeg is GND to (Vcc - 1.5V). For a 5V systems that's 3.5V. The reason is the PNP inputs need to have their inputs two diode drops below th positive rail.
 
Ok. Let me straiten some facts out.
1. I’m a student in high school doing this for a science fair project. And most of the technical meaning gave me no help (*sorry)
2. The voltage that is being measured is a solar panel rated and tested at 7v and it is needed to be above 5v for the circuit to work.
3. What about me giving you guys the diagram so you can see it. I guess that might help.
4. And finally, I won’t be able to answer why the output will be garbage.
 

Attachments

  • Project1.jpg
    108.5 KB · Views: 143
Ok. Let me straiten some facts out.
1. I’m a student in high school doing this for a science fair project. And most of the technical meaning gave me no help (*sorry)
2. The voltage that is being measured is a solar panel rated and tested at 7v and it is needed to be above 5v for the circuit to work.
3. What about me giving you guys the diagram so you can see it. I guess that might help.
4. And finally, I won’t be able to answer why the output will be garbage.
5. The NiMH batteries to the right are being monitored as well. Their voltage is 6v- 7.5v. If their voltage drops below 5v, then the comparator sends a signal to the microcontroller so it can turn off the transistor so the next set of batteries will take the load.
6. Is there a way to switch the power source so the powers to the motor dose not stop?

Thx again
 
Ah, I was under the impression that that you were a univ. student working on a "intro" lab project, hence the response.

However, the circuit you drew will have quite a few issues. So to start from the basics:

Why all the relays and comparators? Why not just use diodes to direct the energy flow?

Why are there 3 battery packs instead of 1?

Have you calculated how much power all the relays will use?
 
For your question # 6 above, you could have the micro turn on the second relay while the first one is still on, then turn off the first. There will be an overlap and the motor will stay running. The second battery will try to charge the first battery while the overlap occurs, so this will have to be accounted for in the program/circuitry. What you may have to do is place a loop in the programming to "ignore" the first battery voltage for a period of time after the program has decided to switch to a new battery. Since the first battery will rise in voltage when the second is connected, the program may think the battery is OK, and try to switch back, ending up with a neverending cycle, depending on how the program is written. You could place a diode in series with each battery output to prevent this, but you lose 0.7 volts or so, in doing this. For the comparators, you would have to add what is called hysterisis, and maybe even this would not be enough, since the first battery will take a short period of time to settle back to the old lower voltage.

Hope this makes sense.
 
To answer hjames question. all of the comparators and relays are used for the porject to compare voltages to determine whether or not voltage from the solar panel should power the motor or the batteries. there are three batteries because is the day after today is raining, then the motor will continue running without stopping. hence it being almost perpetual.

and to ask from the reply from zevon8, what dose a hysterisis do and why do i need it. like i said earlyer, im a novice and this is all making some sence to me. and also do i need a pull up resistor and what should the ohm be. Thanks a bunch.

Sincerely,
me again
 
in order to use a comparator to compare voltages at or above the bias voltage of the comparator itself, you'll need to scale down the voltage being monitored. At the same time, you will also need a good reference voltage that will not vary as the source voltages drop - such as zener diode or maybe even a small linear regulator.

Use the solid reference voltage to create the 'trip' level. A level of 2.5V would probably be good. Tie this voltage to the Inverting input of the comparator. That way when the bias voltage of the comparator drops down to 5V, you'll still have enough headroom.

Now, use a resistor divider connected from the voltage rail that is being monitored to ground. The output of the divider will be tied to non-inverting input of the comparator. Both the top and bottom resistors of this divider should be the same value (use a high value resistance so there is very little current draw). This will put 2.5V on the non-inverting input when the monitored rail is at 5V and the comparator will trip.

I would suggest reading up on hysteresis. This can be accomplished through positive feedback on the comparator and will keep the comparator output from bouncing up and down from noise on the input.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…