# Regenerative Braking

**URL:** https://community.simplefoc.com/t/regenerative-braking/2574
**Category:** developement
**Created:** [October 28, 2022, 7:51pm UTC](https://community.simplefoc.com/t/regenerative-braking/2574 "2022-10-28T19:51:58Z")
**Posts on this page:** 1
**Showing post:** 68

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [November 14, 2022, 3:24pm UTC](https://community.simplefoc.com/t/regenerative-braking/2574/68 "2022-11-14T15:24:36Z")

</div>

Hi everyone interested in the regenerative braking topic!

Some progress on this:

I have implemented a first version of the code that allows control of the FETs in the ways discussed.

I’ve implemented it into the API, and into the hardware drivers for STM32 and RP2040 so far. Other MCU types will gradually follow once we confirm it works as expected.

Note that on STM32 this works with Software 6-PWM, and not with HW 6-PWM. So you have to avoid using the negated PWM channels.  
On RP2040 there is only SW 6-PWM and it works with this.

You can find the branch containing these changes here:

[https://github.com/runger1101001/Arduino-FOC/tree/braking](https://github.com/runger1101001/Arduino-FOC/tree/braking)

And there is some very initial code for a BrakingBLDCMotor in this branch:

[https://github.com/simplefoc/Arduino-FOC-drivers/tree/braking/src/motor](https://github.com/simplefoc/Arduino-FOC-drivers/tree/braking/src/motor)

Usage instructions to follow once I have a chance to put together a test setup and actually try it out… but in the meantime anyone interested could take a look, give feedback, and perhaps even test it out with their setups.

The same implementation on the PWM side will also enable us to do Hi-Z mode in block commutation, enabling BEMF voltage measurements on the phases. This in turn opens the door to “sensorless” commutation based on BEMF readings.  
So that’s another avenue to explore at some point 🙂

And in further good news, my driver board from AliExpress “has arrived in my country or region” 😃 Lets see how long it now takes to get to me!

---

_[View the full topic](https://community.simplefoc.com/t/regenerative-braking/2574)._
