Xcos vs. Simulink® – Continuous time library conversion

In the table below you can find the equivalent between the Simulink® and Xcos blocks for Continuous time library/palette. The block which are not present in both libraries are omitted from the table.

This conversion table can be used in case you need to convert a Simulink® model to an Xcos block diagram model or vice-versa.

Simulink Continuous time library Xcos Continuous time systems palette Xcos block description
DerivativeDerivative DerivativeDerivative The Derivative block approximates the instantaneous derivative of its input with respect to time t. The derivative block has no setting and the initial output for the block is zero.
IntegratorIntegrator IntegrationIntegration This block is an integrator. The output is the integral of the input.
State-spaceState-space Continuous state-space systemContinuous state-space system This block realizes a continuous-time linear state-space system. where x is the vector of state variables, u is the vector of input functions and y is the vector of output variables. The system is defined by the (A, B, C, D) matrices and the initial state X0. The dimensions must be compatible.
Transfer functionTransfer function Continuous transfer functionContinuous transfer function This block realizes a SISO linear system represented by its rational transfer function Numerator/Denominator. The rational function must be proper (denominator degree must be less or equal to numerator degree).
Transport DelayTransport Delay Time delayTime delay The Transport Delay block delays the input by a specified amount of time. It can be used to simulate a time delay. At the start of the simulation, the block outputs the Initial input parameter until the simulation time exceeds the Time delay parameter, when the block begins generating the delayed input. The Time delay parameter must be non-negative.
Variable Transport DelayVariable Transport Delay Variable delayVariable delay The Variable Transport Delay block can be used to simulate a variable time delay between an action and its effect. he block accepts two inputs and one output: the first input is the signal u(t) that passes through the block (data input); the second input is the variable time delay τ(t).

Let’s look at a simple example in which we create a Simulink® block diagram model, simulate it and plot the results. We’ll recreate the equivalent model in Xcos and check if the results are the same.

Simulink® block diagram model

 

Simulink® model - Continuous library blocks

Image: Simulink® model – Continuous library blocks

The purpose of the model is only to use some of the Continuous time Simulink® blocks which have an equivalent in the Xcos palette.

The transfer function is defined as:

\[H(s) = \frac{s+0.1}{2s^2 + 0.5s +1}\]

Writing the coefficients of the transfer function polynomials as arrays, we can use the embedded Matlab function tf2ss() to calculate the A, B, C and D matrices for the state-space model.

num = [1 0.1];
den = [2 0.5 1];
[A,B,C,D] = tf2ss(num,den)

The step input has an amplitude of 1 starting at time equals 1 s. All the other blocks have default parameters. Also, the simulation parameters are set on default values.

By running the Simulink® model above, we get the following plot window:

Simulink® model plot - Continuous library blocks

Image: Simulink® model plot – Continuous library blocks

Xcos block diagram model

We follow the same approach for the Xcos block diagram model. Using equivalent blocks (see table above), we recreate the same functionality of the Simulink model.

Xcos model - Continuous time systems palette blocks

Image: Xcos model – Continuous time systems palette blocks

In order to get the A, B, C and D matrices for the state-space model of the transfer function, we use the embedded Scilab function tf2ss() (which is equivalent with the Matlab one).

s=poly(0,'s');
H=[(s+0.1)/(2*s^2+0.5*s+1)];
Sys=tf2ss(H)
A=Sys(2);
B=Sys(3);
C=Sys(4);
D=Sys(5);

The step function has the same parameters as the Simulink one. All other Xcos blocks have the default parameters , except the Variable delay block which must have the Max delay parameter higher or equal to 3.

After running the Xcos model for 10 s, we get the following graphical window:

Xcos model plot - Continuous time systems palette blocks

Image: Xcos model plot – Continuous time systems palette blocks

As you can see, the outputs of the Xcos block diagram model are identical with the Simulink results. This proves that we can use Xcos as an alternative to Simulink, when we want to simulate and analyze continuous time models.

For any questions, observations and queries regarding this article, use the comment form below.

Don’t forget to Like, Share and Subscribe!

Leave a Reply

Ad Blocker Detected

Dear user, Our website provides free and high quality content by displaying ads to our visitors. Please support us by disabling your Ad blocker for our site. Thank you!

Refresh