Can somebody help me design a comparator circuit?

Thread Starter

Andrew Armstrong

Joined Sep 7, 2016
24
Hi everyone!

I would love to build the following an input signal which will be either:
  1. Between 0 and 0.4V
  2. Between 1V and 3V
For the sake of clarity in this example - lets say I want to light up a red LED if its case 1, and I want to light a green LED if its case 2.

I believe a good way of doing this is to use 2 comparators, or perhaps even just one. I am struggling to actually work out how to use a comparator. Take this one for example : http://www.alliedelec.com/m/d/c4a84b30b64590bafec67aac7f217def.pdf Given this particular chip, how would I use it in a circuit to achieve my goal? Any advice would be highly appreciated!

If anybody can draw a circuit diagram - and for bonus point give actual chip names where they use a specific comparator for example it would be very helpful.
 

JohnInTX

Joined Jun 26, 2012
4,787
Welcome to AAC!

Your question seems simple enough but here at AAC I think you'll find that while you can get lots of help on almost any topic, members won't do your work for you. Show us what you have, what you what it to do, problems you are having and what you've done to try to fix them. You'll get the help you need.

The .pdf you link is an MCP6001 OpAmp. While you can run an OpAmp as a comparator, a real comparator is what you want. Microchip has lots of those, too.

Good luck!
 

hp1729

Joined Nov 23, 2015
2,304
Hi everyone!

I would love to build the following an input signal which will be either:
  1. Between 0 and 0.4V
  2. Between 1V and 3V
For the sake of clarity in this example - lets say I want to light up a red LED if its case 1, and I want to light a green LED if its case 2.

I believe a good way of doing this is to use 2 comparators, or perhaps even just one. I am struggling to actually work out how to use a comparator. Take this one for example : http://www.alliedelec.com/m/d/c4a84b30b64590bafec67aac7f217def.pdf Given this particular chip, how would I use it in a circuit to achieve my goal? Any advice would be highly appreciated!

If anybody can draw a circuit diagram - and for bonus point give actual chip names where they use a specific comparator for example it would be very helpful.
"Below 0.4 V" you can do with one comparator. "Between two values" takes two comparators and some circuitry. How much do you want to spend? LM339 has four comparators in one package, is cheap and available. Yes, use a voltage comparator, not an op amp.

.
 

Thread Starter

Andrew Armstrong

Joined Sep 7, 2016
24
"Below 0.4 V" you can do with one comparator. "Between two values" takes two comparators and some circuitry. How much do you want to spend? LM339 has four comparators in one package, is cheap and available. Yes, use a voltage comparator, not an op amp.

.
I am not particularly fussy on price. Not exceptionally high but not dirt cheap - the components need to be top quality! - I like the idea of being able to do all 4 in one...
 

Thread Starter

Andrew Armstrong

Joined Sep 7, 2016
24
"Below 0.4 V" you can do with one comparator. "Between two values" takes two comparators and some circuitry. How much do you want to spend? LM339 has four comparators in one package, is cheap and available. Yes, use a voltage comparator, not an op amp.

.
This LM339 looks good - can you actually show how it could be wired up?
 

hp1729

Joined Nov 23, 2015
2,304
Hi everyone!

I would love to build the following an input signal which will be either:
  1. Between 0 and 0.4V
  2. Between 1V and 3V
For the sake of clarity in this example - lets say I want to light up a red LED if its case 1, and I want to light a green LED if its case 2.

I believe a good way of doing this is to use 2 comparators, or perhaps even just one. I am struggling to actually work out how to use a comparator. Take this one for example : http://www.alliedelec.com/m/d/c4a84b30b64590bafec67aac7f217def.pdf Given this particular chip, how would I use it in a circuit to achieve my goal? Any advice would be highly appreciated!

If anybody can draw a circuit diagram - and for bonus point give actual chip names where they use a specific comparator for example it would be very helpful.
What kind of accuracy do you need? 5% okay? Running from 5 V?
 

Thread Starter

Andrew Armstrong

Joined Sep 7, 2016
24
View attachment 111641


We don't normally go this far, but for you ...
I haven't built it yet to try it, but here is a start.
Thank you so much!!!!

