Lightning fast Gray to Binary encoder needed any ideas ??
OzStamp
Posts: 377
Hi to all
I have an 8 bit Gray output type rotary encoder that rotates fairly slow and we wish to decode this 8 bit gray value to a binary value as quick as possible.
I was wandering what would be absolute quickest method ..
Write some assembly code or create a lookup table and jump to the locations and get the Binary value out of the lookup table.. ???··
I recall working on a machine a few years ago and it had an eeprom laoded with the lookup table and positiong data loaded in the various locations ( like a programmable cam switch in a packaging machine)
I reckon the Propeller would be awesome for this application..
Ronald Nollet·· Australia
·
I have an 8 bit Gray output type rotary encoder that rotates fairly slow and we wish to decode this 8 bit gray value to a binary value as quick as possible.
I was wandering what would be absolute quickest method ..
Write some assembly code or create a lookup table and jump to the locations and get the Binary value out of the lookup table.. ???··
I recall working on a machine a few years ago and it had an eeprom laoded with the lookup table and positiong data loaded in the various locations ( like a programmable cam switch in a packaging machine)
I reckon the Propeller would be awesome for this application..
Ronald Nollet·· Australia
·
Comments
I have just sorted it .. just need to fill in the table but you can see the principle of operation.
This program will run in a COG and gives us feedback from an absolute 8 bit gray encoder.
{{Gray_bin tester.. just need to fill in the conversion
in the table below presently it is a direct conversion in..out
Ronald Nollet Australia }}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
DAT
Mydata
byte $00,$01,$02,$03,$04,$05,$06,$07
byte $08,$09,$0A,$0B,$0C,$0D,$0E,$0F
byte $10,$11,$12,$13,$14,$15,$16,$17
byte $18,$19,$1A,$1B,$1C,$1D,$1E,$1F
byte $20,$21,$22,$23,$24,$25,$26,$27
byte $28,$29,$2A,$2B,$2C,$2D,$2E,$2F
byte $30,$31,$32,$33,$34,$35,$36,$37
byte $38,$39,$3A,$3B,$3C,$3D,$3E,$3F
byte $40,$41,$42,$43,$44,$45,$46,$47
byte $48,$49,$4A,$4B,$4C,$4D,$4E,$4F
byte $50,$51,$52,$53,$54,$55,$56,$57
byte $58,$59,$5A,$5B,$5C,$5D,$5E,$5F
byte $60,$61,$62,$63,$64,$65,$66,$67
byte $68,$69,$6A,$6B,$6C,$6D,$6E,$6F
byte $70,$71,$72,$73,$74,$75,$76,$77
byte $78,$79,$7A,$7B,$7C,$7D,$7E,$7F
byte $80,$81,$82,$83,$84,$85,$86,$87
byte $88,$89,$8A,$8B,$8C,$8D,$8E,$8F
byte $90,$91,$92,$93,$94,$95,$96,$97
byte $98,$99,$9A,$9B,$9C,$9D,$9E,$9F
byte $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7
byte $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF
byte $B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7
byte $B8,$B9,$BA,$BB,$BC,$BD,$BE,$BF
byte $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7
byte $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF
byte $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7
byte $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF
byte $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7
byte $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF
byte $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7
byte $F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF
PUB Getdata |Temp,ins
dira[noparse][[/noparse]0..7]~
dira[noparse][[/noparse]16..23]~~
repeat
ins := ina [noparse][[/noparse]7..0]
Temp := Mydata [noparse][[/noparse]ins]
outa[noparse][[/noparse]16..23] := Temp
Awesome suggestion thanks alot.
Will work on that conversion list and post it also when done.
Using an Omron E6CP 8 bit gray encoder and this is just great being able to do this all in a COG
while other stuff is happening as well...
Ronald Nollet Australia
If you find yourself needing this sort of thing often, it's worth a look. (No, I don't get a kickback.)
If speed is the criteria here, then the SX-28 will be faster than the propeller...... 120 nano seconds for one conversion at 50 Mhz.
Cheers,
Peter (pjv)
Thanks to both for the suggestions.
Cliff who wrote that book..? will have to put that on my Xmas pressie list..
Peter .. I did not think of using the SX chip in this case as the Propeller will be doing other stuff as well.
Keeping it all inside the Propeller at the end of the day will be faster I think..
( meaning we have to get the data across from the SX into the Propeller.)
But as a standalone solution just doing that I agree with you totally thanks for the pointer Peter.
Ronald Nollet Australia
Henry S. Warren. It's like crack for geeks.
This post is in relation to my initial posting of a small SPIN program that reads an absolute encoder 8 bit·with GRAY output format.
As promised I have added in a text file format the conversion list from Gray <> Bin
The format is in HEX..
So with this list you can do all sort of stuff.
Create a lookup table .. at various angles turn outputs on etc etc. ie the data to outa ... whatever ..Electronic cam type output...
Cheers Ronald Nollet·· Australia