cancel
Showing results for 
Search instead for 
Did you mean: 

3-phase sinusoidal PWM (OPEN LOOP)

muratterzi
Associate II
Posted on October 14, 2009 at 10:44

3-phase sinusoidal PWM (OPEN LOOP)

18 REPLIES 18
muratterzi
Associate II
Posted on May 17, 2011 at 13:26

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6W0&d=%2Fa%2F0X0000000bpf%2FXRCqrP6gvzeAteQZ8TPVcAm8JuYzdtCITAdGde4odss&asPdf=false
gayatri
Associate II
Posted on May 17, 2011 at 13:26

can somebody please help me in understanding this code?

1)how the PWM data is generated.

2)why is that pulse value is constant i.e : PWMdata[0]

3)output frequency of waveform

My problem definition:

I need to create a sinusoidal pulse width modulated wave(SPWM) which should have an output frequency of 50 Hz & switching frequency of H-bridge mosfets to which this signal will be feeded is 20KHz. The main aim is to make a DC voltage to AC waveform by using this SPWM.

Thanks in advance.

Please help me in understanding this.

lowpowermcu
Associate II
Posted on May 17, 2011 at 13:26

Hi gayatri

Can you send the it.c source to try running the code.

NB:  I am not an expert of motor control

lowpowermcu
Associate II
Posted on May 17, 2011 at 13:26

Hi gayatri,

I think you should look insite the interrupt handler to understand how the PWM data is generated.

I think the file name is stm32f1x_it.c or something like that.

gayatri
Associate II
Posted on May 17, 2011 at 13:26

Hi lowpowermcu,

Thanks for the response. I saw the file stm32f1x_it.c, but all i could find from that is exceptions & interrupts.

I wish to understand how the output of this code looks like & at what frequecy does the signal come?

i tried this in keil Uvision & found that it takes only 1st value of PWM data but not the vales defined in array. Suggest me what should i do?

gayatri
Associate II
Posted on May 17, 2011 at 13:26

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6Ys&d=%2Fa%2F0X0000000bqk%2F4bcnv6HDJdH1JmwWXCem3GSP68Bfhl2Erc0ltJjCihA&asPdf=false
lowpowermcu
Associate II
Posted on May 17, 2011 at 13:26

Hi gayatri,

In main, the interrupt CC1 is enabled

TIM_ITConfig(TIM1, TIM_IT_CC1, ENABLE);

and the TIM1 IRQ handler is enabled using:

NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQChannel;

//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

so I was expecting to have in stm32f1x_it.c and exactly in TIM1_CC_IRQHandler()

  to have the incrementation of index of the array  PWMdata[].

In other words, I was expecting

TIM1_CC_IRQHandler()

{

i++;

TIM_OCInitStructure.TIM_Pulse = PWMdata[i];

TIM_OC1Init(TIM1, &TIM_OCInitStructure);

TIM_ClearFlag(TIM1, TIM_Flag_CC1);

}

I am afraid that the stm32f1x_it.c doesn't match the main.c

so can you check this point.

There is no code stm32f1x_it.c, is it?

lowpowermcu

 

 

gayatri
Associate II
Posted on May 17, 2011 at 13:26

Hi lowpowermcu,

I guess you are right, I dont have code for stm32f1x_it.c that matches main.c. Can you tell me or provide code for stm32f1x_it.c? Do i neeed to change other files like gpio,nvic,tim,lib,flash,rcc as well ?

By the way I'm using Timer2 (PA0, PA1) for output. SO please tell me the necessary changes i need to make in code to get the output at that corresponding pin.

I can also use TIMER1 (PA8) if it requires a lot of change in code while shifting from TIMER 1 to TIMER 2. I'm really trying hard to understand all this stuff since I'm a newbie. Thanks a lot for your patience..

lowpowermcu
Associate II
Posted on May 17, 2011 at 13:26

Hi gaya,

One comment:

TIM2 doesn't have a complementary outputs, dead time generation.

So do you need it or not, if so you can update it to TIM2.