# Does PLECS have a module for variable time delay?

**URL:** <https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759>\
**Category:** General\
**Created:** [December 17, 2025, 11:57am UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759 "2025-12-17T11:57:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alps](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alps](https://forum.plexim.com/u/alps)\
**Post date:** [December 17, 2025, 11:57am UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/1 "2025-12-17T11:57:46Z")

</div>

I need to implement variable-frequency phase-shifted operation, but it seems that PLECS does not have a built-in variable time delay block. Are there any reference examples studies available?

---

<div class="post-metadata">

**Author:** ![Munadir\_Ahmed](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/munadir_ahmed/32/1540_2.png) [@Munadir\_Ahmed](https://forum.plexim.com/u/Munadir_Ahmed)\
**Post date:** [December 17, 2025, 2:25pm UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/2 "2025-12-17T14:25:15Z")

</div>

Hi alps, that sounds like an interesting modulator. Could you provide a bit more detail, for example the PWM patterns you are trying to achieve?

PLECS includes a built-in Variable Phase Modulator and a Variable Frequency Modulator, but not both in a single component. However, if you are using PLECS code generation, the TI C2000 PWM (Variable) component supports both variable phase shift and variable frequency. This allows you to both generate code for the MCU and simulate the behavior in the offline model.

---

<div class="post-metadata">

**Author:** ![alps](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alps](https://forum.plexim.com/u/alps)\
**Post date:** [December 17, 2025, 2:40pm UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/3 "2025-12-17T14:40:26Z")

</div>

What I mean is that a PWM wave is input, which will have a time delay. The delay time is provided by an external input and varies continuously.

However, it seems that the waveform delay blocks in PLECS only support fixed time delay

---

<div class="post-metadata">

**Author:** ![Munadir\_Ahmed](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/munadir_ahmed/32/1540_2.png) [@Munadir\_Ahmed](https://forum.plexim.com/u/Munadir_Ahmed)\
**Post date:** [December 17, 2025, 2:46pm UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/4 "2025-12-17T14:46:30Z")

</div>

Hi alps, have you considered using the _Turn-on Delay_ component with the parameter _Dead time source_ set to external? Alternately, maybe the _Monoflop_ component with the _Pulse duration source_ set to external might provide the functionality you are looking for. Again, a model might make it easier to provide a more tailored solution for your challenge.

---

<div class="post-metadata">

**Author:** ![alps](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alps](https://forum.plexim.com/u/alps)\
**Post date:** [December 17, 2025, 3:26pm UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/5 "2025-12-17T15:26:12Z")

</div>

Hi，munadir. Thanks for your suggestions

The Turn-on Delay block can only delay the turn-on instant, but what I want is to achieve a delay of the entire waveform, and the delay time is constantly changing. I’m really sorry, but my computer isn’t with me right now. I’ll send you my model tomorrow.

By the way, how does the Monoflop block achieve this function? Could you roughly explain the implementation idea? I want to try it on my own first.

---

<div class="post-metadata">

**Author:** ![alps](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alps](https://forum.plexim.com/u/alps)\
**Post date:** [December 18, 2025, 1:44am UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/6 "2025-12-18T01:44:54Z")

</div>

Hi,munadir.I’ve been trying to use C-script to write a module that can delay for an arbitrary length of time, but I keep running into issues.

[delay.plecs](https://forum.plexim.com/uploads/short-url/95uCrlUylaJwQU4Wsp2VwAEYsEz.plecs) (27.0 KB)

---

<div class="post-metadata">

**Author:** ![Munadir\_Ahmed](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/munadir_ahmed/32/1540_2.png) [@Munadir\_Ahmed](https://forum.plexim.com/u/Munadir_Ahmed)\
**Post date:** [December 18, 2025, 6:08pm UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/7 "2025-12-18T18:08:24Z")

</div>

Hi alps, I would highly recommend staying away from C-Scripts unless it is absolutely necessary. I would recommend trying to use basic PLECS blocks to implement the desired functionality and only utilizing the C-Script if its absolutely impossible to do using the basic PLECS blocks.

If you must use the C-Script block then I would recommend that you first go through the chapter on it in the [PLECS manual](https://www.plexim.com/sites/default/files/plecsmanual.pdf). There are quite a few issues with your C-Script (e.g. you only have 1 sample time specified in the C-Script mask but are trying to execute code at IsSampleHit(1) which would require you to specify the block to execute with at least 2 sample times).

From what I can tell based on your simulation model would this be sufficient:

[delay\_MA.plecs](https://forum.plexim.com/uploads/short-url/mbaHqqr5IZgqiFoQq1BGm8qTsZp.plecs) (25.9 KB)

Additionally, for those who might want to try something similar using the code generation blocks here is an TI TSP block based solution:

[delayedPwmPulse.plecs](https://forum.plexim.com/uploads/short-url/2fWMgInLGIL4Ja1CQOHaSa2NPp0.plecs) (37.4 KB)

---

<div class="post-metadata">

**Author:** ![alps](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@alps](https://forum.plexim.com/u/alps)\
**Post date:** [December 19, 2025, 5:24am UTC](https://forum.plexim.com/t/does-plecs-have-a-module-for-variable-time-delay/2759/8 "2025-12-19T05:24:40Z")

</div>

Hi,munadir.

Yes, I’m really not that good at using C-Scripts. Thank you for your advice — your model has also been a great help to me. I really appreciate it!
