Comparator Logic Circuit

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Hi all,

I'm currently looking into comparator circuits, and the structure of the logic circuits which can follow them.

In my instance, I'm trying to compare input voltages in the normal manner, but I want the output from the logic circuit to only put a high output from the highest compared voltage point.

I'm not explaining this very well, so I've attached two diagrams to show what I mean.

Anyway, I'm having real trouble creating the logic circuit. I managed to create something which worked, but it needed (my version of!) a triple input Ex OR gate.

But this doesn't seem to exist...

I was wondering of anyone could give me some pointers.

Thanks,

Sparky

P.S. I have read the AAC eBook pages on this.
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
It sounds like you're trying to build the equivalent of an LM3914 in dot mode from individual comparators, right?

Well, what you will need is a "window comparator" for each range.
Have a look at one of Rob Paisley's pages:
http://home.cogeco.ca/~rpaisley4/Comparators.html
Search for "Voltage Window Detector Circuit" on that page. What's shown is a "building block" that you will need to use for your circuit; for each voltage window you will need a copy of that entire circuit, one stacked on top of the other. The only real difference between the circuit Rob posted and the one you need, is connect the LED anode to the two outputs, and the cathode to ground; RL must be of a size that limits the maximum current sunk by the comparators to 6mA. You'll get slightly less current than that through your LED, but you will be able to see it light up.

[eta]
I threw together a schematic and simulation of just four stages for you. Note that when V(n001) is less than 2v or greater than 10v, no LEDs are lit. This is due to R9 and R0, respectively. I put those in there just so you can see how to leave areas with all LEDs off if you want that. Replacing those resistors with wire will result in one LED always being on.
 

Attachments

Last edited:

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Well, is this the correct way to 'wire up' the IC?

It's my first time using multiple circuits on one chip, so bear with me!
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Yes, that'll work for starters. Lots of work for two LEDs, right?

The more stages you add on, the more attractive the LM3914 IC's will look to you.
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
So...

Would this work?

I've set it up with all nine LEDs, and 'tied up' the unused op amps on the last IC.

Have I done this right?

Is the signal input in the right place?

Thanks again for your time.:)
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
You did something different with U6, and I don't know why?

[eta]
Ah, I see - you're not using comparators 3&4. But, you made it much more complicated than it needs to be.

Just ground all of the inputs for comparators 3 & 4, and leave the outputs floating. That means you don't need R27 thru R30.

18 comparators to light 9 LEDs - seems a bit of overkill, no? ;)

Here's a link to National Semiconductors' LM3914 page. That one IC can drive 10 LEDs in dot mode, just like you're doing - and it can also handle the LED current control for you.

It makes you appreciate how much easier it is to do something like that with a dedicated IC.

Oh, don't forget to use 0.1uF bypass caps across all of your '339 V+ and V- pins.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Sorry, Sparky - it can take awhile for us to reply to topics.

There's lots of other stuff going on, but in particular I've been spending a fair amount of time on the "Movie prop help" discussion in the General Electronics Chat forum; the one about the Star Trek "Generations" movie prop for Data's Arm (part played by Mr. Brent Spiner). I've been a fan of the various ST shows since the originals aired back in the 60's.

It was very interesting to figure out how to get the movie prop working again - and doing so with the help of several people from 5 time zones and an ocean away! We got most of it documented and working in under two weeks, without breaking anything - that's not bad at all.

Now that I'm more carefully re-reading your initial problem statement - I'm afraid that I may have led you astray; as neither circuit I've proposed is going to do what you wish; which apparently is:

Compare multiple inputs, and only indicate which input has the highest level output.

Is that an accurate summary of what you want the circuit to do?

What is the input voltage range for all inputs?
Logic level? 0v-5v, or 0v-16v?
Are negative voltages going to be in there as well?
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
First of all, there is no need to apologise, I have the utmost respect for you and all the other electronic 'gurus' on this forum. I realise that you can't attend to everyone's problems at the same time, so sorry about the pressure.

It's - just - that - mine's - more - important!:p Hahaha, just joking!;)


I think that I may have mislead you to begin with or not been entirely clear.

The circuits you've proposed seem to fulfil what I want.

I'll have an airpressure sensor sending a signal by means of a varying voltage depending on the air pressure ( the input).

Upon reaching set intervals, the circuit will turn on an LED.

The middle being the ideal pressure, going down in pressure will result in a lower input voltage signal so the LEDs will respond as such.

Going up in pressure will result in an increased signal.

I'm hoping that the LM3941 will be able to compare the input signal against the preset voltage. If the signal is below this by, for example, 1V, then the next lower LED will light. If it is 2V lower then the next lower LED will light.

Vice Versa for an increase in the signal voltage.
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
You've convinced me to use the IC, so I don't think logic will be used in this circuit?

The Datasheet for the LM3914 says is needs a -V, so I'll probably use 4, 3V lithium coin cells in series to create a 6V and -6V supply.
 

SgtWookie

