Can somebody help me design a comparator circuit?

Discussion in 'Digital Circuit Design' started by Andrew Armstrong, Sep 7, 2016.

  1. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    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.
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    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!
     
    Andrew Armstrong likes this.
  3. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    "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.

    .
     
    Andrew Armstrong likes this.
  4. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,693
    2,765
    Just to complete the specification, what do you want to happen in the case between 0.4 and 1V?
     
  5. #12

    Expert

    Nov 30, 2010
    16,355
    6,852
    For a job as slow as this I think you can get by with op-amps.
     
  6. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    Hey JohnInTX - I completed understand that! However when I try to build something to show you in http://www.partsim.com/simulator I cannot even find the comparator chips!??! Help me get started....
     
  7. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    joeyd999 - if its 0 -> 0.4v I want it to light a red led. 1 - 3v a green led :)
     
  8. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    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...
     
  9. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    This LM339 looks good - can you actually show how it could be wired up?
     
  10. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    joeyd999 - if its 0 -> 0.4v I want it to light a red led. 1 - 3v a green led :)
     
  11. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    What kind of accuracy do you need? 5% okay? Running from 5 V?
     
  12. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    Design 831 LM339 two levels.PNG
    We don't normally go this far, but for you ...
    I haven't built it yet to try it, but here is a start.
     
    Andrew Armstrong likes this.
  13. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    5% sounds pretty good - so at 5% does that mean 0.380mv would trigger it?
     
  14. Andrew Armstrong

    Thread Starter New Member

    Sep 7, 2016
    24
    0
    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!
     
  15. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,546
    1,252
    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
     
  16. ScottWang

    Moderator

    Aug 23, 2012
    4,858
    767
    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?
     
  17. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    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.
     
    Andrew Armstrong likes this.
  18. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    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
     
  19. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    Thanks, Your designing is better than mine. Yes, 2K, 2K and 1K makes good sense.
    I agree also on R7 and R8.
    Thanks.
     
  20. hp1729

    Well-Known Member

    Nov 23, 2015
    1,964
    219
    Design 831 LM339 two levels.PNG
    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: Sep 8, 2016
    absf likes this.
Loading...