Closing the Control Loop

Firstly, start PyMoskito from the commandline and reapply the previous steps:

  • select PendulumModel as Model
  • change the initial state of PendulumModel to [0, 100, 0, 0]
  • select ODEInt as Solver
  • change the end time of Solver to 10
  • select AdditiveMixer as ModelMixer

Now, it gets interesting, select:

  • the new BasicController as Controller
  • change Input A of ModelMixer to Controller and
  • select Setpoint as Trajectory

to generate desired values for out new setup. The setpoint 0 demands that the cart position (the output defined by our model) should be kept at zero.

To enter string values, type 'Controller' or "Controller" and remember to press enter to confirm the input.

The Properties window should now look like Fig. 6

Properties with Changes

Fig. 6 The properties window with changes for testing applied

Now, hit F5 to run the simulation. After simulating, you find a few more diagrams in the data section. Fig. 7 shows the example of the control error.

Interface with Control Error

Fig. 7 PyMoskito’s interface with the control error diagram displayed

Feel free to experiment with the settings and see, if the control loop reacts the way you would have predicted. Keep in mind that the implemented controller is static. The control law does not adapt to changes of the model parameters, since the controller gain is calculated from values stored in the controller class. You can use this effect to simulate the situation, where the controller design was based on model parameters that differ from the real parameters of the process.

These were all the fundamental functions of PyMoskito considered necessary to work with it. One more important, but also more advanced feature is the system’s visualization in 2D or 3D. This animation appears in the window at the top right, which remained grey during this tutorial (see Fig. 3, Fig. 5, Fig. 7). For more information on this topic, see the lesson on visualization.