Simcenter Amesim Model exchange (AME2SL) between MATLAB Simulink and AMESim with MinGw 64bit compiler (Battery management control Example)

Simcenter Amesim Automation Connect Simcenter System Simulation Client for Git Simcenter Amesim Teamcenter Share



This is one more method by which you can import the AMESim model into the Simulink.  In this case, Both AMESim and Simulink models will use Solver set in the Simulink. Hence, the user must take extra care while selecting the solver in Simulink. 

Pre-requisite: -
  • AMESim along with Simulink interface Add On to generate the S function.
  • MATLAB Simulink license
  • After S-function generation, you do not require the AMESim license, but you will at least require the AMERun license to run the 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 Simcenter 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 AMESim model will be exported as Simulink S-function. This S-function will be imported into the Simulink. In this case, Both AMESim and Simulink Model will use only Simulink solver. You can use either a fixed or variable Simulink solver. It is the user's responsibility to select the optimum solver, which will lead to the converged solution.

Step to follow AME2SL Simulation
  • Open AMESim Model.
  • In Sketch Mode, Right-click on the Interface icon, then select “Edit Interface icon”
  • Change the “SimuCosim” option to the “Simulink” option.
  • Ensure that the gcc64 bit is set as your active compiler.
  • Compile and save the AMESim model.
  • Now, you can close the AMESim. AMESim is not needed now.
  • Before closing AMESim, Launch Simulink from AMESim, so that, the requisite path will be added in MATLAB.
  • Follow the below process, if, you are not launching MATLAB from AMESim.
  • Open Simulink Model (.slx) file in Simulink.
  • Delete AME2SLCosim block from this model.
  • Go to the AMESim folder. Right-click on the .ame file and select the “Explode Model” option. Ensure that, you can see the _. mex64 file after this explode.
  • Add AME2SL block in Simulink model.
  • Double click on the AME2SL clock.
  • Click on the “Open Folder” icon and browse the _mexw64 file.
  • You can change the AMESim global parameter from the Simulink interface itself. To do this, click on the spanner icon.
  • You can change the Simulink solver as per your requirements.
  • Connect the AME2SL block properly and start the simulation.
  • Wait till the simulation finishes.
  • You can see the results in Simulink now.
CLICK HERE to download the Demo File

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 “Import MATLAB Simulink Model to AMESim (SL2AMECOSIM) using MinGW 64-bit 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# KB000046491_EN_US



Associated Components

Amesim Automation Connect