Simulink

download Simulink

of 20

description

simulink

Transcript of Simulink

  • Introduccin a Simulink

  • IndiceQu es SimulinkCmo crear un modeloCmo ejecutar la simulacin de un modelo

  • Qu es Simulink ?Es una herramienta interactiva, para modelar y analizar sistemas dinmicos, basada en diagramas de bloques. Est fuertemente acoplada con MATLABMATLABToolboxes: Control, Seales Estadsticas, Finanzas,...SIMULINKReal Time Workshop

  • Crear un modeloEditar un modeloAbrir la ventana de un nuevo modeloConectar los bloquesAadir bloquesCambiar el tamao de los bloquesModificar etiquetas y aadir anotacionesParametrizar los bloquesGuardar un modelo (formato M-File) Abrir un modelo desde Matlab

  • Abrir la ventana de un nuevo modeloEscribiendo simulink se inicia el programa. simulinkSeleccionado, en Simulink, en el men File el submen New se crea la ventana de un nuevo modelo

  • Hacerdoble click en un icono para desplegar los bloques dela libreraAadir bloquesArrastrar los bloques deseados dentro de la ventana del modelo simulink

  • Conectar los bloquesPara aadir una lnea:

    Arrastrar, pulsando el botn derecho del ratn, desde una salida, o desde una entrada,de alguno de los bloques

  • Cambiar el tamao de los bloquesTras seleccionar el bloque, aparecen en l los puntos,desde los cuales se puede arrastrar para cambiar el tamao del bloquePosteriormente se pueden mover el bloquepara que las lneas de conexin queden rectas

  • Modificar etiquetas y aadir anotacionesEtiquetasAnotacionesHacer click en la etiqueta y editarlaHacer click en el fondo y escribir el texto

  • Hacer doble click sobre el bloque que se desea parametrizarParametrizar los bloques

  • Guardar un modeloCrea el fichero del modelo: orden_1.mAbrir el modelo desde Matlab

  • Ejecutar una simulacinPoner los parmetros de la simulacinEjecutar una simulacin desde la ventana del modeloPoner y sacar valores en/desde los modelosUtilizar en Matlab los valores obtenidos en la simulacinVariables definidas en Matlab y SimulinkSimular desde la lnea de comandos

  • Poner los parmetros de la simulacinSimular

  • Parmetros de simulacin

    Mtodo de integracin:

  • Ejecutar una simulacin desde la ventana del modeloSalida del bloque Auto-Scale Graph

  • Poner y sacar valores en / desde los modelos(desde / hacia el espacio de trabajo)

  • Utilizar en Matlab los valores obtenidos en la simulacinDespus de ejecutar la simulacin en Simulink

  • Variables definidas en MatLab y SimulinkTanto desde la ventana de Matlab como la de Simulink se ve el mismo Workspace o Espacio de trabajo T = 2 ; K = 1 ;K = 1pi=3.14159...t = 0:0.01:10T = 2Matlab SimulinkEspacio de trabajo

  • Visualizar el grafico desde MatlabCmo podemos ver los resultados en Matlab?

    Seleccionar en el bloque scope Scope parameters, la opcin save data to workspaces.Colocar en variable name, el nombre del modelo generado.

  • Visualizar el modeloModelo: orden_1.mParmetros de salida del modelo orden_1.mVisulizacin desde la ventana del modelo:

    Se hace doble click sobre el bloque de salida scope.

    Visualizacin desde la lnea de comandos de MATLAB:

    Se utilizan la sentencia:plot (orden_1.time, orden_1.signals.values)

    *At the most basic level, building a model involves four steps: collecting and connecting blocks, simulating the system, analyzing results, and refining the model. Each of these steps will usually be done numerous times over the lifetime of a model. During this course, we are going to look at each of these steps in detail. We will first start with Collecting and connecting blocks. Later on we will simulate a few different types of models, and then we will work with oneof the models to analyze results. Finally we will look at some advanced features which will help you to refine your models.*What is SIMULINK? The course is about SIMULINK, but to understand SIMULINK, you first need to understand something about the environment that SIMULINK lives in: MATLABThe main thing to notice about the picture above is that SIMULINK belongs not at the center of the diagram, but off to the side. MATLAB solidly occupies center stage. So our question about SIMULINK leads to another question: What is MATLAB? I prefer to think of SIMULINK as a child of MATLAB. In order to work, SIMULINK needs MATLAB. The converse is not true.

    See: Using SIMULINK Pages:1-2 and 1-3*See:Using SIMULINK Pages:Chapters 2 and 3*See:Using SIMULINK Pages:3-3*You can get the Signal Generator from the Sources library. Likewise, pull the Gain block from the Linear library and the Scope block from the Sinks library. All you need to do is double click on the block library and then drag the blocks that you need into the new untitled model window.See:Using SIMULINK Pages:3-4*See:Using SIMULINK Pages:3-15 to 3-19*See:Using SIMULINK Pages:3-33, Appendix B**This dialog box is as important to the success of your simulation as anything in the block diagram. It controls the major simulation parameters that are responsible for propagating your system through time. See:Using SIMULINK Pages:4-6 to 4-18*It is very important to understand the settings that you put in here. For instance, create a new model with a Signal Generator that feeds into a Scope. The Signal Generator frequency should be 1 Hz. Now set the stop time of the system to be 50 seconds, use a variable step solver with a max step size set to auto. What do you expect to happen? It is probably not what actually happens. What actually happens is that you get an almost completely flat line at 0. This is because your max step size will be 50/50 or 1 second. Your frequency of the Signal Generator is 1 Hz (or 1 cycle per second). That means that your output will be very close to zero for the entire simulation.See:Using SIMULINK Pages:4-6 to 4-12c*It is possible to get data into and out of models using a number of different methods. If you use the Parameters Dialog Workspace I/O page to do this for you, then the top level of your SIMULINK diagram must contain an appropriate number of inports and outports.See:Using SIMULINK Pages:4-14 to 4-16*The MATLAB workspace is a cauldron into which anything can be dumped including SIMULINK data.See:Using SIMULINK Pages:3-12*Why simulate from the command line? This is a good question. Essentially the answer is that if you want to run repeated simulations and not have to wait around to run the simulation again and again then simulation from the command line is probably what you want. Also, if you are varying parameters ina model and analyzing the results from the variations, then it is much easier to set up a for loop to step through each parameter automatically.See:Using SIMULINK Pages:4-21 to 4-28