## Modelica_LinearSystems2.Controller.Examples

Demonstrate the usage of package Controller

### Information

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

### Package Content

Name | Description
--- | ---
FirstExample | First example to demonstrate representative block
SimpleControlledDrive | Simple P-PI cascade controller to control a flexible drive
Discretization1 | Demonstrates the discretization methods
Discretization2 | Demonstrates the discretization method for impuls exact discretization
DiscretizationSeries | Demonstrates the discretization methods for a series connection
Interpolator | Demonstrate usage of Interpolator
DoublePendulum | Crane trolley controlled by a state feedback controller
InverseDoublePendulum | Controlled inverse double pendulum
InverseDoublePendulumWithObserver | Example of controlled inverse doubel pendulum
MixingUnit | Example of system control with inverse model in a controller with two degrees of freedom
Components | Contains components of the systems used in Examples package

## Modelica_LinearSystems2.Controller.Examples.FirstExample

First example to demonstrate representative block

### Information

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

Name | Description
--- | ---
w |
D |

## Modelica_LinearSystems2.Controller.Examples.SimpleControlledDrive

Simple P-PI cascade controller to control a flexible drive

### Information

This example demonstrates the control of a simple model of a flexible drive system with a continuous or discrete P-PI cascade controller. Simulate for 3 s and plot

      ramp.y          (reference angle of loadInertia)
      loadInertia.phi (angle of loadInertia)
      loadInertia.w   (speed of loadInertia)
      torque.tau      (motor torque)

The standard setting in component sampleClock models a continuous controller. This means that all 3 samplers are just dummy components containing the equation "y=u" and that the PI component in the controller is a continuous PI controller.

Change sampleClock.blockType to "Discrete" block. By this global setting, the 3 sampler blocks and the PI speed controller are transformed into a discrete representation. The base sample time is defined in component sampleClock (= 0.02 s). Every discrete component samples its input and output. The sampling time of every component is a multiple of the base sample time (defined via parameter sampleFactor). Here, the sampler and the PI speed controller are sampled with the base sample frequency. The sample time of the 2 samplers and of the P position controller is a factor of 5 slower.

When comparing the simulations of the continuous and the (more realistic) discrete representation, it turns out that the discrete control systems works a bit worse. This can be improved by reducing the sample time in sampleClock.

The Controller library has several blocks to model this system even more realistically, e.g, by component AD converter to model the quantization errors of the analog measurement signals, component DA converter to model the quantization errors and computing time to determine the analog actuator (torque) signal, and component Noise to add uniformly distributed noise to the measurement signals.

In the following figure simulation results of the discrete and of the continuous controller are shown:

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

Name | Description
--- | ---
kp | Gain of P position controller
kv | Gain of PI speed controller
Tv | Time constant of PI speed controller [s]

## Modelica_LinearSystems2.Controller.Examples.Discretization1

Demonstrates the discretization methods

### Information

Demonstrates the different discretization methods by simulating the step response of a second order system as continuous system and as discrete system with the supported discretization methods. The step starts with an offset at 0.1 s to demonstrate the steady-state initialization.

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

Name | Description
--- | ---
w |
D |

## Modelica_LinearSystems2.Controller.Examples.Discretization2

Demonstrates the discretization method for impuls exact discretization

### Information

Demonstrates the different discretization methods by simulating the step response of a second order system as continuous system and as discrete system with the supported discretization methods. The step starts with an offset at 0.1 s to demonstrate the steady-state initialization.

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

Name | Description
--- | ---
w |
D |

## Modelica_LinearSystems2.Controller.Examples.DiscretizationSeries

Demonstrates the discretization methods for a series connection

### Information

Demonstrates the different discretization methods by simulating the step response of a second order system as continuous system and as discrete system with the supported discretization methods. The step starts with an offset at 0.1 s to demonstrate the steady-state initialization.

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

Name | Description
--- | ---
blockType | Type of Sampled blocks (Continuous or Discrete)
sampleTime | Base sample time for discrete blocks [s]
T1 | [s]
T2 | [s]

