I am working on generating Sinusoidal Pulse Width Modulation (SPWM) signals using the ePWM blocks in Simulink for a Texas Instruments C2000 microcontroller (specifically the TMS320F28379D). This is part of a project involving an Active Neutral Point Clamped (ANPC) inverter topology, where accurate and synchronized SPWM signals are essential to ensure proper switching behavior and voltage balancing.
I want to generate SPWM wave with 12 kHz switching frequency and 50 Hz modulating signal frequency.
My goal is to generate a sine wave in Simulink, use it to modulate the duty cycle of the PWM signals, and implement the control on the hardware using Embedded Coder.
However, I am facing a phase shift or misalignment between the reference sine wave and the actual ePWM outputs. I suspect this is due to a mismatch in sample times or unsynchronized ePWM configurations.
⚙ Setup Summary:
- Sine wave is generated in Simulink using a Sine Wave block.
- The sine signal is directly mapped to the duty cycle input of the ePWM blocks.
- ePWM blocks are configured in Up-Down Count mode.
- Sample time for both the control algorithm and the ePWM blocks is set to a fixed step size (e.g., 1e-5 s).
- I’m using the Embedded Coder support package for TI C2000 to build and deploy the model.
- Target hardware: TMS320F28379D (for a 3-phase ANPC inverter system).
🖼 Observed Issue:
I have attached two waveform captures that clearly illustrate the issue:
Even when the sine reference input is steady, the duty cycle of the PWM outputs gradually increases and decreases over time, instead of remaining constant. This suggests a possible timing misalignment, incorrect update mechanism, or buffer/sample time conflict between Simulink and the hardware.
❓ My Questions:
- How can I correctly synchronize the SPWM generation using ePWM blocks in Simulink?
- What is the best practice to align the sine reference with the PWM output timing in real-time applications?
- Could this behavior be caused by sample time mismatches or improper compare value updates in ePWM?
- Are there any recommended settings or mechanisms to generate stable and consistent SPWM for multilevel inverter applications such as ANPC?
Additionally, I have attached two waveform captures that clearly show the issue. Although the duty cycles should remain constant for a steady sine reference input, I observe that the actual PWM outputs gradually increase and decrease over time, even when the input sine signal remains stable.
This indicates that there may be a timing mismatch, buffer misalignment, or sample time conflict between the generated sine wave and the ePWM block. It appears as if the PWM signal is slowly drifting or modulating on its own, despite a constant input.
I would appreciate any guidance on:
- How to ensure consistent and stable duty cycle generation with ePWM in Simulink,
- How to properly synchronize signal updates to ePWM compare registers.