10.07.2015 Views

Enginyeria de sistemes i Autom`atica: Pr`actiques 2 i 3 d'aula ...

Enginyeria de sistemes i Autom`atica: Pr`actiques 2 i 3 d'aula ...

Enginyeria de sistemes i Autom`atica: Pr`actiques 2 i 3 d'aula ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Enginyeria</strong> <strong>de</strong> <strong>sistemes</strong> i Automàtica:Pràctiques 2 i 3 d’aula informtica.Josep Vehí, Carles Pous, Inès FerrerFebruary 26, 2004


c○Departament d’Electrònica, Informàtica i Automàticaii


Prefaciadsfvlkuh dh goih fgoifg oadifg ofigiii


In<strong>de</strong>x1 Introducció al Matlab/Simulink. Mo<strong>de</strong>lat <strong>de</strong> <strong>sistemes</strong> dinàmics. 11.1 Objectius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Estudi previ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Gràfica <strong>de</strong> la resposta temporal . . . . . . . . . . . . . . . . . . . . . . . . . 11.4 Generació d’un fitxer.m (script) . . . . . . . . . . . . . . . . . . . . . . . . . 11.5 Operació polinòmica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.6 Mo<strong>de</strong>lització <strong>de</strong> <strong>sistemes</strong> dinàmics amb Matlab . . . . . . . . . . . . . . . . 21.7 Mo<strong>de</strong>lització <strong>de</strong> <strong>sistemes</strong> dinàmics amb Simulink . . . . . . . . . . . . . . . 21.8 Mo<strong>de</strong>lització d’un pèndul invertit . . . . . . . . . . . . . . . . . . . . . . . . 32 Anàlisi <strong>de</strong> <strong>sistemes</strong> <strong>de</strong> control amb Matlab/Simulink 52.1 Objectius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Estudi previ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Anàlisi <strong>de</strong> <strong>sistemes</strong> <strong>de</strong> control amb Matlab . . . . . . . . . . . . . . . . . . . 52.3.1 Resposta transitòria en el domini temporal . . . . . . . . . . . . . . 52.3.2 Resposta transitòria en el domini freqüencial . . . . . . . . . . . . . 72.3.3 Pols i zeros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.4 Treballs a realitzar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4.1 Descripció <strong>de</strong>l sistema . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4.2 Especificacions en domini temporal . . . . . . . . . . . . . . . . . . . 82.4.3 Resposta transitòria en domini temporal . . . . . . . . . . . . . . . . 82.4.4 Simplificació <strong>de</strong>l sistema . . . . . . . . . . . . . . . . . . . . . . . . . 92.4.5 Estabilitat i errors estacionaris . . . . . . . . . . . . . . . . . . . . . 92.4.6 Sistema <strong>de</strong> control pertorbat . . . . . . . . . . . . . . . . . . . . . . 9v


1. INTRODUCCIÓ AL MATLAB/SIMULINK.MODELAT DE SISTEMES DINÀMICS.1.1 Objectius1. Familiaritzar-se amb el Matlab/Simulink.2. Utilitzar les eines que proporciona el Matlab/Simulink per fer operacions algebraiquesi polinòmiques i mo<strong>de</strong>litzar els processos lineals i no lineals.1.2 Estudi previUn cop llegida la prctica contesta a les següents preguntes:• Anota tal com escriuries l’equació y(t) <strong>de</strong> la secció 1.4 dins un script Matlab teninten compte quines operacions són matricials i quines són operacions amb llistes).• Prenent la figura 1.1 <strong>de</strong> l’apartat 1.6, aplica àlgebra <strong>de</strong> blocs i troba la funció <strong>de</strong>transferència <strong>de</strong>manada Y (s)R(s)• De la secció 1.8 preneu el punt 2 i doneu l’expressió <strong>de</strong> les equacions linealitza<strong>de</strong>s quees <strong>de</strong>mana.1.3 Gràfica <strong>de</strong> la resposta temporalDonada l’expressió següent:y (t) = e −0.5t sin ωt on: 0 ≤ t ≤ 10Genereu el vector t en increments <strong>de</strong> 0.1 a través <strong>de</strong> l’operador dos puntos i grafiqueu laresposta y ∼ t per ω = 1 i ω = 10 utilitzant la funció subplot.1.4 Generació d’un fitxer.m (script)Donada l’expressió següent:1


