Tutorial: Export an Embed Block from Twin Activate
Export generated code both for simulation and inclusion of generated code in Embed for target deployment purposes.
Prerequisites for This Tutorial
The following software is required for this tutorial:
- Altair Twin Activate
- Altair Embed
- Visual Studio Compiler for compiling generated code from Twin Activate and to create an Embed block.
Overview
One of Twin Activate's code generation options is to export the generated code both for simulation and inclusion of generated code in Embed for target deployment purposes. This tutorial captures the overall steps to set up and achieve a working setup for such a design flow.
Embed provides standard block APIs to define the block behavior for simulation and code generation. The code generation option Embed Block leverages these published APIs to automatically wrap the generated code from Twin Activate.
When creating a simulation diagram in the Twin Activate diagram, you can easily test the generated code in a target environment. The code is target agnostic and optimized, leveraging the inlined code generation option. Embed supports more than 1200 microcontroller targets. You can include the needed target specific drivers and schedule for execution using the visual interface from Embed. You can also customize the RTOS behavior and Software/Hardware Interrupt scheduling in Embed for testing in Processor In the Loop and Hardware In the Loop configurations.
Export an Embed Block
- In a Twin Activate diagram, select the super block to be exported.
-
Select
from the menu ribbon.You can also right-click on the super block and select Code Generation and Export.
-
Set Target to be Embed Block. Set
Processor to 64 bits or 32
bits, depending on your Embed installation. Select the
Embed installation path and your desired
Output directory. Set the other name fields as
necessary.
-
Click Generate.
In the output directory, you now have the following files:
- Body.c: A C file that provides the implementation of the actual super block.
- Body.h: Header file containing the function definition for the implementation in the Body.h.
- main.cpp: Embed Block Specific Wrapper with the Body.h file to include the relevant generated code from Twin Activate. The file contains functions leveraging the Embed Block API for simulation and code generation.
- make.bat and make.sh: Contains
the relevant make process for the generated code.Note: Based on the Embed installation, relevant libraries (Vissim32.lib/Vissim64.lib) are referenced for linking.
- [DLL name].def: Exported functions for the current
diagram.Note: In the example from the above screenshot, this file name is Block_From_Activate.def.
- [DLL name].dll: Compiled model for Embed.
Twin Activate Block in Embed
In Embed, you can find the new block in
.You can use the new block for simulation and code generation.