Running a Test model

Navigation:  Installation >

Running a Test model

Previous pageReturn to chapter overviewNext page

To test if the installation was successful, we will run an example model in 20-sim and generate C-code that will be transferred to 20-sim 4C to run on your target. The model is called Test.emx and has no external inputs or outputs.

Exporting the 20-sim Model to 20-sim 4C

1.From the Windows Start menu open 20-sim.

2.In 20-sim load the model C:\Program Files\20-sim 4C 2.1\examples\20-sim\Test.emx.

Note: For 64-bit Windows versions the location is: C:\Program Files (x86)\20-sim 4C 2.1\examples\20-sim\Test.emx. If your version of 20-sim 4C is installed on a different location, please use the correct path.


The model Test.emx loaded in 20-sim.

The 20-sim model Test.emx contains one submodel (named Test).

3.Select the submodel Test and from the Model menu select Go Down.


The submodel Test contains a block diagram model with no external inputs or outputs.

As you can see the submodel Test is a block diagram model of a first order system which contains no external inputs or outputs.

4.From the Model menu select Start Simulator.

Now the 20-sim Simulator opens showing an empty plot.

5.In the Simulator from the Simulation menu select Run to run a simulation.

You should see a stepwise change in the setpoint signal and a first order response of the system.


The simulation results for the model Test.emx.

We will generate C-code from this model and run it on a target.

6.In the Simulator, from the Tools menu select Real Time Toolbox and C-code Generation. The C-code Generation dialog will pop-up.

7.Select the 20-sim 4C target. Make sure it looks like the figure below (in 20-sim 4.1 multiple targets may be shown). If the 20-sim 4C target is not shown, please check the troubleshooting section.


The C-code generation menu in 20-sim.

8.Click on the Submodel button SubmodelButton and select the submodel Test. The C-code Generation dialog should look like:


The C-code generation menu in 20-sim.

Note that a default location for the C-code files is given in the Output Directory field: C:\temp\20sim-4C\%SUBMODEL_NAME%, where %SUBMODEL_NAME% will be replaced by the submodel name. If you want to use a different location, please enter it here.

9.Click the OK button to close the dialog.

Now the model will be exported to 20-sim 4C as C-code. All code files are stored in a temporary folder. A dialog may appear asking you to create this folder.


The folder for temporary code files.

10.Click Yes to create the folder (or go to step 7 to enter another directory).

If everything works fine, 20-sim 4C will be opened, with the Test model loaded:


20-sim 4C with the Test model loaded.

If an error occurs and 20-sim 4C does not open, please check the troubleshooting section.

20-sim 4C Settings and Monitoring

We will now enter the settings to get the model running on your target and choose the variables that we would like to monitor.


1.Click on the Configure button Configure_Target_Button.

2.Click on the Select button, select the proper target and click OK.

The next picture shows as an example the ARM7300 - Torsion Bar v2.0 target.


Select the proper target.

20-sim 4C will now start a search to find the IP-addresses of connected targets:


Finding the IP-address.

If a firewall is installed, a warning message may pop-up:


The Windows firewall message when the Refresh button is clicked.

3.Click the Allow Access button (Windows 7) or the Unblock (Windows XP, Windows Vista) button (or a similar button if another firewall message is shown) if the name of the program is 20-sim 4C and the publisher is Controllab Products B.V.

4.Optional: Press the Discover button on the Configure Target tab to manually repeat step number 3.

5.Optional: You can change the target name and IP-address manually for your target using the Edit button.


Changing the target name and IP-address manually.

6.Click on the Apply button.

If everything was installed and connected successfully, the Configure button Configure_Target_Button should turn into green configure_target_button_green.


The configuration was entered successfully.

If the Configure button has turned to red configure_target_button_red please check the Troubleshooting section.


7.Click on the Connect button connect_button_orange.

8.Our model does not have external inputs or outputs that we have to connect so click the Apply button.


9.Click on the Compile button compile_button_orange to compile the generated code into an executable.

The Compile button should turn into green compile_button_green when the compilation process is successfully finished. If it has turned into red compile_button_red please check the Troubleshooting section for help.


Our model has no external inputs or outputs. To make sure its runs properly we have to monitor its internal variables during running. That is why we will first choose the variables that we will monitor and then run the model.

10.In the tree-view at the left side of the 20-sim 4C windows click Variables. It will expand showing the available submodels

11.Click on the Step submodel.

Now a list of two parameters (amplitude and start_time) and one variable (output) should be visible.


The list of parameters and variables of the submodel Step.

The variable output has two gray dots (Mon and Log) at the left. You can click these dots to select the variable for monitoring or logging.

12.With your mouse pointer go to the variable output and click on the gray dot to select it for monitoring.

20-sim 4C should now look like:


The list of parameters and variables of the submodel Step.

Now we will choose a second variable for monitoring.

13.Click on the Gain submodel and select the variable output for monitoring.

To see all variables that have been chosen for monitoring, you can view a Monitor Selection.

14.In the tree-view click Run and then the tab Monitor Selection.

Now 20-sim 4C should look like:


The list of monitored variables.

Now we will configure the run settings, open a monitor plot and start to run the model on the target:

15.Select the Configure Run tab and click on the Apply button to accept the default settings for this run experiment. The Run button Run_Button_orange should become green Run_Button.



By default, 20-sim 4C will use the same settings as used in the 20-sim simulator. On the Configure Run tab, you can change for example the Finish time for your model.

16.Click on the Monitor button Monitor_Button to open a plot window.

17.Click on the Run button Run_Button to start running the model on the target.

Now you should see the following plot after 10 seconds of running. The plot shows a stepwise change in the setpoint signal and a first order response of the system.


The monitored variables, shown in a plot.

If your results are similar, 20-sim 4C is properly installed and your target is properly working. If the plot results are not similar but some other variable is shown in the plot, check if the correct variables were chosen for monitoring (hint: check the Monitor Selection tab of step 14).