Control System Toolbox in Scilab
Control System Toolbox in Scilab
Level
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
www.openeering.com
Step 1: LTI systems
Linear Time Invariant (LTI) systems are a particular class of systems
characterized by the following features:
Thanks to these properties, in the time domain, we have that any LTI
system can be characterized entirely by a single function which is the
response to the system’s impulse. The system’s output is the
convolution of the input with the system's impulse response.
The same results are true for discrete time linear shift-invariant
systems which signals are discrete-time samples.
Transfer function representation; A typical representation of a system with its input and output ports and
its internal state
Zero-pole representation.
Input signal: ;
Resistor: ;
// Problem function
function zdot=RLCsystem(t, y)
z1 = y(1); z2 = y(2);
// Compute input
Vin = A*sin(2*%pi*f*t);
zdot(1) = z2; zdot(2) = (Vin - z1 - L*z2/R) /(L*C);
endfunction
// Plotting results
Vin = A*sin(2*%pi*f*t)';
scf(1); clf(1); plot(t,[Vin,y(1,:)']); legend(["Vin";"Vout"]);
(Numerical solution code)
On the right we report a plot of the solution for the following values of the
constants:
[V];
[Hz];
[Ohm];
[H];
[F];
(Simulation results)
The idea is to start assembling the differential part of the diagram as:
and
and then to complete the scheme taking into consideration the relations
(Kirchhoff’s laws) and with . (Simulation diagram)
The simulation results are stored in the Scilab mlist variable "results"
and plotted using the command
(Simulation results)
// Plotting data
plot(results.time,results.values)
(Simulation diagram)
which relates the second derivative of the to the other variables.
(Simulation results)
where is the state vector (a collection of all internal variables that are
used to describe the dynamic of the system) of dimension , is the
output vector of dimension associated to observation and is the input
vector of dimension .
Here, the first equation represents the state updating equations while the State space representation
second one relates the system output to the state variables.
In many engineering problem the matrix is the null matrix, and hence
the output equation reduces to , which is a weight combination of
the state variables.
The diagram representation is reported on the right using the Xcos block:
which can directly manage the matrices "A", "B", "C" and "D".
(Simulation results)
For example, starting from the differential equation of the RLC example,
that is:
which the user can specify the numerator and denominator of the transfer (Simulation diagram)
functions in term of the variable "s".
(Input mask)
(Simulation results)
(Simulation diagram)
where is the gain constant and and are, respectively, the zeros of
the numerator and poles of the denominator of the transfer function.
This representation has the advantage to explicit the zeros and poles of
the transfer function and so the performance of the dynamic system.
(Input mask)
with
(Simulation results)
in an easy way. Before that, it is necessary to review some notes about // Create a polynomial by its coefficient
polynomial representation in Scilab. p = poly([-2 1 1],'s','c')
The main Scilab commands for managing polynomials are: // Evaluate a polynomial
res = horner(p,1.0)
%s: A Scilab variable used to define polynomials;
// Some operation on polynomial, sum, product and find zeros
q = p+2
poly: to create a polynomial starting from its roots or its r = p*q
coefficients; rzer = roots(r)
coeff: to extract the coefficient of the polynomial; // Symbolic substitution and check
pp = horner(q,p)
res = pp -p-p^2
horner: to evaluate a polynomial; typeof(res)
// Transformation
T = [1 0; 1 1];
sl2 = ss2ss(sl,T)
In Scilab it is possible to move from the state-space representation to the
// Canonical form
transfer function using the command ss2tf. The vice versa is possible [Ac,Bc,U,ind]=canon(A,B)
using the command tf2ss.
// zero-poles
In the reported code (right), we use the "tf2ss" function to go back to the [hm]=trfmod(h)
The Scilab command ss2ss transforms the system through the use of a
change matrix , while the command canon generates a transformation
of the system such that the matrix "A" is on the Jordan form.
The zeros and the poles of the transfer function can be display using the
(Output of the command trfmod)
command trfmod.
(Bode diagram)
(Nyquist diagram)
(step response)
(Bode diagram)
Use the following values for the simulations:
[Ohm];
[F];
[Ohm];
[F].
(Nyquist diagram)
www.openeering.com. --------------
Main directory
--------------
ex1.sce : Exercise 1
Thanks for the bug report: Konrad Kmieciak. numsol.sce : Numerical solution of RLC example
poly_example.sce : Polynomial in Scilab
RLC_Xcos.xcos : RLC in standard Xcos
RLC_Xcos_ABCD.xcos : RLC in ABCD formulation
RLC_Xcos_eq.xcos : Another formulation of RLC in Xcos
RLC_Xcos_tf.xcos : RLC in transfer function form.
RLC_Xcos_zp.xcos : RLC in zeros-poles form.
system_analysis.sce : RLC example system analysis
license.txt : The license file
Manolo Venturin