Export an Embed Block from Twin Activate

Export generated code both for simulation and inclusion of generated code in Embed for target deployment purposes.

Attention: Available only with Twin Activate commercial edition.

Prerequesites 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.


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 this tutorial, a standard Twin Activate demo is used, but the process should be the same across any other diagrams. A super block can be exported as a Embed Block if the contents are supported by the inlined code generator. An exhaustive updated list of blocks supported by the inlined code generator can be found in Extended Definitions.
  1. In a Twin Activate diagram, select the super block to be exported.
  2. Select Tools > Code Generation and Export.
  3. 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.
  4. 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.
  5. Open a command prompt and change the directory to the Visual Studio Build folder.
  6. Set up the compiler environment. For example, for 64-bit Visual Studio, call vcvars64.bat x64.
  7. Change directory to the code generation output directory, and then call make.bat.
    If there are no errors, the invocation of the make.bat produces a dll that can be further registered in Embed.

Add the DLL to Embed

After the DLL has been created, add it to Embed as an addon.
  1. Open Twin Activate Embed.
  2. Select Edit > Preferences.
  3. Open the Addons tab, and then double-click ... at the bottom of the list.
  4. Browse to the location of the DLL you created in the export steps, and then select it.
    The DLL is added to the bottom of the Addons list.
  5. Select the DLL from the list, and then click OK.
    The new block is added to the Blocks menu.

    You can use the new block for simulation and code generation.