ESCUELA POLITÉCNICA NACIONAL FACULTAD DE INGENIERÍA ELÉCTRICA ALTERNATIVAS PARA CONTROL Ite DE PLANTAS NO LINEALES" (Anexos) ISMAEL ALEJANDRO MOGROVEJO CÁRDENAS V TESIS PREVIA A LA OBTENCIÓN DEL TÍTULO DE INGENIERO EN ELECTRÓNICA Y CONTROL A. MANUAL DE USUARIO ALTERSIM ALTERSIM MANUAL DE USUARIO A.1 REQUERIMIENTOS DEL SISTEMA Los requerimientos mínimos del sistema para utilizar el programa ALTERSIM son los siguientes: • Microsoft Windows 3. 1 . • Microprocesador 486. • Orive para diskette de 3%". • Ratón. • 10 MB de espacio libre en e! disco duro. • 8 MB de memoria extendida A.2 EMPEZANDO A TRABAJAR CON AL TERSIM Para iniciar la sesión de trabajo con ALTERSIM es preciso ingresar al programa MATLAB y, una vez dentro de su espacio de trabajo, cambiarse al directorio ALTER. Esta carpeta deberá estar cargada previamente en el directorio USUARIOS, dentro del subdirectorio TESIS_JM. El cambio se realiza utilizando el siguiente path: USUARIOS / TESISJM / ALTER. Una vez dentro del directorio en cuestión es preciso digitar el comando aiter, el cual despliega en la pantalla la presentación del programa y a continuación el cuadro indicado en la figura 1 que corresponde al menú de inicio. fíg. 1. Menú cíe inicio A.3 SIMULACIÓN DE PLANTAS NO LINEALES Con ayuda de! ratón se selecciona alguna de las posibilidades presentadas por este menú. Al escoger la opción Simulación de plantas no lineales aparece en la pantalla el cuadro que se presenta en la figura 2, Fig. 2. Menú de Plantas Este cuadro corresponde ai menú de las plantas a simular. Aquí se presenta al usuario los diferentes sistemas no lineales en estudio. Tanto el modelo del sistema de nivel de líquidos como aquel del sistema térmico han sido linearizados, así que al escoger cualquiera de estas opciones en el menú de plantas, aparece en la pantalla del computador el denominado menú de modelos que se muestra en la figura 3. Aquí es posible escoger entre el modelo no lineal o el modelo linearizado del sistema así como realizar una comparación entre ellos. Fíg. 3, Menú de Modefos A! escoger cualquiera de las 3 opciones presentadas por ei menú de modelos en los sistemas de nivel y térmico, o al escoger la opción Servomecanismo en el menú de plantas, el programa ALTERSIM despliega en la pantalla un tercer cuadro que se encuentra en la figura 4. En este cuadro, que se denomina menú de respuestas, se puede escoger entre observar la respuesta temporal del sistema o su característica estática. Fig. 4. Menú de respuestas AI seleccionar, utilizando el ratón, cualquiera de los iconos que presenta el menú de respuestas, se presenta una gráfica inicial que corresponde a datos del sistema tales como voltajes de entrada, puntos de operación, tiempos de simulación, etcétera, que el programa ingresa por defecto. El usuario puede posteriormente modificar estos valores utilizando barras o "sliders" que permiten escogerlos de entre un rango determinado. Estas barras aparecen junto con las curvas de respuesta. A.4 SIMULACIÓN DE ESQUEMAS DE CONTROL Regresando al menú de inicio, si ia opción escogida es Esquemas de Control, entonces se despliega en pantalla el cuadro de la figura 5. Este menú que se denomina menú de controles permite al usuario escoger el esquema de control que desee y observar la manera en que éste actúa sobre un sistema específico. Cabe indicar que no todos los esquemas de control fueron aplicados a cada una de las plantas sino que se realizó una selección de controles de acuerdo a las características y condiciones propias de cada sistema. Fig. 5 Menú de Controles A.4.1 CONTROL LINEAL La aplicación de un control lineal a las plantas en estudio es posible a! escoger la opción Lineal dentro del menú de controles de la figura 5. Enseguida se presenta en pantalla ei menú de la figura 6 que corresponde al menú de aplicación de consoladores PID lineales. Fig. 6. Menú de aplicación de consoladores PID lineales. A.4.2 CONTROL NO LINEAL Los tres métodos de control no linea! estudiados en el capítulo 3 han sido implementados en el programa ALTERSIM. La simulación de estos controles empieza al escoger la opción No Lineal del menú de controles de la figura 5, momento en el cual se desplega el menú de la figura 7, denominado menú de controles no lineales. Sr&i*^ atKSM M J •JK&'lS' • Mt W&ií Í1 < W.ü iíJ&i^í'í •/» í Bífetüí'i / 3in-'l*í tfWf'»' ss¿«¿ nH:VS^:?s& ^ F/t?. 7 Menú de Controles no lineales. Los métodos de control no lineal de Autosintonía y de Control de Relé se ejecutan en el modelo de servomecanismo cuando se escoge cualquiera de estas opciones en el menú de la figura 7. Cuando se selecciona Control ONOFF , aparece el menú de la figura 8 que corresponde al Menú de plantas para el control ON-OFF que permite observar el resultado de aplicar este método a tas dos plantas especificadas. Fig. 8 Menú de Plantas para el control ON-OFF A.4.3 PIDADAPT1VO Al escoger la opción Adaptivo de la figura 5 se aplica un control con Pl adaptivo al sistema de nivel de líquidos, el cual posee una rutina de identificación de los parámetros del modelo discreto de la planta y efectúa el cálculo de los parámetros del controlador. A.4.4 ESTIMACIÓN DE LA FUNCIÓN INVERSA La selección de la opción Estimación de la Función Inversa en e! Menú de Controles despliega el Menú de Métodos de la figura 9, el cual permite seleccionar entre dos métodos a simular, el de Estimación de la función inversa propiamente dicho y el Linearízación por realimentación. Fig. 9. Menú de métodos La opción Función inversa despliega una pantalla parecida a la de la figura 8 en donde se permite escoger la aplicación de este método para el sistema de nivel de líquidos y de temperatura. Si dentro del Menú de Métodos se escoge la opción Linearízación por realimentación, entonces aparece en pantalla el menú mostrado en la figura 10 denominado menú de plantas lineaüzadas, el cual permite escoger entre dos plantas a linealizar, e! sistema de nivel de líquidos y el brazo manipulador de robot. Fig 10 Menú de plantas linearízadas B. ARCHIVOS DE PROGRAMA ALTERSIM %MENÚ DE INICIO % Botones de selección function alter cíe labels = s t r 2 m a t ( . . . 'Simulación de plantas no lineales', ... 'Esquemas de control'); callbacks = [ ... 'plantas 'control ' ']; choicesí 'ALTER1 , 'ALTERNATIVAS DE CONTROL PARA PLANTAS NO LINE ALES', labels, callbacks); NOTA: Los archivos correspondientes a los otros menúes desplegados poseen la misma estructura que el presente archivo, asi que no fueron impresos por razones prácticas. %ARCHIVO RESPTEM1.M {RESPUESTA TEMPORAL MODELO NO LINEAL.TANQ UE) %Parámetros del sistema O400; Cfi=l/C; Kv=258; Kb-204; Ks=0.5; Vi=4; : hO-10; ts=100; %Diseño de la pantalla axes( ... 'ünits ', 'normalized', ... 'Position1,[0,1 0.3 0.85 0.6], ... 'Visible','onT); plantal darkgray=[l/3 1/3 1/3]; cerrar='cióse;'; %Barras Vic = uicontrol('style ', T sliderT, 'units ', 'normal','pos' , [.05 . 05 .30 .035], ... Tmin',O, fmax',10, 'val1,Vi, ... 'cali', 'Vi - get(Vic,''valué1'); plantal1); Vict = uicontrol('style', 'text', 'units','normal','pos', [.05 .1 3 .30 .04], ... 'string','Vi = T,'foreT,'white','back', darkgray); Vict = uicontrol{'style', 'text','units T , T normal', 'pos', [.05 .0 9 .30 .04], ... 'string','0 1 2 3 4 5 6 7 8 9 10', 'fore', 'white1 , Tback', darkgray) ; Vi_field=uicontrol('Style', 'edit', 'Position f , [.23 .13 .07 .035 ], .. . 'Units', 'normalized', 'String',num2str(Vi), 'fore r , 'whit e','back',darkgray); tsc = uicontrol('style', 'slider1,'units', 'normal1,'posr , [.40 . 05 .3 .035], ... 'min',100,'max1,500,'val',ts, ... 'cali','ts = get(tsc,''valué1'); plantal'); tsct = uicontrol('style'f 'text', 'units ', 'normal', 'pos', [. 40 .1 3 .3 .04], ... 'string1,'ts = ','fore1r rwhitef,'back1,darkgray); tsct = uicontrol{' style'f 'textf, ' unitsf,'normal'/'pos', [.40 .0 9 .30 .04], ... 'string1,f!00 200 300 400 500T,'foreF,rwhite','back1, dar kgray); ts_field-uicontrol('Style1, 'edit';'Position1, [.58 .13 ,07 .035 i; •- - 1units', 'normalizad', 'String',num2str(ts), 'fore', 'whit e 1 , 'back',darkgray) ; cerrarh = uicontrol('style1 , 'push', 'units', 'normalf, 'pos', [.8 .075 .1 .06], ... 1string', 'cerrar','cali',cerrar); %ARCHIVO PLANTA1.M (MODELO NO LINEAL TANQUE) cía reset darkgray=[l/3 1/3 1/3]; Vi_f ield=uicontrol('Style'r 'edit?, 'Position', [.23 .13 .07 .035 ], ... 'Units','normalizad'f 'String ',num2str(Vi),'fore', 'whit e' f 'back',darkgray); ts_field=uicontrol( 'Style1, 'edit1 , 'Position', [.58 .13 .07 .035 ], . .. 'Units ' , 'normalizad' , ' String ' , num2str (ts) , ' fore ', 'whit e ' f 'back',darkgray); %Cálculo de la respuesta t=[0: .1:99.9] ' ; vt=[t,Kb*Vi*ones(size(t))]; [T,X, Y]=linsim( 'tanque 1 .ts, [] , [] ,vt) ; %Gráfico de la respuesta plot(TfY) title( 'RESPUESTA TEMPORAL AL CAUDAL DE ENTRADA1) xlabel('Tiempo (s)') ylabel('Voltaje de salida del sensor de nivel (V)1) % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style1, 'frame1, 'Units','normalizad', ... 'Position',frmPos, ... 'Backgroundcolor1,[0.50 0.50 0.50]); %ARCHIVO ESTATIC1.M (CURVA ESTÁTICA. TANQUE) clear yl olear xl %Parámetros del sistema C-400; Cfi=l/C; Kv=258; Kb=204; Ks-0.5; Vi-4 ; hO=10; ts=100; %Diseño de la pantalla axes( ... 'Units'r 'normalized', ... 'Position',[0,1 0.3 0.85 0.6], ... 1Visible','on'); darkgray=[l/3 1/3 1/3]; cerrar='cióse;' ; %Cálculo de la curva estática t=[0:.1:99.9]'; for i=0:10 xint=i*ones(size(t}); ut=[t,Kb*i*ones(size(t))]; [tt,xx/yy]=linsim('tanque1/100, [ ] , [ ] , u t ) ; yint^interpl (tt/yy, t, ' spline ' ) ;yl ( : , iH-l)=yint; xl(: , i+1)=xint; end y=yl(1000/:}; x=xl(1000,:); %Gráfico de la curva plot(x,y) title('CURVA ESTÁTICA1) xlabel('Voltaje de entrada a la bomba (V)'} ylabel('Voltaje de salida del sensor de nivel (V) ' ) % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style1,rframe?, ... 1Units','normalized', ... 1Position1,frmPos, ... 'BackgroundColor',[0.50 0.50 0.50]}; %Botón de cerrar cerrarh = uicontrol('style','push','units','normal', 'pos ', [. 45 .075 .1 .06], ... 1 string 1 , 'cerrar','cali',cerrar); %ARCHIVO RESTEML1.M (MODELO LINEAL. TANQUE) %Parámetros del sistema 0=400; Cfi=l/C;Kv=258; Kb=204; Ks=0.5; ts-100; %Diseño de la pantalla axes ( ... ' Units ' , ' normalized ' , ... 'Position', [0.1 0.3 0.85 0.6], ... 'Visible',Ton' ) ; planlinl darkgray=[l/3 1/3 1/3]; cerrar= ' cióse; ' ; %Barras Vic = uicontrol ( ' style ' , ' slider ' , ' units ' , ' normal ' , ' pos ' , 05 .30 .035] , ... 'min' ,0, 'max1 ,10, 'val1 ,Vi, ... 'cali', 'Vi = get (Vic, ' 'valué' '); planlinll ' ) ; Vict = uicontrol ( ' style ' , ' text ' , ' units ' , ' normal ' , ' pos ' , [ 3 .30 .04], .... 'string','Vi = r , ' fore1 , 'white ' , 'back' , darkgray) ; Vict = uicontrol ( ' style ' , ' text ' , ' units ' j ' normal ' , ' pos ' , [ 9 .30 .04] , ... 'string','0 1 2 3 4 5 6 7 8 9 10 ',' fore ', 'white ',' back ', darkgray) ; Vi_f ield-uicontrol ( ' Style ' ,r edit ' , ' Position ' , [ . 2 .13 . 035 ], . .. 'Units ' , 'normalized1 , ' String' , num2str (Vi) , 'fore' , 'whit e ' , ' back ' , darkgray) ; hOc = uicontrol ( ' style ' , ' slider' , 'units r , ' normal ' , 'pos ' , [ . 05 .30 .035], . . . 'min1 , O, 'max' ,30, 'val' ,hO, ... 'cali' , 'hO = get (hOc, ' 'valué' ' ) ; planlinl' ) ; hOct = uicontrol ( ' style ' , ' text ' , ' units ' , ' normal T , ' pos ' , [ . 68 .1 3 .30 . 0 4 ] , . . . 1 string f , T hO = ','fore?, 'white','back', darkgray) ; hOct = uicontrol('style','textT, 'unitsT , 'normal','pos'r [.68 .0 9 .30 .04] , ... 'string','0 05 10 15 20 25 30 ', ffore','white1, 'back', da rkgray); hO_field=uicontrol('Style1, 'edit1, 'Position', [.85 .13 .035 .03 5], ... 'Units ' r 'normalized' ,! String ' ,num2str (hO) , ' f ore ', 'whit e' , 'back',darkgray); tsc = uicontrol('stylef, 'slider', ? units', 'normal', 'pos', [.355 .05 .3 .035], ... 'min' ,100, 'max',500, 'val1,ts, . . . 'call','ts = get{tsc,''valué''); planlinl'); tsct = uicontrol('style1, 'text','units','normal1,'pos', [.355 . 13 .3 .04], ... 1 string', r ts — ', 'fore','whiteT , 'back',darkgray) ; tsct = uicontrol('style', 'text', 'units ', 'normal','pos' , [.355 . 09 .30 .04], ... 'string', '100 200 300 400 500','fore', 'whiter , 'back1, dar kgray); ts_field=uicontrol('Style','edit','Position',[.55 .13 .08 .035 ], . . . 'Units ' , 'normalized'r ' String1 , num2str (ts) , 'fore' , ' whit e 1 f 'back1,darkgray); cerrarh = uicontrol('style', 'push', 'units', 'normal' , 'pos', [.8 .185 .1 .06], ... 1string','cerrar','cali',cerrar); %ARCHIVO PLANLIN1.M (MODELO LINEAL. TANQUE) cía reset Vi_field=uicontrol(lStyle1, 'edit1, 'Position', [.2 .13 .035 .035 ], .- • 'Units T , 'normalized' , 'String' , num2str (Vi) , T f ore ' , ' whit e ' ,! back ' , darkgray) ; hO_field=uicontrol{' Style' , ! edit ' , 'Position', [.85 .13 .07 .035 ], ... 'Units f r 'normalizad1 , f String' , num2str (hO) , ' f ore ' , 'whit e ' , ' back ? , darkgray) ; ts_f ield=uicontrol ( ' Style r , ' edit T , ? Position ' , [ . 55 .13 .08 . 0 ],--. 'Units ' , 'normalized' , 'String1 , num2str (ts) , ' f ore ' , 'whi e f , ' back f f darkgray) ; %Diseño de la pantalla t=[0: .1:99.9] '; vt=[t,Kb*Vi*ones (size(t) } ] ; ^ts, [] , [] ,vt>; %Gráfico de la respuesta plot (T,Y1) titleí 'RESPUESTA TEMPORAL AL CAUDAL DE ENTRADA') xlabel ( ' Tiempo ( s ) ' ) ylabel ( 'Voltaje de salida del sensor (V)') darkgray=[l/3 1/3 1/3]; % Marco de fondo frrnPos=[0.03 0.03 0.95 0.15]; h=uicontrol ( ... 'Style1 , 'frame' , ... 'Units ' , ' normalized' , ... 1 Position ' , frmPos, . . . 'BackgroundColor' , [0.50 0.50 0.50]); %ARCHIVO ESTATL1.M (CURVA ESTÁTICA MODELO LINEAL. TANQUE) %Parámetros del sistema C=400; CfiKL/C; Kv=258; Kb=204; Ks=0.5; Vi=4;' hO=10; ts=100;%Diseño de la pantalla axes( ... 'Units','' normalizedr, ... 'Position1,[0.1 0.3 0.85 0.6], ... 'Visible1, 'on') ; statll darkgray=[l/3 1/3 1/3]; cerrar='cióse;r; %Barras hOc = uicontrol('style', 'slider', 'units', 'normal','pos ' , [. 68 . 05 .30 .035], ... 'ruin', O, 'max' ,30, 'val1 ,hO, ... 'cali1, 'hO ** get (hOc, ' 'valué' ' ) ; statll1 ) ; hOct = uicontrol('style', 'text','units'f 'normal','pos',[.68 .1 3 .30 .04], ... 'string', 'hO = ' , 'fore', 'white', 'back', darkgray) ; hOct = uicontrol('style', 'text', T units', 'normal', 'pos', [.68 .0 9 .30 .04], ... 'string1,'O 05 10 15 20 25 30 ', 'fore','white','back', da rkgray); hO_field=uicontrol('Style', 'edit'f 'Position', [.85 .13 .08 .035 ], ... 'Units','normalizad','String1,num2str(hO),'fore'f 'whit e' r 'back',darkgray}; %Botón de cerrar cerrarh = uicontrol{'style', 'push', 'units ' , 'normal' , 'pos', [.45 .075 ..1 .06] , ' string', 'cerrar', 'cali',cerrar); Statll %ARCHIVO STATL1.M (CURVA ESTÁTICA MODELO LINEAL. TANQUE) hO_field=uicontrol('Style', 'edit' , 'Position' , [.85 .13 .08 .035 I r - - - 'Units 1 , 'normalizecT , 'String' r nuru2str (hO) , ' f ore ' , 'whit e' , 'back 1 , darkgray) ; cía reset olear yl olear xl %Cálculo de la respuesta t=[0: .1:99.9] ' ; for i=0:10 xint=i*ones {size (t ) ) ; ut=[t,Kb*i*ones (size(t) ) ] ; [tt,xx, yy]=linsim( ' tanqlin ' , 100, [],[], ut) ; yint=interpl (ttf yy, t, T spline ' ) ;yl ( : , i+l)=yint; xl ( : , i+1 ) =xint ; end y=yl(1000, :) ; x=xl(1000/ : } ; %Gráfico de la respuesta plot (x,yl) titleí 'CARACTERÍSTICA ESTÁTICA MODELO LINEAL') xlabel ( 'Voltaje de entrada a la bomba (V)1) ylabel { 'Voltaje de salida del sensor de nivel (V)' % Marco de fondo frmPos-[0.03 0.03 0.95 0.15]; h=uicontrol ( ... 'Style1 , 'frame' , ... 1 Units ' r ' normalized ' , ... ' Position ' , f rmPos , ... 'BackgroundColor' , [0.50 0.50 0.50]); hOct - uicontrol{'style'f 'text', 'units','normal', 'pos ', [. 68 .1 3 .30 .04], ... ' string','hO — ', 'fore T , 'white',T back T , darkgray); hOct = uicontrol ( ' style ', ' text' , ' units ' , ' normal' 'r ' pos ', [, 68 9 .30 .04], ... 'string1,'O 05 10 15 20 25 30 ','fore','white','back', da rkgray); hO_field=uicontrol('Style',!editf,'Position', [.85 .13 .035 .03 5], ... 'Units!, 'normalized1, 'String1,num2str(hO) , 'fore1, 'whit e' , 'backf,darkgray); tsc = uicontrol('style', 'sliderf, 'units', 'normal1, 'pos', [.355 .05 .3 .035], ... 'ruin',100, 'max' ,500, 'val' ,ts, . . . 1 cali', 'ts — get(tsc, ''valué' '); comptanl'); tsct = uicontrol('style','text','unitsT , 'normal'r 'pos', [.355 . 13 .3 .04], . . , ' string1r fts — ', 'fore', 'white', 'back',darkgray); tsct = uicontrol('style','text1, 'units','normal', 'pos', [ .355 . 09 .30 .04], ... 'string1,'100 200 300 400 500',?fore','white','back', dar kgray); ts_f ield=uicontrol('Style' , 'editT, 'Position', [.55 .13 .08 .035 ], - - 'Units','normalized1,'String',num2str(ts),'fore1,'whit e ' , 'back',darkgray); cerrarh — uicontrol('style', 'push', 'units', 'normal', 'pos', [.8 ,185 .1 .06], ... 1string','cerrar','cali',cerrar); %ARCHIVO COMPTAN1.M (COMPARACIÓN DE MODELOS. TANQUE) cía reset Vi_field=uicontrol('Style','edit','Position 1 , [.2 .13 .07 .035] r - •• 'Units', 'normalizad', 'String',num2str(Vi) , 'fore','whit e','back',darkgray); hO_field=uicontrol ( 'Style' , 'edit1 , 'Position1, [.85 .13 .07 .035 'Units', 'normalized1, 'String',num2str(hO),'fore' , 'whit e','back',darkgray); ts_field=uicontrol('Style', 'edit', 'Position', [.55 .13 .08 .035 'Units','normalized', 'String',num2str (ts),'fore'f 'whit e','back',darkgray); %Cálculo de respuestas t=[0:.1:99.9] '; vt=[t,Kb*Vi*ones(size(t))]; [Tn,Xn,Yn]=linsim( 'tanque' ,ts f [] , [] ,vt) ; vt-[t,Kb^Vi*ones(size(t))]; [Tl,Xl,Yl]-linsim('tanqlin',tsf [], [],vt); %Gráfico de las respuestas plot(Tn,Yn, 'r-'fTlrYll, ' g- ' ) titlef 'RESPUESTA TEMPORAL AL CAUDAL DE ENTRADA1) xlabel ( ' Tiempo ( s ) ' ) ylabel ( 'Voltaje de salida del sensor (V) ') % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol ( ... 'Style'f 'frame1 , 'Units ' , ' normalized-' , ... ' Position ' , f rmPos , . . . 'BackgroundColor' , [0.50 0.50 0.50]); %ARCHIVO ESTATC1.M (COMPARACIÓN DE MODELOS. CURVA ESTÁTICA. TA NQUE) %Parámetros del sistema C-400; Cfi=l/C; Kv-258; Kb=204; Ks=0.5; hO=10; ts=100; %Diseño de la pantalla axes ( ... 1 ünitsf , ' normalized ' , ... 'Position' , [0.1 0.3 0.85 0.6], ... 'Visible', 'on1 ) ; statcl darkgray=[l/3 1/3 1/3]; cerrar^' cióse; r ; %Barras hOc = uicontrol ( ' style ' , ' slider1 , 'units T f 'normal ' ,Tpos ' , [ . 68 05 .30 .035] , . . . 'rain1 ,0, 'max1 ,30, 'val',hO, . . . 'cali' , 'hO = get (hOc, ' 'valué' ' ) ; statcl1 ) ; hOct - uicontrol ( ' style ' , ' text ' , 'units ' , 'normal ' r 'pos ' , [ . 3 .30 .04] , ... 1 string ' , ' hO ~ ' , ' f ore ' , ' white ' , ' back ' , darkgray ) ; hOct = uicontrol ( ' style ' , ' text ' , ' units ' , ' normal ' , ' pos ' , [ 9 .30 .04], ... 'string', 'O 05 10 15 20 25 30 ',' fore ', 'white ', 'back' , da rkgray) ; hO_f ield-uicontrol ( ' Style ' , ' edit ' , ' Position ' , [ . 85 .13 . 03 5], ... 'Units ' , 'normalized' , 'String ' , num2str (hO) , ' fore ' , ' e ' , ' back ' , darkgray) ; %Botón de cerrar cerrarh = uicontrol ( ' style ' , ' push ' , ' units ' , ' normal ' , ' pos ' .075 .1 .06] , ... ' string ' , ' cerrar ' , ' cali ' , cerrar) ; %ARCHIVO ESTATC1.M (COMPARACIÓN DE MODELOS. CURVA ESTÁTICA. TA NQUE) %Parámetros del sistema C=400; Cfi=l/C; Kv=258; Kb=204; Ks=0.5; Vi-4 ; hO=10; ts=100; %Diseflo de la pantalla axes( ... 'Units','normalized', ... 'Position1,[0.1 0,3 0.85 0.6], ... 'Visible',Ton'); statcl darkgray=[l/3 1/3 1/3]; cerrar='cióse;'; %Barras hOc = uicontrol{'style',Tslider?, 'units', 'normal','pos',[.68 . 05 .30 .035], ... 'rain',O,'max',30,J val F ,hO, ... 'cali1,'hO - get(hOc,''valué''); statcl'); hOct = uicontrol(' style f,'text','units', 'normal', 'pos' , [.68 .1 3 .30 .04] , ... 'string','hO = ','fore','white','back', darkgray); hOct = uicontrol{'style',ftext', 'units', 'normal','pos'( [.68 .0 9 .30 .04] , ... 'string1, 'O 05 10 15 20 25 30 ','forer,'white', 'back', da rkgray) ; hO_field=uicontrol('Style1,Tedit','Position1,[.85 ,13 .035 .03 5], ... ' Units ' , ' normalizad' , ' String? , num2str (hO) , ' fore ' , e','back',darkgray}; %Botón de cerrar cerrarh = uicontrol('style1r 'push1, 'units'7 'normal', 'pos', [.45 .075 .1 .06], ... 1string','cerrar','cali',cerrar); Statcl %ARCHIVO STATC1.M (COMPARACIÓN MODELOS. CURVA ESTÁTICA. TANQUE cía reset clear yl clear xl hO_field=uicorrtrol('Style', 'edit', 'Position', [ . 8 5 .13 .07 .035 ],... 'Units','normalizad1,'String1/num2str(hO),'fore','whit e' , 'back'rdarkgray); %Cálculo de las curvas t=[0:.1:99.9] '; for i=0:10 xint=d*ones{size (t)); ut=[t,Kb*i*ones(size(t))]; [tt/xx,yy]=linsiin( 'tanque ' , 60 / [] , [] f ut) ; yint=interpl(tt,yy,t, ' s p l i n e r ) ; y n l ( : , i + l ) = y i n t ; xl {:,i+l)=xint; end for i«0:10 ut=[t,Kb^i*ones(size(t))]; [tt,xx,yy]=linsim{'tanqlin 1 ,60, [ ] , [ ] , u t ) ; yint=interpl(tt,yy,t, ' s p l i n e ' ) ; y l l ( ; , i + l ) = y i n t ; end yn=ynl(600, : ) ; yl=yll(600,:); ylp=yl-hO*Ks; x=xl(600,:); %Gráfico de las curvas plot(x,yn,'r-',x,ylp,'g-') title ( 'CARACTERÍSTICA ESTÁTICA1 } xlabel('Voltaje de entrada a la bomba (V)') ylabel('Voltaje de salida del sensor de nivel (V) ' ) % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h-uicontrol( ... 'Style','frame', ... 'Units'r 'normalized', ... 'Position',frmPos, ... 'BackgroundColor1, [0.50 0.50 0.50]); tsct = uicontrol('style','text','units', 'normal', 'pos',[.40 .0 9 .30 .04] , ... 'string', '400 500 600 700 800', 'fore', 'white' , 'back', dar kgray); ts_field=uicontrol{ 'Style1 , 'editr, 'Position1, [.58 .13 .07 .035 1Units', 'normalized','String',num2str(ts) , 'fore','whit e','back'Adarkgray); |cerrarh - uicontrol('style',Tpush', 'units', 'normal','pos T , [ .8 .075 .1 .06], ... 1 string T f 'cerrarf,'cali', cerrar); %ARCHIVO PLANTA2.M (RESPUESTA TEMPORAL MODELO NO LINEAL. -TÉRMI CO) cía reset Vi__field=uicontrol( 'StyleT, 'edit1 , 'Position'r [.23 .13 .07 .035 ],... 'Units ' r 'normalized1,' String',num2str(Vi) , 'fore','whit e' f 'back'rdarkgray); ts_field=uicontrol( 'Stylef , 'edit1 ,?Position' , [.58 .13 .07 .035 ],.-'Units','normalized1 , 'String1,num2str (ts),'fore1,Twhit e ', 'back',darkgray); %Cálculo de la respuesta t=[0:l:999] ' ; Vrms=Vs-Vs*sqrt( (1/3.1416) * (3 .1416-(Kd*Vi*3.1416/180 ) + 0.5*sin(2*Kd*Vi*3.1416/180))); vt=[t,Vrms^ones(size(t))]; [T,X,Y]=linsim( 'focol' ,ts, [] f [] ,vt) ; %Gráfico de la respuesta plot(T7y) title( 'RESPUESTA TEMPORAL DEL SISTEMA TÉRMICO') xlabel('Tiempo (s)') ylabel('Voltaje de salida del sensor de temperatura(V)') % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style' , 'frame'-, . . . 1Units','normalized', ... 1 Position T,frmPos, ... 'BackgroundColor', [0.50 0.50 0.50]); t %ARCHIVO ESTATIC2.M (CURVA ESTÁTICA MODELO NO LINEAL. TÉRMICO) clear yl clear xl % Parámetros del sistema Kd-18; Vs=110; ts=500; %Diseño de la pantalla axes ( ... 'Units 1 f ' normalized1 , ... 'Position', [0.1 0.3 0.85 0.6], ... 'Visible1 , 'on' ) ; darkgray=[l/3 1/3 1/3]; cerrar=' cióse; '; %Cálculo de la curva estática t=[0:l:999] '; for i«0:10 Vrms=Vs-Vs*sgrt ( (1/3.1416)* (3 . 1416- (Kd*i*3 .1416/180 ) +0 .5*sin(2*Kd*i*3. 1416/180) ) ) ; xint=i*ones (size (t } ) ; ut=[t,Vrms*ones (size (t } ) ] ; [tt,xx,yy]=linsim( ' f ocol ' , 1000, [] , [] , u t ) ; yint^interpl ( tt , yy , t , ' spline ' ) ; yl ( : r i+1 ) =yint ; xl ( : , i+1) =xint; end y=yl(1000, :) ; x=xl(1000/ : ) ; %Gráfico de la curva estática plot (x,y) titlef 'CARACTERÍSTICA ESTÁTICA') xlabel ( 'Voltaje de entrada al circuito de disparo (V)') ylabel ( 'Voltaje de salida del sensor de temperatura (V) ' ) % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol ( ... 1 Style1 , 'frame' , ... ' Units ' , ' normalized ' , ... ; Position',frmPos, ... 'BackgroundColor', [0.50 0.50 0.50]); T %Botón de cerrar cerrarh = uicontrol{'style','push', 'units', 'normal', f pos', [.45 .075 .1 .06], ... 1string','cerrar','cali',cerrar); tsct = uicontrol('stylef , 'text', ' units', 'normal', 'pos' , [.355 . 09 .30 .04] , ... 'string1, '400 500 600 700 800',ffore','white1 , 'back1, dar kgray); ts_field=uicontrol('Style','edit' , 'Position1, [.55 .13 .08 .035 ] 'Units', 'normalizad1, 'String1,num2str(ts), 'fore1,'whit e' r Tback!,darkgray); cerrarh == uicontrol (' style ', ' push f , ' units ', ? normal' , ' pos ', [. 8 .075 .1 .06], ... 1string','cerrar','cali',cerrar); %ARCHIVO RESTEML2.M (RESPUESTA TEMPORAL MODELO LINEAL. TÉRMICO ) % Parámetros del sistema Vi=6; Kd=18; Vs=110; ts=500; %Diséño de la pantalla axes( ... ' CJnits ' r ' normalized', ... 'Position',[0.1 0.3 0.85 0.6], ... 'Visible1,'onr}; planlin2 darkgray=[l/3 1/3 1/3]; cerrar='cióse;'; %Barras Vic = uicontrol('style','slider', 'units', 'normal', 'pos', [.03 . 05 .30 .035], ... 'min',0,'max1,10,'val1,Vir ... 'cali','Vi - get(Vic,''valué''); planlin2f) ; Vict = uicontrol('styleT, 'text', 'units','normal', 'pos', [.03 .1 3 .30 .04], ... 'string', 'Vi = ' , ' fore', 'white ' , 'back', darkgray); Vict = uicontrol(!style', 'text', 'units T , 'normal', 'pos', [.03 .0 9 .30 .04], ... 'string', 'O 1 2 3 4 5 6 7 8 9 10 ' , 'fore' , 'white','back', darkgray} ; Vi_field-uicontrol('Style', 'edit', 'Position', [.2 .13 . 035 . 035 ], - - . 'Units','normalized','String',num2str(Vi),'fore1,'whit e ' , 'back1,darkgray); tsc = uicontrol('style','slider','units','normal','pos',[.355 .05 .3 .035], ... 'min',400,'maxT,800,'val',ts, ... 'call','ts - get (tsc, ' 'valué' ')'; planlin2 ' } ; tsct = uicontrol('style','text1, 'units', 'normal1 , 'pos', [.355 . 13 .3 .04], ... 'string', 'ts = ','fore','white1, 'back',darkgray) ; * %ARCHIVO PLANLIN2.M (RESPUESTA TEMPORAL MODELO LINEAL. TÉRMICO ) cía reset Vi_field=uicontrol{'Style'f 'edit', f Position', [.2 .13 .035 .035 ], ... 'Units', 'normalizad1, 'String',num2str(Vi) , 'fore1, 'whit e','back',darkgray); %> '• ts_f ield=uicontrol { ' Style ' r ' editr r ' Position ' f [. 55 .13 -. 08 . 035 ], ... 'Unitsf , 'normalized', 'String1^num2str(ts), 'fore1, 'whit e'r'back',darkgray); %Cálculo de la respuesta § t=[0:l:999] ' ; vt=[tfVi*ones(size(t))]; [T,X, Y]=linsim( ' f ocolinl' ,tsf [] , [] ,vt) ; sd=3.25*Kd*1.9*0.07691; Y2=Y-sd; %Gráfico de la respuesta Í plot(TrY2) title( 'RESPUESTA TEMPORAL AL VOLTAJE DE ENTRADA1) xlabel('Tiempo (s) ' ) ylabel('Voltaje de salida del sensor de temperatura (V) ') darkgray-[l/3 1/3 1/3]; % Marco de fondo ¿ frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style1,'frame1, ... 1Units','normalized', ... 1Position',frmPos/ ... 'BackgroundColor1, [0.50 0.50 0.50]); %ARCHIVO ESTATL2.M (CURVA ESTÁTICA MODELO LINEAL. TÉRMICO) %Parámetros del sistema Vi=6; Kd-18; Vs=110; ts=500; %Diseño de la pantalla axes( ... 1ünits ', •normalizedT, ... 'Position', [0.1 0.3 0.85 0.6], ... 'Visible1,'on1}; stat!2 darkgray=[l/3 1/3 1/3]; cerrar='cióse; '; %Botón de cerrar cerrarh = uicontrol ( ' style ' f 'pusíi1 ,Tunits ', 'normal', 'pos ' , [. 45 .075 .1 .06], ... 'string','cerrar','cali',cerrar); cía reset clear yl clear xl t=[0: .1:999.9] ' ; for i=0:10 xint=i*ones(size(t)); ut=[t,xint]; [tt,xx,yy]==linsim( 'focolinl',1000, [] , [] ,ut) ; yint^interpl (tt,yy, t, 'spline' ) ;yl { : , i+l)-yint; xl (: , i+1) =xint; end y-ylílOOO,:}; x=xl{1000,:); sd=3.25*Kd*l.9*0.07691; y2=y-sd; plot(x,y2) title( 'CARACTERÍSTICA ESTÁTICA' ) xlabel('Voltaje de entrada al circuito de disparo (V) ' ) ylabel('Voltaje de salida del sensor de temperatura(V)' % Marco de fondo frmPos=[0.03 0.03 0,95 0.15]; h-uicontrol( ... 'Style','frame1, ... 'Units','normalized', .., 1Position',frmPos, ... 'BackgroundColor1, [0.50 0.50 0.50]); %ARCHIVO RESTEMC2.M (COMPARACIÓN MODELOS. TÉRMICO) %Parámetros del sistema Vi=6; Kd=18; Vs=110; ts=500; %Diseño de la pantalla axes( ... 'Units ', 'normalized', ... TPosition',[0.1 0.3 0.85 0.6], ... 'Visible1,Ton'); compfoc2 darkgray=[l/3 1/3 1/3]; cerrar='cióse;'; %Barras Vic = uicontrol('style', 'slider'r 'units'f 'normal', 'pos', [.05 . 05 .30 .035] , ... I min í , O, 'max1 ,10, 'val',Vi, ... 'cali' , 'Vi = get(Vic, ''valué''); compfoc2'); Vict = uicontrol('style',' text','units', 'normal','pos ' , [. 05 .1 3 .30 .04], ... 'string','Vi = ',!fore1,Twhite','back', darkgray); Vict = uicontrol('style f , 'text','units', 'normal','pos' , [.05 .0 9 .30 .04], ... 'string',T 0 1 2 3 4 5 6 7 8 9 10r ,'fore', 'white','back', darkgray); Vi_field=uicontrol('Style1,'edit','Position',[-25 .13 .035 .03 5], ... 'Units', 'normalizad', 'String',num2str (Vi)r 'fore', ' whit e1,'back',darkgray); tsc = uicontrol('styleT,'slider','units','normal','pos',[.4 .0 5 .3 .035], ... 'min' ,400, 'max',800, 'val',ts, ... 'call','ts = get(tsc,''valué''); compfoc2'); tsct = uicontrol('style!, 'text','units', 'normal', 'pos', [.4 .13 .3 .04], ... 1string','ts = ','fore','white','back',darkgray); tsct = uicontrol { 'style1 , ' text ' , 'units ' r 'normal1 f 'pos ' , [ . 4 .09 .30 .04] , ... 'string' , '400 500 600 700 800 ? ,f fore T , ' white ' ,?back ' , dar kgray) ; ts_f ield=uicontrol ( 'Style1, ' edit ' , 'Position1 , [.6 .13 .08 .035] i •-* 'Units ? , 'normalized 1 , ' String' / num2str (ts) , ' fore' , 'whit e 1 , 'back' ,-darkgray) ; cerrarh = uicontrol ( T style ' , ' push! , ' units ' , ' normal ' , ' pos ' , .075 .1 .06], ... 1 string ' , 'cerrar1 , ' cali f , cerrar) ; %ARCHIVO COMPFOC2.M (COMPARACIÓN DE MODELOS. TÉRMICO) cía reset Vi_f ield=uicontrol { ' Style ' , ' edit ' , ' Position ' , [ . 25 .13 . 0 5], ... 'Units1 r 'normalized1 f ' String1 ,num2str (Vi) , ' f ore ' , 'whit e ' , ' back ' , dar kgray ) ; ts_field=uicoirtrol( f Style1 , 'edit1 , 'Position1, [.6 .13 .08 .035] r • "• 1 Units ' , 'normalized 1 , 'String 1 , num2str (ts) , ' f o r e ' , 'whit e ' , ' back T , darkgray ) ; %Cálculo de las respuestas t=[0:l:999] ' ; Vrms=Vs-Vs*sqrt( (1/3.1416)* ( 3 . 1416- (Kd*Vi*3 . 1416/180) + 0.5*sin(2*Kd*Vi*3. 1416/180) ) ) ; vt= [torniscones (size (t ) ) ] ; [Tn f Xn,Yn]=linsira( ' f ocol ' ,ts f [] , [] f v t ) ; vt=[t. Virones (size ( t ) ) ] ; [TI, XI, Yl]=linsim( ' f ocolinl ' ,ts, [] , [] ,vt) ; sd=3.25*Kd*1.9*0- 07691; Yll-Yl-sd; %Gráfico de las respuestas plot(Tn,Yn, 'r-'^Tl^Yll, ' g- ' ) title( 'RESPUESTA TEMPORAL AL VOLTAJE DE ENTRADA1) xlabel ( T Tiempo ( s ) ' } ylabel ( 'Voltaje de salida del sensor de temperatura (V) ' ) darkgray=[l/3 1/3 1/3]; % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol ( ... 'Style1 , 'frame1 , ... 'Units ' , ' normalized1 , ... 1 Position ' , f rmPos , ... 'BackgroundColor1 , [0.50 0.50 0.50]); %ARCHIVO ESTACT2.M (COMPARACIÓN MODELOS CURVA ESTÁTICA. TÉRMIC O) %Parámetros del sistema Vi=6; Vs=110; ts=500; %Diseño de la pantalla axes ( ... 1 Units ' , ' normalized ' , ... 'Position', [0.1 0.3 0.85 0.6], ... 'Visible1 , 'onT ) ; statc2 darkgray=[l/3 1/3 1/3]; cerrar=' cióse; ' ; %Botón de cerrar cerrarh = uicontrol(^tyle1,'push1,'units1, 'normal1r 'pos1 / [. 45 .075 .1 .06], ... 1 string1 ,, ' cerrar' , ' call r, cerrar) ; %ARCHIVO STATC2.M O) (COMPARACIÓN MODELOS CURVA ESTÁTICA. TÉRMIC cía reset clear yl clear xl %Cálculo de la respuesta t=[0:Í:999] '; for i=0:10 Vrms=Vs-Vs*sgrt( (1/3.1416) * (3 .1416- (Kd*i*3. 141 6/180 )+0 .5*sin(2*Kd*i*3.1416/180) ) ) ; xint=i*ones (size (t ) ) ; ut=[t,Vrms*ones (size (t ) ) ] ; [tt,xx,yy]=linsim( ' focol ' , 1000, [] , [] ,ut) ; yint=interpl (tt,yy, t , ' spline ' ) ;ynl ( : r i+l)=yint; xl ( : f i+1 ) =xint ; end for i=0:10 xint=i*ones (size (t) ) ; ut= [t,xint] ; [tt,xx,yy]=linsim( 'focolinl 1 , lOO'O, [] , [] , u t ) ; yint=interpl (tt,yy, t, ' spline ' ) ;yll ( : , i+l)=yint; xl ( : , i+1 ) =xint ; end yn=ynl (1000, : ) ; yl=yll(1000, : ) ; x«xl{100, : ) ; sd=3.25*Kd*1.9*0.07691; yll=yl-sd; plot (x,yn, 'r-' ,x,yll, f g- 1 ) title( 'CARACTERÍSTICA ESTÁTICA1) xlabel ( 'Voltaje de entrada al circuito de disparo (V)1) ylabel ( 'Voltaje de salida del sensor de temperatura (V)') % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol ( ... 'Style1 , 'frame' , ... 'Units ' , 'norrnalized'r . . . ' Pos i t ion1 , frmPos, . . . 'BackgroundColor' , [0.50 0.50 0.50]); %ARCHIVO RESPTEM3.M (RESPUESTA TEMPORAL SERVOMECANISMO) %Parámetros del sistema Ra-0.4; La=0; J—5; Vi=7 ; ls=5; ts=10; b=3; Kt=l ; Kb=l; %Pantalla axes( ... 1Units','normalizad', ... 'Position',[0.1 0.3 0.85 0.6], ... 'Visible1,'on'); planta3 darkgray^[l/3 1/3 1/3]; cerrar='cióse; ' ; %Barras Vic = uicontrol('style', T slider1, 'units', 'normal1, 'pos', [.03 . 05 .30 .035], ... 'min',0,'max',10,'val1,Vi, ... 'cali1 , 'Vi - get{Vic, ' 'valué' '}; plantaS'); Vict = uicontrol('style', 'text', 'units', 'normal'f 'pos ' , [. 03 .1 3 .30 .04], ... 'string'/'Vi = ','fore', 'white', 'back'r darkgray) ; Vict = uicontrol('style', 'text', 'units', 'normal', 'pos', [.03 .0 9 .30 .04], ... 'string','0 1 2 3 4 5 6 7 8 9 10 ',' fore ', 'v/hite ',' back ', darkgray); Vi_f ield^uicontrol('Style'f 'edit','Position', [. 22 .13 .07 .035 ], . - 'Units', 'normalized', 'String',num2str(Vi), 'fore', 'whit e','back',darkgray); Isc = uicontrol('style1, 'slider1, 'units', 'normal','pos' , [. 4 . O 5 .30 .035], ... 'min' , O, 'max',10, 'val',ls, ... 'cali', 'ls = get(Isc, ''valué1 '); planta3'); Isct = uicontrol(Tstyle',*text'r runitsr,'normal', 'pos', [.4 .13 .30 .04], ... 'string!,T sat = ','fore', 'white',Fback', darkgray) ; Isct = uicontrol('style', T text','units', 'normal',Tpos! , [. 4 .09 .30 .04], ... 'string1,'O 1 2 3 4 5 6 7 8 9 10 f , 'fore1,Twhite', 'back1, darkgray); ls_field=uicontrol('Style1,'edit', 'Position',[.6 .13 .07 .035] r • •• 'Units','normalizad','String1,num2str(Is),'fore','whit e'/'back',darkgray); §, cerrarh = uicontrol('style',Tpush', 'units','normal' , 'pos', [. .075 .1 .06], ... ' string', ' cerrar' , ' cali'r cerrar) ; %ARCHIVO PLANTAS (RESPUESTA TEMPORAL. SERVOMECANISMO) cía reset Vi_field=uicontrol('Stylef,'edit1,'Position',[.22 '.13 .07 .035 ]/ ..'Units','normalized'f !String', num2str (Vi),TforeT, 'whit e 1 r 'back1,darkgray); ls_field=uicontrol(TStyle','edit1,'Position1,[.6 .13 '.07 .035] i •** 1Units'r 'normalized','StringT,num2str(Is),'fore'r 1whit e','back',darkgray}; %Cálculo de la respuesta t=[0:.1:9.9]'; vt=[tl,Virones (size (t) ) ] ; [T,X,Y]=linsim( ' servo ',ts, [] f [] ,vt) ; %Gráfico de la respuesta plot(T,Y) title('VARIACIÓN TEMPORAL DE LA POSICIÓN DEL ROTORT) xlabel('Tiempo (s)T ) ylabel('Voltaje de salida del sensor de posición(V)') % Marco de fondo frmPos=[0.03 0,03 0.95 0.15]; h=uicontrol( ... 'Style',Tframe', ... 'Units','normalized1, ,.. 1Position T ffrmPosr ... 'BackgroundColor1,[0.50 0.50 0.50]); %ARCHIVO ESTATIC3.M (CURVA ESTÁTICA SERVOMECANISMO) %Parámetros del sistema Ra=0. 4 ; La=0.065; J=5; ls=5; ts-10; Kt=l ; Kb=l ; b=0 ; %Pantalla axes( ... 1Units'T 'normalizad'r ... 'Position', [0.1 0.3 0.85 0.6], ... 'Visible','on1); static3 darkgray=[l/3 1/3 1/3]; cerrar='cióse;'; %Barras Isc = uicontrol('style1, 'slider', Tunits', 'normal1 / 'pos', [.05 . 05 .30 .035], ... 'min',O,Tmax*,10,'val',ls, ... 'call'^'ls = get(Isc,''valué1 '}; static3' ) ; Isct = uicontrol('style', 'text', 'units T , 'normal', 'pos! , [.05 .1 3 .30 .04], ... ' string1, 'sat = ', 'fore', 'white', 'back', darkgray) ; Isct = uicontrol('style', 'textf, 'units T , 'normal', 'pos', [,05 .0 9 .30 .04], ... 'string1,'O 1 2 3 4 5 6 7 8 9 10','fore','white','back', darkgray) ; ls_field=uicontrol('Style', 'edit','Position', [.23 .13 .07 . 035 ], - - 'Units', 'normalized', 'String',num2str(ls), 'fore' ,fwhit e','back',darkgray); cerrarh = uicontrol('style', 'push', 'units', 'normal', 'pos', [. .075 .1 .06] , ... ' string', 'cerrar','calif,cerrar); %ARCHIVO STATICS.M (CURVA ESTÁTICA SERVOMECANISMO) cía reset clear yl olear xl clear yint ls_field=uicontrol('Style1,'edit1,'Position1, [.2 .13 .07 .035] i • •• 'Units'r 'normalized', 'String',num2str(Is),'fore'r !whit e' f 'back',darkgray); %Cálculo de la curva estática t=[0: .1:9.9] '; for 1=0:100 xint=i*ones(size(t) )/10; ut=[t,ibones(size(t))]; [tt,xxryy]=linsim(Tservo1,10, [], [],ut); yint=interpl{tt,yy,t,'spline1);yl{:,i+l}=yint; xl(:,i+1)=xint; end y-yl(100,:); x=xl(100,:); %Gráfico de la curva estática plot(x,y) title('CARACTERÍSTICA ESTÁTICA1 ) xlabel('Voltaje de entrada (V)1} ylabel('Voltaje de salida del sensor de posición angular (V)') % Marco de fondo frmPos=[0.03 O.03 O.95 O.15]; h=uicontrol( ... 'Style1,'frame', ... 1ünits',!normalizedT, ... 1Position',frmPos, ... 'BackgroundColor1,[0,50 0.50 0.50]); Página 1 %ARCHIVO ROBOT.M (MANIPULADOR DE BRAZO DE ROBOT) %Cargar valores precalculados almacenados en archivos .mat load load load load load load load x2 y2 t xa xb xc xd %Voltajes (torques) aplicados a los servos en cada juntura tl=l; t2=2; %Pantalla darkgray=[l/3 1/3 1/3]; % Marco de fondo frmPos=[0.03 0,03 0.95 0.15]; h=uicontrol( ... 'Style? , 'frame', ... 1Units', 'normalized', ... 'PositionT,frmPos, ... 'BackgroundColor1,[0.50 0.50 0.50]); cerrar^1cióse; '; %Barras tic — uicontrol ( ' style ' , ' slider' , 'units ' , 'normal' , 'pos ' ,• [. 05 05 .30 .035], ... 'rnin1 , O, 'max' ,10, 'val1 , ti, ... 'cali1,'ti = get(tic,''valué'f); planta4'); tlct = uicontrol('style', 'text','units', 'normal',rpos' , [. 05 .1 3 .3 .04], ... ' string', 'ti = f,'fore'f 'white', 'back', darkgray) ; tlct = uicontrol('style ', 'text', 'units', 'normal', 'pos', [.05 .0 9 .30 .04], ... 'string', 'O 1 2 3 4 5 6 7 8 9 10', 'fore1,rwhite', 'back', darkgray) ; tl_field-uicontrol('Style1,'edit','Position1,[.22 .13 .07 .035 ], - - 'Units', 'normalized',TString',num2str(ti) , 'fore', 'whit e','back1,darkgray); t2c = uicontrol('styleT ,' slider', 'units', 'normal', 'pos ' , [. 40 . 05 .3 .035], ... 'min',0, 'max',10,'val',t2, ... 'call','t2 = get(t2c,''valué''} ; planta4'); t2ct = uicontrol('style','text',Tunits', 'normal1 , 'pos ',[. 40 .1 3 .3 .04] , ... 1 string' f T t2 = ','fore1,'white1,'back1,darkgray) ; t2ct = uicontrol(f style','text','units','normal', 'pos', [.4 .09 .30 .04], ... 'string','O 1 2 3 4 5 6 7 8 9 10','fore','whiteT, 'back', darkgray); t2_f ield=uicontrol('Style', 'edit', T Position', [.57 .13 .07 .035 ]/ ... 'Units', 'normalized', 'String',num2str (t2), 'fore', 'whit e','back',darkgray); %Aviso de esperar color-[O 01]; pres = uicontrol{'style', 'text', 'units', 'normal','pos ', [. 8 .07 5 .1 .065] , ... 'string', 'Presione enter', 'foreT, 'white' , 'back', color %Gráfico de valores precalculados axes( ... ' 'Units','normalized1r ... 'Position1,[0.1 0.3 0.85 0.6], 'Visible','on'); plot(x2,y2) title('TRAYECTORIA DEL EXTREMO DEL BRAZO1 xlabelí'X 1 ) ylabel('Y') pause plot(t,xa) title( 'RESPUESTA TEMPORAL DE 01') ylabeK '01' ) xlabel('t1) pause - t plot(t,xb) title('RESPUESTA TEMPORAL DE 02') ylabel('02') xlabel('t') pause plot(t,xc) titlef'RESPUESTA TEMPORAL DE d01/dtT) ylabel(ld02/dt1} xlabelf't 1 ) pause plot(t,xd) titleCRESPUESTA TEMPORAL DE d02/dt') ylabelf'd02/dt') xlabel('t') %Botón de cerrar cerrarh = uicontrol('style'r 'push', 'units', 'normal', 'pos', [ .075 .1 .065], ... 'string','cerrar','calil,cerrar); %ARCHIVO PLANTA4.M {MANIPULADOR DE BRAZO DE ROBOT) cíe tl__field=uicontrol{'Style','edit1, 'Position', [.2 .13' .07 .035],... 'Units', 'normalized', ' String',num2str(ti),Tfore','white',T back',darkgray); t2_field-uicontrol('Style1,'edit1, 'Position1, [.55 .13 .07 .035],.. 'Units'f 'normalized1, 'String' , num2str(t2),'fore', 'white1, ' back',darkgray); xO—[O O O 0] ' ; save temp ti t2 workspace %Condiciones iniciales %Guardar valores para ser cargados en otro %Aviso de esperar colorl=[0.5 O 1]; pres = uicontrol('style', 'text', 'units','normal','pos', [. 8 . 075 .1 .065], ... ' string', ' Esperar...','fore', colorí); %Solución de ecuaciones diferenciales en archivo Tarru' [t,x]=ode23 ( 'arm' ,0,10,xO) ; %Definición de trayectoria del extremo del brazo x2=0.25*cos(x(:,1))+0.16*cos(x(:,l)+x(:,2)); y2=0.25*sin(x(:,1))+0.16*sin(x(:fl)+x(:,2)); %Avi s o color=[0 O 1]/ pres = uicontrol('style', 'text', 'units', 'normal','pos ' , [.8 .075 .1 .065], ... 'string1,'Presione enter','fore1,'white','back1, color); %Gráfico de la trayectoria plot(x2,y2) title('TRAYECTORIA DEL EXTREMO DEL BRAZO') xlabel('X') ylabel('Y') pause Página 1 : %Gráfico de las respuestas temporales plot(t,x(:,l)} title('RESPUESTA TEMPORAL DE 01') ylabeK'01' ) xlabeK 't1 ) pause plot(t,x(:,2) ) title('RESPUESTA TEMPORAL DE 02') ylabeK'02') xlabeK 't1 ) pause plot(t,x(:,3)) titleC RESPUESTA TEMPORAL DE d01/dt') ylabeK 'd02/dt' ) xlabeK't1 ) pause plot(t,x(:,4) ) titleC RESPUESTA TEMPORAL DE d02/dtf) ylabeK 'd02/dt' ) xlabeK 't') cerrarh = uicontrol('style',T push r , 'units T , 'normal', 'pos' .075 .1 .065], ... 1 string ' r ' cerrar' , ' cali' ,, cerrar) ; %ARCHIVO ARM.M (MODELO DEL MANIPULADOR DE BRAZO DE ROBOT) function xp — arm(t,x) %Cargar valores de anterior espacio de trabajo load temp %Parámetros del sistema g-9.8; ml=9.5; m2=5; al=0.25; a2=0.16; %Ecuaciones M(l, I) = (ml+m2) *al"2+m2*a2ys-2+2*m2*al*a2*cos (x(2) ) ; M(l,2)=m2*al*a2*cos(x(2) ) ; M(2,l)=m2*a2"2+m2*al*a2*cos(x{2) ) ; MI=inv{M) ; N(l}=-m2*al*a2*(2*x{3)*x(4)+x(4)*x(4) )*sin(x(2) ) + (ml+m2 eos (x(l) )+m2*g*a2*cos (x(l)+x(2) } ; (x (1) +x{2) %Definición de variables de estado xp(l)=x(3); xp(2)=x(4); xp ( 3 } =MI ( 17 1 ) * ( -N ( 1 ) +t 1 ) +MI ( 1 r 2 ) * ( -N ( 2 ) +t 2 ) ; xp ( 4 ) =MI ( 1 , 2 ) * ( -N ( 1 ) +t 1 ) +MI ( 2 f 2 ) * ( -N ( 2 ) +t 2 ) ; %ARCHIVO PIDRESP1.M (CONTROL PID TANQUE) % Parámetros del sistema O400; Cfi=l/C; hO=10; ts=120; kp-0.7843; kd=0; ki=0.08; ' - %Diseño de la pantalla axes ( ... 1 Units ' , ' normalized ' , ... 'Position1, [0.1 0.3 0.85 0.6], ... 'Visible1 , 'on' ) ; pidplanl darkgray=[l/3 1/3 1/3]; cerrar^1 cióse; '; % Barras deslizantes de = uicontrol (' style1 ,' slider1 r 'units ', 'normal ', 'pos ' r [. 03 .0 5 .30 .035] , ... 'min' , O, 'max1 , 4, 'val ' , d, . . . 'cali1, 'd = get (de, ' 'valué' f ) ; pidplanl1 ) ; dct = uicontrol ( ' style ' , ' text ' , ' units ' , ' normal ' / r pos ' .30 .04] , ... 1 string ' , ' Perturbación%='r ' fore ' , 'white ' , 'back1 , darkgray dct = uicontrol('styleT, 'text', 'units', 'normal'f 'pos ' , [ . 03 .09 .30 .04] , ... 'string1,'0 20 40 60 80 100','fore1,'white1,'back1, darkgray); d__f ield-uicontrol ( 'Style' , 'edit1 , 'Position', [.27 .13 .03 .035] r .. . 'Units ' , ' normalized1 , ' String ' , num2str (d) , ' fore ' , .'w 1 , 'back',darkgray); kpc = uicontrol('style', 'slider', 'units', 'normal' , 'pos', [.68 . 05 .30 .035], ... 'min ? ,O.5, 'max',1, ' val',kp, ... 'cali?, 'kp = get(kpc, ' 'valué' '); pidplanl') ; kpct = uicontrol(f style ','text', 'units', 'normal', 'pos', [.68 .1 3 .30 .04] , ... 'string!f'kp = ','fore','white1,'back', darkgray); kpct = uicontrol('style',' text', 'units','normalT, 'pos', f.68 .0 9 .30 .04], ... 'string',f0.5 0.6 0.7 0.8 0.9 1', 'fore', 'white', 'back1, d arkgray) ; kp_f ield=uicontrol('Style', f edit?, 'Position', [.85 .13 .07 .035 ], ... TUnits', fnormalized', 'String1,num2str(kp),'fore1 , 'whit e', 'back'fdarkgray) ; kic = uicontrol('style','slíder*,'units','normal','pos', [.355 .05 .3 .035], ... 'min' ,0, 'inax1 ,0.15, 'val1 ,ki, ... 'cali','ki = get{kic,''valué'f); pidplanl'); kict = uicontrol('style','text', 'units', 'normal','pos', [.355 . 13 .3 .04], ... 1string1,'ki = f,'fore','white', 'back',darkgray) ; kict = uicontrol('style','text', 'units','normal','pos', [.355 . 09 .30 .04], ... 'string1, 'O 0.05 0.10 0.15f, 'fore','white1 , 'back', darkgray); ki_field=uicontrol('Style','edit','Position',[.53 .13 .07 .035 ], . - 'Units ', 'normalized*, 'String' , nurn2str (ki) , ' fore' , 'whit e','back',darkgray); cerrarh = uicontrol('style', 'push', 'units', 'normal', 'pos' , [.8 .185 .1 .06], ... 'string','cerrar','cali',cerrar); %ARCHIVO PIDPLAN1.M (CONTROL LINEAL DE NIVEL DEL TANQUE) cía reset d_f ield-uicontrol(f Style ','edit', ' Position',[.27.13 .03 . 035] f .. . 'Units ',fnormalized', 'String1,num2str(d),'fore1r 'white ' r 'back',darkgray); kp_field=uicontrol('Style1,'edit1,'Position1,[.85 .13 .07 .035 ],... 'UnitsT , 'normalized', ' String1,num2str(kp) , 'fore!, 'whit e 1 r 'back1,darkgray}; ki_f ield=uicontrol ( f Style f , ' edit', ' Position' , [. 53 .13 .07 . 035 ], - - • 1Units', T normalized', 'String T,num2str(ki) ,!fore', 'whit e ' ,fback',darkgray); %Cálculo de la respuesta t=[0: .1:199.9] '; vt^Ct, Virones(size(t)}]; [T,X,Y]=linsim( 'pidtanq' , ts, [] , [] f vt) ; vt=[t,Virones(size(t))]; [Tl,Xl,Yl]=linsim( 'pidtalin1 , ts, [] t [] ,vt) ; %Gráfico de la respuesta plot(T,Y,Tl,Yl) titleí 'RESPUESTAS DEL MODELO LINEAL Y NO LINEAL CON CONTROL PI ') xlabel('Tiempo (s)') ylabel('Voltaje de salida del sensor (V)1) % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 1 Style T , 'frarne1 , ... 'Units','normalized'r ... 'Position',frmPos, ... 'BackgroundColor1,[0.50 0.50 0.50]); %ARCHIVO PIDRESP2.M (CONTROL PID LINEAL. SISTEMA DE TÉRMICO) cíe Kd=18; Vs«110; ts=500; d=2 ; ki=0.1; %Diseño de la pantalla axes{ ... 1Units','normalized', ... 'Position',[0.1 0.3 0.85 0.6], ... 'Visible1,'on'); pidplan2 darkgray-[l/3 1/3 1/3]; cerrar='cióse; '; %Barras deslizantes de == uicontrol('style','slider','units','normal','pos',[. 05 .0 5 .20 .035], ... 1min',O,'max',6,'val',d, ... 'cali1,'d = get(de,''valué1'); pidplan2'); dct = uicontrol('style', 'text', 'units'r 'normal' , 'pos ' , [. 05 .13 .20 .035] , ... 1 string','Perturbación%=', 'fore', 'white', 'back', darkgray dct == uicontrol ( ' style ', ' text', ' units ' f T normal', ' pos ' , [. 05 . .20 .035], ... 'string1,'O 25 50 75 100 T ,ffore','white1,'back1 , darkgray d_f ield=uicontrol ( 'Style1 , ' edit' , 'Position', [.23 .13 .05 .035] r *** 'Units ' , 'normalized1 , 'String1 ,num2str (d) , ' fore' , 'v/hite 1 , 'back',darkgray); : kpc = uicontrol('style', 'slider', r units','normal', ' pos ' , [. 52 . 05 ,20 .035], ... 'min1 ,0, 'max',100,'val',kp, ... 'call','kp = get(kpc,''valué''}; pidplan2'); kpct = uicontrol('style','text','units','normal1,'pos'r [.52 .1 3 .20 .035], ... 'string', 'kp=T,'fore1,'white','back', darkgray); kpct = uicontrol( 'style','text',funits', 'normal1,'pos f , [.52 .0 9 .20 .035], ... 'string1r'O 25 50 75 100', 'fore', 'white1,'back1 , darkgray kp__f ield=uicontrol ( 'Style' , 'edit', 'Position', [.64 i 13 .07 .035 ], . . . 'Units','normalizad', 'String1,num2str(kp) , 'fore1, 'whit e 1 f 'back1,darkgray); kic = uicontrol('style','slider1, 'units', 'normal1 , 'pos' , [.29 . 05 .2 .035], ... ' ruin' r O, ' max', 1, ' val' , ki, ... 'cali'r f ki = get(kic, ' 'valué' '); pidplan2') ; kict = uicontrol{'style'/ 'text', 'units', 'normal','pos ' , [. 29 .1 3 .2 .035], ... 1string', 'ki=', 'fore', 'white', 'back',darkgray) ; kict = uicontrol(rstyle', 'text'f 'units','normal', 'pos'r [.29 .0 9 .20 .035], ... 'string1, 'O .25 .5 .75 1',ffore1,'white1,!backf , darkgray ki_field=uicontrol('Style1, 'edit1,'Position', [.42 .13 .07 . 035 ], . • 'Units'f 'normalized', 'String1,num2str(ki) , 'fore', 'whit e' f 'back',darkgray); kdc = uicontrol('style', 'slider1, 'units', 'normal', 'pos', [.755 .05 .2 .035], ... 'min 1 ,O, T max' f 3,'val T ,kd, ... 'cali', 'kd = get(kdc,''valué''); pidplan2') ; kdct = uicontrol('style1, 'text1,'units','normal' , 'pos'r [.755 . 13 .2 .035], ... ' string', ' kd=! , ' fore1 , ' v/hite ' , 'back', darkgray) ; kdct = uicontrol('style', 'textr, 'units', 'normal' , 'pos', [.755 . 09 .20 .035], ... 'string', 'O 1 2 3 ' , ' fore ' , ' v/hite', 'back' , darkgray) kd_field=uicontrol('Style','edit1,'Position',[.87 .13 .07 .035 ], - - 'Units', 'normalized'f 'String',num2str(kd) , 'fore1, 'whit e' f 'back',darkgray); cerrarh = uicontrol('style1, 'push1,'units', 'normal1, 'pos', [ .185 .1 .06], ... T string!,!cerrar', T cali',cerrar); %ARCHIVO PIDPLAN2.M (CONTROL PID LINEAL. SISTEMA TEMPERATURA) cía reset d_field-uicontrol(TStyle','edit','Position', [.23 .13 .05 .035] / .. . 'Units','normalized1f 'String',num2str(d),'fore1r 'white 1 , T back',darkgray); kp_field=uicontrol(' Style','edit','Position', [.64 .13 .07 .035 ], . .. : 1Units','normalized','String1,num2str(kp),'fore1,'whit e 1 r 'back',darkgray); kiJEield=uicontrol('Style','edit','Position', [.42 .13 .07 .035 ], ... 'Units','normalized','String1,num2str(ki), 'fore','whit e','back',darkgray); kd_field=uicontrol{TStyle','edit','Position1,[.87 .13 .07 .035 ], ... 'Units', 'normalized', 'String',num2str(kd),'fore ' , 'whit e ', 'back'rdarkgray); %Cálculo de la respuesta t=[0:l:999] '; vt=[t,Virones(size(t))]; [T/X,Y]-linsim( 'pidfoco' , ts, [] , [] ,vt) ; vt=[t,Virones{size(t))]; [TlfXl,Yl]=linsim('pidfocli1,ts, [], [],vt); %Gráfico de la respuesta plot(T,Y,Tl,Yl) titlef'RESPUESTA DE LOS MODELOS LINEAL Y NOLINEAL CON CONTROL PI' ) xlabelf'Tiempo (s) T ) ylabel{'Voltaje de salida del sensor de temperatura (V)1) % Marco de fondo frmPos-[0.03 0.03 0.95 0.15]; h=uicontrol( ... 1 Style 1 ,'frame 1 , ... 'Units','normalized', ... 'Position',frmPos, ... 'BackgroundColor', [0.50 0.50 0.50]); %ARCHIVO PIDRESP3.M (CONTROL PID SISTEMA TÉRMICO) %Parámetros del sistema Ra=0 . 4 ; La-0; J=5 ; ts-25; Kt=l ; Kb-1; kp=2 . 2 ; kd=2 ; ki-0; %Diseño de la pantalla darkgray-[l/3 1/3 1/3]; axes ( ... ' Units f , ' normalized ' , ... 'Position' , [0.1 0.3 0.85 0.6], ... 'Visible' , 'on' ) ; pidplan3 cerrar^1 cióse; '; %Barras Vic = uicontrol ( ' style ' , ' slider ' , ' units ' , ' normal ' , 'pos ' , 05 .20 .035]r ... 'min1 ,0, 'max1 ,10, 'val1 ,Vi, ... 'cali', 'Vi = get( Vic, ' 'valué' '); pidplan3 ' ) ; Vit = uicontrol ( ' style f , ' text T , ' units ' ,T normal ' , ' pos ' , [ . 05 .20 .035] , ... 'string','Vi = ' , ' fore ' , ' white ' r ' back ' , darkgray) ; Vit = uicontrol ( '.style ' , 'text ' , 'units ' , 'normal 'r 'pos ' , [ . 05 .20 .035] , ... 'string','0 2,5 5 7.5 100 ',' foref , 'white r , 'back1 , darkgra y); Vi_f ield-uicontrol ( ' Style ' , ' edit 1 ,f Position ' , [ . 17 .13 .07 . ], . .. ' Units ' , 'normalizad' , 'String1 , num2str (Vi) , ' fore ' r ' wh e ' , ' back ' , darkgray) ; kpc = uicontrol ( ' style ' , ' slider ' , ' units ' , ' normal ' , ' pos ' , [ 05 .20 .035], ... 'min',0, 'max1,10, 'val1, kp, ... 1 cali','kp = get(kpc, ''valué1 '}; pidplan3') ; kpct = uicontrol('style1,'text', 'units', 'normal1, 'pos', [ .52 .1 3 .20 .035], ... 'string1, ' kp =T , 'fore','white','back', darkgray); kpct = uicontrol('style',' text','units'r ' normal' , 'pos'f [.52 .0 9 .20 .035], ... 'string1,'O 2 4 6 8 10 ', ' fore ', 'white ', 'back'', darkg ray) ; kp_field=uicontrol('Style1, 'edit', 'Position', [.67 .13 .07 .035 ], - .'Units','normalized', 'String1,num2str(kp) , 'fore', 'whit e','back1,darkgray); kic = uicontrol('style', 'slider', 'units', 'normal1 , 'pos', [.29 . 05 .2 .035], ... 'min1,O, 'maxf,10, 'val',ki, ... ' cali' , ' ki = get (kic, ? ' valué ' ' ) ; pidplan3 ' ) ; kict = uicontrol('styler,ftext?, 'units', 'normal' , Tpos ' , [. 29 .1 3 .2 .035], ... 1 string1,'ki = ', 'fore', 'white','back',darkgray) ; kict = uicontrol('style1, 'text','units', 'normal1 , 'pos', [.29 .0 9 .20 .035], ... 'string' , 'O 2 4 6 8 10' , 'fore' , 'white1, 'back1 , darkg ray) ; ki_field=uicontrol('Style', 'edit' , 'Position? , [.42 .13 .07 . 035 ], - .. 'Units', 'normalized1, 'String',num2str(ki) , 'fore', 'whit e ' , ' back',darkgray) ; kdc = uicontrol('style', 'slider', 'units r , 'normalr, 'pos', [.755 .05 .2 .035], ... 'min' , O, 'max' ,10, 'val' , kd, ... 1 cali','kd = get{kdc, ' 'valué' '); pidplan3'} ; kdct = uicontrol('style1, 'text', 'units', 'normal','pos' , [.755 . 13 .2 .035], ... 'string', 'kd = ', 'fore', 'white', 'back1,darkgray) ; kdct = uicontrol('style1, 'text', 'units', 'normal', 'pos', [.755 . 09 .20 .035], ... 'string', 'O 2.5 5 7.5 100','fore', 'white1, 'back1, darkgra y); kd_f ield=uicontrol ( ' Style ' , ' edit' , ' Position ', [. 87 .13 .07 . 0 ,. . . 'Units ' , 'normalized1 , 'String1 , num2str (kd) ,ffore' , 'whit e' , 'back',darkgray); cerrarh = uicontrol('style','push','units' , 'normal' , 'pos r , [.8 .175 .1 .06], ... 1string', 'cerrar',T calif,cerrar) ; %ARCHIVO PIDPLAN3.M (CONTROL PID DEL SERVO) cía reset kd_f ield=uicontrol('Style1, 'edit'r 'Position', [.87 .13 .07 .035 ],., . 'Units','normalized', 'String',num2str(kd) ,'fore', 'whit e','back',darkgray); ki_field«uicontrol(!Style1, 'edit1,'Position', [.4 .13 .07 .035] i . . . ' ünits ', ' normalized', ' String ', num2str (ki) ,T fore ' , ' whit e1,'back',darkgray); kp_field-uicontrol('Style1 , 'edit','Position1, [.65 .13 .07 .035 ], ... 'Units ' , 'normalized'r ' String' , num2str (kp) , 'fore ' , 'whit e','back',darkgray); Vi_field^uicontrol('Style1, 'edit1r 'Position', [.16 .13 .07 .035 ], - - 'ünits ' r 'normalized' , 'String' ,num2str (Vi) , ' fore ' , 'whit e 1 , 'back1,darkgray); darkgray-[l/3 1/3 1/3]; t=[0:.1:24.9]'; vt=[t,Virones(size(t))]; [T,X,Y]=linsim('pidservo',ts,[], [],vt); plot(T,Y) title('RESPUESTA UTILIZANDO UN CONTROL PD ') xlabel('Tiempo (s)') ylabel('Voltaje de salida del sensor de posición (V)') % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style1,'frame', ... 'Units','normalized', ... 'Position',frmPosf .. . 'BackgroundColor',[0.50 0.50 0.50]); %ARCHIVO AUTOTUNE.M (AUTOSINTONÍA. SERVOMECANISMO) %Parámetros del sistema Vi=l; e=l; d-20; kp=l; kd=l ; ki-0; ts=25; %Diseño de la pantalla black=[0 O 0]; axes( ... 1Units','normalized', ... 'Position', [0.1 0.3 0.85 0.6], ... 'Visible1,'on1); ziegapid darkgray=[l/3 1/3 1/3]; cerrar—'cióse'; %Barras deslizantes de = uicontrol('style','slider'/'units','normal','pos', [.03 .0 5 .30 .035], ... 'rnin', O, 'max1,50, 'val' ,d, 'cali','d = get(de,''valué''};motrelay'); dct = uicontrol('style', 'text', ' units', 'normal', 'pos',[.03 .13 .30 .04], ... 1string', 'Ganancia del relé=', T fore', 'white','back' , dark gray); dct = uicontrol{'style','text','units','normal','pos',[.03 ,09 .30 .04], ... 'string', 'O 10 20 30 40 50', ' f ore ' , 'white' ,'back 1r darkgray); d_field=uicontrol('Style','edit', 'Position', [.29 .13 .035 .035 I r ... 'Units', 'normalized1, 'String1,num2str(d)r 'fore ', 'white ' f T backr,darkgray); ec = uicontrol('style', 'slider',funits', 'normal1 , 'pos', [.68 .0 5 .30 .035], ... 1 ruin' , O, ' max', 5, ' val' , e, ... 'cali','e = get(ec,''valué''); motrelay'); ect = uicontrol('style','text'r 'units','normal'f 'pos', [. 68 .13 .30 .04], ... 'string'f 'Histéresis =T , 'fore','white','back1, darkgray); ect = uicontrol('style1,'text','units1,Tnormal1,'pos' , [.68 .09 .30 .04], ... 1string r , f O 1 2 3 4 5' , 'fore','white' ,'back1, darkgray); e_field=uicontrol('Style','edit', 'Position', [.90 .13 .035 .035 ], .- 'UnitsT , 'normalized' , 'String' , num2str (e) , 'fore1 , 'white ' r 'back',darkgray); Vic = uicontrol('style', 'slider*, 'units', 'normal','pos', [.355 .05 .3 .035], ... 'min',0, 'max',10, 'val1,Vi, . , . 'cali', 'Vi = get(Vic, ''valué''); motrelay'); Vict = uicontrol('style','textT, 'units','normal', 'pos T , [.355 . 13 .3 .04] , ... 'string', 'Vi =', 'fore', 'white1, 'back1,darkgray) ; Vict = uicontrol('style', 'text', 'units', 'normal', 'pos', [. 355 . 09 .30 .04] , ... 'string', 'O 2 4 6 8 10', 'fore' , 'white ','back', darkgray); Vi_field=uicontrol('Style', 'editT, 'Position', [.55 .13 .035 .03 5], ... 'Units ', 'normalized' , ' String' ,num2str (Vi) , ' fore ' , 'whit e','back'/darkgray); cerrarh = uicontrol('style','push', 'units', 'normal', 'pos', [.8 .2 .1 .06] , ... 'string','cerrar','cali',cerrar); %ARCHIVO MOTRELAY.M (AUTOSINTONÍA. SERVOMECANISMO) cía reset d_field=uicontrol('Style', 'edit','Position', [.29 .13 .035 .035 ], ... 'Unitsf,'normalized1,'String1,num2str(d),'fore1 , 'white 1 r 'back1,darkgray); e_field=uicontrol('Style1, 'edit', 'Position1, [.90 .13 .035 .035 ], ... 'Units ' r 'normalized', 'String1,num2str(e),'fore', 'white 1 f 'back'rdarkgray); Vi_f ield=uicontrol('Style','edit1, 'Position', [.55 .13 .035 .03 5], ... 'Units',Tnormalized1,'String',num2str(Vi),'fore','whit e','back1,darkgray); %Ciclo límite t=[0:.1:299.9]'; vt=[t,Vi*ones(size(t))]; [T,X,Y]=linsim( 'servrela' ,tsr [] , [] ,vt) ; %Gráfico del ciclo limite plot(T,Y) titleí'OSCILACIÓN DEL SISTEMA CON RELÉ1) xlabel ('Tiempo (s)') ylabel ('Voltaje de salida del Sensor de velocidad1) % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style', 'frame1, ... 'Units1, 'normalized1, ... 'Position'rfrmPos, ... 'BackgroundColor1, [0.50 0.50 0.50]); color=[0 O 1] ; pres = uicontrol('style', 'text',funits ' r 'normal', 'pos', [,8 .2 .1 .06], ... 'string','Presione enter','fore','white','back', color ); pause %Cálculo de la ganacia critica y periodo crítico n=l; for n=l:l:10 while Y(i)<Y(i+l end while Y(i)>Y(i+l i=i end n=n end tl-T(i); min=Y (i) ; aciones %Minimo valor luego de 2 oscil while Y(i)<Y(i+l) end t2=T(i) ; max=Y ( i ) ; aciones a=max-min; =2^ (t2-tl) ; %Máximo valor luego de 2 oscil %Amplitud %Periodo de oscilación RNa=4*d*sqrt 2-6^2) / (pi*a"2) ; %Parte real de N(a) ^2) ; %Parte Imaginaria de N(a) kc=sgrt (RNaA2+INa/N2) ; %Ganacia critica %Parémetros del controlador según Ziegler-Nichols kd=0 . 6*kc*0 . 12*per; ki=0. ziegapid %ARCHIVO ZIEGAPID.M (AUTOSINTONÍA.. SERVOMECANISMO) cía reset kp_field=uicontrol{'Style' , 'edit','Position 1 , [ . 9 .41 .035 .035 ],... 'Units','normalized1 , 'String1,num2str(kp), 'fore',fwhit e 1 ,'back 1 , black); ki_field^uicontrol('Style' , 'edit',''Position', [.9 .36 .035 .035 I,.'.' 'Units', 'normalized1 , ' String1, num2str(ki), 'fore', 'whit e','back1, black); kd_field=uicontrol('Style1, 'edit'r 'Position', [.9 .31 .035 .035 ], - - 'Units', 'normalized' , 'String1, num2str(kd), 'fore', 'whit e 1 ,'back 1 , black); kpct = uicontrol ( ' style ' f ' text' , r units ' , ' normal'r ' pos ' , [. 83 1 .07 .035], ... 1 string 1f 'kp = ','fore','white*,'back', black); kict = uicontrol('style','text1,'units','normal',Tpos',[.83 .3 6 .07 .035], ... 'string1,'ki = ','fore',rwhite','back'r black); kdct = uicontrol('style','text','units','normal','pos',[.83 .3 1 .07 .035], ... 'string1,'kd - r /'fore 1 ,'white 1 ,'back 1 , black); %Cálculo de la respuesta t=[0:.1:9.9]'; vt=[t,Virones(size(t))]; [T,X,Y]=linsim('ziegpid',ts, [], []fvt); %Gráfico de la respuesta plot(T,Y) title{'RESPUESTA CON PID AUTOSINTONIZADO ') xlabel('Tiempo (s)') ylabel{'Voltaje de salida del sensor de velocidad (V)1) cerrar='cióse'; cerrarh = uicontrol ( ' style ' r 'push '., ' units ' , ' normal' , 'pos ' , [. 8 .2 .1 .06], ... 'string', 'cerrar','cali',cerrar); % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style','frame1, ... TUnits ', ' normalizad'r ... 1Position*,frmPos, ... 'BackgroundColor1, [0.50 0.50 0.50]); %ARCHIVO PDPHASE.M (CONTROL DE POSICIÓN CON RELÉ EN EL PLANO D E FASE) %Cargar valores precalculados load el load e2 load tph kp=2; kd=2.2; Vi=l; darkgray=[l/3 1/3 1/3]; % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style','frarne', ... 1Units'f 'normalized' , ... ' Position',frmPos, . . . 'BackgroundColor1,[0.50 0.50 0.50]}; cerrar='cióse; '; %Barras Vic = uicontrol('style', 'slider'r 'units', 'normal' , 'pos f , [.35 . 05 .35 .035], ... 'min' , 07 'max',10, 'val1,Vi, ... 'cali1,'Vi = get(Vic,f'valué''); pfase1); Vict = uicontrol('style', 'text',f units', 'normal' , 'pos f , [.35 .1 3 .35 .035], ... ' string1, !Vi=' ,, ' f ore ' , ' white' / 'back1 ,darkgray) ; Vict = uicontrol('style','text','units','normal','pos', [.35 .0 9 .35 .035], ... 'string1,'O 1 2 3 4 5 6 7 8 9 10','fore1,'white 1 r 'back 1 , darkgray); Vi_field=uicontrol('Style','edit','Position1, [.55 .13 .035 .03 5],... 'Units', 'normalized1,'String1,num2str(Vi) , 'fore', 'whit e','back',darkgray); %Señal de espera color-[0 O 1]; pres = uicontrol('style',!text'/ 'units', 'normal', 'posf , [. 1 .07 5 .1 .065], ... 1string', ' Presione enterT, 'fore', 'white', 'back', color axes( ... 1Units', f normalizadl, - . . 'Position1,[0.1-0.3 0.85 0.6], ... 1 Visible', 'on'); %Gráfico valores precalculados plot(el,e2) title('PLANO DE FASE DEL ERROR') ylabel('X2?) xlabelí'XI1) pause y-Vi-el; plot(tph,y) titlef'RESPUESTA TEMPORAL DEL SISTEMA1) ylabel('Voltaje del sensor de posición') xlabelí'Tiempo') cerrarh = uicontrol('style', 'push ', 'units', 'normal'r 'pos', [.1 .075 .1 .065], ... 'string', 'cerrar', r cali Tfcerrar); %ARCHIVO PFASE. M (CONTROL DE POSICIÓN CON RELÉ EN EL PLANO DE FASE) cía reset cíe Vi_f ield-uicontrol ( 'Style1 , ' edit ' , 'Position1 , [.55 .13 .035 .03 5] ---'Units ' , 'normalized' ,!String' , num2str (Vi) , ' f ore ' , 'whit e ' , ' back ' , darkgray } ; xO=[Vi,0] '; %Condiciones iniciales colorl=[0.5 01]; pres = uicontrol { ' style1 , ' text ' , 'units* , 'normal' , 'pos ' , [ . 5 .1 .065] , ... 1 string1 ,! Esperar- . . ' , 'fore' , colorí) ; clear x clear y clear t %Solución de la ecuación diferencial [t/x]=ode23 ( 'faseserv' , 0,25, xO) ; color=[0 O 1] ; pres = uicontrol ( ' style7 , 'text ' , 'units ' , 'normal' , 'pos ' , [ . 1 . 5 .1 .065] , ... ' string ' , ' Presione enter ' , ' fore ' , ' v/hite ' , ' back ' , ); %Gráfico de la respuesta title(T PLANO DE FASE DEL ERROR DEL SISTEMA' ylabel( 'X21 ) xlabel( 'XI' ) pause plot (t,y) title( 'RESPUESTA TEMPORAL DEL SISTEMA') ylabel ( 'Voltaje de salida del sensor de posición (V)') xlabel( 'Tiempo (s) ' ) cerrarh = uicontrol ( ' style ' , ' push ' , ' units ' , ' normal ' , ' pos .075 .1 .065] , ... 1 string ' , ' cerrar ' , ' cali r , cerrar) ; i %ARCHIVO FASESERV.M (MODELO DEL CONTROL POR RELÉ EN EL PLANO D E FASE CON ECUANCIONES DIFERENCIALES) function ep = faseserv(t,e) kp=2.2; kd=2; ep(2)=-0,5*sign(m)-l.l*e(2); k %ARCHIVO RELAY1.M (CONTROL ON-OFF) ts=50; Vi=5 ; %Diseño de la pantalla ^ axes( ..'Units', f normalized', ... 'Position1,[0.1 0.3 0.85 0.6], ... 'Visible','on1); reletanq darkgray=[l/3 1/3 1/3]; cerrar='cióse'; %Barras deslizantes I Vic = uicontrol('style','slider','units','normal','pos',[.45 . 05 .3 .035] , ... 'min' ,0, 'max1,10, 'val',Vi, ... 'cali', 'Vi = get(Vic, ' 'valué' '); reletanq'); Vict = uicontrol('style','text','units','normal','pos',[.45 .1 3 .3 .04], ... 'string1, 'Vi =', 'fore', 'white1, 'back',darkgray); I Vict = uicontrol('style','text','units','normal','pos',[.45 .0 9 .30 .04] , ... 'string1,'O 2 4 6 8 10','fore','white 1 ,'back', darkgray); Vi_field=uicontrol('Style', 'edit', 'Position', [.63 .13 .07 .035 'Units r , 'normalized', 'String',num2str(Vi),'fore', 'whit e','back',darkgray); *' de = uicontrol('style', 'slider1,'units', 'normal', 'pos' , [.1 .05 .30 .035] , ... 'min' ,0, 'max' ,0.5, 'val' ,d, ... 'call^'d = get (de, ' 'valué' ') ;reletanq! ); dct = uicontrol('style','text','units','normal','pos',[.1 .13 .30 .04] , ... 'string ' , 'Histéresis = f , ' fore ' , 'white ';, 'back' , darkgray) ; dct = uicontrol('style1,'text','units','normal','pos',[.1 .09 .30 .04], ... 1 string','0 0.1 0.2 0.3 0.4 0.5','fore', 'whit e' f 'back' , darkgray); d_field=uicontrol('Style1, 'edit', 'Position1, [.32 .13 .07 .035] i •*'Units ' , 'normalizad', 'String* ,num2str (d) , 'fore1 r 'white 1 f 'back'rdarkgray); * cerrarh = uicontrol('style!, 'push',!units', 'normal','pos', .075 .1 .06], ... 'string','cerrar1,'cali1Acerrar); %ARCHIVO RELETANQ.M (CONTROL ON-OFF TANQUE) cía reset darkgray=[l/3 1/3 1/3]; Vi_field=uicontrol ( ' Style ' r ' editT, ' Position ', [. 63 .13 . 035 . 03 5], ... 'Units', 'normalized1, 'String1,num2str(Vi) , 'fore', 'whit e 1 f 'back1,darkgray); d_field=uicontrol('Style', 'edit','Position',[.32 .13 .035 .035 ], ... 'Units', 'normalized1, 'String',num2str(d) , ' fore', 'white 1 , 'back1,darkgray); t=[0:.05:199.9] '; vt=[t,Virones(size(t))]; [T,X f Y]«linsim( 'releniv 1 , ts, [] , [] ,vt) ; %Gráfico de la respuesta plot(T,Y) title('CONTROL ON-OFF DEL NIVEL DEL TANQUE ') xlabel('Tiempo (s)') ylabel('Voltaje de salida del sensor (V)1) % Marco de fondo frmPos=[0.03 0.03 0.95 Q.15]; h=uicontrol( ... 'Style1, 'frame'r ... 1Units','normalized', ... 1Position ? rfrmPos/ ... 'BackgroundColor1, [0.50 0.50 0.50]); %ARCHIVO RELAY2.M (CODNTROL ON-OFF. SISTEMA DE TEMPERATURA) Vi=7 ; ts=300; %Diseño de la pantalla axes ( . . . 1 Units! ,? normalized ' r ... 'Position1 , [0.1 0.3 0.85 0.6], ... 1 Visible', f on' ); reletemp darkgray- [1/3 1/3 1/3]; cerrar= ' cióse ' ; %Barras deslizadoras Vic = uicontrol ( ' style ' , ' slider ' , ' units ' , ' normal ' , 'pos ' 05 .3 .035] , ... 'min'/O, 'max',10,T val1 /Vi, . . . 'cali',1 Vi = get (Vic, ' 'valué1 '); reletemp1); Vict = uicontrol (' style1 , ' text ', 'units ',' normal ', 'pos ' r [. 45 .1 3 .3 .04] , ... ' string' , 'Vi =' , ' fore ' / 'white ' r 'back1 , darkgray) ; Vict = uicontrol ( ' style ' , ' text ' , ' units f / ' normal ' , ' pos ' , [ . 9 .30 .04] , ... 'string1, 'O 2 4 6 8 10 ',' fore ' / 'white 1 f 'back' f darkgray) ; Vi__f ield^uicontrol ( ' Style ' / T edit T , ' Position ' , [ . 63 .13 .07 . 03 ]/ - .' units ' , ' normalized ' , ' String ' , num2str (Vi ) , ' fore ' , ' w e ' , 'back' , darkgray) ; de = uicontrol ( ' style' , ' slider1 , 'units ' / 'normal ' , 'pos 'r [ . 1 .0 .30 .035] , ... 'min1 ,0, 'max' ,0.5,r val T ,d, . . . ' cali ' , 'd = get (de, ' 'valué' ' ) ; reletemp' ) ; dct = uicontrol ( ' style ' , ' text ' , ' units ' , ' normal ' , ' pos ' , [ . .30 .04] , ... 1 string1 , 'His teres is =' , ' fore' , 'white1 , 'back' , darkgray) ; dct = uicontrol ( ' style ' , ' text ' , ' units ' , ' normal ' , ' pos ' / [ .30 .04], ... 'string' ,'0 0.1 0.2 0.3 0.4 0.5', 'fore', 'whit e ' , 'back' , darkgray) ; *d_field=uicontrol('Style'f 'editr, 'Position', [.32 .13 .07 .035] r • •• 'Units!, 'normalized',rString',num2str(d)f 'fore', 'white' ,'back',darkgray); cerrarh = uicontrol('style','push','units'r 'normal*, 'pos',[.8 .075 .1 .06], ... 'string?,fcerrar',f cali',cerrar); %ARCHIVO RELETEMP.M (CONTRO ON-OFF. SISTEMA DE TEMPERATURA.) cía reset Vi_f ield-uicontrol { ' Style ', f edit', f Position', [. 63 .13 . 035 . 03 5], ... 'Units ', 'normalized', ' String',num2str(Vi) , 'fore', 'whit e1,'back',darkgray); d_field=uicontrol('f Style1 ,f edit' , 'Position1, [.32 .13 .035 .035 ], ... 'Units','normalized1, 'String1,num2str(d) , 'fore', 'white 1,'back1,darkgray); %Cálculo de la respuesta t=[0:.05:199.9]T ; vt=[tfVirones(size(t))]; [T/X/Y]=linsim('relefoc1,ts, [],[]fvt); %Gráfico de la respuesta plot(T,Y) title('CONTROL ON-OFF SISTEMA DE TEMPERATURA ' ) xlabel('Tiempo ( s ) T } ylabel ('Voltaje de salida del sensor de temperatura (V) ' ) % Marco de fondo f r m P o s = [ 0 , 0 3 0 . 0 3 0 . 9 5 0,15]; h=uicontrol ( ... 'Style1,'frame', ... 1Units','normalized1, ... 'Position1,frmPos, ... 'BackgroundColor', [0.50 0.50 0.50]); %ARCHIVO ADAPTIVO.M (CONTROL PID ADAPTIVO) Vi=5; ts=25; %Voltaje de entrada inicial %Tiempo de simulación %Diseño de la pantalla black=[0 O 0] ; axes( ... 1Units','normalized', ... 'Position1,[0.1 0.3 0.85 0.6], ... 'Visible','on1); darkgray=[l/3 1/3 1/3]; cerrar^T cióse' ; %Definición de las barras deslizantes Vic = uicontrol{'style', 'slider',Tunits', T normal', 'pos', [.1 .0 5 .3 .035], . . . 'min',0, 'max',10,'val1,Vi, ... 'cali','Vi = get(Vic,''valué1'); rlsql'); Vict = uicontrol('style ', ' text', 'units', 'normal' , 'pos', [.1 .13 .3 .04], ... 'string1, ' Vi =', 'fore','white', 'back1,darkgray) ; Vict = uicontrol(!style', 'text', 'units', 'normal', 'pos', [.1 .08 .30 .04], ... 'string', 'O 2 4 6 8 10','fqre', 'white ','back1, darkgray); Vi_field-uicontrol('Style1,'edit','Position',[.3 .13 .035 .035 ],..". 1units', 'normalized f , 'String',num2str(Vi) , 'fore', 'whit e','back',darkgray); rlsql %Botón de cerrar cerrarh = uicontrol('style', 'push', 'units','normal' , 'pos', [. .07 .1 .06], ... 1string','cerrar','cali',cerrar); %ARCHIVO RLSQ1.M (CONTROL PID ADAPTIVO) cía reset clear y Vi_field-uicontrol('Style','edit','Position1, [.3 .13 .035 .035 ],... . 'Units ' , 'normalized','String',num2str(Vi), 'fore', 'whit e','back',darkgray) ; % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 1Style','frame1, ... 'Units',^ormalized1, ... 1Position',f rmPos, ... 'BackgroundColor1,[0.50 0.50 0.50]); %Identificación de los vectores de entrada y salida ruido=Vi/10*rand (200,1) -Vi/20; U=Vi+ruido; t=[0: .1:19.9] '; ut=[tfU] ; [T/x/yy]==linsim( ' tanguel T , 20, [] , [] ,ut) ; Y=interpl (T,yy,t, ' spline1 ) ; %Rutina de identificación de los parámetros de la planta discr etizada alfa=100000; P-alfa*eye(2) ; thetaO=[0 0] ' ; E(1)«Y(2)-X(1, : )*thetaO; L(:fl)-P*X(l/ :) '/(1+X(1, :)*P*X(1/ :)T ); P-(eye(2)-L(:,l)*X(l, :))*P; theta ( : , 1 ) -thetaO+L ( : , 1 ) *E ( 1 ) ; X(2,1:2) = [Y(2) U(2)]; for i=l:28 : )*theta( :,i) ; /(l+X(i+l, : }*P*X(i+l, :) ') ; P=(eye(2)-L(:,i+l)*X(i+l/ :))*P; theta ( : f i+1 ) =theta ( : , i ) +L ( : , i+1 ) *E ( i+1 ) ; end a=theta(l,29) ; b-theta(2,29) ; %Visualización del modelo de la planta Parct = uicontrol('style', 'text', 'units', r normal' , 'pos',[.42 . 08 .37 .04], ... 'string'r 'y(k)*y(k-l)+ *u(k-l) ' , 'fo re','white',fback', darkgray); a_field=uicontrol(?Style1, 'editf, 'Position', [.49 .08 .065 .035 ],.-'Units','normalized','String1,num2str(a),rfore','white ','back1fdarkgray); b_field=uicontrol('Style1 , 'edit1, 'Position'r [.65 .08 .065 .035 ], .. . 'Units','normalized1,'String1,num2str(b), 'fore','white ','back',darkgray); color=[0 O 1]; pres = uicontrol{'style', 'text', 'units ', 'normal1,'pos', [.8 .07 .1 .06], ... 'string','Presione enter'r 'fore', 'white','back1, color %Gréfico de la variación de los parámetros the(:,l)=[0 0] '; the( :,2:30)=theta; kl-[0:l:29] '; plot ( kl , the ( 1 , : ) ' , kl , the ( 2 , : ) ' ) title( 'COEFICIENTES DE LA ECUACIÓN DE DIFERENCIAS') xlabel ( 'Número de iteraciones k !) ylabel ( 'Coeficientes a, b ? ) pause %Diseño del los parámetros del controlador discreto %kp=(a/b)*0.0199; kp=(a/b)*0.01; ki=kp/a~kp; bo=kp+ki; % Condiciones Iniciales y_l=0; e_l=0; u_l=0; eO=Vi-y_l; %Implementación del controlador. Cálculo recursivo uO=u_l+bo*eO-bl*e_l; yO=a*y_l+b*u_l; e(l)=Vi-yO; u(l)=uO+bo*e(l)-bl*eO; y(l)=a*yO+b*uO; for i-2:1200; e(i)=Vi-y(i-l); u(i)=u(i-l)+bo*e{i)-bl*e(i-l) ; y(i)=a*y(i-l)+b*u{i-Í); end k=[0:1:1200]'; yk(l,l)=0; yk(2:1201,l)=yí; uk{lrl)=0; uk(2:1201,l)=u'; %Gráfico de la respuesta discreta del sistema plot(k,yk) title( 'RESPUESTA DISCRETA DEL SISTEMA DE CONTROL DE NIVEL1) xlabel('Número de iteraciones k ') ylabel('Respuesta del sistema y(k) 1 ) cerrarh = uicontrol{'style', 'push', 'units'r 'normal', 'pos', [ .07 .1 .06], ... 1string','cerrar','cali',cerrar); %ARCHIVO INPID1.M EL TANQUE) (ESTIMACIÓN DE LA FUNCIÓN INVERSA. MODELO D %Inicialización C=400; Cfi=l/C; Vi=5 ; hO-10; ts=120; Kb-204; Ks=0.5; Kv=258; kp=0.7843; kd=0; ki=0.08; %Diseño de la pantalla axes( ... 'Units'f 'normalizad', ... 'Position',[0.1 0.3 0.85 0.6], ... 'Visible1,'onr); darkgray=[l/3 1/3 1/3]; cerrar='cióse;T ; inplanl %Barras deslizaderas Vic = uicontrol(T style', 'slider', 'units', 'normal', 'pos', [,03 . 05 .30 .035], ... 'min',O,'max1,10, fval',Vi, ... 'cali','Vi = get(Vic,''valué''); 'inplanl'); Vict = uicontrol{'style', 'text','units','normal' , ' pos ' , [. 03 .1 3 .30 .04], ... 'string','Vi = ','fore',TwhiteT,'back', darkgray) ; Vict = uicontrol('style','text', 'unitsT ,rnormal','pos ', [. 03 .0 9 .30 ,04], ... 'string','0 2 4 6 8 10 ' , ' fore', ' white ' r ' b a ck', darkgray}; Vi field=uicontrol('Style','edit','Position1,[.2 .13 .07 .035] 'Units','normalizad1,'String1,num2str(Vi),'fore','whit e','back',darkgray); kpc = uicontrol('stylef , T slider',T units','normal' , 'pos', [.68 . 05 .30 .035], ... 'ruin', O, 'max1 ,2, 'val' , kp, ... 'cali','kp= get(kpc,''valué1'); inplanl'); kpct = uicontrol('stylef,f text'r 'units',* normal', 'pos', [.68 .1 3 .30 .04], ... 'string','kp = ', 'fore'r 'white', 'back1, darkgray); kpct = uicontrol{'style', ' text','units', 'normal', 'pos', [.68 .0 9 .30 .04], ... 'string1,'O 0.25 0.5 / 1.5 2T , ' forer , 'white ' , 'b ack', darkgray); kp_field=uicontrol('Style1, 'edit1, 'Position', [.85 .13 .07 .035 ],. .. 'Units ', 'normalized',fString1,num2str(kp), 'fore',Twhit e','back',darkgray); kic — uicontrol('style't 'slider','units','normal1,'pos',[.355 .05 .3 .035], ... 'min',O,'max1,2,'val',kif ... 1 cali', 'ki=get(kic, ' 'valué1 '); inplanl'); kict = uicontrol('style', 'text','units', 'normal','pos' , [.355 . 13 .3 .04], ... 1 string', 'ki = ? , 'fore', 'white', 'back',darkgray); kict = uicontrol('style1,'text'f 'units'f 'normal', 'pos', [ .355 . 09 .30 .04], ... 'string1,'O 0.25 0.5 1.5 2','fore','white1,'b ack 1 , darkgray); ki_field-uicontrol('Style' , 'edit!, 'Position', [.53 .13 .09 .035 ], . .. 'Units', 'normalized', 'String' , num2str(ki), 'fore', 'whit e'/'back',darkgray); cerrarh = uicontrol('style','push','units','normal','pos',[.8 .185 .1 .06], ... 1string','cerrar','cali',cerrar); %ARCHIVO IMPLAN1.M (ESTIMACIÓN FUNCIÓN INVERSA. TANQUE) cía reset %Visualización de los nuevos valores Vi_field=uicontrol('Style', 'edit', 'Position1, [.2 .13 .07 .035] r • •• 'Units',!normalizad',rString',num2str(Vi),'fore','whit e','back',darkgray); kp_field=uicontrol ( 'Style1 , 'edit1 , 'Position' , '[.85 .13 .07 .035 ], . .. 'Units', 'normalizedr, f String',num2str(kp) , 'fore', 'whit e f , 'back',darkgray) ; ki_f ield=uicontrol ( 'Style' , 'edit' , 'Position1 , [.53 .13 .09 .035 ]/ - - • .'Units ' , 'normalizad' , ' String' ,num2str (ki) , 'fore1 , 'whit e','back',darkgray); %0btención de datos simulados t=[0: .1:119.9] ' ; vt=[t,Virones(size(t))]; [ T / X / Y J - l i n s i m í ' inversal' , t s r [] , [] ,vt) ; %Gráfico de la respuesta plot(T7Y) title( 'CONTROL DE NIVEL CON FUNCIÓN INVERSA ') xlabel('Tiempo (s)') ylabel ('Voltaje de salida del .sensor de nivel (V)') % Marco de fondo frmPos-[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style','frame1, ... 1Units','normalized', ... 1 Position', frmPos, ... 'BackgroundColor1,[0.50 0 . 5 0 0 . 5 0 ] ) ; %ARCHIVO INPID2.M (ESTIMACIÓN DE FUNCIÓN INVERSA. TEMPERATURA Vi=6; Kd=18; Vs=110; kp=6; ki=0.1; %Diseño de la pantalla axes ( ... 'Units ' , 'normalized' , 'Position', [0.1 0.3 0.85 0,6], ... 'Visible1 , 'on' ) ; darkgray=[l/3 1/3 1/3]; cerrar^' cióse; '; inplan2 %Barras Deslizantes Vic — uicontrol ( ' style ' , ' slider ' , 'units T , ' normal ' , 'pos ' r [ . 05 .30 .035] , . . . 'rain1 , O, 'max' ,10, 'val' ,Vi, ... 'cali' , 'Vi = get (Vic, ' 'valué' ' ) ; inplan2 ' ) ; Vict — uicontrol ( ' style T , ' text ' , ' units ' , ' normal ' , ' pos ' , [ . 3 .30 .04], ... ' string1 , 'Vi = ' , ' fore ' , 'white ' , 'back' , darkgray) ; Vict = uicontrol ( f style ' , ' text ' , ' units T , ' normal r , ' pos ' , [ . 03 9 .30 .04] , ... 'string', 'O 2 4 6 8 10 ',' fore' , 'white ' , 'ba ck ' , darkgray) ; Vi_f íeld=uicontrol ( 'Style1 , ' edit ' , 'Position' , [.2 .13 .07 .035] i • •• 'Units ' , 'normalized' , 'String' , num2str (Vi) , 'fore1 ,fwhit e ' , ' back ' , darkgray) ; kpc = uicontrol (' style ',' slider ',' units ',' normal ', 'pos ',[. 68 . 05 .30 .035] , . . . 'min1 ,0, 'max' ,100, 'val1 , kp, ... 'cali' , 'kp= get (kpc, ' 'valué' ' ) ; inplan2 ' ) ; kpct = uicontrol ( ' style T , ' text ' , ' units ' , ' normal ' , ' pos ' , [ 3 .30 .04] , ... 'string1, 'kp = ',' fore ' , 'white ', 'back' , darkgray); kpct = uicontrol('style1,'text','units','normal1,'pos',[.68 .0 9 .30 .04], ... 'string1,'O 20 40 60 80 100','fore','white','ba ck 1 , darkgray); kp_field=uicontrol('Style','edit1,'Position', [.85 .13 .07 .035 ], .. . 'Units!r 'normal!zed'r 'String1rnum2str(kp),'fore'f 'whit e' , 'back',darkgray); kic = uicontrol(? style', 'slider',!units', 'normal', 'pos!, [.355 .05 .3 .035], . . . 'min1, O, 'max',10, 'val1, ki, ... 1 cali','ki=get(kic,' 'valué r r ); inplan2'}; kict = uicontrol('style','text'/'units'f 'normal','pos',[.355 . 13 .3 .04], ... 1string','ki = T,'fore','white1,TbackT,darkgray); kict = uicontrol('style1,'textT, 'units'r ? normalT, 'pos', [.355 . 09 .30 .04], ... 'string1,'O 2 4 6 8 10','fore','white ','back 1 , darkgray); ki__f ield=uicontrol ( 'Style', 'edit', 'Position' , [.53 .13 .09 .035 ] f ... 1Units','normalized','String',num2str(ki),'fore','whit e','back1,darkgray); cerrarh = uicontrol('style', 'push', 'units', 'normal', 'pos', [.8 .185 .1 .06], ... 'string•,'cerrar1f 'cali',cerrar); %ARCHIVO INPLAN2.M (ESTIMACIÓN FUNCIÓN INVERSA. TEMPERATURA) cía reset clear Y Vi_field=uicontrol('Style','edit', 'Position', [.2 .13 .07 .035] i * •• 'Units ', 'normalized'r 'String' , num2str (Vi) , ' fore', 'whit e' r !back',darkgray); kp_f ield=uicontrol('Style1, 'edit1, 'Position1, [.85 .13 .07 .035 ],... 1Units',fnormalized1,fStringr,num2str(kp) ,! fore r , 'whit e ' , 'backr,darkgray); ki_field-uicontrol('Style1,'edit1, 'Position', [.53 .13 .09 .035 ],... 'Unitsf,'normalized1,'String1,num2str(ki),'fore','whit e','back',darkgray); %Cálculo de la respuesta t=[0:.1:119.9] '; vt=[t,Virones{size(t))]; [T,X,Y]=linsim( r inversa2 ', ts, [] , [] ,vt) ; %Gráfico de la respuesta plot(T,Y) titleí 1 CONTROL DE TEMPERATURA CON FUNCIÓN INVERSA1) xlabel('Tiempo (s)') ylabel('Voltaje de salida del sensor- de temperatura (V)') % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style1,'frame1, ... 'Units','normalized1, ... 'Position',frmPos, ... 'BackgroundColor', [0.50 0.50 0.50]); %ACHIVO BRAZOPID. M (LINEARIZ ACIÓN POR REAL IMENTAC IÓN. MANIPULA DOR BRAZO ROBOT) %Valores precalculados almacenados en archivos .mat load load load load load load load xr2 yr2 tr xra xfb xrc xrd • %Parámetros del controlador kp=500; kd=200; ki=500; %Pantalla darkgray=[l/3 1/3 1/3]; % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style1,'frame1, ... 'Units'f 'normalized'r ... 1Position',frmPos, ... 'BackgroundColor1,[0.50 0.50 0.50]); cerrar^'cióse;'; %Barras kpc = uicontrol('style', 'slider', 'units', 'normal', 'pos', [.52 . 05 .20 .035], ... 'ruin1 r O, 'max' ,600, 'val1 ,kp, ... 'cali' , 'kp = get(kpc, ' 'valué''); armpd1); kpct = uicontrol ( ' style ' , ' text' , ' units ' , ' normal' , ' pos ' , [. 52 3 .20 .035], ... 'string^'kp = ' , ' fore ' , ' white ' , 'back ', darkgray) ; kpct — uicontrol('style', Ttext'f 'units', 'normalr, 'pos', [.52 .0 9 .20 -.035] , ... ''stringT,?0 200 400 600(,'fore', 'white','back', darkgray) kp_f ield=uicontrol('Style', 'edit', 'Position', [.64 .13 .07 . 035 'Units ', 'normalizad', 'String'r num2str {kp}., 'fore'f ' whit e', 'back',darkgray); kic = uicontrol{' style','slider','units','normal' , 'pos! , [. 29 . 05 .2 .035], ... 'min',O,'max', 600,'val1, ki, ... 1 cali', 'ki = get(kic,! 'valué' '); armpd1); kict = uicontrol(f style','text', 'units ', 'normal','pos', [.2 9 .1 3 .2 .035], ... - 'string', 'ki = ', 'fore','white1, 'back',darkgray) ; kict = uicontrol('style1, 'text', 'units? , 'normal1, 'pos', [.29 .0 9 .20 .035], ... 'string1,'O 200 400 600',fforer,'white1,'back', darkgray) t ki_field=uicontrol{'Style1,'edit','Position', [.42 .13 .07 .035 ], .. . 'Units', 'normalized'f 'String1,num2str(ki) , 'fore1,'whit e','back1,darkgray); kdc = uicontrol('style'r 'slider','units','normal', 'pos r , [. 755 .05 .2 .035], ... 'min', O, 'max',300,'val',kd, ... 1 cali' , 'kd = get(kdc,' 'valué1'); armpd1); kdct = uicontrol('style', 'text','units', 'normal','pos' , [.755 . 13 .2 .035] 1string', 'kd = ', 'fore', 'white', 'back',darkgray) ; kdct = uicontrol('style1, 'text', 'units', 'normal'f 'pos ' , [.755 . 09 .20 .035] , ... 'string','O 100 200 300','fore', 'white','back' , darkgray) kd_field^uicontrol('Style','edit','Position',[.87 .13 .07 .035 ], - - 'Units', 'normalized', 'String',num2str(kd) , 'fore',¡whit e','back',darkgray); color=[0 01]; %Aviso de esperar pres = uicontrol('stylef,'text','units', 'normal', 'pos', [.1 .07 5 .1 .065] , ... 1string', 'Presione enter','fore' , 'white' , 'back' , color %Gráfico de las respuestas precalculadas axes ( ... 'Units ' , 'normalized' , ... 'Position1, [0.1 0.3 0.85 0.6], .. 'Visible', f on ! ) ; plot(x2,y2) title( 'TRAYECTORIA DEL EXTREMO DEL BRAZO1 xlabel( 'X1 ) ylabeK 'Y1 } pause plot (t,xra) titleC RESPUESTA TEMPORAL DE 01'} ylabeK '01' ) xlabelí 't1 ) pause plot (t,xrb) title( 'RESPUESTA TEMPORAL DE 02 r ) ylabeK1 02' ) xlabeK 't1 } pause plot (t,xrc) title( 'RESPUESTA TEMPORAL DE d01/dt') ylabeK 'd02/dt' ) xlabeK 't1 } pause plot (t,xrd) title( 'RESPUESTA TEMPORAL DE d02/dtl) ylabeK Td02/dt' ) xlabeK 't1 ) qdl=0.9+3/10*sin(2*pi*t) ; qd2=2 . l+3/10*cos (2*pi*t) ; el=qdl-xra; e2=qd2-xrb; pause ; plot (t, el) titleC ERROR DE 01 EN FUNCIÓN DEL TIEMPO1 xlabeK 't1 ) ylabel ( 'Error1 ) pause plot (t,e2) titlef ERROR DE 02 EN FUNCIÓN DEL TIEMPO1) xlabel('t'} ylabel('Error') cerrarh = uicontrol('style ', 'push', 'units', 'normal', 'pos', [.1 .075 .1 .065], ... 'string',f cerrar?,? cali?, cerrar); %ARCHIVO ARMPD.M (LINEARIZACIÓN POR REALIMENTACIÓN. BRAZO ROBO T) cíe xO=[0,O,O, O,O,0]f ; %Condiciones iniciales save temp kp kd ki %Guardar valores colorl=[0.5 01]; pres = uicontrol('style', 'text','units', 'normal','pos! , [. 1 .07 5 .1 .065], ... 1string',' Esperar...T,rfore', colorí); %Solución de ecuación diferencial [t,x]=ode23('ctrarmpd1,0,10,xO); xl=Q.25*cos(x(:,l)); yl=0.25*sin(x(:,1)); x2=xl+0.16*cos(x(:,1)+x(:,2)); y2=yl+0.16*sin(x(: , 1} +x ( : , 2 ) ) ; %Señal de espera color=[0 01]; pres = uicontrol('styleT, 'text', 'units','normal','pos ', [. 1 .07 5 .1 .065], ... 'string1,'Presione enter'r rfore','white1,'back1, color ); %Gráfico de la respuesta plot(x2,y2) titlef'TRAYECTORIA SEGUIDA POR EL EXTREMO DEL BRAZO1} ylabeK 'Y') xlabeK 'X' ) pause plot(t,x(:,l) ) title ('RESPUESTA TEMPORAL DE 01') ylabeK '011 ) xlabel('t!) pause plot(t,x(:,2)) i title('RESPUESTA TEMPORAL DE 02') ylabeK '02' } xlabel('t') pause plot(t,x(:,3)} titlef'RESPUESTA TEMPORAL DE d01/dtr) ylabel('d01/dt') xlabel('tf) pause plot(t,x(:,4)) titleC RESPUESTA TEMPORAL DE d02/dtT) ylabel('d02/dt!) xlabel(ft!) qdl=0.9+3/10*sin(2*pi*t); qd2=2.1+3/10*cos(2*pi*t); el=qdl-x(:, 1} ; e2=qd2-x{:, 2) ; plot(t,el) title(fERROR DE 01 EN FUNCIÓN DEL TIEMPO1) xlabel('t') ylabel('Error*) pause plot (t,e2) title(rERROR DE 02 EN FUNCIÓN DEL TIEMPO') xlabelf T t r ) ylabel('Error1) cerrarh = uicontrol('style','pushl,1units','normal','pos',[.1 .075 .1 .065], ... 1 string 1 ,'cerrar 1r 'cali'Acerrar); %ARCHIVO CTRARMPD.M (LINEARIZACIÓN POR REALIMENTACIÓN BRAZO. E GUACÍONES) function xp = arm(t,x) %Parámetros del sistema ml-9.5; g=9.8; load temp M(l,2)==m2*al*a2*cos{x(2) ) ; M(2,l)=m2*a2"2-i-m2*al*a2*cos(x{2) ) ; M (2, 2) =1112*32^2; MI-inv(M) ; N(l)=-m2*al*a2* (2*x(3) *x (4) +x (4) *x (4) )*sin(x(2) ) + (ml+m2) cos(x(l) )+m2*g*a2*cos(x(l)+x(2) ) ; x(2) ) +m2*g*a2*cos ( %Ecuaciones de la trayectoria deseada qd(l)=0.9-i-3/10*sin(2*pi*t) ; qd(2)=2.1+3/10*cos(2*pi*t) ; qdp(2)=-3*pi/5*sin(2*pi*t) ; qdpp (l)=-6*pi^pi/5*sin (2*pi*t) ; qdpp(2)«-6*pi*pi/5*cos(2*pi*t) ; % Señales de error e(l)=qd(l)-x(l); e(2)=qd(2)-x(2) ; ep(l)=qdp(l)-x(3}; ep(2)=qdp(2)-x{4) ; sl=qdpp(l)+kd*ep(l)+kp*e(l)+ki*x(5 s2=qdpp(2}+kd*ep(2)+kp*e{2)+ki*x(6 %Señal de torque tl=M(l/l)*sl+M(l,2)*s2+N{l) ; t2=M(2,l)*sl+M(2,2)*s2+N(2) ; %Ecuaciones diferenciales xp(l)=x(3); xp(2)=x(4); xp(3)=MI(l,l)*(-N(l)+tl)+MI(l,2)*(-N(2)+t2 xp(4)=MI(l,2)*{-N(l)+tl)+MI(2r2)*(-N(2)+t2 xp(5)»e(l); xp(6)=e(2) ; %ARCHIVO NIVELCP.M (LINEARIZACIÓN POR REALIMENTACION. TANQUE) cíe kp=0.7843; ki=0.08; %kp=0.07843; %ki=0.008; %Diseño de la pantalla axes( ... 1Units ' f 'normalized' , ... •Position1,[0.1 0.3 0.85 0.6], ... 'Visible*,'onT); darkgray-[l/3 1/3 1/3]; % Marco de fondo frmPos=[0.03 0.03 0.95 0.15]; h=uicontrol( ... 'Style',!frame', ... 1 Units' f 'normalized'r ... 1Position',frmPos, ... 'BackgroundColor1,[0.50 0.50 0.50]); cerrar='cióse;'; levelcp %Barras deslizantes Vic = uicontrol('style? , 'slider'r 'units', 'normal', ' pos ' , [. 03 . 05 .30 .035]r ... 'min1,O,'rnax1,10,'val',Vi, ... 'cali1,'Vi = get(Vic,''valué1'); levelcp1); Vict = uicontrol('style',(text','units','normal't 'pos!,[.03 .1 3 .30 .04], ... 'string'^Vi = ! , ' fore! ,(white1 , •back1 , darkgray) ; Vict = uicontrol('style f , 'textf, r units', 'normal', 'pos', [.03 .0 :9 .30 .04], ... 'string','0 2 4 6 8 10','fore','white','ba ck 1 , darkgray); Vi field-uicontrol(TStyle1, *edit','Position1,[.2 .13 .07 .035] %ARCHIVO LEVELCP.M (LINEARIZACIÓN POR REALIMENTACIÓN. TANQUE) cía reset Vi_field=uicontrol('Style', 'edit', 'Position1, [.2 .13 .07 .035] r • •• 'Units','normalizad','String',num2str(Vi),'fore',?whit e' , 'back',darkgray) ; kp_field=uicontrol('Style1 , 'edit1, 'Position1, [.85 .13 .07 .035 ],- .. 'Units ', 'normalized', T String1, num2str (kp) , ' fore' , ' whit e','back',darkgray) ; ki_field=uicontrol('Style', 'edit1, 'Position1, [.53 .13 .09 .035 ],... 'Units','normalized1,'String1,num2str(ki),'fore1,'whit e','back',darkgray); %Guardar datos para trabajar en otro espacio de trabajo save kpt kp ki Vi colorl=[0.5 O 1] ; pres — uicontrol('styleT, 'text','units', 'normal'r 'pos', [.8 .18 5 .1 .06], ... 1string', ' Esperar. .. ', T fore', colorí); VoO=[0/0]!; %Condiciones iniciales %Solución de ecuaciones diferenciales [T/Vo]=ode23('ctrtang',O,O.5,VoO); %Gráfico de la respuesta plot{T,Vo(:,l)) title( 'LINEARIZACIÓN POR REALIMENTACIÓN DEL MODELO DEL TANQUE' ) ylabel('Voltaje del sensor de nivel (V)') xlabel('tiempo') cerrarh = uicontrol (''style1 , 'push1 , 'units ', 'normal' , 'pos ' , [. 8 .185 .1 .06], ... ' string'r 'cerrar' , 'calif,cerrar); %ARCHIVO CTRTANQ. M (LINEARIZACIÓN POR REAL IMENTAC ION TANQUE) function Vop=ctrtanq(t,Vo) % Parámetros del sistema Kv=258; C=400; Ci=l/C; %Valores del anterior espacio de trabajo load kpt %Lazo externo de control e=Vi-Vo(l) ; v=kp*e+ki*Vo(2) ; %Lazo interno de control N=Kv*sqrt (C*v)+N; %Ecuaciones diferenciales Vop(2)=e;