How to save position of the Motor and shadow_counts under non volatile memory


For my application, after the motor reboots it needs to remember the position it was at before. How to save the Pos_estimate and Shadow_count parameters to non volatile memory so when the controller restarts it knows its last position.

See Encoders — ODrive Pro Documentation 0.6.3 documentation

You can’t do it unless you have an encoder that supports this.

Can you atleast write back to the Pos_estimate variable or Shadow_count variable? If not how do I modify the codebase to either save Pos_Estimate and shadow_count to non volatile memory on reboot or make the parameter writable?

Another idea was adding a Last_Position parameter to the config of the Encoder and that way make it save it to the non volatile memory by saving the configuration

We don’t allow it because it’s unsafe. If you are absolutely sure the motor won’t rotate at all when the power is off, you can modify the code to make encoder.is_ready writeable I think?

Industrial robot servos usually use battery-backed memory and magnetic brakes to store last position and power up without homing. If battery goes low, they refuse to start and ask to call authorized tech and pay a lot of money for recalibration :). It’s strange that ODrive has no battery holder for that. STM32 has battery-backed memory.

You can use AS5047 encoder with absolute position anyway. It will remember it’s position for one turn. If you need more turns, just check if absulute position is same as on power off. If it’s same, then motor was not moved while it was off.

1 Like

How would that help? I beleive enocder.is_ready only tells whether Hall sensors are ready to be used or not. Can you help me in making the pos_estimate/shadow_count params writeable?