Simcenter Amesim Export the AMESim model Blackbox to MATLAB Simulink using GNU MinGW gcc x64 bit compiler (Battery management control model)

2021-07-12T04:28:19.000-0400
Simcenter Amesim Automation Connect Simcenter System Simulation Client for Git Simcenter Amesim Teamcenter Share

Summary


Details


Summery
There are limitations on which libraries can be used in the Simcenter AMESim model. A list of libraries compatible with Black Box Export is given in the section Black-Box compatibility in the help file.
  1. The ASBB is limited to the Simulink interface using the Simulink solver - it is not applicable when using the Simcenter AMESim-Simulink co-simulation.
  2. By design, it is not possible to generate code (e.g. with the Simulink Coder) from a Simulink model containing a Simcenter AMESim Black Box. In particular, it is not possible to export this model to a real-time target. The Black Box option is only intended for running the model within the Simulink environment with all dependencies to Simcenter AMESim removed.

Pre-requisite  -
  • AMESim base with required libraries along with Simulink Blackbox Add-on.
  • MATLAB Simulink license
You will require the AMESim license to generate the Blackbox. After generation, you will not require any AMESim license to run the AMESim model in Simulink.
We will again use the same demo with some required changes. In this case, the AMESim model will be imported into Simulink as a Blackbox in this case both models will use the Simulink solver.

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.

Step to follow AME2SL Simulation
  • Open the AMESim Model.
  • In Sketch Model, Right-click on the Interface icon, then select the “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.
  • Go to Interfaces >>> Generate AMESim-Simulink Black box. It will open another window. Click on Generate button to generate the Black box file.
  • After this, you should able to see “Modelname_.mex64” and “Modelname.mex” file in the directory. “Modelname.mex” is file related to BlackBox.
  • Before closing AMESim, Launch Simulink from AMESim, so that, the requisite path will be added in the MATLAB.
  • Open the 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.
  • 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.
  • To generate the Black box, click on the last Black icon “Create BlackBox Mask”. This will open the new Masked model in another Simulink file.
  • Copy this masked part, and paste it into the original model, where, you will have to replace the AME2SLCOSIM block with this masked model.
  • You can change the Simulink solver.
  • Run the model.
  • You can use the scope to view results in Simulink.
CLICK HERE to download the 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 “Import MATLAB Simulink Model to AMESim (SL2AMECOSIM) using MinGW 64-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# KB000046493_EN_US

Contents

SummaryDetails

Associated Components

Amesim Automation Connect