Author Topic: [SOLVED] STM32F103 CubeIDE HAL setting variable deadtime PWMN  (Read 791 times)

0 Members and 1 Guest are viewing this topic.

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 286
  • Country: 00
[SOLVED] STM32F103 CubeIDE HAL setting variable deadtime PWMN
« on: January 26, 2021, 03:57:31 pm »
Hi,
i really dont like asking questions about programming but on this one im a bit out of ideas.

Im trying to learn about forward converters and to stay flexible i wan to control ist by a micro controller. Also getting into STM for the first time.

I have set up my controller to put out complimentary PWM by HAL with deadtime and this worked fine so far, just followed what other people have posted before. Sadly any examples i coud find stop at this point and im completely without a clue on how to change the deadtime without restarting the timer (which really sucks for the CC and CV closed loops for obvious reasons).

I expected it to work by just changing the timers compare value

__HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,value);

but for some reason this function seems to turn off the N channel and turn the pwm on te regular pin to a normal pwm with no regard to the desired deadtime.

What am i missing out on? Do i really have to start bitbanging registers after there is such a comfortable way of setting it up and using normal pwm?

thanks for all help i can get :D
« Last Edit: January 26, 2021, 09:17:29 pm by Amper »
 

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 286
  • Country: 00
Re: STM32F103 CubeIDE HAL setting variable deadtime PWMN
« Reply #1 on: January 26, 2021, 04:56:23 pm »
Ok, i have the suspition that i didnt understand the timer right, my goal is a 1:1 turn on ratio for both channels and a variable deadtime. Seems like changing the compare value will only shift the ratio between channels but not the duty cycle as i intended.

So is there a way of changing the duty on the fly or is it fixed after initializing the timer?
 

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 286
  • Country: 00
Re: STM32F103 CubeIDE HAL setting variable deadtime PWMN
« Reply #2 on: January 26, 2021, 09:16:55 pm »
Aaaaand i solved it. Looks like asking helps thinking about problems better (also i had some help).

Turns out its the case as i said in my last post, it wont work with the advanced timer and dead time.
In the end i just took timer2 channels 1 and 2, the timer set so phase correct mode 2 so the signals are centered on each other, ten inverted one signal and added/subtracted the dead time in my program feeding the two compare values separately. Next all try getting the preload to work to prevent glitches and then find my hardware mistakes. Those converters seem to be a bit difficult when not running full duty it oscillates...

Still thanks for everyone who considered reading, maybe this will be a help to someone some day.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf