Sort of Gray code to binary converter

[snip]
[snip]

I quit because I thought you were leaning toward one of those gross uP solutions ;-)

...Jim Thompson

-- | James E.Thompson, P.E. | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona Voice:(480)460-2350 | | | E-mail Address at Website Fax:(480)460-2142 | Brass Rat | |

formatting link
| 1962 | I love to cook with wine. Sometimes I even put it in the food.

Reply to
Jim Thompson
Loading thread data ...

Ok, this is a good question.

First, the uC solution. Need a uC with 12 digital I/O's, and then it is a simple case statement. Question is, What are you doing with the output? Is this going to a display? Is it being logged? Is it going to a PC for display and logging? In which case, you don't want a 4 bit output, but a serial output.

Now, assuming that this is going to another system that needs a 4 bit output, then you could build this into any FPGA or PAL that has at least

4 flip-flops. Then it is just create the state machine, and burn it. Could be interesting, as some FF would only need some of the inputs, so they could be bridged across some parts where the input logic is limited to just a few signals per FF.

Or, for the easiest one part solution, burn the whole table into a ROM. Then, you just translate instantly the input to the corrected output.

Charlie

PS: I did the ROM trick to take a bunch of little state machines and combine them into a single chip. Just fed the output lines back to some of the input lines...

Reply to
Charlie Edmondson

Ok, after reading all the other solutions, I would definitely say go with an EPROM. Simple, straight forward, a single chip. Biggest problem is debouncing the inputs a little, and maybe having to add logic level translations.

Charlie

Reply to
Charlie Edmondson

A look-up table. Set aside 256 bytes, and just use the 8 bits from your thingie as the address lines, and the data is either your direction code or "error", since you're only using 16 of 256 bytes.

i.e.:

Address Data 00000000 **** 00000001 N 00000010 NE 00000011 NNE 00000100 E 00000101 **** 00000110 ENE 00000111 **** 00001000 SE 00001001 **** 00001010 **** 00001011 **** 00001100 ESE

and so on.

Cheers! Rich

Reply to
Rich Grise

How is that easier than

unsigned int table[256]; /* Usually compilers initialize arrays to 0 */

table[1] = 1; table[3] = 2; table[2] = 3;

etc?

Thanks, Rich

Reply to
Rich Grise

It must be, since that was my first choice, and I'm the laziest guy I know; I might be the laziest guy there is. ;-)

Cheers! Rich

Reply to
Rich Grise

OK, here's my nominee for "junk-boxiest" - a piece of stripboard and a diode matrix. ;-) (in effect, 16x 8-input ANDs) I guess you'd need eight inverters too.

Cheers! Rich

Reply to
Rich Grise

On Sun, 11 Dec 2005 19:00:38 +0000, John B wrote: ...

[Spehro Pefhany wrote:]

Of course, you know how to tell a connoisseur from a wino?

The connoisseur takes the bottle out of the paper sack before he drinks it. ;-)

--
Cheers!
Rich
 ------
 "A cowhand way out in Seattle
  Had a dooflicker flat as a paddle.
    He said, "No, I can\'t fuck
    A lamb or a duck,
  But golly! it just fits the cattle.""
Reply to
Rich The Newsgroup Wacko

Is it even possible for a PIC to _do_ a look-up table?

Thanks, Rich

Reply to
Rich Grise

Nothing to it - 16 transistors, about 24 diodes, And a handful or so of resistors. ;-)

Depending on your inputs, you might not even need the buffers, so 8 transistors. :-)

Cheers! Rich

Reply to
Rich Grise

I thought we had another week, at least.

Reply to
Richard Henry

I don't subvocalize or communicate code verbally, so I generally don't, but--

btfsc is "bit test file (register) skip (if) clear" xorlw is "xor literal with w" (result left in w)

where---

- w is the 'accumulator'

- 'file registers' are on-chip RAM or SFRs, organized in banks on most chips, with some overlap on some chips, etc. real pug-ugly.

It's not my favorite 8-bit uC instruction set, but one can generally get the job done with it. In this particular case, the code is almost bordering on near-elegance.

Best regards, Spehro Pefhany

--
"it\'s the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

uP's are not gross! Overkill here, but definitely cool in lots of apps. Can *you* do an analog 16x16 multiply accurate to one LSB? Hell, you don't even *have* LSBs!

John

Reply to
John Larkin

Branch on Too F***ing Scared to Continue.

Exclusive OR Last Week (a threaded instruction).

Reply to
Paul Burke

On 13/12/2005 the venerable Paul Burke etched in runes:

At least with a PIC there are only 35 instructions to remember and only one register to worry about.

--
John B
Reply to
John B

Some can, but with others you have to do an indexed jump (handling any program memory page boundaries) into a table of retlw xx instructions. You only get 8 bits back for each 12 or 14 bit 'return literal in w' instruction.

Best regards, Spehro Pefhany

--
"it\'s the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

Although the PIC origins go back into the 1970s, it does not mean that newer CPUs have better opcodes...

The MAC-instructions of the PPC: About 40 in all combinations from halfword/word, (un)signed, (un)saturated, overflow en/disabled and so on. So it should be clear what the difference between "maclhwsuo" and "machhwso" is...

PS:Ah, wait, I've forgot another 20 "negative MAC" variants like nmachhwso: "Negative Multiply Accumulate High Halfword to Word Saturate Signed with Overflow"

;-)

--
         Georg Acher, acher@in.tum.de
         http://www.lrr.in.tum.de/~acher
         "Oh no, not again !" The bowl of petunias
Reply to
Georg Acher

Noise? What noise? uP programs work the same way, every time, exactly. Usually.

Well you know, accurate to 15 PPM.

No, but a decent Vertex chip can do 100 multiplies (using 100 multipliers!) in a single clock, at 100 MHz. That's 10 GHz, sort of.

This is like arguing whether to have food or wine.

John

Reply to
John Larkin

Yep, we do... the noise floor ;-)

Talk about mixed metaphors... ".. _analog_ 16x16 multiply.."

I can do multiplies at 5GHz, can you ?:-)

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
|  Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
|  Phoenix, Arizona            Voice:(480)460-2350  |             |
|  E-mail Address at Website     Fax:(480)460-2142  |  Brass Rat  |
|       http://www.analog-innovations.com           |    1962     |
             
I love to cook with wine.      Sometimes I even put it in the food.
Reply to
Jim Thompson

On Tue, 13 Dec 2005 21:15:27 +0000, John B wrote: ...

And people wonder why I poke smot. %-}

Thanks! Rich

Reply to
Rich Grise

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.