# How to insert a phase delay value calculated during a running simulation to a delay or any other block?

**URL:** <https://forum.plexim.com/t/how-to-insert-a-phase-delay-value-calculated-during-a-running-simulation-to-a-delay-or-any-other-block/623>\
**Category:** PLECS\
**Tags:** integrator, variable, pulses, delay\
**Created:** [February 13, 2019, 3:44pm UTC](https://forum.plexim.com/t/how-to-insert-a-phase-delay-value-calculated-during-a-running-simulation-to-a-delay-or-any-other-block/623 "2019-02-13T15:44:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snehathakur](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@snehathakur](https://forum.plexim.com/u/snehathakur)\
**Post date:** [February 13, 2019, 3:44pm UTC](https://forum.plexim.com/t/how-to-insert-a-phase-delay-value-calculated-during-a-running-simulation-to-a-delay-or-any-other-block/623/1 "2019-02-13T15:44:28Z")

</div>

Hi

How can I insert a variable calculated during a simulation to block. I know, we can write the initialization commands and the blocks pick up the variable value. But I want my circuit to sense the current and calculate the time values and provide that as a delay to the block.

Fig attached.

I want to provide a delay ‘t1’ for my pulse2 i.e. pulse2 should start after pulse1. Either I should be able to provide delay t1 to the sawtooth waveform as shown or I use a delay block. But Plecs throws an error, as it does not pick the value from running simulation.

Can you please help?

 ![Capture.JPG](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/f40da97c4a3b640e7bca4412871c78726d4b5179.jpeg)

---

<div class="post-metadata">

**Author:** ![Oliver\_Schwartz](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/oliver_schwartz/32/6_2.png) [@Oliver\_Schwartz](https://forum.plexim.com/u/Oliver_Schwartz)\
**Post date:** [February 27, 2019, 11:55am UTC](https://forum.plexim.com/t/how-to-insert-a-phase-delay-value-calculated-during-a-running-simulation-to-a-delay-or-any-other-block/623/2 "2019-02-27T11:55:23Z")

</div>

You cannot change block parameters at runtime.

To get the desired behavior, the turn-on block needs to be rewritten so that the delay is read from an input signal. This can be realized using a C-Script, please see the attached example.

Kind regards,

Oliver Schwartz

[DelayVar.plecs](https://forum.plexim.com/uploads/short-url/kYqAlTAhXDZ4NO9JLIBK3MhxBGU.plecs) (9.4 KB)

---

<div class="post-metadata">

**Author:** ![snehathakur](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@snehathakur](https://forum.plexim.com/u/snehathakur)\
**Post date:** [March 2, 2019, 6:37pm UTC](https://forum.plexim.com/t/how-to-insert-a-phase-delay-value-calculated-during-a-running-simulation-to-a-delay-or-any-other-block/623/3 "2019-03-02T18:37:16Z")

</div>

Thank You Oliver.

---

<div class="post-metadata">

**Author:** ![ankul892](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@ankul892](https://forum.plexim.com/u/ankul892)\
**Post date:** [August 22, 2019, 8:44pm UTC](https://forum.plexim.com/t/how-to-insert-a-phase-delay-value-calculated-during-a-running-simulation-to-a-delay-or-any-other-block/623/4 "2019-08-22T20:44:31Z")

</div>

In the attached example, the phase shift works fine but the duty of the phase-shifted pulse is reduced. Can you share an example where the duty of both the pulses remain the same but the phase shift varies?
