Python Forum
the name of a sequence of numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
the name of a sequence of numbers
#1
i once saw a reordered sequence of numbers which when expressed in binary there would only be one bit that was different between adjacent numbers of that order. i want to know the name of this sequence because i cannot remember its name. with only one bit different, you could step through the sequence without the need to tightly synchronize the change of two or more bits at one time. the usual sequence of counting cannot do this because going from 3 to 4 involves changing 3 bits there are many steps with multiple bit change such as 7 to 8 and 11 to 12. i saw this sequence in a book on electrical engineering which i no longer have. does anyone know the name of this sequence?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
i found the name. it is called "Gray Code".
Gribouillis likes this post
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#3
Yes, it's Gray Code.

I've used it ~3 weeks ago to read an Encoder like this one: https://www.reichelt.com/de/en/alps-stec...73923.html

The purpose is to suppress false readings and that only one bit is swapped during state change.
If you use the binary representation for numbers, then a change could affect more than one bit.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
FYI -- You may be interested in a book I used back in the 1980's which can be downloaded fro free from Internet archive:

8080 Programming For Logic Design By Adam Osborne

Very good info on binary logic.
Reply
#5
(Nov-07-2024, 08:24 AM)DeaD_EyE Wrote: Yes, it's Gray Code.

I've used it ~3 weeks ago to read an Encoder like this one: https://www.reichelt.com/de/en/alps-stec...73923.html

The purpose is to suppress false readings and that only one bit is swapped during state change.
If you use the binary representation for numbers, then a change could affect more than one bit.

24 detents? i would have expected a power of 2. did it support going around from last to first in the forward direction or was it blocked from doing that?

> switch travel: 0.5 mm

i would have expected degrees, 15 degrees if it can loop around (11.25 degrees for 32 detents), or less if it does the 24 detents not all the way around.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
(Nov-10-2024, 01:36 AM)Skaperen Wrote: 24 detents? i would have expected a power of 2. did it support going around from last to first in the forward direction or was it blocked from doing that?

It's an incremental encoder (no absolute position). You can turn it infinite, there is no mechanical limitation.

The Gray Code for each interrupt is converted to binary and compared to the previous binary number.
Then you can detect the direction. Some Microcontrollers have hardware support for it.

Each detent has in summary on A+B = 4 edges => different states.
B is shifted by +90°

https://en.wikipedia.org/wiki/Incrementa..._and_phase

The calculation for 24 detents (quarter steps):
360° / (24 * 4) = 3.75°

AFAIK our model drives 48 mm per one turn of the incremental encoder. I calculated backward, because I could only remind the 0.5 mm accuracy.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#7
years ago i wrote code to convert both directions (different code for each) between an ordinary sequence of numbers and the gray code number at that position. i do not recall if i did that in C or in assembly language. i am wanting to do it in Python. i just couldn't recall the name of it (to name functions and describe in comments). i finally hit on the wording describing it to match actual usage of the code where the name was found. search engines still don't match thought processes; they still do word matching. the age of AI based searching in not here yet, at least not trained on all existing source code.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020