# Error - Generate 3 X 120 phase shifted PWM

**URL:** <https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013>\
**Category:** PLECS\
**Tags:** inverter, converter, pwm, gate-driver-circuit\
**Created:** [April 22, 2021, 10:03am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013 "2021-04-22T10:03:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreerajarole](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sreerajarole](https://forum.plexim.com/u/sreerajarole)\
**Post date:** [April 22, 2021, 10:03am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/1 "2021-04-22T10:03:03Z")

</div>

Hello All,

I am trying to generate 3 PWM which are 120degree phase apart in Fixed step simulation model and having trouble with choosing sample time.

PWM generator high resolution period as sample time for 65khz signal which create issue in choosing integer multiple sample times !

PLECS MSG : Required sample time period (3.846153846153846e-06)

Any help would be much appreciated.

Thanks in Advance

 ![292](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/5fc525a76954cc6e783e290b55349d8847f6182c.jpeg)

---

<div class="post-metadata">

**Author:** ![shichenseu](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@shichenseu](https://forum.plexim.com/u/shichenseu)\
**Post date:** [April 23, 2021, 11:36am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/2 "2021-04-23T11:36:48Z")

</div>

Please upload your model to the forum ,only in this way, can others help you examine your error.

---

<div class="post-metadata">

**Author:** ![sreerajarole](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sreerajarole](https://forum.plexim.com/u/sreerajarole)\
**Post date:** [April 24, 2021, 12:25am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/3 "2021-04-24T00:25:37Z")

</div>

Hello ! Thank you for the reply.

Attached the PLECS stand alone model

[PWM\_PhaseShift.plecs](https://forum.plexim.com/uploads/short-url/sD6ADZKxknuPyJhAXduSB8WBWMn.plecs) (9.16 KB)

---

<div class="post-metadata">

**Author:** ![sreerajarole](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sreerajarole](https://forum.plexim.com/u/sreerajarole)\
**Post date:** [April 26, 2021, 12:00am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/4 "2021-04-26T00:00:13Z")

</div>

Hello ! Thank you very much for the reply. Attached the model

[PWM\_PhaseShift.plecs](https://forum.plexim.com/uploads/short-url/sD6ADZKxknuPyJhAXduSB8WBWMn.plecs) (9.16 KB)

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [April 26, 2021, 4:13pm UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/5 "2021-04-26T16:13:34Z")

</div>

Why do you require a fixed step simulation for this model?

And you really mean to feed the modulator an index of 0.5? If the reference signal is sinusoidal, for example, you can simply vectorize the phase parameter for the Sine Wave Generator block, as, e.g. [0 -2_pi/3 2_pi/3].

---

<div class="post-metadata">

**Author:** ![sreerajarole](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sreerajarole](https://forum.plexim.com/u/sreerajarole)\
**Post date:** [April 27, 2021, 12:06am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/6 "2021-04-27T00:06:30Z")

</div>

Hello Kris !

Thanks for the reply.

I am trying to integrate the PLECS plant with my Simulink model which has requirement to run in fixed step.

Currently just to demonstrate, 0.5 value fixed value is used to see whether I can generate PWM with 50% duty cycle and phase shift it.

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [April 27, 2021, 1:23pm UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/7 "2021-04-27T13:23:01Z")

</div>

When using a fixed time step, you have to make sure that all fixed-step events in the model are an integer multiple of the defined fixed step size parameter. With Tsw=1/65e3:

The PWM modulator requires a fixed time step that’s an integer divisor of Tsw/4 (your current time step of 3.846e-06 from the error message).Phase shifts require a time step that’s an integer divisor of Tsw/3 and 2\*Tsw/3.You probably want something less than that in order to accurately generate the PWM waveforms for different duty cycles. The PWM duty cycle quantization is directly linked with the fixed step size.So with the points above, your fixed step solver size should be an integer divisor of Tsw/12 in order to eliminate the error messages. The divisor factor determines your PWM quantization error. Attached is a model that shows this. Note it uses variables set in the Model Initialization Commands.Using a variable step solver simplifies this process greatly. It might also run faster by avoiding unnecessary solver steps. Also note there’s no provision against having fixed-step periodic events when using a variable-step solver. Please reconsider if there’s another way to model the fixed-step portion of your system in a way that’s compatible with a variable-step solver.

Lastly, you probably want to implement the phase delay by shifting the carrier as you would in most hardware, not by delaying the PWM signals, as shown in the attached model.

[PWM\_PhaseShift\_BL.plecs](https://forum.plexim.com/uploads/short-url/377uD7Qm0jtcAMLJVTSekbNdOeH.plecs) (12.8 KB)

---

<div class="post-metadata">

**Author:** ![sreerajarole](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sreerajarole](https://forum.plexim.com/u/sreerajarole)\
**Post date:** [May 3, 2021, 10:54am UTC](https://forum.plexim.com/t/error-generate-3-x-120-phase-shifted-pwm/1013/8 "2021-05-03T10:54:16Z")

</div>

Hello Bryan,

Thank you very much for the detailed information. Much appreciated.
