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.
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).
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 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.
Happy new year!