cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Center aligned PWM

Sunday Ezeilo
Associate
Posted on July 25, 2017 at 08:15

How can I generate 360 degree out of phase center-aligned PWM waveform (modified sine wave) on two pins with STM32F103?

#stm32f103-pwm
4 REPLIES 4
Posted on July 25, 2017 at 15:15

Hello!

It is not posible with no external hardware to create theese waveforms  (you don't have negative voltage at any pin. In case you set VDD/2 as zero voltage you need  external componets to set. I do not suggest this.)

You can produce this waveform by a transformer in push pull setup .. (use mosfets or IGBT in case you make an inverter)

The drive circuit includes also Gate drivers (totem pole outputs) .

The MCU PWM output center mode is the less important in this setup.

Posted on July 25, 2017 at 20:16

Thanks, Vangelis!

I thinks you didn't get it. To generate modified sine wave, you need to run your PWM hardware in center-aligned mode. In doing so you will have a pin generate the upper half of the waveform I attached to my previous post. Now having two pins generate signals in phase-shifted manner, you obtain exactly what you see in that picture. Now my challenge is just how to make the two signals out of phase. Special PWM chips do that by hardware but I want to use my MCU for other tasks too.

Hope you get it now.

Thank you!

Posted on July 25, 2017 at 20:48

Hello again Sunday!!!

Sorry still i dont understand . In Modified sine we have 3 states. (Squarewave has two states) 

1. upper peak.

2 .Zero state (or midle state)

3. Negative peak (or ground voltage state)

Please describe what the states of two

Digital

pins would be to complete the table.0690X00000603ySQAQ.jpg

Rgrds

Posted on July 25, 2017 at 22:04

Hi again..

Finaly i understand !!

You Describe the push -pull setup. (complemetary outputs with dead time adjusted)

In case all project has galvanic isolation it can be used as modified  sine generator..!!(or use a tranformer)

So you need to setup two timers.

same clock source

same prescaller

same counter reload values,

one pin per timer.

same duty cycle (~33%..  to study further )

same output polarity

same edge aligned

same count direction

different initial counter values ( 0,~50% of reload value)

Start the two timers simultaneously(not exactly. by soft.)

The difference in phase is the initial difference in counters values.

So you can 'play' with counter values difference between two counters to trim your phase you want.