what is 'Variable-step discrete task'?

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

1 Like

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” .