r/lowlevel • u/[deleted] • Dec 02 '20
Binary decoder - Why it is needed?
It takes an input and it creates and output.
I did google it, but I'm unable to understand what is the point of it, what it exactly decodes?
2
Upvotes
6
u/TheApadayo Dec 02 '20
It takes in a binary number in N inputs and has 2N outputs with just one output high. If you send 5 in binary to the input of a decoder then the 5th output line would go high. When you combine it with AND gates on the outputs you get a multiplexer.
5
u/antiduh Dec 02 '20
I thought about this just yesterday.
Lets say you have a set of resistance-style temperature probes that you want to attach to a microcontroller, say, 8 of them.
But the microcontroller only has one analog-to-digital channel; but it does have several bits of digital output that you might be able to use. How do you extend the A-D interface on the microcontroller so you can get readings from all 8 temp probes?
Simple. Use some small solid-state relays to disconnect all but one temp probe from the A-D. But now you have 8 SS relays, and thus you have 8 enable lines you need to control. Your microcontroller has 3 digital outputs, which can represent 8 different values. So you wire the digital outputs from the microcontroller to a binary decoder, and then the 8 outputs from the binary decoder turn into the 8 enable lines on each of the 8 solid-state relays.
Now when the controller wants to sample a temp probe, it just has to put out the right binary value to the decoder, wait a very short amount of time for the solid state relay to act, and then start sampling the A-D. Done.