This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi
I need to generate two pwm signals based on the polarity of a sine wave as shown in the figure attached. The deadband should be 2us symmetrically around the zero crossing of vref.
The code has to be written inside an ISR which is serviced at every 25us. Kindly let me know an efficient and simple way to realize the pwms.
Thank you.
Sorry, i could not make any headway even after reading that. Mine is a more specific requirement as mentioned above.
Hi,
We do not have any example which I can refer it to you.
Are you reading the sine wave using ADC, is that correct? If yes, then the link I provided earlier is good place to start. If it is fixed Sine Wave, then you can setup Timebase period and CampA of ePWM based on the fixed sine wave.
Regards, Santosh
Thanks for the reply. The code snippet is attached below.
if ((vab_ref >= 0) && (t1==0)) { t2=0; EPwm2Regs.AQCTLA.all = 0x0001; EPwm3Regs.AQCTLA.all = 0x0002; t1=1; } if ((vab_ref < 0) && (t2==0)) { t1=0; EPwm2Regs.AQCTLA.all = 0x0002; EPwm3Regs.AQCTLA.all = 0x0001; t2=1; }
The whole code is inside an ISR serviced at 25us. I cannot decrease 25us because of code length. SInce the interrupt is at every 25us only, the pwm switchings are slightly away (approx. 10-15us) from the zero crossing. I would like it to happen at exact zero crossing in a symmetric way as shown in the figure.
If I need to use TBPRD and CMPA, what PWM frequency do you suggest. Also, please note that the CMPA value is very small, i.e., sin(wt) at 50 Hz with t=1us.
Kindly provide your suggestions.
Thank you.
Hi,
Let me check with expert and get back to you by tomorrow if that will work.
Regards, Santosh
I am assigning to one of our expert to help on this.
Aditya Dholakia : can you please help here?
Hi,
Can you clear out few points?
- As Santosh asked previously, is the Vref signal (vab_ref in your code) being read through the ADC or is it manually fed in your code as a sine wave?
please note that the CMPA value is very small, i.e., sin(wt) at 50 Hz with t=1us.
- I see that you need a 50Hz output from the PWM with a 50% duty ratio. The compare registers (CMPA) is a parameter which defines the duty ratio of your PWM, which in your case would be 50% of the TBPRD value. You can setup the PWM prescalars to adjust for the required PWM frequency. Can you share what are the current clock settings that you've implemented to achieve the 50Hz PWM output?
Aditya