ePWM setting for C2000 DSP, output not the right frequency

22 次查看(过去 30 天)
Hi All,
I am trying to generate PWM pulses for a three-phase inverter using C28335 DSP and Matlab Simulink. My switching frequency is set to 6 kHz and DPS is 150 Mhz (Timer period TBPRD = 12500). I am sending a 50 Hz sinusoidal reference, but my measured AC voltage output is 12,5 Hz! Why is this happening? Is there a setting I missed in ePMW block.
Also, if I look at ePWMA and ePWMB panes setting, is there a mistake for ePWMB output pane -- should CMPA on up-count (CAU) be set to Do nothing instead of Set? I don't know where this four times lower frequency comes from. I assume even the phases are not 120° deg shift.
Interestingly enough, when I connect with External mode and record data, the output voltage is 50 Hz. But on an oscilloscope with a differential probe is 12,5 Hz!


Venkatesh Chilapur
Venkatesh Chilapur 2018-7-16
Hi Mike,
Regarding your point of 'Also, if I look at ePWMA and ePWMB panes setting, is there a mistake for ePWMB output pane -- should CMPA on up-count (CAU) be set to Do nothing instead of Set?' the configuration for CAU field for ePWMB is independent of CAU field for ePWMA. So this configuration on one output will not impact output.
And going by your model it is very likely that since you have used Simulink 'Sine wave' blocks, it will generate code that is not optimized for embedded applications. This can result in overrun scenario as you clearly identified. We encourage you to use TI Math Library to generate the Sine values.
The following link provides some insight in to the same.
To interface to external C/C++ code from Simulink, like in this case you will need to call the Sin() function from Math library, please following the link:
You can also quickly do the real time execution profiling of the generated code by following link:

更多回答(1 个)

Venkatesh Chilapur
Venkatesh Chilapur 2018-7-13
Please share your model and provide MATLAB version details, and Hardware version details for further investigation.
  1 个评论
Mike Buba
Mike Buba 2018-7-13
编辑:Mike Buba 2018-7-14
Hi Venkatesh,
please find simple model in the attachment. It contains voltage reference that is multiplied by sine waveform and this is input to PWM. Switching frequency is 4 kHz and DPS base frequency is 150 MhZ which gives Timer period TBPRD = 18750. I am using sinusoidal modulation for three-phase inverter.
PWM block is from the C2000 DSP library for C28335 processor (you need this to look into block). I am running all this on TMS320F28335 Experimenter Kit. Matlab is R2015a and Code Composer Studio is 5.5.
Kind regards
If I set samples per period two times higher (Tcontrol*2) I can get closer to 50 Hz but still not exactly. My reference is 100 Hz as recorded by Simulink, but output voltage frequency is ~ 45 Hz
ePWM settigns:
Update II:
When I run only open loop three-phase inverter (simplified code, only reference and PWM as in the attachment) I can get frequency around 40 Hz (with initial settings for Tcontrol = 5e-5 sec).
As if this task is not executing at Tcontrol but with some other sample time?! The 'smaller' the code the closer I am getting to 50 Hz output frequency! All inputs to PWM block are with sample time Tcontrol. This might explain why my software recoding is always 50 Hz, but output changes its frequency as the size of the code changes.
Can I somehow see if I have overflow or check that the code is completely executed in sample time?
I cannot explain why my reference is 50 Hz and output changes its frequency as the size of the code changes. PWM switching frequency is always 4 kHz (measured by oscilloscope), only reference changes its frequency. Can You please provide any explanation and advice on how to solve this problem.





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by