Graycode
Erik
Posts: 31
When an input is high and·then an·other input·two times high then i like to start with count up·in a gray code.
Start on "000" then two times i/o 0 high then "001"·and so on.also count down but first count up
so is it easy to make a gray code counter?????
Best regards erik
Start on "000" then two times i/o 0 high then "001"·and so on.also count down but first count up
so is it easy to make a gray code counter?????
Best regards erik
Comments
"Gray Code" was created so that when you 'counted' in it, only a single bit would change at a time.
0 -- 000
1 -- 001
2 -- 011
3 -- 010
4 -- 110
5 -- 100
6 -- 101
7 -- 111
For example (which is probably wrong -- 111 goes to 000, but you get the idea). You could google "gray code" or "grey code" to get more detail.
It turns out this is nice for position encoders.
Usually, these days, people "count" in binary:
0 -- 000
1 -- 001
2 -- 010
3 -- 011
4 -- 100
5 -- 101
6 -- 110
7 -- 111
So I don't usually see much call for "gray code".
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
we like to use the graycode because our monitor software counts in graycode. we use the graycode a lot in the elevator world because he counts right when we change one bit.
it's to measusre the position off an elevator in the shaft.
we like to count when he see two times a input because· when the elevator is driving from floor to floor he see two times a switch.
best regards Erik
gc=(bn>>1)^ bn ' to convert binary bn to Gray code gc
The conversion the other direction is little harder, if needed, but there is a description here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
thanks I will look to it
best regards Erik