J
John B
Branch on Too F***ing Scared to Continue.
Exclusive OR Last Week (a threaded instruction).
At least with a PIC there are only 35 instructions to remember and only
one register to worry about.
Branch on Too F***ing Scared to Continue.
Exclusive OR Last Week (a threaded instruction).
John Larkin said:Good grief, what an instruction set! How do you pronounce "btfsc" or
"xorlw"?
Georg Acher said: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...
On 11 Dec 2005 14:18:22 GMT, "John B"
[snip...snip...]What logic do I need to convert these 16 values to a 4-bit binary
number.
Depends somewhat on the resources that you have available. Personally
I'd take the lazy way out and either program it into a 16V8 GAL chip
or an inexpensive uC like an 89C2051.
OK, so let's say I'm going to do it in 'C'. I've played with shifting
and XOR'ing values but can't find the right combination. Converting
4-bit real Gray code to 4-bit binary is simple:
code ^= (code>>2);
code ^= (code>>1);
There must be a similar solution to my input, but I just can't see it.
Must have had too much Fetzer Merlot at lunchtime, but it was worth it.
Y = Table[X];
I considered that one. That requires an array of 256 elements 93.75% or
which simply store errors/illegal values. The switch statement on the
other hand requires less typing (16 cases instead of 256 values).
Good idea! I've already been poking at it... I just love a good
problem.
How about some pre-process to get it to real gray code? Although I
suspect a look-up table has to be easiest.
On 11/12/2005 the venerable Spehro Pefhany etched in runes:
.
Oh, what a pedant you are.
OK, in this case 'best' means least amount of 'C' code or smallest
amount of external hardware. Cost of components can be ignored since
this has become an academic exercise and academics tend to ignore costs.
Oh no, another pagan who drinks his red wine cool. Red wine should be
drunk at room temperature and allowed to breathe for some time before
drinking. That's always the hardest part.
Any ugly CPU like a PIC probably looks forward having its PCLATH
diddled once in a while.
[...]I've got you very beat on chip count but mine are higher level chips.
See my post elsewhere in this thread.
How about comparing solutions on the basis of equivalent number of
gates? Obviously an ASIC could be built to do this job, but the
puzzle, as an intellectual exercise, is more interesting if you place
complexity limitations on the solution.
(For a practical solution I would just program a PIC.)
A PIC has a really huge number of gates inside. Personally, I'd more
likely put it into a CMOS 22V10. Both you and my practical solutions
contain more logic than the ones we are comparing.
A real contest would be to do it in terms of transistors.
Good grief, what an instruction set! How do you pronounce "btfsc" or
"xorlw"?
At least with a PIC there are only 35 instructions to remember and only
one register to worry about.
Jim appeared to be working on a solution but faded at the last furlong,
Is it even possible for a PIC to _do_ a look-up table?
Thanks,
Rich
John said:I say 'sort of' because the input I have is not true reflected binary
Gray code. The input is a wind direction sensor with eight discrete
positions. They are activated by a small magnet which triggers either
one or two sensors at any time. Thus the eight sensors produce the
following sequence:
00000001
00000011
00000010
00000110
00000100
00001100
00001000
00011000
00010000
00110000
00100000
01100000
01000000
11000000
10000000
10000001
What logic do I need to convert these 16 values to a 4-bit binary
number.
Thanks for your attention.
John said:I say 'sort of' because the input I have is not true reflected binary
Gray code. The input is a wind direction sensor with eight discrete
positions. They are activated by a small magnet which triggers either
one or two sensors at any time. Thus the eight sensors produce the
following sequence:
00000001
00000011
00000010
00000110
00000100
00001100
00001000
00011000
00010000
00110000
00100000
01100000
01000000
11000000
10000000
10000001
What logic do I need to convert these 16 values to a 4-bit binary
number.
Thanks for your attention.
John B said:Stop, stop, stop.
I have just counted 65 messages in this thread and we have already
descended into bickering. That wasn't meant to happen until at least
the middle of next week.
It's probably only lunchtime for you guys across the pond, but I have
just had a wonderful dinner of roast chicken, roast parsnips, baked
potatoes, carrots and brussle sprouts (why do we call them that? I
don't think they came from Brussles) accompanied by a bottle of Fetzer
Sundial Merlot 2004. Why do those Californian winemakers insist on
pouring molten wax on top of the cork, it never comes off cleanly and
there's always bits floating about, but that's another story. Followed
by chocolate and coffee cheesecake with fresh cream. Mmmm, and all
cooked by me!
Well I think it's time to announce the winners already, otherwise I'll
never be able to toast them all between now and the New Year. My wine
cellar only has 47 bottles in it at the moment!!
First prize for most elegant hardware solution goes to Andrew Holme for
his 16V8 code.
First prize for lowest number of discrete components to Ken Smith.
First prize for the best off the wall solution goes to Rich for his
diode matrix.
This is just a personal thing but anyone who even mentioned PIC has
been killfiled (no not really, but you get my meaning) as I'm an AVR
and ARM protagonist. I have to say that all of the software solutions
have been as ugly as my original code. OK, a look-up table is probably
the fastest solution but it is soooo UGLY. 'if' 'else if' etc. or
switch{} are also OK but have no elegance.
Sorry guys, but so far the software solutions have been meagre but what
else did I expect from a group whose favourite programming language is
'Solder'.
Jim appeared to be working on a solution but faded at the last furlong,
but where was Win? He doesn't seem to have even made it out of the
starting gate.
Anyway, I congratulate all of the hardware winners, and will toast them
all very soon. As for you software guys, well you've failed me and I'll
just have to drink an extra toast to Anon in the hope that he/she will
come up with the magic bullet solution. Why did we always use that
phrase along with 'Paradigm shift' in the batwing corporation?
Merry Christmas to all from the pagan in the West of Scotland.
First prize for the best off the wall solution goes to Rich for his
diode matrix.
On 13 Dec 2005 21:15:27 GMT, "John B"
[snip]Jim appeared to be working on a solution but faded at the last furlong,
[snip]
I quit because I thought you were leaning toward one of those gross uP
solutions ;-)
...Jim Thompson