Mechanical Brake control through arduino

A bit of background on my use case before I jump in. I’m using odrive and the motor to control a winch that will constantly be under load. In this case in order to save power, I’d like the mechanical brake to engage whenever the motor is not moving or idle.

I’ve set my odrive up with a relay board that’s being controlled by the Odrive’s gpio which I set up according to this page: ODrive/mechanical-brakes.md at fw-v0.5.2 · odriverobotics/ODrive · GitHub

That article showed me how to configure the gpio to use the brake via the usb odrivetool commandline interface:

..mechanical_brake.config.gpio_num = 5
.config.gpio5_mode = GPIO_MODE_MECH_BRAKE

After saving the config and rebooting I tested the engage() and release() commands on the command line and it works fine.

From here I switched back to my arduino which is set up to be controlled via ethernet and is working well.
I noticed that when I ran the calibration it automatically turned the brake off which was previously engaged.
The problem I’m running into is that after the calibration runs and is finished, the brake doesn’t automatically engage anymore. I looked through the documentation for the odrive arduino library and don’t see a way to call the engage and release commands via the arduino library.

Please help me figure out a way to call the engage and release commands in my arduino code.

Thank you!

It’s not possible to call functions from ASCII, unfortunately, so you’ll have to add those commands as a special function in the code.

@Wetmelon

What code are you referring to?

Are you talking about the Arduino code? The C++ code powering that? Or the oDrive firmware itself?

The ODrive firmware itself.