Create an arbitrary delay time using C-script

Hi everyone, I have several questions:

(1) Here is a code to create a delay with one sampling period from the PLECS manual:

Output function code: OutputSignal(0, 0) = DiscState(0);

Update function code: DiscState(0) = InputSignal(0, 0);

      Now, I want to create a delay with "[b]n*Ts[/b]": Ts being the sampling period. How could I do that in PLECS               C- script?

(2) There is a block “Pulse Delay” in the Library. However, the delay time needs to be input manually.

In my controller, the delay time should be from a PI controller. Is there any way to put the delay time from a controller to the “Pulse Delay” block?

Thanks in advance!

1 Like

Hello,

The Pulse Delay block cannot accept a variable time delay input via its mask parameters or input ports, but if you look under the mask of its implementation you will see that it is based on a C-Script block. I would suggest you look at the Space Vector Modulator block to see how the C-Script block is used to calculate variable timing events internally. With the C-Script block, you can use an external value, such as the output of your PI controller, as part of the algorithm. Good luck!

Kris

even i have that doubt of creating the delay hope some one answers its

Please see my comment above.