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

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

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

Tutorial #1: Times Two TutorialThis tutorial introduces the user on how to link Matlab Simulink block diagrams with C-source code.Introduction:Matlab links source code to simulink diagrams using the S-Function. The S-Function is found in thesimulink library under the non-linear toolbox. Refer to the simulink model below (xtwo.mdl) to see howthe S-Function is used within a Simulink block diagram. Notice that the input goes into the S-Function andthe output comes out of the S-Function (simple right).The diagram is simple however the code is not. Look at the C-File source code shown below (timestwo.c).For a simple program that reads in one value, multiplies that value by two, then returns it becomes quitecomplex. For now, don't get too discouraged about figuring out the code. The objective of this tutorial is tolearn how to link simulink block diagrams with C-Source code. The next tutorial is to actually understandthe code.Steps:When performing these steps, don't just copy the model but actually draw the simulink diagrams.Remember this is a tutorial for your own benefit.1. Create a directory for you to practice your tutorials in.2. Create a simulink block diagram similiar to xtwo.mdl.3. Name the S-Function. Right click on the S-function to get the parameters window. NOTE: Make sure theS-Function has a different name then the simulink model.4. Copy the timestwo.c to your tutorial directory. Look over the code and become familiar with it'sstructure. Find where the S-Function is defined. Make sure that this name is the same as the one that youused earlier in step 3. Find where the input is multiplied by two then returned.56

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

Saved successfully!

Ooh no, something went wrong!