mattjlewis / diozero

Java Device I/O library that is portable across Single Board Computers and microcontrollers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos / Pico. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad.
https://www.diozero.com
MIT License
261 stars 59 forks source link

Enhancement Request: active braking for PwmMotor #176

Open sparry0407 opened 1 year ago

sparry0407 commented 1 year ago

Currently PwmMotor implements a coasting stop: when you set the speed to zero or stop it sets both the forward and backward channels of the bridge to zero, allowing the motor to continue freely rotating. Other implementations seem to include an active braking approach, allowing you to set both forward and backward channels to 1.0, which causes the wheels to stop dead and also helps keep the vehicle from rolling away. Could we please have a brake function? I have implemented a variation of PwmMotor for my own use, which appears to work well. The only hitch I found was that I had to add forward and backward stop calls to the close function to stop random wheel movements during close down.

mattjlewis commented 1 year ago

Will take a look