Skip to main content
Thomas.Greg
Associate
May 18, 2018
Question

MC SDK4.3 PWM frequency >65kHz

  • May 18, 2018
  • 2 replies
  • 2268 views
Posted on May 18, 2018 at 08:46

I would like to run the Sensorless FOC firmware with a PWM frequency greater than 65kHz.

My hardware configuration:

Nucleo-F446RE -> X-Nucleo-IHM09M1 -> Custom power-stage with ICS current sensors and bus voltage measurement.

My software configuration:

ST MC SDK4.3 -> STM32F4xx_MC Library -> STM32F4xx_UserProject - SM32446E-EVAL

IAR Embedded Workbench IDE

I have successfully configured, compiled, uploaded and tested the sensorless FOC firmware with a PWM frequency of 30kHz. However, once the PWM frequency is increased above 65kHz, the compiler produces a number of warnings, and the controller is not able to drive the test motor.

I have inspected the source code for the firmware. The PWM_FREQUENCY is declared in Drive_parameters.h, with no type. All subsequent calls cast the value to uint16_t, which explains the 65kHz limit.

I have attempted to change the declaration of variables that will take the PWM_FREQUENCY and TF_REGULATION_RATE to uint32_t. I have worked through the variables one-by-one to check that everything still works with a PWM frequency of 30kHz. I can change all calls apart from one:

Once I change the 'hMeasurementFrequency' member of the SpeednPosFdhkParams_t structure in SpeedNPosFdbkClass.h from uint16_t to uint32_t, the code will compile but the motor will not run. I have unsuccessfully tried to identify operations that use .hMeasurementFrequency and determine why they won't work with a uint32_t value.

I would be incredibly grateful if someone with a more in-depth understanding of the SDK (and software debugging in general) would be able to assist me with figuring out how to modify the code.

Thank you in advance!

Greg

#foc-4.3 #foc-sdk-4.3.0 #motor-control-foc-library
This topic has been closed for replies.

2 replies

PBo
Visitor II
June 11, 2018
Posted on June 11, 2018 at 11:40

Hello Greg,

You're right, debugging with the MC SDK4.3 is not so easy.

Among other things, this is a main reason why ST has started with the MC SDK from 5.x ;-).

FYI, the latest release available if MC SDK5.1.1. Maybe you should try from this version.

Cheers,

PBo

Thomas.Greg
Associate
June 13, 2018
Posted on June 13, 2018 at 04:10

Hi PBo,

I'm reluctant to move away from the SDK4.3, as I have the configure-build-upload chain working comfortably. However, one of the first things I did was check whether SpeedNPosFdbkClass.h and VirtualSpeedSensor_SpeednPosFdbkClass.c had been updated. Although the variables have been renamed, the functionality/structure of the code appears to be the same.

I've switched from my custom hardware to the STEVAL-ESC001V1, as this allows debugging and a separate serial link for control (although I guess I could have used the user button on the Nucleo board to start the motor).

The 'good news' is that the problem still exists on a completely clean version of the SDK4.3 suitable for the STEVAL-ESC001V1. Changing the declaration of hMeasurementFrequency from uint16_t to uint32_t prevents the virtual speed sensor from working. Although in this case the motor does at least spin.

I have debugging working, and I'm slowly plugging away at this as time permits. My current working hypothesis is that something odd is happening with the SpeednPosFdbkParams_t structure when the size of hMeasurementFrequency doubles.

Greg

cedric h1
Visitor II
June 14, 2018
Posted on June 14, 2018 at 10:30

Hi Greg,

Could you share your hardware configuration ?

you mentioned STEVAL-ESC001V1, so I guess you are building a drone application. Is your custom board based on a STM32F303 too ? 

I would like to understand why you need a such high PWM frequency ? 

we are testing drone motor nicely with a 30 Khz PWM. 

Be aware that for FOC operation, we compute at each PWM cycle all the parameters for the next PWM cycle. So if you multiply the PWM frequency by 2, we will not have the time to execute the FOC algorithm (this is the FOC duration issue you see from the WB). (We have tricks to compute the FOC algo only each 2 periods but ...)

Last remark. the 4.3 ESC001 that is available from the ST download is a customized version. The 5.1.1 does not support ESC001 yet. initial support is plan for 5.1.2, and full support in 5.2

regards

Cedric

If you agree with my answer, please accept it by clicking on 'Accept as solution'.""
Laurent Ca...
Senior III
June 15, 2021

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards