cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to create 120 degrees 3 phase shifted pwm with controllable duty cycle?

ABene.1
Associate II

Hello,

I am working on a 3 phase buck converter project.

I am using stm32f303ze nucleo board for the project using HAL libraries and STM32CubeIde.

The problem is that i want to generate 3 phase shifted pwm with complementary outputs and i need to control duty cycle according to pid control.

I want to use a single advanced timer and according to stm32f303ze datasheet, it has 3 advanced timers.

I have found that asymetrical pwm mode can produce such phase shifted pwm signals but I couldn't find any apparent example source codes or applications.

That is why i request the community's assistance.

9 REPLIES 9

> I want to use a single advanced timer

I don't think it's possible to generate 3 mutually phase shifted pwm within one timer.

You can generate one "baseline" pwm, which has one edge aligned to the timer's overflow/reset/update, and then one more, which has edges situated freely within the timer's period, but that freedom requires two adjacent channels, so already three channels are used up and another freely adjustable pulse would require two more channels. It would appear that Advanced timers in 'F3 have 6 channels, but CH5 and CH6 can't generate outputs onto pins.

It's still possible to generate this on two or three mutually master-slave linked timers.

JW

ABene.1
Associate II

Could you elaborate with the linked timers? I found synchronization of timers but didn't find a useful explanation for my usage in the reference manual.

Could you elaborate with the linked timers? I found synchronization of timers but didn't find a useful explanation for my usage in the reference manual.

You want the timers to run synchronously. You can start one after the other, and unless you allow interrupts during that, they will be only a few cycles apart, and that may be good enough for your application, it's up to you to judge.

Or, you can set one timer as master, setting its TIMx_CR2.MSM to Enable; other timer as slave, setting TIMx_SMCR.TS to ITRx corresponding to master according to table at end of TIMx_SMCR description; TIMx_SMCR.SMS to Trigger mode. Set up both timers as usually except don't run them, i.e. don't set TIMx_CR1.CEN. Then, when you set master's TIMx_CR1.CEN, slave's TIMx_CR1.CEN will be set automatically. There will be a couple of cycles delay, but that should be small and constant, so it can be compensated for by setting slave's TIMx_CNT beforehand.

JW

Javier1
Principal

@ABene.1​  Are you trying to implement your own trapezoidal motor control modulation?

we dont need to firmware by ourselves, lets talk

hello, sorry for the late response.

I am trying to achieve 3 phase buck converter.

My goal is to produce 3 phase 120 degrees phase shifted pwm using timer modules and/or software.

I will not be using this in motor application.

@ABene.1​ is the PWM what needs to be 120 degrees phase shifted or is the carrier signal what needs to be 120 degrees phase shifted?.

You could explore the Master-Slave functionalities of stm32s timers.

we dont need to firmware by ourselves, lets talk

I have investigated more about your suggestion and using timers in master slave configuration. I have thought about a system for this configuration. Could you check if my logic is somewhat on the track?

I need 3 phase shifted pwm(0,120,240) thus i need 3 asymmetrical pwm output.

Each advanced timers(TIM1,TIM8,TIM20) can have 2 asymmetrical pwm outputs.

Asymmetrical pwm combines two channels to output the pwm: CH1&CH2 and CH3&CH4

If i set TIM1 to be master and TIM8 to be slave, they will synchronize the count.

for phase 0 -> Using TIM1 and CH1&CH2

for phase 120 -> Using TIM1 and CH3&CH4

for phase 240 -> Using TIM8 and CH1&CH2

If i synchronize the timers and put the numbers correctly into CCR registers of timers channels, i think i will be able to get the 3 phase pwm.

> If i synchronize the timers and put the numbers correctly into CCR registers of timers channels, i think i will be able to get the 3 phase pwm.

Yes, it should work.

I personally would prefer the Combined mode, and I would avoid the up/down counting, as it's IMO unnecessarily complicated; but you may find it otherwise.

JW