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

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?

1 Like

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 (9.4 KB)

Thank You Oliver.

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?