This repository provides sample FMUs exported from the Beckhoff TwinCAT TE1421 Simulation Runtime for FMI. These FMUs (PneumaticCylinderController2.fmu for FMI 2 and PneumaticCylinderController3.fmu for FMI 3) contain a preconfigured TwinCAT UserMode Runtime for controlling a pneumatic cylinder model (PneumaticCylinderModel2.fmu for FMI 2 and PneumaticCylinderModel3.fmu for FMI 3) in a SiL-Simulation. In addition to the FMUs, this repository also provides the TwinCAT project with the control algorithm.
The pneumatic cylinder model and the control algorithm is documented below. Further documentation on the required TwinCAT installation and on how to use the TE1421 is available at Beckhoff InfoSys.
All provided FMUs support FMI 2/3 and implement both interface types (Co-Simulation and Model-Exchange). The FMUs are distributed as binary FMUs for 64-Bit Windows only.
- fmpy
- Dymola
- MapleSim
- OpenModelica
- Simulink®
Further documentation on the Beckhoff TwinCAT TE1420 Target for FMI is available at Beckhoff InfoSys.
The TwinCAT FMU import requires source code FMUs, it supports FMI 2/3 and both interface types (Co-Simulation and Model-Exchange).
- Dymola
- MapleSim
- Reference FMUs
- Simulink®
Using the example of a single-acting pneumatic cylinder and the associated position controller, a real-world SiL simulation scenario is elaborated below. The cylinder is modeled using the momentum conservation and the ideal gas law. The controller is derived using the method of exact state linearization.
The pneumatic cylinder to be modeled is a so-called single-acting cylinder, i.e. the cylinder is pressurized with air from one side only and returned to its home position by spring force. To simplify matters, the system is modeled without a valve. The physical model of the pneumatic cylinder is shown in the following figure.
In this image,
The momentum conservation theorem yields the following formula for the piston movement
Here,
Assuming an isothermal change of state, this formula can be rewritten as follows.
This equation can be used to derive a differential equation for the air pressure in the pneumatic cylinder. Derivation of the ideal gas equation (for the case of isothermal change of state) with respect to time yields
With
The differential equation system describing the overall system is therefore denoted by the following formula.
The piston position
The system is singular in
Parameter | Value | Unit | Description |
---|---|---|---|
Piston mass | |||
Spring stiffness | |||
Piston area | |||
Initial position of the piston | |||
Lower piston position limit | |||
Upper piston position limit | |||
Initial piston speed | |||
Initial cylinder air pressure | |||
Lower cylinder air pressure limit | |||
Upper cylinder air pressure limit |
It is recommended to use an Euler integrator with a step size of
Position control is a common requirement for a linear actuator. A PI controller is commonly used for this task. However, due to the non-linear air pressure dynamic, it is reasonable to expect that such a linear controller design will not provide a particularly high control bandwidth. A better approach is to take the non-linearity into account when designing the controller. A controller design method considering these non-linearities is the so-called exact state linearization.
First, the differential order
Here,
The system is then denoted by the equation system bellow.
The following control law is used for mathematical compensation of the non-linearity.
The state linearized system has a new virtual input
In the state controller equation,
The closed control loop dynamic is a low pass of order three and can be denoted by the transfer function below.
For calculating the controller gains and the reference gain, the closed control loop dynamic is required to have a triple real eigenvalue in
Using this requirement then yields the controller parameters as follows.
The resulting control loop is stable and steady-state accurate.
Copyright © Beckhoff 2024. All rights reserved. The models and accompanying materials may only be used for testing and validation of FMI implementations.