AmesimKnowledge

Using the Simcenter Amesim to Simulink Interface

Constructing the model in Simcenter Amesim

Figure 1: The model in Simcenter Amesim

The process of constructing the Simcenter Amesim model is described with the help of a simple example. You will understand the process better if you create and run the system yourself. The exercise can be completed within about an hour.

Create the system shown in the figure above, calling it skyhook. It consists of two masses connected with a spring which represent a quarter car suspension.

Note

  • Two transducers determine the positions of the wheel and the car body.

  • Connected to the wheel is a spring to which the road profile is applied.

  • The system is incomplete with six ports unconnected.

Figure 2: The Simcenter Amesim model with the interface block

The force representing the damping in the suspension will be provided by Simulink and the output from the velocity transducers will be sent to Simulink. To scope the displacement in Simulink, two outputs from displacement transducers are sent to it. Finally, the road profile is provided by Simulink.

To complete the system it is necessary to add a special Interface icons interface icon. The figure above shows this block added to the system.

Figure 3: First step in creating the interface icon

To create the interface blocks, click on the Interface block pulldown menu shown in the previous figure. This menu is designed to be used with the Simulink interface and other interfaces but in our case it will be Simulink. Select the item labeled Create interface block. This is used to define the variables which are provided and received by the companion software. From Simcenter Amesim these variables are seen as inputs and outputs respectively. The dialog box shown in the following figure is produced.

Figure 4: Interface Icon Creation dialog box

There are currently no input or output variables. By selecting the arrow buttons in the top corners, the Interface icons specifying number of inputs number of input or Interface icons specifying number of outputs output variables can be adjusted. You can have any number including 0 but a reasonable upper limit is 10. If you want more than this, it is better to use more than one interface block. In our example, we require two input variables and one output variable, so ensure that the fields have the values 4 and 2 respectively.

The next stage is to get Simcenter Amesim to create a specific icon for the interface. The number of ports is now specified but it is also necessary to add a label to each port. To do this, we will add text to give a name to the variables. In addition, we will give a general name for the whole interface block. The following figure shows text added in this way. Select each field and type an appropriate text string. In this example, we select the “model exchange” interface (AME2SL). This implies that the Simcenter Amesim model will be exported without its solver. If you want to perform co-simulation, you should select the AME2SLCosim interface type.

Figure 5: Specifying the interface block

Note the three buttons labeled Clear all text, OK and Cancel.

  • Click on Cancel to abandon the process.

  • Click on Clear all text to remove any text you have entered.

  • Click on OK to obtain the icon produced by Simcenter Amesim.

An icon similar to that shown in the following figure will appear. Note the port position is denoted by >.

Interface icons adding to sketch

Figure 6: The completed interface block

The pointer will take on the appearance of the icon and can be treated like a normal Simcenter Amesim component icon. Thus it can be mirrored, rotated, deleted or added to system sketch. All Simcenter Amesim interface blocks have signal type ports.

Connect the block inputs and output to the other components of the model as shown in Figure 2.

It is worth mentioning the following important points:

  • You can have more than one interface block but if you do, they must all be of the same type (all Simulink standard interface blocks in the current example) - See Using more than one interface block.

  • the Simcenter Amesim AMESim model model must be explicit. In other words, there cannot be any implicit variables, unless the co-simulation interface is used.

  • Input and output variables to and from Simulink cannot be vectors.

  • Each interface icon is limited to 99 ports to keep the size of the icon reasonable.

Note

In most cases, models containing interface blocks cannot be run as they are. However, it can be useful to perform some basic checks such as open-loop simulations to see if the configuration of your model is correct; for example to check whether it can locate all its resources (typically tables) and that it initializes correctly. See section Open-loop simulations for basic model checks for more detail on this topic.

Now switch to Submodel mode. The interface block will automatically be associated with a special submodel and you are not allowed to change these. For the other submodels select Premier submodel so as to get the simplest submodels.

Figure 7: Compilation to create the S-Function

Next, change to Parameter mode. Normally Simcenter Amesim would create an executable program that you would start in Simulation mode. However, because the system contains Simulink interface blocks, an S-Function is created. The normal System Compilation produces S-Function System Compilation window should appear (as in the previous figure) and you should enter Parameter mode. If any errors occur, it is likely that the MATLAB environment variable is not properly set. In this case save the system, exit from Simcenter Amesim and carry out the instructions for setting this variable as described in Common requirements.

You might also get an error message if you select an incompatible architecture/compiler, for instance GNU GCC (32-bit) whereas MATLAB only supports 64-bit. To check which compiler is being used, go to Tools > preferences:

Figure 8: Simcenter Amesim preferences

On the Compilation tab, make sure a suitable 64-bit active compiler is selected: either one of the available versions of Microsoft Visual C++, or the 64-bit version of GNU GCC (Mingw64), distributed with Simcenter Amesim, that can be used with MATLAB R2018a or above.

In order to change parameters of the Simcenter Amesim model from Simulink, a set of global parameters must be created. These parameters will be accessible in Simulink and will be able to be modified independently of Simcenter Amesim.

Create the following set of global parameters:

Real global parameters
Name Title Unit Value Minimum Default Maximum
Bodymass Mass of a quarter car kg 400 0 400 1e+06
Wheelmass Mass of one wheel kg 40 0 40 1e+06
Suspspring Suspension spring N/m 15000 0 15000 1e+06
Totalmass Total mass kg Bodymass +Wheelmass 0 440 2e+06
Submodel name and type Belongs to category Main simulation parameters
Property definition
MECMAS21 1D translation mass Mechanical mass[kg] = Bodymass
SPR000A-1 ideal linear spring Mechanical spring rate [N/m] = Suspspring spring force with both displacements zero [N] = 9.81*Bodymass
MECMAS211D translation mass Mechanical mass [kg] = Wheelmass
SPR000A-2 ideal linear spring Mechanical spring force with both displacements zero [N] = 9.81*Totalmass spring rate [N/m] = 200000

Warning

When you change from Parameter mode to Simulation mode, special data files containing the parameters are written. When you run the S-Function within Simulink, these files will be read. Therefore when you change any parameters, make sure you enter Simulation mode. If not, your changes will not be seen by Simulink.

At this point, you are ready to run the Simcenter Amesim model within Simulink. To do so, use the Tools > Start MATLAB menu from Simcenter Amesim. In this case the MATLAB Current Directory and path are automatically set to the directory where the Simcenter Amesim model is stored, ensuring that the MATLAB environment is the same as for Simcenter Amesim.

The MATLAB path is automatically updated to point to the directory where the currently-used Simcenter Amesim is installed.

  • In the normal way, use the Tools > Start MATLAB menu from Simcenter Amesim. In this case the MATLAB Current Directory and path are automatically set to the directory where the Simcenter Amesim model is stored, ensuring that the MATLAB environment is the same as for Simcenter Amesim.

  • Right-click on the interface block and select Launch Interface. The following dialog box appears:

Select Simulink and click OK. As indicated previously, the MATLAB environment is automatically set.

  • Start a simulation run (F7). The Select Action dialog box opens as above. As indicated previously, the MATLAB environment is automatically set.

  • The MATLAB path is automatically updated to point to the directory where the currently-used Simcenter Amesim is installed.

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Simulink/Constructing_the_model_in_AMESim · retrieved 2026-07-17