Although I have known that I can use two RT-BOXes to realize plant and controller and I have four boxes,but I still want to know whether I can use one RT-BOX to simulate plant and controller with different discretization step size.
There are two approaches here:
- With the RT Box 2 and 3 hardware and PLECS 4.4 you can generate multi-tasking code and assign the code to different processor cores. For an example, refer to the H-Bridge Converter demo model included with the latest RT Box Target Support Package (2.0.2). The demo model has the controller defined as a separate task by using a Task Frame component.
By default the model is configured for Single-tasking. You can change this from the Coder Options window. First, select the target as an RT Box 2 or RT Box 3 and click the Scheduling tab. If you change the Tasking Mode setting to Multi-tasking, you will see that the controller and plant are defined as separate tasks, each with their own sample time, and assigned to separate cores.
- If you do not have access to an RT Box 2 or 3, you can achieve a discrete controller operating at a different discrete time step than the plant. This would be done by placing your controller in an Atomic Subsystem with a defined sample time or a Triggered Subsystem. The sample time will have to be an integer multiple of the discretization step size. All target IO blocks must remain at the top-level of the code generation subsystem.
Thank U so much!