![]() |
the name of a sequence of numbers - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html) +--- Forum: Bar (https://python-forum.io/forum-27.html) +--- Thread: the name of a sequence of numbers (/thread-43508.html) |
the name of a sequence of numbers - Skaperen - Nov-07-2024 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? RE: the name of a sequence of numbers - Skaperen - Nov-07-2024 i found the name. it is called "Gray Code". RE: the name of a sequence of numbers - DeaD_EyE - Nov-07-2024 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-stec12e-rotary-pulse-encoder-24-24-vert-w-pb-stec12e08-p73923.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. RE: the name of a sequence of numbers - Larz60+ - Nov-07-2024 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. RE: the name of a sequence of numbers - Skaperen - Nov-10-2024 (Nov-07-2024, 08:24 AM)DeaD_EyE Wrote: Yes, it's Gray Code. 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. RE: the name of a sequence of numbers - DeaD_EyE - Nov-10-2024 (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/Incremental_encoder#Symmetry_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. RE: the name of a sequence of numbers - Skaperen - Nov-13-2024 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. |