Cyclic Encoder behaviour at extremes

Hi, All.

Following along with the buildinghtm.systems site and twitch sessions. I have a question about the CyclicScalar encoder’s behaviour at the extremes of the range. I understand why the bits “wrap around” when approaching and hitting the maximum value. What I don’t understand is why they do not wrap around when approaching/hitting the minimum value.

I have reviewed and understand why the code produces the current behaviour. What I am looking for clarification on is why this is desired behaviour. If I picture in my head a circle and my scale is degrees then my expectation would be that there would be bits on both sides of the zero mark when 0° or 360° is encoded. The current code would put all bits to the right of the zero mark for 0° but would straddle the zero mark for 360°. (Feel free to substitute 359° for the max and have the bits slightly favour the left of the zero mark).

Follow up, but unrelated question: would it be beneficial to incorporate a modulus operator into this encoder? For instance, if the scale was in radians, then the range could be 0 to 2π and encoding 4π would produce a valid response.

Thanks.

2 Likes

Thanks for following along, and for your feedback.

I don’t think it matters except for the aesthetic value in the visualization. To the SP, where the cycle begins and ends is irrelevant as long as smooth wrapping occurs.

Makes sense, but I would want an option to enable / disable this feature. In some cases you may want to limit the range of the encoding, in others perhaps not.

2 Likes