Hard stop homing

Hi all,
I wanted to share a feature that I coded in python allowing me to home an axis using a hard stop.
While building this 6-DOF articulating arm, I wanted to avoid messy wiring from end stops or photo electric sensors.

The idea:
Homing function initiate, and axis starts to rotate while current to motor is being monitored. Once the current exceeds a certain threshold (programmable), the axis halts and remains in closed loop control. Then it is commanded to move to certain offset away from hard stop (zero position).

The setup:
I monitored the current as the axis rotated freely under full load, and found that it consumes about 3A.
So i set my end stop detection current to 5A, which then stops the motion.

The trick:
The trick in stopping a motion in the ODrive that i found, is putting the axis in idle then followed by closed loop command. The issue is that once back in closed loop, the axis wants to finish the trajectory it was commanded to execute. This ALWAYS results in a very fast motion tripping the over current and over speed errors.
Thus, once the idle command is sent, the input_pos must equal encoder pos_estimate.
Now, once the closed loop command is giving after an idle (during motion) command, the controller thinks the trajectory has been completed and holds the current position.

Python function:



Happy new year!


was wanting to do something very similar but never got round to it. well done, this is super useful!!

1 Like