You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quote from the user:
"So, the move_relative_position (mrp) function in the kipr library is broken. 5-10% of the time it simply fails to move the motor at all."
The text was updated successfully, but these errors were encountered:
I was able to repro the issue using the code above. It also repros with mtp, since mrp is just a wrapper around mtp. I think the problem is a race condition in the "motor done" logic - after the "done" flag gets cleared, it sometimes gets immediately set again, resulting in the motor not moving. More details below.
If I understand correctly, the "motor done" flag gets cleared when the motor mode register changes (see wallaby_dma.c#L226-L234):
After this finishes, the goal position is 1000, the current position is around 1000, and the "done" flag is true.
Now you call mtp again. Line (A) sets the motor mode, which clears the "done" flag. Before line (B) runs, the STM32 code may run and see that the goal position (the old one) has been reached, so it sets the "done" flag back to true. Now line (B) runs and sets the new goal position, but it's too late. The "done" flag has been set, so the motor won't move towards the new goal position.
I think the easiest solution is reordering the register writes to B, C, A. There can still be different race conditions, but thinking through the possibilities, they shouldn't result in bad behavior.
More complex but possibly better solutions could be:
Combine the register writes so they're written together, if possible
Move the responsibility of clearing the "done" flag to libwallaby, so mtp can ensure the "done" flag isn't cleared until it's time
The discord user "Jammo2000" has reported that mrp is not functional.
He said he recreated the problem using the following code:
Quote from the user:
"So, the move_relative_position (mrp) function in the kipr library is broken. 5-10% of the time it simply fails to move the motor at all."
The text was updated successfully, but these errors were encountered: