# trying to create a "priority switch"?

#### pgo1

Joined Nov 7, 2012
67
I'm trying to create a quantising circuit to quantise a signal at 1 volt steps. The input is a +/-4V analog signal - the signal is quantised in steps of 1 volt, giving 9 possible output conditions. Normally the output condition for -4V is set, and is "overridden" by anything higher. You can select to disable certain some of the steps if you want to, for example i can disable the steps at 1 and 2 volts, and the output will change at 0v but not again until the input reaches 3V. I decided to implement this with analog, given that im more comfortable with components than microprocessors

Im trying to think of the neatest, cheapest and smallest way of selecting which output state is in operation. Logic to drive the all the inputs low seems to get a bit messy when I consider the chip packages available. I thought of using an encoder and multiplexer, but since some of the states are not always on i can't count sequentially which makes the implementation a bit more messy. I was thinking maybe there is a more clever way to do it - something like a multiplexer but with 9 inputs, the higher of which has priority over the others - 2 has priority over 1, 3 over 2 and 1 etc all the way up to 9 which has priority over all of them - only the highest input is ever "active"

does this type of circuit have a name? How can i achieve this?

#### AlbertHall

Joined Jun 4, 2014
12,269
It's dead easy with a very small microcontroller.

#### djsfantasi

Joined Apr 11, 2010
9,081
It's dead easy with a very small microcontroller.
But the TS doesn’t want to use a micro-controller. But then states the solution should be the “neatest, cheapest and smallest” solution. That is indeed a microprocessor.

There are simple solutions that do not require a heavy duty micro-controller. Just a simple one, especially if the determination of the steps to be skipped are constant. Then an 8 pin micro-controller is all the TS needs.

I suspect unless the TS is an expert in analog circuit design, coming up with an analog circuit will be much, much harder than a digital solution.

If the steps to be skipped can be defined in code, all he needs is a micro-controller with more than two input/output pins. And simple code.

With supporting circuitry (of which the TS claims familiarity) to shift -4v to 4v to 0V to 4v, the TS could map the input range to values from 0-9. That requires two lines of code. Then with two lines of code, it’s entirely possible to output the desired signal. Thus, excluding setup, his function is realized in four lines of code (Disclaimer: I haven’t actually written this code).

Too bad the TS has eliminated a micro-controller solution.

#### crutschow

Joined Mar 14, 2008
32,918
I agree, the this gets rather messy using a non-microcontroller approach, especially if you want to arbitrarily skip steps.
It would appear that, if you really want the simplest design, it's time to bite-the-bullet and learn how to do some simple programming.
There are several on this website that would be happy to help you with that.

#### BobaMosfet

Joined Jul 1, 2009
2,082
Use a resistance ladder and control it with logic gates.

#### ebeowulf17

Joined Aug 12, 2014
3,307
Just for a moment, I'm going to cheat and ignore the arbitrarily skipping steps part. With that out of the way, couldn't you connect each voltage source in question to the anode of a diode, then tie all of their cathodes together as the output? That would give you the highest voltage, minus the Vf of the diode. Then you can use a simple voltage follower op amp configuration with a diode in the feedback loop to (approximately) add back the diode Vf. Should get pretty close, I think.

#### MisterBill2

Joined Jan 23, 2018
15,689
In my RCA CMOS digital data book there are 2 "priority encoder" IC.s CD4532B and CD40147B. Really, you can also do it with a simple A/D converter and some magnitude comparator ICs. (CD4063B) OR you can use just the binary output and "AND" gates. That digital logic does get a bit tedious but not nearly as bad as with a micro controller. But just using AND gates to decode the binary number and then OR gates to do the grouping will provide the functionality that you are asking for. Fairly simple in that it can be done with no counters or state machines and each condition can be done by itself.

#### crutschow

Joined Mar 14, 2008
32,918
couldn't you connect each voltage source in question to the anode of a diode, then tie all of their cathodes together as the output?
I believe he has only one voltage source that varies in voltage.

#### ebeowulf17

Joined Aug 12, 2014
3,307
I believe he has only one voltage source that varies in voltage.
Fair enough... although in that case I don't understand what it means to make higher outputs take priority over lower ones.

It's safe to say I don't fully understand the intended circuit here. Maybe if there was a schematic, I could catch up and be more helpful. Failing that, I'll just sit this one out.

#### MisterBill2

Joined Jan 23, 2018
15,689
I think that the priority encoder IC may be able to deliver what is wanted, but the whole package concept is a bit unclear. Probably a graph or chart will help to clarify the intended functionality, a circuit would not help very much.
Just like many requests, explaining the whole thing allows answers that are better than guesses.

#### pgo1

Joined Nov 7, 2012
67
In my RCA CMOS digital data book there are 2 "priority encoder" IC.s CD4532B and CD40147B.
aha! yes that is exactly what i needed. Thanks

for those still wondering i can actually program microcontrollers but I just don't particularly like them, plus, it's fun to see what you can achieve with only analogue. and yes, in future ill provide a schematic

#### ebeowulf17

Joined Aug 12, 2014
3,307
aha! yes that is exactly what i needed. Thanks

for those still wondering i can actually program microcontrollers but I just don't particularly like them, plus, it's fun to see what you can achieve with only analogue. and yes, in future ill provide a schematic

I must admit that I obviously really don't understand the situation, because I'm not following how the priority encoder does what you need.

Anyway, best of luck with what sounds like an interesting project. If/when you end up with a schematic of this project (whether complete or just work in progress,) I'd be very interested in seeing it.

Cheers!

#### djsfantasi

Joined Apr 11, 2010
9,081

I must admit that I obviously really don't understand the situation, because I'm not following how the priority encoder does what you need.

Anyway, best of luck with what sounds like an interesting project. If/when you end up with a schematic of this project (whether complete or just work in progress,) I'd be very interested in seeing it.

Cheers!
I think that if he has several comparators (one for each step) feeding into the priority encoder, then the priority encoder will output (in binary) the highest level.

#### eetech00

Joined Jun 8, 2013
3,431
I think that if he has several comparators (one for each step) feeding into the priority encoder, then the priority encoder will output (in binary) the highest level.
Maybe re-scale the bi-polar signal to a 0-(to some convenient +level) signal using an opamp, then use the comparators...

eT

#### djsfantasi

Joined Apr 11, 2010
9,081
Maybe re-scale the bi-polar signal to a 0-(to some convenient +level) signal using an opamp, then use the comparators...

eT
I had suggested that as part of a microprocessor circuit. I guess it stuck in my head, because I assumed your suggestion was being used.

#### eetech00

Joined Jun 8, 2013
3,431
I had suggested that as part of a microprocessor circuit. I guess it stuck in my head, because I assumed your suggestion was being used.
Then your suggestion was a very good one

I was thinking bipolar in-> Opamp (scaler)->Cmp(s)->PE(input to binary out)->something other than uC (depending on the goal).

Edit:
Might be able to replace "Cmp(s)" with LM3917.

Anyway...good call...

Last edited: