2009-10-14 01:44 AM
3-phase sinusoidal PWM (OPEN LOOP)
2011-05-17 04:26 AM
2011-05-17 04:26 AM
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.2011-05-17 04:26 AM
Hi gayatri
Can you send the it.c source to try running the code.NB: I am not an expert of motor control2011-05-17 04:26 AM
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.2011-05-17 04:26 AM
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?2011-05-17 04:26 AM
2011-05-17 04:26 AM
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
2011-05-17 04:26 AM
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..2011-05-17 04:26 AM
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.