Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

what is 'Variable-step discrete task'?

+1 vote
I am playing with fixed step solver and trying to convert a variable-step simulation model into a fixed-step one. But I get error message saying 'variable-step discrete task are not supported with a fixed-step solver'

what is this variable-step discrete task? Error message told me that it comes from double-edge c script block?

Any help would be appreciated. Thanks
asked Jan 21, 2020 by JonZ (13 points)

1 Answer

+1 vote

Hi Jon,

First, I just want to mention that variable-step solvers are more accurate and typically faster than fixed-step solvers for simulating power electronic systems. 

The reason you are seeing this error is because that particular C-Script block is using a Discrete-Variable sample time. This means it uses the NextSampleHit macro to specify the next simulation time, at which the block should execute. This is not supported with fixed-step simulations (or code generation), as PLECS cannot guarantee that it can fulfill the request since the NextSampleHit might not be an integer multiple of the fixed step size.

If you click on the “Help” button of the C-script block, you will notice that there are four types of Sample time possible. Apart from “Discrete-Variable”, you can use all the other Sample time types with fixed-step solver. If you are using “Discrete-Periodic”, the sample period and sample offset should be an integer multiple of the base step size.

To learn more about the "Discrete-Variable Sample Time", click on "Sample Time" .

answered Jan 22, 2020 by Manu Parimi (363 points)