6 PWM driver initialisation causes shoot through


I’ve recently joined the simplefoc community and I love whats going on here.
I have made a custom driver board based around an STM32F405 and is rated for 200 amps or so. It uses IR2181 drivers which have to be driven in 6 pwm mode and does not have an enable pin.

Everything is working great except shoot through occurs during the driver initialisation.
I have scoped the PWM outputs and i can see multiple of them toggle high very momentarily. Fortunately I have been using a current limited PSU which has likely saved the board.

After setting a few breakpoints and stepping through the code, I can see that this event is caused within init->_configure6PWM->_initHardware6PWMInterface->_initHardware6PWMPair->setMode

In which we now leave the simplefoc code scope.

Within setMode there is a call to pin_Pullconfig which is essentially a wrapper around LL_GPIO_SetPinPull which seems to configure the pin in pull up mode. This subsequently pulls the pin high for a short duration before it is set low, therefore causing shoot through.

I temporarily commented out setMode (not recommended as this could have negative effects else where) and this resolved the shoot through issue.

1 Like

Aha! Looks like the configuration that determines whether a pin is in pull up or pull down mode is defined within the PeripheralPins.c PinMap_TIM. I will experiment with this tonight. Fingers crossed this sorts out the issue, and if so then it may be worth adding a note on the 6 PWM docs to ensure that the pulldown mode is selected if your board does not have an enable pin on the gate drivers

Hey @Cdoel,

This problem arises if you don’t have a separate enable pin for the drivers.
I mean, if you’d have an enable pin, then you’d not have these issues?
Am I getting this right?

Hi @Antun_Skuric, Yep you’re absolutely right, an enable pin would allow the drivers to ignore any erroneous PWM signals until completely initialised.
However, a lot of widely used and low cost half bridge drivers such as the IR2101 and the IR2181, L6498, EG2181D, FAN7390, etc. require 6 PWM and do not have an enable pin. So anyone using a board based around such chips could end up blowing up their board

Sure, I just wanted to make sure that I understood. :slight_smile:
We need to investigate this for sure and try to avoid this in any way possible!
Thanks for reporting this.

1 Like

It’s very interesting and a little bit strange. Thanks for investigating it.

Please let us know the result with changing PinMapTIM if you have a chance to try it.

Hoverboard controllers use 6pwm without an enable pin, actually most of the boards have no driver. But I never faced any issue during the initialization.

They must be another reason.

[EDIT] maybe the pwm polarity?

Its my pleasure :slight_smile: hopefully we can get to the bottom of it

Awesome so changing all the PWM pins to pulldown within the pinmap_TIM has fixed the shoot through. So i think it is indeed caused by the pins being pulled up momentarily during initialisation

Hmmmm interesting. What MCU do these hover board drivers use? This problem seems to be limited to STM32s from the looks of it.

I dont think it can be PWM polarity because the shoot through only occurs for a very short amount of time during initialisation and then everything works perfectly afterwards

On stm32f1.
Yeah then it’s not the polarity, I missunderstood.

Maybe my mosfets are too slow lol

1 Like

Maybe there are external pull-downs? The internal pull-ups are quite weak…

Thank you very much for checking.
Based on where the problem occurs I am not 100% sure we can fix it, it might require a change in stm32duino.
But perhaps we can work around it in the init code, and certainly users can work around it by changing the pin map.

The only change I can think of is to cross reference the pins passed to the driver object and check whether theyre set to pulldown mode, if not then a warning is printed.

I dont think its essential but could be a nice warning for those who have similar hardware