Simcenter Prescan Import MATLAB Simulink Model to AMESim (SL2AMECOSIM) using MinGW 64 bit compiler. (Battery Management Control Example)

Prescan Teamcenter Share Simcenter Prescan Marketing


By using this method, you can import the AMESim model into Simulink.  In this case, the AMESim model will use AMESim Solver and the Simulink model will use the Simulink solver. Please note that MVC++ compiler is must to use this interface


By using this method, you can import the AMESim model into Simulink.  In this case, the AMESim model will use AMESim Solver and the Simulink model will use the Simulink solver. Note the below important points
  1. For SL2AMECosim, please note that once the Simulink model has been imported into Simcenter AmesimSimulink is not needed anymore for running the simulation (and no Simulink license either).
  2. In SL2AMECosim, the embedded Simulink solver is always of type fixed-step. Simulink model referencing is supported.
  3. Without any Visual compiler on the machine, you won’t be able to use the SL2AMECosim script (i.e. to compile the Simulink DLL).
  4. However, the SL2AMECosim import submodel that is also generated by this script and that acts as a wrapper on the top of the Simulink DLL can be compiled with MinGW (and use the DLL compiled with MSVC).
  5. Hence, You may be able to use the Simulink DLL with the MinGW compiler in AMESim.
  • MVC++ compiler is a must on your system. Without this compiler, you will not able to use the sl2amecosim interface seamlessly.
  • Simulink coder license to generate the Simulink lib of the Simulink model.
  • AMESim license to build the model.
  • After this, you may not need AMESim, but, at least the AMERun license to run the AMESim Model.
Short description of Demo

The electrical vehicle is gaining popularity and it is seeing as a technology of the future. Battery pack design is playing very important from the safety and performance point of view. Generally, a separate Battery management control unit is used to manage the performance of the battery. MIL, SIL, HIL, etc method is generally used to verify the algorithm and logic of the Battery management control unit. Simulink is generally used as a graphical language for coding of most of the electronic control units.  In this demo, a simplified BMC for battery cell balancing control algorithm is developed in Simulink; the model of the battery pack is implemented in Simcenter AMESim. By coupling between AMESim and Simulink, one can verify the effectiveness of code in the design stage. AMESim can be coupled with Simulink in several ways. In this demo, we will see “How AMESim can be coupled with Simulink to verify your control unit logic”. AMESim model is giving voltages of various cells as an output. This output is sent to the Simulink model. At every time step Simulink processes this output and give the optimum command to each cell so that cell balancing can be achieved.

How do I select the interface I need?
  • There is no single answer to this question. The answer depends on many things. There are Simcenter Amesim systems that are difficult or impossible to solve using the Simulink solver. If this is the case, then the user needs to select co-simulation. This means that both the sim center Amesim and the Simulink solvers will be used and that each one will be responsible for its part.
  • Sometimes the Simulink system is very complex and importing it into Simcenter Amesim is probably not the best solution as it will enforce the use of a Simulink fixed-step solver, which sometimes is not suitable.
  • In addition to the technical reasons, one must also consider what the model is to be used for. If the main purpose is to test/develop the Simcenter Amesim model, it might be the best strategy to import the Simulink model into Simcenter Amesim. If the main purpose is to test/develop a controller in Simulink with a physical model written in Simcenter Amesim obviously it is a better idea to work in Simulink.
  • In many cases, one person develops the Simulink model, and another develops the Simcenter Amesim model. The person responsible for integrating the models will obviously prefer to work in "his" environment.
  • There are some obvious "rules": if the Simulink model is small and the Simcenter Amesim model is large, you would put the Simulink model into Simcenter Amesim. If access is required to unique features in Simcenter Amesim you would also put the Simulink model inSimcenter Amesim. If there are special features in MATLAB® /Simulink that you need to use, you would put the Simcenter Amesim model into Simulink.
We will again use the same demo with some required changes. In this case, the Simulink model will be exported to AMESim. In this case, Both AMESim will use AMESim Solver and Simulink Model will use imported Simulink solver. Simulink solver will be exported along with Simulink model.
A screenshot of a cell phone  Description automatically generated
Step to follow AME2SL Simulation
  • Open the Simulink model.
  • Copy the BMS control-related part into some other file. Let say the filename is “BMS.slx”
  • Connect the input and the output port.
  • Save the Simulink model.
  • Go to MATLAB and run the below command “sl2amecosim (‘.slx file name’ , ‘Directory path’, ‘auto’)
    • In this case, the command will be
    • Sl2amecosim(‘BMS’, ‘Directory path’, ‘auto’)
  • This will generate the “lib” folder in the Simulink working directory. This folder will be used by the AMESim to access the Simulink model.
  • Open AMESim and add a directory path in the category path list. This will add the Simulink model file to the path list.
  • Now, you should able to see the Simulink model as a part of your library tree.
  • To build the model, delete the interface block and replace it with the Simulink submodel.
  • Set the same solver as in the Simulink while exporting so that you will not face the convergence issue.
  • Run the model and now you can watch the results in the AMESim
CLICK HERE  to download this demo model

If you are interested to know the other method of cosimulation with Simulink, then please visit below VIDEO articles.

CLICK HERE to know about “Cosimulation between Simulink & AMESim (AME2SLCosim) using MinGW-w64 (gcc 64 bit) compiler
CLICK HERE to know about “Model exchange (AME2SL) between MATLAB Simulink and AMESim with MinGw 64bit compiler
CLICK HERE to know about “Export the AMESim model Blackbox to MATLAB Simulink using GNU MinGW gcc x64 bit compiler.
CLICK HERE to know about “FMU/FMI - Export a cosimulation FMU from the AMESim & Import it in the Simulink
CLICK HERE to know about “FMU/FMI - Export a Model Exchange FMU from the AMESim & import in the Simulink
CLICK HERE to know about “Import MATLAB Simulink FMU to AMESim

If you still need support or clarification, then click here to raise the case on the support portal.


KB Article ID# KB000046492_EN_US



Associated Components

Documentation Installer License Software