Y = dll(filename,functionname,X);
Given a function (functionname) of a dll (filename), the dll function returns the output values (X) for a given input (Y).
Users can write their own source code using a native compiler such as Visual C++ or Borland C++. With these compilers it is possible to create DLL’s with user defined functions that have an input- output relation which can be embedded in simulation code.
string filename = 'example.dll';
string function = 'myFunction';
x = [ramp(1);ramp(2)];
y = dll(filename,function,x);
filename and functionname must be string parameters. Note that the size of Y and X (scalars or matrices) must correspond with the size that is expected for the given dll-function.
20-sim uses the following search order for the dll-file:
|1.||The bin directory of 20-sim (usually C:\Program Files\20-sim 4.6\bin).|
|2.||The current directory.|
|3.||The Windows system directory.|
|4.||The Windows directory.|
|5.||The directories that are listed in the PATH environment variable.|
The simplest place to put the dll-file is the bin directory, but it is always possible to give a complete path for the dll filename.
20-sim allows for code generation of the 20-sim model. In case of a DLL call, 20-sim cannot generate the complete code for a DLL call since it only knows the DLL file name, function name and arguments and not the internal DLL code.
Therefore, in the generated code, the dll(dll_name, function_name, in) will be generated as:
%dll_name%_%function_name%(double *inarr, int inputs, double *outarr, int outputs, int major)
Where %dll_name% and %function_name% are replaced with the actual DLL and function name. You have to add the C-code implementation of this function yourself to the generated code before you can compile it.