Using the External Library Block
This tutorial explores the possibility to use a Library Built as x64 DLL on windows in Simba. To describe this feature, this tutorial is based on an example of a buck chopper controlled by a C-code block. Both files can be downloaded above.
The whole process used in this tutorial is described in the figure below:
Description of the C-code file
Here, the .DLL library is generated from a .C file which performs current control and voltage control loops of the considered buck chopper.
Get the .DLL library
The .dll library which is considered here has been built with gcc compiler which can be downloaded from this official website.
Type the following commands in a terminal:
x86_64-w64-mingw32-gcc.exe -D SIMBA_EXTERNAL_LIB_EXPORT -c library.c -O3
x86_64-w64-mingw32-gcc.exe -shared -o library.dll library.o
Note
The library must export the functions defined in simba_library.h
Pick the external library block from the control library
Th external library block can be dragged an dropped from the control library.
Define the parameters of the external library block
Then, let's define:
- the number of inputs and outputs; in this case, the .C file that generated the .DLL library considers 3 inputs (clock, i_L current and V_o output voltage) and 1 output (the duty cycle).
- the .DLL file location.
Run the simulation file
The design is ready! Let's run the simulation !