Customization > SySim- SysML model execution > Working with the example SySim models > Working with the speed controller model (SySim)
  
Working with the speed controller model (SySim)
The Speed Controller model is provided in the Examples database, which you can install with Modeler.
The SysML model models a system that controls the speed of a motor. Through the SySim model execution you can set the demanded speed, set the applied load, and validate how the system responds to achieving that demanded speed and the current required to do so:
The demanded speed is set through the slider control and the demanded value is shown on the graph through the pink line.
The current motor speed is shown on the meter and on the graph through the white line.
The applied load is set through the knob and the set value is shown on the graph through the red line.
The current being drawn by the motor is shown in the LED display and on the graph through the yellow line.
When the brake is applied to slow down the motor, the red LED is illuminated.
The model contains a ReadMe text diagram that provides information about the model.
The SySim Simulators package in the model contains two SySim Simulation Scenarios:
The Speed Controller simulation scenario makes no use of Simulink.
The Speed Controller Using Simulink simulation scenario uses a referenced Simulink model to define processing.
If you expand the simulation scenario you want to use and open its Internal Block Diagram, you can see the SysML Blocks, SySim Control Blocks, Ports and Connections that are involved in the SySim Simulation Scenario.
The SysML Components package contains the SysML blocks that are being validated:
The SMController block is used by both SySim Simulation Scenarios.
The Electric Motor block is used only by the Speed Controller simulation scenario.
The Electric Motor In Simulink block is used only by the Speed Controller Using Simulink simulation scenario.
The SySim Custom Controls package contains the FourInputsGraph SySim control block, which is a customized control based on the provided PTC provided Graph SySim control block. This customized graph displays the values of four inputs, whereas the PTC provided Graph control displays the value of only one input.
Speed Controller simulation scenario
To generate the Visual Studio project and build the SySim model execution for the Speed Controller SySim simulation scenario, follow the generic tasks provided in the 'Generating and Building a SySim Model Execution' section of this Help. To open the first task of this section, refer to Setting up Microsoft Visual Studio to work with SySim
Note that you can ignore the 'Setting up the SySim model execution form' task, because this form's design has been stored in the model, and you can ignore the 'Building the Simulink shell' task.
To start the SySim model execution application and work with the SySim Control Bar, follow the generic tasks in the 'Working with a SySim Model Execution' section of this Help. To open the first task of this section, click here Setting up Microsoft Visual Studio to work with SySim
Note that there are no useful state diagrams to simulate in the model.
Speed Controller Using Simulink simulation scenario
The Electric Motor In Simulink block references a Simulink model named SimpleInput3 through the tagged value of its SySim SimulinkModelPathName tag definition, which is applied by the «SySim SimulinkBlock» stereotype. The SimpleInput3.mdl model has been created using version 2011a of Simulink; if you are using a later version of Simulink, Simulink will create a back up copy of the SimpleInput3.mdl model and messages will appear in the SySim log.
To generate the Visual Studio project and build the SySim model execution for the Speed Controller Using Simulink simulation scenario, follow the tasks provided in the 'Generating and Building a SySim Model Execution' section of this Help. Note that you can ignore the 'Setting up the SySim model execution form' task, because this form's design has been stored in the model. Refer to Setting up Microsoft Visual Studio to work with SySim to open the first task.
To start the SySim model execution application and work with the SySim Control Bar, follow the tasks in the 'Working with a SySim Model Execution' section of this Help. Note that there are no useful state diagrams to simulate in the model.
Step by step instructions for simulation of the Speed Controller model with Simulink
1. Copy the SimpleInput3.slx file from the Modeler installation folder (Modeler\ItsShadow\SySim\Simulink\Exe) to the MATLAB home directory (usually C:\Users\<user name>\Documents\MATLAB).
2. Open the Speed Controller model in Modeler from the Examples repository.
3. Find the block named Speed Controller Using Simulink.
4. Right click that block and select SySim-PTC Integrity Modeler SySim. SySim will open. In SySim, click the More Options button.
5. In SySim click the Open Simulink Models button. This requires time as Simulink can be slow to start.
6. Simulink opens the SimpleInput3 model but (the very first time) it is not able to find the “shell” model as it has not been built yet. Consequently, SySim returns an error in the Preparation Tasks pane. This error is displayed by design.
7. In SySim, click on the Build Simulink Shell button and wait the operation completes (Build Successful is displayed in the Preparation Tasks pane).
8. Click on the Open Simulink Models button again. This time Simulink opens both models, one is called TheMotor, the other is SimpleInput3 (the same as before).
9. The next step is a necessary preparation of the Simulink models so they both match the word size of the actual Simulink version.
a. If Simulink is an x64 edition:
a. In the Simulink model editor for model TheMotor, click Simulation-Model Configuration Parameters, then select Hardware Implementation, set the Device Type to x86-64 (Windows64)” (It might be necessary to click on the “Enable Hardware Definition” button). Press OK then save the model.
b. In the Simulink model editor for model SimpleInput3, click “Simulation-Model Configuration Parameters”, then select “Hardware Implementation”, set the Device Type to “x86-64” (Windows64)” (It might be necessary to click on the “Enable Hardware Definition” button). Press OK then save the model.
b. If Simulink is an x86 edition:
a. In the Simulink model editor for model TheMotor, click “Simulation-Model Configuration Parameters”, then select “Hardware Implementation”, set the Device Type to “x86-32” (Windows32)” (It might be necessary to click on the “Enable Hardware Definition” button). Press OK then save the model.
b. In the Simulink model editor for model SimpleInput3, click “Simulation-Model Configuration Parameters”, then select “Hardware Implementation”, set the Device Type to “x86-32” (Windows32)” (It might be necessary to click on the “Enable Hardware Definition” button). Press OK then save the model.
10. In SySim, select a suitable version of Visual Studio, then press the Make Model Executable And Run button. The simulation is generated, built and run (This step requires some time). The SySim executable simulation form is displayed (caption = “Speed Controller Using Simulink”), but the Simulation Start/Resume button is not enabled as the Simulink simulation has not started yet.
11. Go to the Simulink TheMotor model. Set the simulation duration (a textbox in the toolbar of the Simulink model editor, which default value is usually “10.0”) to 1000, then (still in the Simulink model editor) click the “Run” simulation button. Simulink compiles the model and runs it.
12. In Modeler, show the State Simulation toolbar and click the Run State Machine button in a way it is in the pressed state.
13. In the SySim executable simulation form (caption = “Speed Controller Using Simulink”), the Simulation Start/Resume is now active. Press it and the co-simulation will run.
14. Move the input controls such as the speed and the load and see the speedometer moving.