Pràctiques <strong>de</strong> Regulació Automàticay (t) = 10 + 5e −t cos (ωt + 0.5) on: 0 ≤ t ≤ 10Desenvolupeu un fitxer <strong>de</strong> script que dibuixi la resposta temporal <strong>de</strong> y ∼ t en una mateixagràfica pels valors <strong>de</strong> ω = 1,3,10 (rad/s), <strong>de</strong> dues maneres diferents, incloent en la gràficael següent:Títol: y (t) = 10 + 5 exp (−t) ∗ cos (ωt + 0.5)Etiqueta <strong>de</strong> l’eix t: Temps (s)Etiqueta <strong>de</strong> l’eix y: y (t) (rad/s)ReixetaText:ω = 1, ω = 3, ω = 10 (en un lloc aprop <strong>de</strong> la traça corresponent)1.5 Operació polinòmicaDonats els polinomis següents:P 1 (s) = s 3 + 2s 2 + 10 P 2 (s) = s + 11. Obteniu els polinomis A (s) i B (s) tals que:A (s) = P 1 (s) P 2 (s)B (s) = P 1 (s) + P 2 (s)2. Calculeu A (1) i B (0).3. Trobeu els valors <strong>de</strong> s que fan A (s) = 0.1.6 Mo<strong>de</strong>lització <strong>de</strong> <strong>sistemes</strong> dinàmics amb MatlabConsi<strong>de</strong>reu el sistema <strong>de</strong> la Figura 1-1 amb:G (s) =1s 2 + 1.5s + 1G c1 (s) = 10G c2 (s) = 10 sCalculeu la funció <strong>de</strong> transferència Y (s)s + 1per a H (s) = 1 i per a H (s) =R (s) s + 2 , utilitzantles funcions series, paralell, cloop i feedback.1.7 Mo<strong>de</strong>lització <strong>de</strong> <strong>sistemes</strong> dinàmics amb SimulinkConsi<strong>de</strong>ru el sistema <strong>de</strong> la Figura 1-1 amb H (s) = 1. Desenvolupeu un programa ambSimulink per a una entrada r (t) <strong>de</strong> graó unitari i visualitzeu la resposta y (t) ∼ t per0 ≤ t ≤ 10 (temps <strong>de</strong> simulació).2Pràctica 1:Introducció al Matlab/Simulink. Mo<strong>de</strong>lat <strong>de</strong> <strong>sistemes</strong> dinàmics.


Pràctiques <strong>de</strong> Regulació AutomàticaFigura 1-11.8 Mo<strong>de</strong>lització d’un pèndul invertitFigura 1-2La dinàmica <strong>de</strong>l pèndul invertit <strong>de</strong> la Figura 1-2 es <strong>de</strong>scriu per les següents equacionsdiferencials no lineals:(M + m)ẍ + bẋ + ml¨θcosθ − ml ˙θ 2 sinθ = F(I + ml 2 )¨θ + mglsinθ = −mlẍcosθessent:Massa <strong>de</strong>l carro:M = 0.5 KgMassa <strong>de</strong>l pèndul:m = 0.2 KgFricció <strong>de</strong>l carro:b = 0.1 N/m/sLongitud <strong>de</strong>l centre <strong>de</strong> masses <strong>de</strong>l pèndul: l = 0.3 mInèrcia <strong>de</strong>l pèndul: I = 0.006 Kg · m 2Força aplicada al carro:FCoor<strong>de</strong>nada <strong>de</strong> posició <strong>de</strong>l carro: xAngle <strong>de</strong>l pèndul respecte a la vertical: θSecció 1.8: Mo<strong>de</strong>lització d’un pèndul invertit 3


Pràctiques <strong>de</strong> Regulació Automàtica1. Construïu un esquema <strong>de</strong> Simulink que representi les equacions dinàmiques <strong>de</strong>l sistema<strong>de</strong>l pèndul invertit essent la sortida <strong>de</strong>l sistema l’angle θ i l’entrada <strong>de</strong>l sistema la forçaF .2. Feu la linealització <strong>de</strong> les equacions dinàmiques, suposant que θ = π + φ, és a dir queφ representa un angle petit respecte a la posició vertical cap amunt i el punt <strong>de</strong> treballés θ ∗ = π o sigui φ = 0. Així es po<strong>de</strong>n fer les següents aproximacions: cos θ ≃ −1,sin θ = −φ i ˙θ 2 ≃ 0. Obteniu la funció <strong>de</strong> transferència entre F i φ.4Pràctica 1:Introducció al Matlab/Simulink. Mo<strong>de</strong>lat <strong>de</strong> <strong>sistemes</strong> dinàmics.


