The Modelica language is intended for the modelling and simulation of complex multi-domain systems but can also be used for the classical design and simulation of control systems. This tutorial will use openModelica to demonstrate this by using transfer function models, step responses and PID controllers found in the standard Modelica library. Consider the system represented by the following transfer function:
The components need would be the transfer function block (for the plant), the feedback summation and the step response source. The locations of these are shown in the menu breakdowns shown in figure 2 below.
Drag and drop the points to make the connections then double click the components to change the parameters. In this case we change the parameters of the transfer function to match the plant and leave everything else at default. You can right click the transfer function and change its attributes to make it say “plant” instead of “tranferfuntion1”.
The parameter window for the plant is shown in figure 3 below.
We now setup the simulation to have an end time of 0.05 seconds, then run it.
Now we go to the plotting window and the select the ‘y’ variable of our plant, which represents it’s output. This is the closed loop step response and is shown below.
Now we can add the controller. This is a PID controller and can be added from the same menu as the transfer function. We insert the controller in the loop as shown in figure 6.
The PID controller is represented in the standard form and the parameters we will use are Kp = 0.309, Ti = (0.309/4.5) and Td = (0.0006/0.309), these were already determined from tuning. The step response of this new system is then:
With this basic setup you can experiment with different plants and different controller parameters and definitely different control laws.
Don’t forget to share with interested friends and colleagues and to support our sponsors. Happy coding 🙂
This simulation uses the Modelica modeling language to model two identical tanks connect together by a pipe. The platform used is OpenModelica and the components are from an ‘under development’ library that aims to be a simpler to use alternative to the modelica fluid library.
The tanks are 25 m high and have a radius of 2 m, the pipe is 5 m long and has a radius of 2.5 cm. The OpenModelica diagram of this system is sown in figure 1 below.
Figure 1: Two Tank System in OpenModelica Continue reading
This presentation outlines solving second order differential equations (ode) with python. The solution is obtained numerically using the python scipy ode engine (integrate module), the solution is therefore not in analytic form but the output is as if the analytic function was computed for each time step. The method is generally applicable to solving a higher order differential equation with python as well.
We will use a series RLC circuit as our ordinary differential equations example. Continue reading