Closed AndyLindsay closed 6 years ago
The actual time it takes to overflow will be less because the measured angle is multiplied by certain values.
I think we might see the highest values from these calculations in API_PUBLIC.c: offset = fb[p].angleTarget; target = position * UNITS_ENCODER / fb[p].unitsRev; fb[p].angleTarget = target + offset;
Rollover will be at 2^31 / 2^12 = 2^19 = 524,288 turns. 524,288 turns (1 s / 2 turns) (1 min / 60 s) * (1 hr / 60 min) = 72.8 hours
Max degree units = 188,743,680.
Max ActivityBot units (64ths) = 33, 554, 432.
Search term: ].angle
It's probably best to start by writing a reset function that the user can call after checking and and finding that the angle is approaching 188 M degrees, or 33 M ActivityBot encoder ticks, or maybe just 500,000 turns.
Commit: Fix servo360 - Prevent binary overflow of 12-bit angle (Issue 92)
Added functions for checking and setting the number of turns. Example programs that use the functions are in:
in ...Documents\SimpleIDE\My Projects\Tests Servo360\
The servo360 library needs code added to prevent binary overflow in its angle tracking. Overflow will happen after 524000 revolutions. That could happen after 72 hours of top speed 120 RPM rotation in a given direction.