## Modelica_LinearSystems2.Controller.Examples.Interpolator

Demonstrate usage of Interpolator

### Information

This example demonstrates the usage of the Interpolator block. This block is used in multi-rate controllers to interpolate between two different sample rates. In this example, a sampled sine-signal is interpolated in different ways:

1. A "sine" signal (= blue and red curve in the figure below) is sampled with 20*Ts (= green curve in the figure below) where Ts is the sample time of 1 ms.
2. This "sine" signal is interpolated with "interpolator1" which has a "continous" blockType. In this case, the interpolator just passes the input signal (y = u) and therefore the signal is identical to the sine signal (therefore the blue and the red curve are the same).
3. The sampled sine signal is interpolated with "interpolator2" to arrive at a sample time of 4*Ts (= violet curve in the figure below). This gives a 20*Ts delay and a sine signal sampled with 4*Ts (instead of 20*Ts).
4. In order to remove frequencies introduced by the interpolation, "interpolator3" additionally filters the linearly interpolated signal with a mean value filter of the same length (= black curve in the figure below). This gives an additional delay (= a total delay of 24*Ts), but results in a filtered interpolation signal.

Extends from Modelica.Icons.Example (Icon for runnable examples).

## Modelica_LinearSystems2.Controller.Examples.DoublePendulum

Crane trolley controlled by a state feedback controller

### Information

This example shows a control system with constant state feedback. The system model of a crane trolles system is taken from [1]. The feedback matrix and the pre filter can be loaded from MATLAB files. By default, this files are generated by call of Modelica_LinearSystems2.Examples.StateSpace.craneController.

References

      [1] Föllinger, O. "Regelungstechnik", Hüthig-Verlag

Extends from Modelica.Icons.Example (Icon for runnable examples), Templates.SimpleStateSpaceControl (Template for simple state feedback controllers with an optional pre-filter).

## Modelica_LinearSystems2.Controller.Examples.InverseDoublePendulum

Controlled inverse double pendulum

### Information

This example shows a control system with constant state feedback. The system model of a crane trolles system is taken from [1]. The feedback matrix and the pre filter can be loaded from MATLAB files. By default, this files are generated by call of Modelica_LinearSystems2.Examples.StateSpace.craneController.

References

      [1] Föllinger, O. "Regelungstechnik", Hüthig-Verlag

Extends from Modelica.Icons.Example (Icon for runnable examples), Controller.Templates.SimpleStateSpaceControl (Template for simple state feedback controllers with an optional pre-filter).

## Modelica_LinearSystems2.Controller.Examples.InverseDoublePendulumWithObserver

Example of controlled inverse doubel pendulum

### Information

This example shows a control system with constant state feedback. The system model of a crane trolles system is taken from [1]. The feedback matrix and the pre filter can be loaded from MATLAB files. By default, this files are generated by call of Modelica_LinearSystems2.Examples.StateSpace.craneController.

References

      [1] Föllinger, O. "Regelungstechnik", Hüthig-Verlag

Extends from Modelica.Icons.Example (Icon for runnable examples), Templates.SimpleObserverStateSpaceControl (Represents the structure of a simple state feedback controller with observer and optional pre filter).

## Modelica_LinearSystems2.Controller.Examples.MixingUnit

Example of system control with inverse model in a controller with two degrees of freedom

### Information

This example demonstrates the usage of the control structure template Modelica_Controller.Templates.TwoDOFinverseModelController2 to control a system by using of a inverse system model in the forward path.
The controlled system is a mixing unit described in [1].

References

      [1] Föllinger O., "Nichtlineare Regelungen I",
          Oldenbourg Verlag, 8. Auflage.

Extends from Modelica.Icons.Example (Icon for runnable examples), Templates.TwoDOFinverseModelController (Template of a controller with two structural degrees of freedom and an inverse plant model in forward path).

### Parameters

Name | Description
--- | ---
l | number of measurable outputs
additionalMeasurableOutputs |
x10 |
x10_inv |
x20 |
u0 |
freq | Critical frequency of filter [Hz]