Question of F280049C sawtooth genreation

2 views (last 30 days)
DA HEON HONG
DA HEON HONG on 25 Jul 2022
Answered: Sayan on 28 Sep 2023
Hello, I'm using F280049C launchpad with Simulink Embedded Coder for create PWM signal.
My sampling time is 40us which is same as the pwm switching period.
However, I want to make additional 40us sawtooth signal.
Because sawtooth period is exactly same as the sampling period, the signal is not printed properly.
I'm wondering how to create a waveform which period is same as the sampling time.
Is there any method other than reducing the sampling time?
Thanks.

Answers (1)

Sayan
Sayan on 28 Sep 2023
Hi DA HEON HONG,
I understand from your query that you are trying to generate PWM using the "ePWM" block of the "C2000 Microcontroller Blockset" library with the same time period as the sampling period of the "Solver" in Simulink, where no output is found from the "ePWM" pin of the F280049C board.
In this case, please know that generating the sawtooth carrier signal with the same period as the sampling period of the "Solver" is possible due to the following reasons:
  • When the model with the "ePWM" block is built using "Embedded Coder", it goes through code generation, which is dumped into the microcontroller board in machine level form. So, it does not depend on the solver to take the next discrete step in time.
  • When the code is dumped into the microcontroller, it runs in a continuous mode, which does not depend on the discrete steps of the solver.
However, you can generate a PWM of the desired frequency or period using the following steps:
  • Define the "Timer period" of the "ePWM" block using the following formula to find the sawtooth ("Up" or "Down" count in this case) carrier signal in "Clock cycles"
"Timerperiod= F_clk/F_des
Here, F_clk = Clock frequency of the microcontroller,
F_des= Desired frequency of PWM
  • The reference value to which the sawtooth pulse is compared needs to be defined in the block. You can define it by filling in the "CMPA units" field in "Clock cycles" or "Percentage" and providing the value in the "CMPA value" field to define the pulse width of the PWM.
  • Set the logic of comparison in the "ePWMA" tab of the "ePWM" block.
  • Connect the appropriate "ePWM" pin with the measurement device.
For more information on the "ePWM" block, please refer to the following MathWorks documentation link:
Hope this answers your query.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!