Difference between revisions of "SIMarchitect Tutorial"

From OpenMBD
Jump to: navigation, search
(Creating a model)
Line 1: Line 1:
This Tutorial elaborates and demonstrates the interface of SIMarchitect and functions as a step-to-step guide for creating a simple model. This section is intended for first time users.
+
This Tutorial elaborates and demonstrates the interface of SIMarchitect and functions as a step-to-step guide for creating a simple model. This section is intended for first time users. A fully worked-out example is found in SIMarchitect. From Start-Up, select Open Example. The other option is to build the example using the guide below.  
  
 
== Creating a model ==
 
== Creating a model ==

Revision as of 14:15, 15 February 2019

This Tutorial elaborates and demonstrates the interface of SIMarchitect and functions as a step-to-step guide for creating a simple model. This section is intended for first time users. A fully worked-out example is found in SIMarchitect. From Start-Up, select Open Example. The other option is to build the example using the guide below.

Creating a model

To create a new model in SIMarchitect, the first step is to open MATLAB®. Navigate to the path in which the SIMarchitect.m file is located (root of SIMarchitect) and in the Command Window, type SIMarchitect and press enter (Command is case-sensitive). An initialisation occurs: Initialisation of SIMarchitect succesfull Please type 'SIMarchitect' to start. Here, type SIMarchitect and press enter to start the programme. After first-time use, it is necessary to enter the command only once.

SIMarchitect Startup.jpg

Now SIMarchitect will load libraries and directories. A prompt will appear at every new startup of SIMarchitect asking to save a new path. Click 'Yes'

Next, the SIMarchitect Start Figure appears. Click on 'Create New Model' and save the model to the desired location.

SIMarchitect start figure.jpg

A new model in the SIMarchitect environment is opened. An SIMarchitect model has several unique features. Starting with the 'Component Blocks', which are inside the green area. These three blocks are part of every SIMarchitect model:

  • Test: This is where the test protocol is modelled. All variables and parameters related to testing the system are to be placed here.
  • Control: The control system is to be placed here. The control system controls the response between the test input and the plant model response.
  • Plant Model: The plant model is the model of the system which is simulated.

SIMarchitect new model.jpg

Next, the components inside the red area. This is the main connector. The main connector is the point where all signals of the model are merged into one data bus, which can be used to analyse results. The desired signals can be selected in the 'Output Selector' by double-clicking on this block. The signals selected here are saved to the data bus and MATLAB® workspace for analysis.

Finally, the components inside the blue area. These components are the 'Parameter Settings' and the 'Results Plot GUI'. The parameter settings are a way to define parameters of each sub-component. The results plot GUI is a fast way to plot results for analysis.

Building a simple model

The next step to modelling in SIMarchitect is to build a simple module.

For this tutorial, let's model a simple equation: y = a * x + b with:

  • a = 2
  • b = 5

All modelling in this example will be done in the 'plant_model'component. The plant model sub-component contains all modules related to the plant model. In this case, the equation is the plant model. First, add an empty_module from the SIMarchitect Library. This difference between and empty_module and empty_component is that the first can be assigned a parameterfile and the latter cannot.

Advgenlib.jpg

Double click on the module to type in the related parameter file.

Newparafile.jpg

Next, rename the parameterfile to 'experiment'. This ensures that the empty_module searches for a .m file called 'experiment'. As this file has, not yet, been created, we will do that now.

Navigate to the top-layer of the simulation model and double-click on the 'Parameter Setting' subsystem. This opens the window seen below. First, check the 'Location for Parameterfiles'. This is were the model searches for the parameterfiles. This should be in the location where the example model was created, inside a folder called 'parameterfiles'. Now, we will assign the parameterfile to the component. Expand the plant_model tree under 'Select Module' and select 'empty_module'. Then, under the 'Select Parameterfile' heading, click 'Browse'. This opens a window in the specified location. This window contains the file 'empty_module_default.m', which is placed by default when a new empty_module is added to a model. Rename this file to 'experiment.m' and click open. Now the parameterfile selected is 'experiment'.

Parameterpromptwindow.jpg

In the parameterfiles window, click 'Edit'. This opens the .m file in which all the parameters are stored for this example. There are no parameters defined yet, so that is the next step. Delete the unnecessary information in the file, to keep a clear overview. Also, in the commented section, fill in the filename 'experiment.m'.

Fill in all of the necessary parameter of the module inside the parameter file, together with the connection information. For this tutorial, a and b are the parameters so these must be defined inside the parameter file. Use a = 2 and b = 5. Then, in the 'Connection Information' fill in the values seen in the figure.

Experimentmfile.jpg

Next, create the simulation model. Navigate to the plant_model and rename the empty_module to 'experiment'. Then open the 'experiment' component. To do this, click on the small arrow located on the lower left of the module block. The text in the centre of the model is a description on building in SIMarchitect. This can be deleted when read.

There are two sides of the module which represent the input port and the output port:

  • Left side (orange ports): All of the input signal to the module
  • Right side (Green ports): All of the output signal from the module

Important to know: In SIMarchitect styling, signals between input->model, and model->output are connected with 'go-to' and 'from' blocks instead of lines. This is shown in the figure below. Build the model as seen in the figure, and name the output signal (to 'con_o') appropriately.

Modelexperiment.jpg

Finally, connect the input signal to the module by selecting the appropriate signal in the bus selector prompt. Do this by navigating up one level, and double-clicking the black rectangle on the input port of the experiment module. This opens the bus selector window. For this step, we will use 'one' as an input, but signals from the whole model can be entered to use as an input.

Busselectorexp.jpg

All of the signals available in the simulation, which are connected to the main bus connector, are displayed in the signal in the bus box and connect the signal according to the order of the connection inside the module if the module requires more than one inputs.

Plotting simulation result

Navigate to the top-layer of the simulation model. Double-click the 'Output Selector' block to select which signals are going to be displayed in the 'Results Plot GUI' function.

Outputselect.jpg

For this tutorial, choose plant_model -> experiment -> y. This is the output of the plant_model.


The result simulation can be viewed by using the 'Results Plot GUI' function.

PlotGUI.jpg

All selected signals are seen in the right-hand panel. Double-click to plot the signals in the selected graph.

To view more signals, connect more parts of the plant_model to 'goto' and 'from' blocks, and connect these blocks to the bus (output of plant_model). Name these signals and select in the output selector. These signals are also sent to workspace with the name 'data_set' and in a structure data-type.