Using MathWorks™ Simulink Coder® to Export a Simulink Model to a Twin Builder C-Model DLL
This section describes how to export a Simulink model to a Twin Builder C-Model using MathWorks Simulink Coder. Simulink Coder generates the model based C-code, the Twin Builder C-interface functions, and the necessary makefile for Microsoft Visual C++. After the C-code generation, Simulink Coder calls the compiler and generates a ready-to-use Twin Builder C-interface DLL for a Twin Builder model library.
Twin Builder uses Simulink models directly, without co-simulation. The exported models run standalone directly in a Twin Builder environment. Communication with Simulink is not necessary.
Features and Limitations
There are target entries in the Simulink Coder system target list for exporting to a Twin Builder target.
- You can export the Simulink model to a Twin Builder C-Model Target. That target will work with fixed step size. The maximum integration step size in Twin Builder is fixed by the sample time. You can use more than one instance of the model, exported to that target in one Twin Builder sheet. For the Twin Builder C-Model target, no Simulink license is necessary. The model runs without Simulink because the Simulink integration solver is also exported, and built into the model itself.
- Simulations run completely in the Twin Builder environment. The models have no step delay, and performance is much better than with the Simulink co-simulation interface.
- Because Simulink models don't have separate AC or DC behavior; the exported model works only for transient simulation in Twin Builder.
- All ports must be scalar of
type=double. Vector or complex ports are not supported. - Data transfer to the DLL can only be performed through input and output interface ports. Variables defined in the original Simulink model will not appear as quantities on the generated model, and cannot support S-Functions that call MATLAB such as Twin Builder's co-simulation S-Function block (AnsoftSFunction).