cancel
Showing results for 
Search instead for 
Did you mean: 

MC SDK4.3 PWM frequency >65kHz

Thomas.Greg
Associate II
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
8 REPLIES 8
PBo
Associate III
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

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

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'."
Posted on June 15, 2018 at 01:52

Cedric,

My target hardware configuration is an STM32F446RE running at 180MHz. The power stage uses three LMG3410-HB-EVM modules, with a target PWM frequency of 175kHz and 50ns dead time. Phase current measurements are made using three ACS722 hall-effect sensors. Bus voltage measurement is made using a simple potential divider.

The hardware works fine with a PWM frequency of 64kHz, using a Nucleo STM32F446RE board.

The objective is to drive a 1.2kW, 500krpm motor for a very small turbo-compressor. The control bandwidth requirements are not high (the controller only needs to take the motor to a target speed and hold it there, and the load on the compressor will be constant), so it should be acceptable to compute the FOC algorithm every two or three PWM periods.

I have chosen to debug the SDK using the STEVAL-ESC001V1 because I need separate serial and debug lines, and the Nucleo board uses the virtual serial link, which can't operate at the same time as the debugger.

Thank you for your help.

Greg

Posted on June 22, 2018 at 11:43

Dear Greg,

It can be fixed by the using different redefinition uint32 instead uint16 as you have mentioned.

Please check it in the files 'Parameters conversion_F30x.h' and 'Parameters conversion_F30x motor 2.h' on the rows 107+817 and 95/754.

&sharpdefine TF_REGULATION_RATE (uint16_t) ((uint16_t)(PWM_FREQUENCY)/REGULATION_EXECUTION_RATE)

=>

&sharpdefine TF_REGULATION_RATE (uint16_t) ((uint32_t)(PWM_FREQUENCY)/REGULATION_EXECUTION_RATE)

&sharpdefine PWM_PERIOD_CYCLES (uint16_t)(ADV_TIM_CLK_MHz*\

(unsigned long long)1000000u/((uint16_t)(PWM_FREQUENCY)))

=>

&sharpdefine PWM_PERIOD_CYCLES (uint16_t)(ADV_TIM_CLK_MHz*\

(unsigned long long)1000000u/((uint32_t)(PWM_FREQUENCY)))

For the second motor is similar.

Best Regards,

Giuseppe Scuderi

Posted on June 24, 2018 at 03:25

Giuseppe,

I will give this a try. However, while this will allow the PWM_FREQUENCY to be >65kHz, the the TF_REGULATION_RATE will still need to be <65kHz because it is still cast as uint16_t.

For my application, where I am aiming for a PWM frequency of 175kHz, this will require that REGULATION_EXECUTION_RATE is set to 3. This should be acceptable, but is it possible to allow TF_REGULATION_RATE to be >65kHz as well? So that I could try with REGULATION_EXECUTION_RATE = 2?

Thank you!

Greg

Posted on July 09, 2018 at 22:00

Giuseppe,

I have made the changes, and tested with my hardware.

The motor starts and runs with PWM_FREQUENCY = 167kHz and REGULATION_EXECUTION_RATE = 3. However, if I increase the PWM_FREQUENCY above this, I get an FOC_DURATION fault on the control panel.

This PWM_FREQUENCY is 95% of my target, so it is probably acceptable. Assuming initial testing is successful, I may revisit the firmware to improve the performance.

Thank you for your help,

Greg

Laurent Ca...
Lead II

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