Hi everyone, I’m working on a project where I need to limit the movement of my motor to a specific range due to physical constraints. The motor should only move within ±1 radian from its central position. The angle control works as expected, but I need to ensure that the motor doesn’t exceed this movement window.
In other words, I want to ensure that the motor doesn’t continue increasing the angle when it is at +1 rad to reach -1 rad by moving clockwise. Instead, it should move counterclockwise to reach -1 rad, staying within the defined window.
If you’re using angle control, then during operation this is automatic - angles are absolute, so let’s say you’re middle point is 0rad, then you have +1rad and -1rad as your limits.
But if you keep going forward from +1 rad then the angle will only increase, as our sensor abstraction tracks the full rotations. So it won’t take the “other path” to -1 rad because going forwards will never let it reach -1… Instead it will go backwards, pass through 0, and eventually reach -1 rad.
A more difficult question is what happens at startup, and how to handle the case that the position starts out of range. In this case you’ll have to take care of making sure the motor goes to the desired starting position using the desired direction.
On another note, I am not sure we support the Nano Every…