Open and Examine the Model

Simulation schematic

This schematic is the top-level schematic for simulation. It shows clearly how the controller (Controller1) is connected to a model of the physical system (Plant1) in a closed loop. Typically, it is the controller block that is the top-level block for code generation. The physical system model block is only active during simulation, and describes how a real physical system would react to the control value. The physical system model in this example is quite arbitrary (it contains some gain, offset, delay and integration - common elements in a typical system model), and should for the purpose of this tutorial be considered as a black box.

The Pre block between the controller and the plant can be seen as a model of the slight electrical delay of the control signal as it flows from the controller to the physical system. More importantly, however, it prevents the closed loop from becoming a causality loop, that is, a set of blocks that are connected in a loop with no delay. Causality loops are forbidden in RTflow, because it may be difficult or impossible to compile them into executable code. Since the controller contains data paths without delays, and the physical system is a black box that could potentially also contain data paths without delays, a Pre block must be inserted to ensure that there is a delay in the loop.

As can be seen, the setpoint to the controller is 2. Therefore, if the controller is tuned properly, we can expect that the process value stabilizes at 2 after some time. The goal of this tutorial is to use the simulator in RTflow to tune the controller further, so that process stabilizes more quickly.

Run a simulation

First we will see how the controller performs with the current parameters.