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.
I am working on a 14400 Hz, 3-phase pwm using the TMS320F280049C to generate a 400 Hz sine wave. I am a beginner in firmware programming and have gone through the workshop and some examples. I am using code from the C2000Ware ePWM example called epwm_ex11_configure_signal. I am now trying to change the pwm periods to vary as to be passed through a filter to produce the sine wave. I believe this is to be done in an ISR but I am not sure. I planned to alter the EPWM_SignalParams object based on a counter which uses a clock to make these changes every 70us. I am having trouble finding how to set up the counter and alter the duty cycles according. The duty cycle values will be stored in a look up table and passed through the EPWM_SignalParams constructor and then used with the EPWM_configureSignal() function but I was getting an error saying the parameters of the constructor had to be constant. Any help would be greatly appreciated.
Hi,
Your query has been forwarded to an expert and should get a response shortly
Best Regards
Siddharth
Hi Matthew,
Your requirement is to generate a PWM waveform with duty cycle varying as a function of sine wave. You got the solution pretty much correct, that you will need to update the duty ratio in the interrupt routine of PWM.
I would define a variable, say x as a function of sin(theta) at the start of ISR. Use 'x' as an input to the CMPA register for your EPWM module. Later while getting out of the ISR, you can increment the theta by whatever small deviation is required. If you're targeting an EPWM switching frequency of 14400 Hz, you can compute the theta increment according with the EPWMCLK frequency.
As far as the code is concerned, you can refer to the example 2 i.e. epwm_updown_aq where the variable duty ratio functionality is shown where duty is updated but in linear fashion. You may need to update the code as per your requirement.
Hope this helps.
Thanks,
Aditya