Basic Scicoslab and Scicos
Total Page:16
File Type:pdf, Size:1020Kb
Florence University, October 2010 Basic ScicosLab and Scicos ScicosLab/Scicos for dummies like us Simone Mannori – ScicosLab/Scicos developer 1 Florence University, October 2010 Basic ScicosLab and Scicos Digital control systems design and simulation: the Bermuda Triangle for engineers Computer science Control systems Physics Simone Mannori – ScicosLab/Scicos developer 2 Florence University, October 2010 Basic ScicosLab and Scicos What ScicosLab is? An interpreted language (“Scilab Language”, very similar _but_not_equal_ to Matlab) Full support for matrix computation (BLAS, LAPACK, single and multi cores support using ACML now, GPU support in the near future using OpenCL). Basic programming (just like Matlab) GUI development (using TCL/TK and UICONTROL) Linear algebra Polynomial calculation Control systems modelling and design (continuous, discrete and hybrid systems) Robust control toolbox Optimization and simulation (build-in solvers) Signal processing (filters design, etc.) ARMA modelling and simulation Basic statistics Basic identification PVM support TCL/TK and Java support Max-plus algebra toolbox Simone Mannori – ScicosLab/Scicos developer 3 Florence University, October 2010 Basic ScicosLab and Scicos What you can do with ScicosLab? • Interact with the command line • Write a program, one line at time, using the internal or with an external editor • Run the program in an user friendly interpreted environment (easy debug) • Use the rich embedded library. • You can develop your ScicosLab functions using C, Fortran, Java, etc. • Produce nice graphics diagrams. Simone Mannori – ScicosLab/Scicos developer 4 Florence University, October 2010 Basic ScicosLab and Scicos What Scicos is? Scicos is a graphical dynamical system modeller and simulator developed inside the METALAU project at INRIA, Paris Rocquencourt centre. Scicos is a graphics, object oriented tool where the user create block diagrams to model and simulate the dynamics (time domain) of hybrid dynamical systems and compile models into executable code (code generation for simulation and embedded applications). Scicos is used for signal processing, systems control, queuing systems, and to study physical and biological systems. New extensions allow generation of component based modelling of electrical and hydraulic circuits using the Modelica language. Simone Mannori – ScicosLab/Scicos developer 5 Florence University, October 2010 Basic ScicosLab and Scicos What you can do with Scicos? Graphically model, compile, and simulate dynamical systems Combine continuous and discrete-time behaviours in the same model Select model elements from “Palettes” of standard blocks Program new blocks in C, Fortran, or Scilab Language Run simulations in batch mode from ScicosLab command line Generate C code from Scicos model using the built in Code Generator Generate C/C++ libraries ready to be integrated in Kepler using FC2K Run simulations in real time with and real devices using Scicos-HIL Generate hard real-time control executables with Scicos-RTAI, Scicos-FLEX and Scicos-ITM code generators. Use implicit blocks developed in the Modelica language. Discover new Scicos capability using additional toolboxes like RTSS, Scicos-HDL, Coselica, etc. Simone Mannori – ScicosLab/Scicos developer 6 Florence University, October 2010 ScicosLab Basic ScicosLab and Scicos Simone Mannori – ScicosLab/Scicos developer 7 Florence University, October 2010 Basic ScicosLab and Scicos Modelling of complex dynamical systems ScicosLab and Scicos are designed to handle explicit (ODE, Ordinary Differential Equation) or implicit (IDA, Implicit Differential Algebraic equation) differential equation problem (in the continuous domain) and difference equation (in the discrete domain). ScicosLab and Scicos can handle also partial differential equation (PDE) and finite element problem, but the user must develop some code to implement features like meshing (not built in ScicosLab). Simone Mannori – ScicosLab/Scicos developer 8 Florence University, October 2010 Basic ScicosLab and Scicos Continuous systems Linear controller for a floating apple. Simone Mannori – ScicosLab/Scicos developer 9 Florence University, October 2010 Basic ScicosLab and Scicos Discrete systems Same diagram, but realized with (time) discrete blocks. Simone Mannori – ScicosLab/Scicos developer 10 Florence University, October 2010 Basic ScicosLab and Scicos Hybrid systems Welcome to the Real World: continuous system, discrete controller. Simone Mannori – ScicosLab/Scicos developer 11 Florence University, October 2010 Basic ScicosLab and Scicos Implicit model: an easy example. Consider the basic LR circuits show below. You would like to control the current “i(t)” that flows inside the inductance using “vu(t)” (the voltage source that drive the coil). “lr_cc_modelica_r1.cos” Simone Mannori – ScicosLab/Scicos developer 12 Florence University, October 2010 Basic ScicosLab and Scicos Basic modelling The equations are: d v t =R⋅it t u dt =L⋅i d d d v t=R⋅itL it it Lt v t=R⋅itL it u dt dt u dt N 2 A = = d L=⋅K⋅ <material> K f l Nagaoka l Simone Mannori – ScicosLab/Scicos developer 13 Florence University, October 2010 Basic ScicosLab and Scicos Root locus and Bode plots with ScicosLab Simone Mannori – ScicosLab/Scicos developer 14 Florence University, October 2010 Basic ScicosLab and Scicos Root locus and Bode plots with ScicosLab PLANT PLANT + CONTROLLER Simone Mannori – ScicosLab/Scicos developer 15 Florence University, October 2010 Basic ScicosLab and Scicos Why do you need control systems? Control technology was born in order to improve the performances of the “PLANT”, e.g. the system that makes the work. Examples: - furnace (temperature control) - audio amplifier (distortion, bandwidth) - motion control (precision, speed) - AAA (Anti Aircraft Artillery) - Flight control (efficiency, comfort, performances) - Combustion engine (efficiency, emission's reduction) Simone Mannori – ScicosLab/Scicos developer 16 Florence University, October 2010 Basic ScicosLab and Scicos Continuous systems Simone Mannori – ScicosLab/Scicos developer 17 Florence University, October 2010 Basic ScicosLab and Scicos Linear, continuous and time invariant systems Continuous: all the internal and external signals are “proper” time functions. They are unequivocally defined for all values of “t”. Linear: if u1, u2 are two inputs and y1 and y2 are the two corresponding outputs, the input u = u1 + u2, produces the output y = y1+ y2 Time invariant: the response of the systems does not vary in time (system parameters are time invariant, no “ageing effect”). LTI continuous systems: the Paradise Simone Mannori – ScicosLab/Scicos developer 18 Florence University, October 2010 Basic ScicosLab and Scicos Control system means feedback NO FEEDBACK : open loop system Input Output PLANT Simone Mannori – ScicosLab/Scicos developer 19 Florence University, October 2010 Basic ScicosLab and Scicos Control system means feedback: standard config. Input Output Controller in the PLANT “feedback” path Controller Controller in the “direct” path Error Output Input Controller PLANT Simone Mannori – ScicosLab/Scicos developer 20 Florence University, October 2010 Basic ScicosLab and Scicos Example of feedback system: the floating apple I have an apple at y(0)=y0=1.0m. At t=0 I drop the apple, and the apple falls down. I'm not satisfied: I'd like to see the apple floating at a reference height (ref=0.5m). I need a controller to implement a closed loop feedback system. To design a controller you need: - a theory : Newton's gravity law - a model of the “PLANT” Simone Mannori – ScicosLab/Scicos developer 21 Florence University, October 2010 Basic ScicosLab and Scicos Open Loop “PLANT” model The “PLANT” : a free falling apple m m F=G a T r2 F = mT =− / 2 F=m a a= a G ; g 9.81m s m a r2 = ∫ = ∫ v t v0 a t dt y t y0 v t dt 1 yt= y g t 2 0 2 Simone Mannori – ScicosLab/Scicos developer 22 Florence University, October 2010 Basic ScicosLab and Scicos Open loop PLANT model: Scicos simulation = ∫ v t v0 a t dt = ∫ y t y0 v t dt Open loop simulation of the free falling apple. “apple_ff_01.cos” Simone Mannori – ScicosLab/Scicos developer 23 Florence University, October 2010 Basic ScicosLab and Scicos Example: the floating apple First “instinctive” trial-and-error controller (P only) This controller does not work. “apple_c_01.cos” Simone Mannori – ScicosLab/Scicos developer 24 Florence University, October 2010 Basic ScicosLab and Scicos Example: the floating apple Hint: you need to introduce an additional term producing “artificial friction”. It works ! “apple_c_02.cos” Simone Mannori – ScicosLab/Scicos developer 25 Florence University, October 2010 Basic ScicosLab and Scicos Example: the floating apple Conclusions and observations: “intuitive” design (no theory) may produce catastrophic results The ubiquitous PID controller may be able to solve most of the common situations. Not every PLANT can be stabilized using a simple PID In order to design a suitable controller we need a specific theory Simone Mannori – ScicosLab/Scicos developer 26 Florence University, October 2010 Basic ScicosLab and Scicos Basic tool for continuous system: the Laplace transform Solving with “paper and pencil” differential equations is too difficult: we need a better tool. Laplace transform a differential equation problem in a polynomial problem F(s) is a complex function of complex variable Simone Mannori – ScicosLab/Scicos developer 27 Florence University, October 2010 Basic ScicosLab and Scicos