Using a Mechanical Switch to Set ODrive S1 to IDLE via GPIO

I’m using an ODrive S1 and would like to connect a mechanical switch to one of its GPIO pins so that when the switch is pressed, the ODrive transitions to IDLE mode.

Is it possible to configure a GPIO pin to achieve this? If so, what would be the recommended approach for setting it up in firmware?

Additionally, should I use an external pull-up resistor, or does the ODrive S1 have internal pull-ups that can be enabled? Any guidance or suggestions would also be appreciated.

Thanks in advance!

Hi! You can configure the min_endstop – the ODrive will exit closed loop when pressed. I’d probably use one of the hall or ABZ encoder pins for this, as it has an internal pullup: ODrive S1 Datasheet — ODrive Documentation 0.6.10 documentation.

I’m using a BLDC to pull a carriage, and once it approaches the end of its travel, I need to IDLE the ODrive to prevent the driver from getting damaged. I’d like to handle this directly within the internal STM of the ODrive S1 instead of adding extra hardware like limit switches, which could introduce more points of failure.

Would it be possible to write a line in the firmware to idle the motor when a certain position is reached? If so, what would be the best way to implement this?

Hmm, unfortunately at the moment we don’t have support for software endstops. Are you going to be in position or velocity control mode? If you’ll be in position control mode, then I’d just recommend making sure you don’t send setpoints past the end of travel. Note you can change vel_limit in real time to modify the maximum allowable velocity in position control mode – so you could simulate a position-limited velocity mode by just sending the carriage limit position as the position setpoint, and then modulate the vel_limit to your desired velocity.

I’m using an ODrive Pro in Velocity mode to drive a BLDC with a carriage that launches a projectile. I need to control the end velocity, but the issue is that when the carriage reaches the stopper, its velocity and momentum are quite high, generating a lot of reverse current and causing an error each time. I have a regen clamp in place, but I’ve already lost two S1s, so I’d rather not risk it.

Would there be a way to safely idle the motor before impact, maybe with another method? Any suggestions on mitigating this issue?

Also, I’m facing another problem—despite extensive tuning, the motor doesn’t reach the commanded velocity within the required distance. For example:

  • If I command 24 it only reaches 18
  • If I command 21 it reaches 16
  • If I command 18 it reaches around 14

I’ve tried increasing the integrator gain significantly, but it hasn’t helped. I need a way to ensure the motor reaches the commanded velocity as quickly as possible.

heya, would you have any insights on this?