Importing DLLs from PSIM and Twin Activate

In PSIM and Twin Activate, you cannot generate code for Arduino, Raspberry Pi, STMicroelectronics, and most Texas Instruments microprocessors. You can, however, create DLLs from PSIM schematics and Twin Activate diagrams and automatically import those DLLs as blocks into Embed. Imported blocks can be used in a block diagram like any other Embed block. However, they are particularly useful for PIL and HIL testing on a microprocessor. For annotated examples of HIL testing with imported blocks, go to Examples > Blocks > Extensions > Imported Blocks.

To perform HIL testing with imported blocks:

1.    Follow the directions in the Twin Activate documentation or PSIM documentation to generate a DLL and export it as a block to Embed’s Imported Blocks menu.

2.    Start Embed.

The newly-generated PSIM or Twin Activate block appears in the Imported Blocks menu.

A screenshot of a computer error

Description automatically generated

3.    Open the Embed diagram in which to insert the imported block.

4.    From the Imported Blocks menu, insert the imported block you generated. Note that PSIM generated blocks have _Taskn appended to the block name to differentiate them from other blocks generated from the same schematic.

5.    Wire the imported block into the Embed diagram.

6.    To verify that the imported block is operating correctly, wire a plot or display block to the imported block and simulate the diagram. Signal values from the imported block are displayed in the plot or display block.

7.    Connect the hardware device you are using to your computer.

8.    Add the necessary hardware-specific target blocks — such as, the Target Config block and peripheral blocks — to the diagram.

9.    Encapsulate the imported block in a compound block.

10.  Click Tools > Code Gen.

11.  In the Code Gen dialog:

a.    Select the target and subtarget for the hardware device you are using, if they are not already selected.

b.    Activate Use selected compound edge pins for data exchange.

c.     Press Compile.

12.  From Embedded > target-from-step11a > Target Interface, insert a Target Interface block into the diagram.

13.  Replace the compound block that contains the imported block with the Target Interface block.

14.  Click System > System Properties > Range and activate Run in Real Time.

15.  Click Go to simulate the diagram and execute the code on the target device.

16.  Compare the simulated results in step 6 with the HIL results in step 15.