Priority encoder - Page 1
Forum section: electronics / projects

author: gaminn
author_rank: Frequent Contributor
timestamp: August 23, 2019, 11:08:17 am
content: Hi,I'm looking for a device similar to priority encoder. I have 3 inputs a 3 outputs.If input 3 is high (no matter what level is on input 2 and 1) then output 3 is high and all other outputs are lowIf input 2 is high (no matter what level is on input 1) then output 2 is high and all other outputs are lowIf input 1 is high then output 1 is high and all other outputs are lowIs there any IC available that do this logic?

author: JuanGg
author_rank: Regular Contributor
timestamp: August 23, 2019, 12:31:26 pm
content: It should not be too hard to make a truth table and design a circuit with some nand gates to perform the task.Attached is a schematic that will do with a couple quad nand gates. Something like that, I'm sure there are plenty of ways of doing it.JuanEDIT: Thanks to Renate for pointing out a major simplification.

author: gaminn
author_rank: Frequent Contributor
timestamp: August 23, 2019, 12:59:01 pm
content: I know but I hope there is a suitable part that can do this in one package.This can do what I want:http://www.mouser.com/datasheet/2/308/MC14532B-D-96716.pdfbut if there is something with less inputs....

author: ledtester
author_rank: Super Contributor
timestamp: August 23, 2019, 01:01:55 pm
content: Use a priority encoder ic like a 74LS148 followed by a demultiplexer like a 74LS138.Note that the '148 uses active low logic.

author: jhpadjustable
author_rank: Frequent Contributor
timestamp: August 23, 2019, 01:35:09 pm
content: That would be a priorityarbiter.Some details would be nice. What's the application? What are you optimizing for in this project? How fast does it have to be? What's wrong with the 4532 and what do you need instead?I doubt you'll find that function in an orderable package, but you should review the compiled lists of 7400, 4000, and 74xG00 series logic, as on Wikipedia or elsewhere, just in case I missed one. You might be able to assemble the function out of only a couple of small packages using the 74xG series. If it doesn't have to work at several MHz (and honestly if you're using CD4000 series logic it probably doesn't) I doubt it takes all of 20 instructions in 8-bit machine code.

author: Renate
author_rank: Super Contributor
timestamp: August 23, 2019, 01:37:40 pm
content: @JuanGg The second output reduces to 2 = B · /CI'm not quite joking because this is the way I'd do it with parts on hand.Use an Atmel ATtiny85 uP. It's an 8 pin DIP, 3 in, 3 out, 2 power.If your use case involved "break-before-make" or timing considerations it would be easy to add.

author: gaminn
author_rank: Frequent Contributor
timestamp: August 23, 2019, 02:42:25 pm
content: It seems I will use MC14532B, as this is the only part that can do what I need in one package.The application is power path switching.

author: Renate
author_rank: Super Contributor
timestamp: August 23, 2019, 04:16:03 pm
content: Well, I'll just add a couple of thoughts to the whole thing.As you can see by searching, priority encoders aren't a real popular thing nowadays.Ok, they are fine if you are really condensing symmetrical things, like interrupts in old-age discrete processors.But today we might need something more advanced like "which asserted input have we addressed the longest time ago?"Moreover, a priority encoder may not be the best design to shoe-horn in some logic that doesn't really scream "priority encoder".If this is all USB related, you may find that switching things around does not work reliably unless there is a properly sequenced virtual "unplug, pause, plug".

author: ledtester
author_rank: Super Contributor
timestamp: August 23, 2019, 04:55:40 pm
content: Oh I get it -- you use inputs 1, 2 and 4 and then you don't need the demultiplexer.

author: David Hess
author_rank: Super Contributor
timestamp: August 23, 2019, 05:36:03 pm
content: Any asynchronous parallel non-volatile memory could also be programed to do this function. This includes PROMs, EPROMs, PALs, GALs, and CPLDs.A priority encoder followed by a 2-to-4 or 3-to-8 decoder was my first thought but requires two packages.A microcontroller is probably the least expensive solution now but much slower. The cheapest PLD I could find was about $1.50.Update: There are some EEPLDs available for about 75 cents.

author: ledtester
author_rank: Super Contributor
timestamp: August 23, 2019, 05:44:41 pm
content: Quote from: David Hess on August 23, 2019, 05:36:03 pmIn this situation you don't need the decoder if you use inputs 1, 2 and 4 of the priority encoder.

author: MarkF
author_rank: Super Contributor
timestamp: August 23, 2019, 05:58:35 pm
content: You could use a small 8-pin microcontroller like a PIC12(L)F1822.However, you would need to be aware of the input sample rate and propagation delay achievable.

author: David Hess
author_rank: Super Contributor
timestamp: August 23, 2019, 09:36:57 pm
content: Quote from: ledtester on August 23, 2019, 05:44:41 pmOh, well, there it is. Problem solved.