# Deadtime 6pwm - hacking 10$ 36v/500w bldc controller to run simplefoc

**URL:** https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431
**Category:** hardware support
**Created:** [January 7, 2021, 1:12pm UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431 "2021-01-07T13:12:00Z")
**Posts on this page:** 8
**Page:** 2

<div class="post-metadata">

### Author: ![Uli](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/u/ccd318/32.png) [@Uli](https://community.simplefoc.com/u/Uli)
#### Post date: [January 11, 2021, 5:31pm UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/21 "2021-01-11T17:31:27Z")

</div>

I think the problem is, that there is no braking chopper. The motor controller is pushing back energy to the DC bus while braking. If you use a battery it is charged with this energy. If you use a PSU without braking chopper the voltage will rise very high and damage it.  
You could check if it only happens while braking and if there is a voltage rise just before the PSU shuts down.

---

<div class="post-metadata">

### Author: ![Aleksandar\_Markovic](https://community.simplefoc.com/user_avatar/community.simplefoc.com/aleksandar_markovic/32/480_2.png) [@Aleksandar\_Markovic](https://community.simplefoc.com/u/Aleksandar_Markovic)
#### Post date: [January 13, 2021, 4:29pm UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/22 "2021-01-13T16:29:10Z")

</div>

@Uli thanks for pointing this out. I’ll definitely have to think of something for breaking.

@Antun_Skuric I was wondering about BluePill and driving two motors with one. I never looked at it until now, so I’m quite clueless. From what I could understand, it has only one advanced timer that can output 3 complementary pwms. That would drive one motor ih hardware pwm mode, and the other one would have to work in software pwm mode.

Did I understand that part correctly, and do you know if there are any performance difference between the modes?

---

<div class="post-metadata">

### Author: ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)
#### Post date: [January 13, 2021, 4:40pm UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/23 "2021-01-13T16:40:08Z")

</div>

Yes, there is only one timer that supports inverted channels. But this is not just the case for Bluepill but for most of the stm boards.  
That’s why there is the software configured one.

The benefit is that you can drive more motors.  
The problems are:

- you need at least two timers for one motors
- the timers are not perfectly synchronized (not too far, but not 100%, the timers are started at the same time)
  - this will not cause any problems in terms of foc because the low/high pairs are in perfect sync
  - the problem can come in current sensing when you need very high degree of sync with the adc

So in your case, there isn’t too many drawbacks in terms of performance.

---

<div class="post-metadata">

### Author: ![Owen\_Williams](https://community.simplefoc.com/user_avatar/community.simplefoc.com/owen_williams/32/105_2.png) [@Owen\_Williams](https://community.simplefoc.com/u/Owen_Williams)
#### Post date: [January 13, 2021, 6:34pm UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/24 "2021-01-13T18:34:47Z")

</div>

stm32f405/7 have two timers that support inverted. TIM1 and TIM8. I don’t think they have any nano sized boards but they do a discovery stm32f407. I expect most of the mid/top end stm32 chips have 2 timers that support CHxN

---

<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: [January 17, 2021, 1:05am UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/25 "2021-01-17T01:05:13Z")

</div>

There’s a feather board with the STM32F405…

> **[Adafruit STM32F405 Feather Express](https://learn.adafruit.com/adafruit-stm32f405-feather-express)**
>
> ST takes flight in this fantastic Feather board. The new STM32F405 Feather that we designed runs CircuitPython at a blistering 168MHz – our fastest CircuitPython board ever! We put a STEMMA QT / Qwiic port on the end, so you can really easily plug...

---

<div class="post-metadata">

### Author: ![Aleksandar\_Markovic](https://community.simplefoc.com/user_avatar/community.simplefoc.com/aleksandar_markovic/32/480_2.png) [@Aleksandar\_Markovic](https://community.simplefoc.com/u/Aleksandar_Markovic)
#### Post date: [June 21, 2021, 1:46pm UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/26 "2021-06-21T13:46:46Z")

</div>

Hi,

I had some hobby time to continue playing around, and I’m sharing some pics and a video of the velocity mode working (good enough for my application) - still on low voltage until I assemble the battery (will probably go for 6s).  
I had to set dead zone to 0.1 to eliminate mosfet heating, which is probably due to cheap crappy mosfets

[https://drive.google.com/drive/folders/1IdoMmIeDoNPVZ7Rmaeznwamz764dU\_3s](https://drive.google.com/drive/folders/1IdoMmIeDoNPVZ7Rmaeznwamz764dU_3s)

I will be taking 5v from the controller to power the bluepill (it’s currently powered from USB) - two pins that anchor the connector to the controller are 5v and gnd. Hall sensors are powered from BP 3.3v pin.

2 BluePills will be connected to I2C bus to be managed and instructed by an Arduino Mega probably on 5v (I dod a quick test and it seems to work fine on 5v - I’d appreciate if anyone has suggestions, pros/cons in using I2C on bluepill at 5V).

I have a question:

- is the hall sensor pinout/sequence important?  
I swapped the pins, and the init part when the motor turn a bit seems to be different, and the zero electrical angle varied from 1 to 4, but the motor seemed to behave as expected no matter the pin arrangement of hall sensors - it looks to me as if simplefoc is smart enough to rearrange them in the correct order after the init

Thanks  
Aleksandar

---

<div class="post-metadata">

### Author: ![happytm](https://community.simplefoc.com/user_avatar/community.simplefoc.com/happytm/32/123_2.png) [@happytm](https://community.simplefoc.com/u/happytm)
#### Post date: [January 14, 2022, 4:42am UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/27 "2022-01-14T04:42:28Z")

</div>

@Aleksandar_Markovic Any more progress on your project?

---

<div class="post-metadata">

### Author: ![jonathan\_clerier](https://community.simplefoc.com/user_avatar/community.simplefoc.com/jonathan_clerier/32/2671_2.png) [@jonathan\_clerier](https://community.simplefoc.com/u/jonathan_clerier)
#### Post date: [March 22, 2022, 5:33am UTC](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/28 "2022-03-22T05:33:26Z")

</div>

Could you help me with what I’m doing wrong? I did the same thing as you, but when using the 6pwm code, I see that the high and low are working simultaneously and the motor does not work.

[Previous page](https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431.md?page=1)
