Using LM339 as XOR gate

Thread Starter

jbord39

Joined Mar 31, 2010
41
Hey all,

I am working on a digital-ish ammeter for my power supply. I am using about 6 reference voltages (from series resistors) to compare this to a known resistor voltage and in turn find the current (in piecewise ranges).

The 339's are working as far as distinguishing if the voltage is above or below the threshold. Here is an example truth table for my data:

Input Comp1 Comp2 Comp3 Comp4
0 0 0 0 0
1 1 0 0 0
2 1 1 0 0
3 1 1 1 0
4 1 1 1 1

I was using another row of comparators to now compare these values (1 and 2, 2 and 3, 3 and 4) to find the range of the input. The problem is that for some reason the comparators are working sort of funny (not just around the reference voltage either). Is it possible to use the comparators in this way (like a XOR) gate?

The final truth table should be like this:
Input Out(1-2) Out(2-3) Out(3-4)
0 0 0 0
1.5 1 0 0
2.5 0 1 0
3.5 0 0 1

Thanks. I am not worried about the output changing erratically at the threshold voltages.

John
 

SgtWookie

Joined Jul 17, 2007
22,230
Hey all,

I am working on a digital-ish ammeter for my power supply. I am using about 6 reference voltages (from series resistors) to compare this to a known resistor voltage and in turn find the current (in piecewise ranges).

The 339's are working as far as distinguishing if the voltage is above or below the threshold. Here is an example truth table for my data:
Rich (BB code):
Input Comp1 Comp2 Comp3 Comp4
  0     0     0     0     0
  1     1     0     0     0
  2     1     1     0     0
  3     1     1     1     0
  4     1     1     1     1
I was using another row of comparators to now compare these values (1 and 2, 2 and 3, 3 and 4) to find the range of the input. The problem is that for some reason the comparators are working sort of funny (not just around the reference voltage either). Is it possible to use the comparators in this way (like a XOR) gate?

The final truth table should be like this:
Rich (BB code):
     (1-2)(2-3)(3-4)
Input Out  Out  Out
   0   0    0    0            
 1.5   1    0    0
 2.5   0    1    0
 3.5   0    0    1
Thanks. I am not worried about the output changing erratically at the threshold voltages.

John
I quoted your reply to help with the table formatting.
Tabular data format doesn't work well unless you use the CODE blocks around the text. Compose the table using Notepad or other fixed-width font text editor.
 

Thread Starter

jbord39

Joined Mar 31, 2010
41
I have looked into it and am planning on ordering it in the future.

I am trying to construct it using only comparators and discrete components. Could a comparator be used as an XOR gate?

Thanks
 

SgtWookie

Joined Jul 17, 2007
22,230
Sort of. But instead of being called "XOR gates" they are called "window comparators".

If you want a real XOR gate, use a CD4070B.
 

Thread Starter

jbord39

Joined Mar 31, 2010
41
Maybe I'm confused but it seems like that doesn't really answer my question. Window comparators provide a high logic when the input voltage is between a range voltages. XOR gates provide a high logic when there is a difference in input logics.

My question is if a single comparator can be used as an XOR gate.

Example: a comparator has inputs V- and V+. (outputs high when V+ is greater than V-). So if the two inputs are not analog waveforms but rather digital type signals, would the comparator function as an XOR gate?
When both signals are high, there would be no difference in input voltages, so it would output a 0; if both signals are low, the same thing.

Do you know if this could work?

Thanks,

John
 

SgtWookie

Joined Jul 17, 2007
22,230
No, a single comparator that just has a single inverting input, a single noninverting input, and a single output cannot be used as an XOR gate.
 
Top