Hi Everyone!
I’m trying to use Arduino to control the ODrive S1 with the MK8325S motor but everytime I initialize my variable “pos_val”, the motor move to position 0. Even if I include in the setup function that pos_val = getPosition(), the motor still moves to the encoder count 0. When the program starts up, I want to set the current position of the motor to be “0” and then move the motor in position control. So the motor will be start at “0” and then move by counts until it hits my limit switch and then that value will become the new “0”.
Hi! If you want to set the position, check out Controller — ODrive Documentation 0.6.11 documentation
In brief, you’ll want to set axis0.controller.config.absolute_setpoints
to True. On initialization/startup, you’ll want to set axis0.pos_estimate
to 0. Then, you can move the motor until you hit he limit switch, and then set axis0.pos_estimate
to 0 again.
Using the GUI setup, I can set axis0.controller.config.absolute_setpoints
to True and then in the Arduino code I use axis0.pos_estimate = 0
?
Correct! Note two things:
- Setting absolute_setpoints to True will require you to initialize pos_estimate to 0 before moving the motor (after each ODrive reboot). You can initialize it automatically by setting an absolute encoder reference frame, to set it based on the encoder reading.
- Make sure to call
save_configuration
in the inspector tab after setting absolute_setpoints to True (also in the inspector tab).
Are you using the Arduino over UART or CAN?