Hardware tools and blocks

Hello 
I would like to inquire about the implementation model that I built with Matlab on the hardware side. I did it with normal PWM and it works by connecting each pulse to the GPIO block.
So here as in picure, I need to implement it by using SPWM (Sinwave and comparing it with sawtooth). Which block should I use in hardware like (GPIOx or ePWM) and is there a private block that I should use instead of that used with normal PWM and simulation?
If anyone could please guide me, send me a hardware model or send a video to understand this issue,
These are the pulses that I want to send to my circuit and this picture includes the GPIO block from hardware tools. 
Thanks in advance. 

3 commentaires

SALAH alatai
SALAH alatai le 14 Juil 2021
up
LO
LO le 18 Juil 2021
Hi Salah, which kind of hardware would you like to interface with MATLAB and for what purpose ? It is not clear at all what your issue is, at least not to me :)
SALAH alatai
SALAH alatai le 18 Juil 2021
Hi LO I want to implement a circuit Multilevel Inverter. Normal Hardware by using F2879D launchpad Microcontroller to get signal on ociliscope.

Connectez-vous pour commenter.

Réponses (1)

Nivedita
Nivedita le 23 Juil 2026 à 6:24

0 votes

Hello Salah,
The GPIO block only writes a digital value from software at the model sample time. That can work for slow/manual pulses, but it is not suitable for accurate high-frequency PWM/SPWM because the timing depends on CPU execution and sample time.
For SPWM, the better hardware implementation is:
  1. Use the C2000 ePWM block. ePWM Type 1-4 - Generate enhanced Pulse Width Modulated (ePWM) waveforms - Simulink
  2. Configure the ePWM time-base as the carrier, for example up-count or up-down count.
  3. Generate the sine reference in Simulink.
  4. Convert the sine reference to a duty-cycle/compare value.
  5. Feed that duty/compare value to the ePWM block.
  6. Route the ePWM output pins to the inverter gate driver circuit.
  7. If complementary switches are used, configure dead time/dead-band to avoid shoot-through.
In other words, you normally should not compare sine and sawtooth in Simulink and then send the result through GPIO. The ePWM peripheral already provides the hardware carrier/timer and compare logic with much more accurate timing.
For a multilevel inverter, use multiple ePWM modules/channels to generate the required gate pulses. The ePWM outputs are still physical device pins, but they should be configured for their ePWM function, not driven as plain GPIO digital outputs.
GPIO DO is acceptable only for slow control signals or simple on/off outputs. For oscilloscope PWM/SPWM gate pulses, use ePWM.
Thanks,
Nivedita.

Réponse apportée :

le 23 Juil 2026 à 6:24

Community Treasure Hunt

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

Start Hunting!

Translated by