2. ANÀLISI DE SISTEMES DE CONTROLAMB MATLAB/SIMULINK2.1 Objectius1. Familiaritzar-se amb el Matlab/Simulink.2. Utilitzar les eines que proporciona el Matlab/Simulink per analitzar els <strong>sistemes</strong> linealsen llaç obert i realimentats.2.2 Estudi previUn cop llegida la pràctica contesta les qüestions:• Tot i que existeix la funció step <strong>de</strong> Matlab per donar una entrada graó unitari a unsistema, com utilitzaries la funci lsim per fer el mateix.• Fes l’algorisme ( o diagrama <strong>de</strong> fluxe) <strong>de</strong>ls 2 scripts <strong>de</strong>manats a la secció 2.3.22.3 Anàlisi <strong>de</strong> <strong>sistemes</strong> <strong>de</strong> control amb MatlabConsi<strong>de</strong>reu un sistema <strong>de</strong> control amb una funció <strong>de</strong> transferència i una equació d’estat comla següent:{num (s)·x (t) = Ax (t) + Bu (t)G (s) = ⇐⇒<strong>de</strong>n (s)y (t) = Cx (t) + Du (t)2.3.1 Resposta transitòria en el domini temporal• step5


Pràctiques <strong>de</strong> Regulació AutomàticaObtenir la resposta temporal <strong>de</strong>l sistema a un graó unitari.• impulse>> step(num, <strong>de</strong>n)>> step(A, B, C, D)>> [y, x, t] = step(num, <strong>de</strong>n);>> [y, x, t] = step(A, B, C, D);>> plot(t, y)>> t = t i : δt : t f ;>> [y, x, t] = step(num, <strong>de</strong>n, t);>> [y, x, t] = step(A, B, C, D, iu, t);>> plot(t, y)Obtenir la resposta temporal <strong>de</strong>l sistema a un impuls.• lsim>> impulse(num, <strong>de</strong>n)>> impulse(A, B, C, D)>> [y, x, t] = impulse(num, <strong>de</strong>n);>> [y, x, t] = impulse(A, B, C, D);>> plot(t, y)>> t = t i : δt : t f ;>> [y, x, t] = impulse(num, <strong>de</strong>n, t);>> [y, x, t] = impulse(A, B, C, D, iu, t);>> plot(t, y)Obtenir la resposta temporal <strong>de</strong>l sistema a una entrada donada u(t).• stepfun>> t = t i : δt : t f ;>> u = u(t);>> [y, x] = lsim(num, <strong>de</strong>n, u, t);>> [y, x] = lsim(A, B, C, D, u, t);>> plot(t, y)Crear un graó unitari que tingui una funció temporal tal com:{ 1 per t ≥ t0u(t) =0 per t < t 0>> t = t i : δt : t f ;>> u = stepfun(t, t 0 );Amb l’ús conjunt <strong>de</strong> stepfun i lsim, es pot obtenir la resposta temporal <strong>de</strong>l sistemaa un graó unitari amb qualsevol temps d’inici.6 Pràctica 2: Anàlisi <strong>de</strong> <strong>sistemes</strong> <strong>de</strong> control amb Matlab/Simulink


Pràctiques <strong>de</strong> Regulació Automàtica• dcgainCalcular el guany k <strong>de</strong>l sistema en el régim estable.>> k = dcgain(num, <strong>de</strong>n)>> k = dcgain(A, B, C, D)2.3.2 Resposta transitòria en el domini freqüencial• bo<strong>de</strong>Obtenir el diagrama <strong>de</strong> Bo<strong>de</strong>.>> bo<strong>de</strong>(num, <strong>de</strong>n)>> bo<strong>de</strong>(A, B, C, D)>> [mag, phase, w] = bo<strong>de</strong>(num, <strong>de</strong>n);>> [mag, phase, w] = bo<strong>de</strong>(A, B, C, D);>> w = logspace(N min , N max , punts);>> bo<strong>de</strong>(num, <strong>de</strong>n, w)>> bo<strong>de</strong>(A, B, C, D, iu, w);>> [mag, phase, w] = bo<strong>de</strong>(num, <strong>de</strong>n, w);>> [mag, phase, w] = bo<strong>de</strong>(A, B, C, D, iu, w);>> w = freqint(num, <strong>de</strong>n, punts);>> bo<strong>de</strong>(num, <strong>de</strong>n, w)>> [mag, phase, w] = bo<strong>de</strong>(num, <strong>de</strong>n, w);>> w = freqint(A, B, C, D, iu, punts);>> bo<strong>de</strong>(A, B, C, D, iu, w);>> [mag, phase, w] = bo<strong>de</strong>(A, B, C, D, iu, w);2.3.3 Pols i zeros• pzmapObtenir la localizació <strong>de</strong>ls pols i zeros gràficament i els seus valors corresponents.>> pzmap(num, <strong>de</strong>n)>> pzmap(A, B, C, D)>> [p, z] = pzmap(num, <strong>de</strong>n);>> [p, z] = pzmap(A, B, C, D);Secció 2.3: Anàlisi <strong>de</strong> <strong>sistemes</strong> <strong>de</strong> control amb Matlab 7


Pràctiques <strong>de</strong> Regulació Automàticagraó unitari, rampa i parabola per 0 ≤ t ≤ 10. Representeu les respostes <strong>de</strong> y ∼ t perk = 0.1,1,10 i poseu títol, etiqueta i text a cada figura.2.4.4 Simplificació <strong>de</strong>l sistemaConsi<strong>de</strong>reu un sistema amb funció <strong>de</strong> transferència:G o (s) =1(s + 20) (s 2 + 0.5s + 1)1. Representeu gràficament la localització <strong>de</strong>ls pols i zeros <strong>de</strong> G o (s) i <strong>de</strong>termineu si existeixla dominació d’uns pols respecte als altres. Valoreu la possibilitat <strong>de</strong> reduir l’ordre<strong>de</strong>l sistema i obteniu la funció <strong>de</strong> transferència d’ordre reduit G r (s). Representeu enuna figura les respostes temporals <strong>de</strong>ls <strong>sistemes</strong> original G o (s) i reduit G r (s) a ungraó unitari i compareu els resultats.2. Representeu en una figura els diagrames <strong>de</strong> Bo<strong>de</strong> <strong>de</strong>ls <strong>sistemes</strong> original G o (s) i reduitG r (s) pel rang <strong>de</strong> freqüència [ 10 −2 , 10 2] i indiqueu en quin rang <strong>de</strong> freqüència ésvàlida la simplificació <strong>de</strong>l sistema.2.4.5 Estabilitat i errors estacionarisConsi<strong>de</strong>reu el sistema <strong>de</strong> control <strong>de</strong> la Figura 2-1 sense pertorbació (D (s) = 0) amb:C (s) = k sG (s) =1(s + 20) (s 2 + 0.5s + 1)1. Creeu un programa iteratiu <strong>de</strong> tipus script, amb el guany k <strong>de</strong>l controlador com avariable, per comprovar l’estabilitat <strong>de</strong>l sistema en llaç tancat mitjançant el criteri<strong>de</strong> Rouht-Hurwitz i <strong>de</strong>termieu el límit k lim a partir <strong>de</strong>l qual el sistema realimentatresulta inestable.2. Amb tres guanys diferents k que generin respostes temporals estables, calculeu elserrors <strong>de</strong> posició, velocitat i acceleració, <strong>de</strong>termineu el tipus <strong>de</strong>l sistema i comenteula influència <strong>de</strong> k als errors estacionaris.2.4.6 Sistema <strong>de</strong> control pertorbatConsi<strong>de</strong>reu el sistema <strong>de</strong> control <strong>de</strong> la Figura 2-1 amb:G (s) =1(s + 20) (s 2 + 0.5s + 1)Secció 2.4: Treballs a realitzar 9


Pràctiques <strong>de</strong> Regulació Automàtica1. Quan s’utilitza un controlador P amb C (s) = 10, obteniu amb Matlab la resposta<strong>de</strong>l sistema y ∼ t a una consigna graó unitari amb temps d’inici t 0 = 1 s. i auna pertorbació graó unitari amb temps d’inici t 0 = 5 s. S’estabilitza la resposta <strong>de</strong>lsistema a y = 1? Doneu explicacions sobre els resultats obtinguts utilitzant el teorema<strong>de</strong>l valor final.2. Repetiu els treballs anteriors y creeu un programa amb Simulink per comprobar elresultat que s’obté quan s’utilitza un controldor PI amb C (s) = 10 + 5 s .10 Pràctica 2: Anàlisi <strong>de</strong> <strong>sistemes</strong> <strong>de</strong> control amb Matlab/Simulink

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!