cancel
Showing results for 
Search instead for 
Did you mean: 

TIMER Control

Mirza-AEC
Associate II

Hello

 

I am designing a controller that will drive a 3 phase BLDC 0.5kW motor. I choose STM32G474VET3 to generate the signaling with external gate driver and some beefy MOSFETs for that.

 

The MCU has advanced timer controller, and for my application i went with TIM20, ch1, ch2 and ch4. I see they can generate "PWM Generation CH CHN". How ever i dont see how to generate those with proper phase shift for a 3phase motor.

 

Can you please provide me some guide lines how to generate 3 phase pwm that is properly phase shifted. Which settings in the Cube i should look in to. If you have any app note i take a look it would be appreciated. 

 

Thank you 

 

Mirza

14 REPLIES 14
Fred V.
ST Employee

Hello @Mirza-AEC

Did you give a try to the ST Motor Control SDK? Even though it may not generate a code for the exact configuration you are designing, the generated code will show you how to generate three/six, properly phase-shifted signals to drive the phases of your motor.

Is it indeed what you are looking for: generating three sine voltage references (or SVPWM voltage references) spread 120° apart and turning them into PWM duty cycles and their complementaries to feed the six inputs of the drivers? 

Best Regards,

FredV

 

Hello

 

thank you very much for your suggestions. I have NUCLEO-IHM03 with NUCLEO- IHM16M1 and motor GBM2804H-100T. Using ST Motor Controller SDK and instructions i was able to generate the project and make my motor spin. I was very helpful and insightful. 

 

However i am looking for a 6-step commutation settings for TIMER control. Before i proceed with ordering my PCB i would like to know if a single TIMER (TIM20 in my case) using CH1, 2 and 4 can generate the needed signals for driving my motor. I also implemented HALL sensors as feedback and BEMF (voltage and current). I know that STM has also support for HALL sensor direct integration in TIMER control. Some code/video instructions would be much appreciated for this.

 

As i mentioned, i am a bit confused if a single TIMER can be used to generate 3 aligned/synced channels for 6-step commutation.

 

Also, if you can maybe suggested .... for 6 step commutation algorithm is it better to generate PWM or OC type control

 

I watched your online videos in regards with TIMER and PWM. I was also very educational. Still missing though is the 6-step commutation, with HALL sensor implementation.

 

Thank you

I am not sure i can understand your question completely but in workbench you have this configuration

SRedd5_0-1697955081348.pngSRedd5_1-1697955119013.pngSRedd5_2-1697955155835.png

I think you can use the above configuration to generate 6 step commutation using Hall sensor.

Hello,

You can use the workbench as @SRedd.5 suggested to get a 6-Step with Hall sensors project. 

 

However, the workbench does not support TIM20 for the time being and will only propose TIM1 or TIM8 (acutally only TIM1 in the case of the P-NUCLEO-IHM03 kit). But, you can use the project generated by the Workbench and modify it to use TIM20. 

It'll require that you modify the hardware configuration using STM32CubeMX by opening the *.ioc found file in the generated project and that you update the Motor Control firmware accordingly. This not a small task and the way to do this is not documented, but that is doable.

 

Two things to note: 

  • Make sure to regenerate the project after you have modified it with STM33CubeMx... 😉 
  • Once you have modified the hardware configuration in STM32CubeMX, you should not reload the *.stwb6 project file in the Motor Control Workbench to change its settings otherwise the modifications you made in STM32CubeMX will be lost. If you need to change some aspects of the motor control configuration, open the *.ioc file from the Motor Control Workbench instead. This will prevent you from making any modification to the hardware configuration, but it'll allow you to update the Motor Control parameters.

Best Regards,

Fred V.

Mirza-AEC
Associate II

Hello

 

the reason why TIM20 is not supported is because STM32G431 doesnt have TIM20. The MCU i want to use STM32G474VET3 has TIM20. 

 

I have followed the NUCLEO-IMH03 motor workbench. Now i want to replicate PWM generation on the NUCLEO-IMH03. I use TIM8 CH1,2, and 3 as PWM CH and CHN. Timer TIM8 CH4 i set as PWM No output generation. I copy all the settings from motor workbench settings. After generate code i add in the main function

 

 

 

/* USER CODE BEGIN 2 */
  HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1);
  HAL_TIM_OC_Start_IT(&htim8, TIM_CHANNEL_1);
  HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2);
  HAL_TIM_OC_Start_IT(&htim8, TIM_CHANNEL_2);
  HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_3);
  HAL_TIM_OC_Start_IT(&htim8, TIM_CHANNEL_3);
  HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_4);
  /* USER CODE END 2 */

 

 

however after i compile and download the code there is no output. I read the RM0440 and on page 1081 there is a table 252. I am not sure i understand the table.

MirzaAEC_0-1698049655228.png

I am saying that i dont understand the table since i choose TIM8 in Trigger Mode and ITR8 as trigger source. I looked on internet regarding "TIMx internal trigger connection" and they are a  bit different, much easier to understand than one in RM0440. 

 

So for my configuration on NUCLEO-IHM03, using TIM8 CH1, CH2 and CH3 as output and CH4 as trigger (i assume) how should i read the table 252. What should be my trigger source?

 

Thank you

Mirza-AEC
Associate II

Hello

 

i was wondering if someone can help me understand table 252 from RM0440

 

Thank you

According to me you can TIM8 for Ch1, Ch2, Ch3 and for trigger source you can use ITR1 which is tim2_trgo but only thing is you have to start the timer2 then you will get the PWM in my understanding.  

Mirza-AEC
Associate II

Hello

 

thank you very much for the response. I did as you have mentioned.

 

If you could maybe just write few words how did you come to this conclusion. For example what is first column TIMx? And how did you chose timer2? I imagine that is TIM2? Could you elaborate a bit?

SRedd.5
Senior III

But do you get the PWM outputs?