12.07.2015 Views

Developement Of An Instrument Landing Simulation ... - Cal Poly

Developement Of An Instrument Landing Simulation ... - Cal Poly

Developement Of An Instrument Landing Simulation ... - Cal Poly

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorial #2: Speed of Sound TutorialThis tutorial introduces the user on how to link Matlab Simulink block diagrams with multiple inputs andoutputs to C-source code, as well as becoming familiar with the S-Function format.Introduction:This tutorial is similiar to Tutorial #1 except now we are going to have multiple inputs and outputs for theS-Function. The goal of this tutorial is to create a model that reads 4 inputs: gamma, R, Temp, and velocity;then calculates the speed of sound and Mach number and displays them in the Simulink window. To do thisyou will need to develop a subsystem (seeMach.mdl).A subsystem is necessary whenever there are multiple inputs and outputs or when you are developing amodel. This allows the entire simulation diagram to become less cluttered and easier to follow. Thesubsystem icon can be found in the Simulink library under connections. Basically, when you doubleclickon a subsystem, it gives you a new Simulink window.<strong>An</strong> S-Function that has multiple outputs and inputs needs a Multiplexer (MUX) and DeMultiplexer(DEMUX). The MUX and DEMUX icons can be found in the simulink library under connections. Thisbasically allows the input and output to be in array form. Each of the inputs and outputs must be assigned toa port. You can specify the number of ports by right clicking on the MUX and DEMUX and selectingparameters. The input and output ports can be found in the connections toolbox as well.Once we have the model set up, we need to develop the S-Function. This time, instead of copying the codedirectly, you're going to write each line of the code and achieve a simple understanding of the S-Functionformat. Look at speed_sound.c. This file is a little cleaner in comparison to timestwo.c but is still of thesame form. Go over the code, and look at the comments. The comments show you where variables aredeclared, where the number of inputs and outputs are determined, where the inputs and output arrays arefilled, and where the computation occurs.Once you have finished writing the code, repeat the process you did in tutorial #1 to generate the dllnecessary for run time. Other important files to look over to try to understand the S-Function formatare:simstruc.h , simulink.c , and sfuntmpl.doc .58

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

Saved successfully!

Ooh no, something went wrong!