1
\$\begingroup\$

I understand an Encoder is 2^n input lines and n output lines`.

I want to construct an Encoder from scratch so I can understand how it works, so that I can construct any other Encoder in the future.

I believe that the Input lines are an address to the output lines. So for a 4 by 2 encoder we would first construct a truth table. My biggest problem is I can't construct the output part of the truth table for an encoder. I don't know how to get the output, if I knew the logic I could build it.

Encoder Truth table with what I think the output is. http://www.flickr.com/photos/76226081@N08/8931456484/

Every time the input lines are x x 0 0 I put a 1 for O0.
Every time the input lines are x x 0 1 I put a 1 for O1
\$\endgroup\$
5
  • \$\begingroup\$ en.wikipedia.org/wiki/Priority_encoder#Simple_encoder \$\endgroup\$
    – The Photon
    Jun 3 '13 at 1:43
  • \$\begingroup\$ Key point, the only valid inputs are when exactly one of the inputs is high. That means there are lots of don't cares in the output columns of the truth table. \$\endgroup\$
    – The Photon
    Jun 3 '13 at 1:45
  • \$\begingroup\$ So only I3 and I2 matter? Edit: Actually I don't get it, what do you mean by "when exactly one of the inputs is high" \$\endgroup\$
    – Mike John
    Jun 3 '13 at 1:49
  • \$\begingroup\$ The only valid inputs are 0001, 0010, 0100, 1000. Any other input is not valid. That's what I mean by exactly one of the inputs must be high. \$\endgroup\$
    – The Photon
    Jun 3 '13 at 1:57
  • \$\begingroup\$ see also en.wikipedia.org/wiki/Rotary_encoder \$\endgroup\$ Jun 3 '13 at 5:49
1
\$\begingroup\$

The solution is found by searching for "encoder" on Wikipedia:

enter image description here

Key point, the only valid inputs are when exactly one of the inputs is high. That means there are lots of don't cares in the output columns of the truth table.

\$\endgroup\$
3
  • \$\begingroup\$ Ok, but my question is why are 0001, 0010, 0100, 1000 important? I see they are powers of 2. 1,2,4,8. What, besides Wikipedia, tells you that those are the values to look for? \$\endgroup\$
    – Mike John
    Jun 3 '13 at 2:37
  • \$\begingroup\$ @MikeJohn: An encoder is like the opposite of a decoder. The inputs to the encoder are 0001, 0010, 0100, 1000 because those are what the outputs of a decoder would be. \$\endgroup\$ Jun 4 '13 at 2:22
  • \$\begingroup\$ @MikeJohn That's just the definition of what an encoder does. For an example of how its used, maybe imagine a case where you have a microcontroller and 8 peripherals which can each generate an "attention" signal indicating they have data available. If you're lucky enough to know (or you're willing to pretend) that only one of those peripherals will have data at a time, then using an encoder you only need to use 3 inputs to your uC to determine which peripheral needs attention. \$\endgroup\$
    – The Photon
    Jun 4 '13 at 4:22
1
\$\begingroup\$

The 0000, 0001, 0010, 0100, and 1000 are used as a "one hot" scheme. This simply means that only one input/output is on at a time. Think about how this works out: if only one I/O can be on at a given time, and you have, say, 4 variables (I/Os), then it just works out to be b0, b1, b2, b4, b8, etc. Nothing is enabled, the first bit is enabled (while the rest are off), the second bit is enabled, etc. This isn't actually something that you generally look at in binary though. It's a totally different technique and the binary numbers that are a result just "work out" that way.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.