Reference voltage to output 2 different logic

Thread Starter

MrsssSu

Joined Sep 28, 2021
234
Hi all, it has been a long time.
Just curious, is there a circuit that can do the following?
input:less than 3V will output logic of 1 and 0 (2 different wires)
input:3V-4V will output logic of 0 and 1 (2 different wires)
input:4V-5V will output logic of 1 and 1 (2 different wires)
input:more than 5V will output logic of 0 and 0* (2 different wires)

Thank you and have a nice day!
 

MisterBill2

Joined Jan 23, 2018
12,745
Yes, such a circuit exists, it would indeed be called a window comparator circuit, It would have three comparators. An easier implementation would give 0,0,, o,1, and 1,1 for the different voltages. Giving a "2" for zero to one volt adds another cmparator.
 

WBahn

Joined Mar 31, 2012
26,932
Hi all, it has been a long time.
Just curious, is there a circuit that can do the following?
input:less than 3V will output logic of 1 and 0 (2 different wires)
input:3V-4V will output logic of 0 and 1 (2 different wires)
input:4V-5V will output logic of 1 and 1 (2 different wires)
input:more than 5V will output logic of 0 and 0* (2 different wires)

Thank you and have a nice day!
Yes, it can be done, but there is a hidden demon. Let's say that the voltage is right on the 3 V boundary such that noise is taking it back and forth across the threshold. If you look at your two logic outputs, you will likely find that they are sometimes saying that the voltage is more than 4 V, or even more than 5 V, because both outputs won't change at exactly the same time, so they might go (1,0) -> (0,0) -> (0,1) -> (1,1) -> (1,0) and repeat. If this would cause problems for your system, it needs to be addressed.

Is there a specific reason why you need those specific logic levels associated with the different ranges?

A much better approach would be to use Gray code encoding. Perhaps

<3 V => (0,0)
3 V to 4 V => (0,1)
4 V to 5 V => (1,1)
> 5 V => (1,0)

Now, if you are close to a boundary and noise takes you back and forth, only one output changes and your system goes back and forth between the two states that share that boundary. This shouldn't cause problems since if you are that close to the boundary, either state should be acceptable (consider that your own spec is unclear what the output should be if the input is exactly 4 V).
 

MisterBill2

Joined Jan 23, 2018
12,745
It is not that complicated to add a few millivolts of hysteresis to a comparator and with the specified accuracy of the switch points ten millivolts will not matter, nor even 50 millivolts would matter.
 

WBahn

Joined Mar 31, 2012
26,932
Agreed. But did the very first comparator you made have hysteresis designed into it? Crawl, then walk, then run.

Even with hysteresis built in, you are still needing the system to change two outputs at the same time. There will be a glitch state in there. Virtually guaranteed. Depending on how the signals are being used, it may not matter. But why not make it so that it can't matter?
 

MisterBill2

Joined Jan 23, 2018
12,745
Given that we are not provided with any information about any additional requirements, why add feature bloat to the basic functions requested? We are not given any hints about the purpose, and based on the coding it is not the same as typical logic. So we can wait for the TS to add whatever additional requirements that should have been stated initially but were not. That is apart of the educational portion of this forum, teaching the importance of considering all of the requirements from the start.
 
Top