Joined Jul 17, 2007
22,230
OK.
An LM3914 is a very versatile LED 10-segment bar/graph driver IC. It has on-board a voltage regulator and LED current limiter that can be used to establish the reference voltage to set the detection range, as well as the current limit for all of the LEDs, and it can be operated in bar or dot mode, as well as being cascaded with additional LM3914 ICs to increase the precision of the display. Just one LM3914 IC will replace 20 individual comparators, a voltage regulator, and 10 current control circuits - along with the voltage divider string. That's pretty impressive for a linear IC that you can buy for just a couple of USD's.

RS Components carries the LM3914N for £1.93 +VAT, which seems pretty good for UK prices:
http://uk.rs-online.com/web/p/led-driver/5342977/
Farnell UK also carries them; same price:
http://uk.farnell.com/national-semiconductor/lm3914n-1-nopb/ic-driver-led-3v/dp/1468964
I don't know where you usually source parts from, but now you know exactly what you're looking for, and have a couple of sources.

As I've already mentioned, this part can control 10 LEDs, and you can control the voltage ranges where the LEDs light up.

What I need to know now is:
  1. What is the input voltage range that you want to monitor?
  2. At what voltage do you want the lowest LED to turn on?
  3. At what voltage do you want the highest LED to turn on?
  4. Are 10 LEDs enough, or would you like to see 20 LEDs over your input voltage range?
  5. What voltage supply do you have available for powering the circuit? (need voltage and current, and whether regulated or not)
 

SgtWookie

Joined Jul 17, 2007
22,230
We cross-posted, but that's OK.
If your input voltage range will be all positive, you will only need a positive voltage supply.

Coin cells are rather limited in their output current (mAh rating); if you really want to use those, your run-time will be brief. I suggest that you consider using multiple AA batteries in a battery holder instead.

Four alkaline AA batteries in a series battery holder will give you 6v @~2400mAh to work with; enough to power LEDs for a fair amount of time.

I don't know if you want continuous operation, or just a "press to test" type of thing.
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
In that case, I'll use the AA batteries, I'll be needing continuous testing.

If you give me a few minutes, I'll come up with the voltage range.
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Jeeze Louise...

I'm planning to use this sensor;

http://www.freescale.com/files/sensors/doc/data_sheet/MPXHZ6130A.pdf

I'll only be measuring between 15PSI and 17 PSI.

Each PSI is equal to 0.265V.

So my reference voltages will all be between 3.968V and 4.497V respectively. (This will be set up with a pot.)

I'm wanting nine LEDs. They will be lined up. The centre led will come on when the input signal is near to the supply voltage.

If the pressure drops, below the threshold for the centre led, then the next one lights. Vice Versa for an increase in pressure.

I'm wanting this threshold to be in 0.01PSI increments (0.0026V). So if the reference voltage has been set at 15 PSI, it will light the next LED if it goes below 14.9PSI or above 15.1 PSI.

Give me a couple more minutes and I'll draw a diagram to show what I mean, I'm confusing myself!:D
 

SgtWookie

Joined Jul 17, 2007
22,230
You're running close to the limit, but it seems do-able.
The minimum resolution is 40mV/step, and you're at 52mV.

I realized that I forgot to link to the datasheet, so here it is from National Semi's site:
http://www.national.com/ds/LM/LM3914.pdf
Tip: always use the most current datasheet available at the mfgr's site, and always check the mfgr's resource page to make certain that the part you are intending to use is not planned for obsolescence.

Since your circuit is going to need some mighty fine adjustments, you'll need to use some trimmer pots along with fixed resistors.

Rob Elliott of Elliot Sound Products has a convenient calculator for the LM3915 IC on his download page:
http://sound.westhost.com/download.htm

It's about 2/3 of the way down. Search for LM3915.zip.
Running through the calculator function really quickly, you enter Vref (the maximum voltage you wish to monitor) - I plugged in 4.497 - and the LED current (since you're using battery power, I put in 3 for mA; with super-bright LEDs you'll be able to see them lit and it will use less current.)

It came back with 13.08k for R1, and 18.49k for R2. So, what you could do is use 12k plus a 2k pot for R1, and an 18k resistor and a 1k pot for R2.

Inside the IC, there is a resistor network (see page 7 of the datasheet) that is composed of ten 1k Ohm resistors in series, totaling 10k Ohms. To establish your low reference voltage at 3.968v, you basically need to add resistance between ground and the RLO (pin 4) input, so that you wind up with 3.968v at RLO.

You've already stated your high reference voltage at 4.497v, and your low reference voltage at 3.968v.
Vref high - Vref low = 4.497-3.968 = 529mV.
529mV / 10k Ohms = 52.9uA (micro-amperes); the current that will be flowing through the 10k divider.
So, now you need to know what amount of resistance will cause a drop of 3.968v between ground and Rlo with 52.9uA flowing through it.
R = E/I, so R = 3.968v/52.9uA = 75,009.452 Ohms. We could round that off to 75k, but you won't have any adjustment available.

Better to round it off to 68k, and use a 10k trim pot in series with it.

Are you following this?
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Er - just about!:D

If there's a human equivalent of the Blue Screen of Death, then I'm pretty close to it!

I'll have my dinner, to clear my head, and come back to this afterwards.


Thanks Sgt, I really appreciate your time.
 
Top