Dear PLECS community,I am reaching out for help with an issue I am facing while using the RT Box for a pure simulation experiment (no analog or digital I/O involved).I have split the simulation into two separate subsystems, one for the power circuit (plant) and one for the controller. I set the sample time of the power circuit subsystem to 5e-6 s (5 µs) and the sample time of the controller subsystem to 10e-6 s (10 µs). However, when I try to build the model and download it to the RT Box, I receive the following error:"Sample time period and/or offset [5e-06, 0] are not an integer multiple of the base step size (1e-05)."I do not fully understand why this error occurs. Would someone be kind enough to explain what I am doing wrong and how to properly configure different sample times for these two subsystems on the RT Box? I have attached screenshots of the sample time settings, and the relevant RT Box parameters for reference.Any suggestions or guidance would be greatly appreciated. Thank you very much in advance for your time and help!
Hi Runxin,
When generating code for a real-time system the PLECS Coder requires a discretization step size or step size for each task. All events that occur within the task must be synchronous to that step size, otherwise they will not occur at the precise moment.
Consider a simple example: a C-Script configured with a sample time of 5 µs (5e-06 s) running inside a task with a base step size of 10 µs (1e-05 s). The code generator expects the C-Script to execute every 5 µs but the task only ticks every 10 µs, so there is no execution slot at the 5 µs mark. Because 5 µs is not an integer multiple of the 10 µs step size, PLECS raises the error above.
The same rule applies to any block that carries its own timing parameters, such as a Pulse Generator configured with a period of 20 µs and a 25% duty cycle. Again, if the base step size is 10 µs then the 5 µs offset cannot be resolved, producing the error.
The fix is to ensure every timing parameter is an integer multiple of the task’s base step size.
While the “Sample time period and/or offset…” has a clear explanation, the numbers in your post don’t align with the error messages. For example the reported base step size in the error message is 100 µs, while the supposed value should be 10 µs. Your switching frequency fsw is also 20 MHz, making Ts_ctrl equal to 50 nanoseconds.
I believe your model configuration isn’t as you intended and so you need to systematically track down these issues to ensure consistent timing.
Regards,
Bryan
Thank you very much for your kind help. I will continue to work hard.