I assume the numbers next to the comparator symbols is the appropriate pin? So -- now I just need to buy myself one of these LM339....that will fit nicely into my breadboard!

Ive found this : http://www.digikey.co.uk/product-detail/en/texas-instruments/LM339ADR/296-6604-6-ND/749212 but the LM339 seems to come in various different flavours!? I have no idea which one is right / wrong.

i.e which one of these do I want : http://www.digikey.co.uk/product-se...rcuits-ics/linear-comparators/2556221?k=lm339 and why that specific one!
 

AnalogKid

Joined Aug 1, 2013
11,037
joeyd999 - if its 0 -> 0.4v I want it to light a red led. 1 - 3v a green led :)
Repeating post #1 is not a good answer for something *not* in post #1. Joey's question is not about the two voltage bands you defined, it is about the band you did not define. Again:

what do you want to happen in the case between 0.4 and 1V?

Also, what do you want to happen if the input is greater than 3 V?

If you want LEds lit *only* when the input is within one of the two bands, that will take two window comparator circuits for a total of four comparators. One LM339 can do this. Also, you will need some kind of voltage reference part for the comparators to compare to. I like the LM4040 series.

ak
 

ScottWang

Joined Aug 23, 2012
7,398
View attachment 111641

We don't normally go this far, but for you ...
I haven't built it yet to try it, but here is a start.
If the Vcc is 5V then you could using the R4, R5, R6 as:
R4 = 2K/1%
R5 = 2K/1%
R6 = 1K/1%

I haven't try the circuit yet, but maybe you don't need the R7, R8, when U1c and U1D all are high then the Ib of Q1 already provide by R9, so why need R7, R8 for?
 

hp1729

Joined Nov 23, 2015
2,304
5% sounds pretty good - so at 5% does that mean 0.380mv would trigger it?
Depending on the accuracy of the resistors, yes.
I have an excel file for you but I can't include it here. I can post the pdf version of it if you are interested. It would be helpful in designing your own. I can step you through how it works so you can modify the design later if you want.
 

hp1729

Joined Nov 23, 2015
2,304
Thank you so much!!!!

I assume the numbers next to the comparator symbols is the appropriate pin? So -- now I just need to buy myself one of these LM339....that will fit nicely into my breadboard!

Ive found this : http://www.digikey.co.uk/product-detail/en/texas-instruments/LM339ADR/296-6604-6-ND/749212 but the LM339 seems to come in various different flavours!? I have no idea which one is right / wrong.

i.e which one of these do I want : http://www.digikey.co.uk/product-se...rcuits-ics/linear-comparators/2556221?k=lm339 and why that specific one!
The LM339ADR is SMD, not DIP. If you want it to fit in your breadboard get an LM339AN.
http://www.digikey.com/product-detail/en/texas-instruments/LM339AN/296-6605-5-ND/372806
 

hp1729

Joined Nov 23, 2015
2,304
If the Vcc is 5V then you could using the R4, R5, R6 as:
R4 = 2K/1%
R5 = 2K/1%
R6 = 1K/1%

I haven't try the circuit yet, but maybe you don't need the R7, R8, when U1c and U1D all are high then the Ib of Q1 already provide by R9, so why need R7, R8 for?
Thanks, Your designing is better than mine. Yes, 2K, 2K and 1K makes good sense.
I agree also on R7 and R8.
Thanks.
 

hp1729

Joined Nov 23, 2015
2,304
Design 831 LM339 two levels.PNG
Thanks, Your designing is better than mine. Yes, 2K, 2K and 1K makes good sense.
I agree also on R7 and R8.
Thanks.
After a second look, are the diodes really necessary?
We could not do this with op amps. The open collector design of the output of the LM339 allows us to connect outputs together. The diodes version would be better for op amps.
Is my thinking correct in general?
If the input is below 1 V U1D output is low, keeping the transistor off. U1C output is not low.
If the input is above 3 Volts U1C output is low, keeping the transistor off.
If the input is between 1 V and 3 V neither output is low and the transistor is allowed to turn on.
 
Last edited:
Top