RSS
email

How to use PSIM dll

This time we will learn how to use dll block in PSIM. Other software we need is C/C++ Compiler such as Borland, Dev, MinGW, etc.. You can get it free by searching on Google. In this tutorial we'll use free distributed MinGW C Compiler.

On MinGW window, click Project and select New Project as shown in the picture below!


After the following window appear, select Win32 Dynamic Link Library. Choose your Project name for example 'test' and store it on D:\test\. Test is our folder on drive D:\ which will contain PSIM file, *.dll, and c code.


Run PSIM program and open 'custom dll' folder in the PSIM example. Select dll-rms.sch and save as on folder D:\test\.. You can save it as test.sch or another. Copy msvc_dll.c from custom dll file to D:\test\.

On MinGW window, right click Source File and click Add Source files to project as shown below.


Open D:\test\ and click msvc_dll.c.

After that, click Source File and double click msvc_dll.c. C code will appear on your MinGW screen like the picture below. Now build or compile it. If use MinGW you can prees F7 button on your keyboard as a shortcut to build it.

Now let us back to PSIM and double click DLL block to change its name. Type test.dll.

If you succeed to compile your c code, there will be debug folder. Open it and copy paste test.dll file to test folder as shown picture below.


Finally, run PSIM you'll get simulation result as shown below. You can create your own dll block for example PI control in dll or another.
Good Luck!

Bookmark and Share

4 comments:

Aditya said...

Hi, we are trying to set up a DLL block for our PSIm model. But the problem is that it keeps giving an error message saying Unable to access the function "RUNSIMUSER" in DLL file:
project1.d
Our project code is

void __declspec(dllexport) simuser (double t, double delt, double *in, double *out)

{
double aa=0, bb=0, cc=0;
a=aa;
b=bb;
c=cc;

a=sqrt(2/3)*(in[2])*(cos(in[0]));
b=sqrt(2/3)*(in[2])*(cos(in[0]-0.2122));
c=sqrt(2/3)*(in[2])*(cos(in[0]+0.2122));

out[0]=a;
out[1]=b;
out[2]=c;

aa=out[0];
bb=out[1];
cc=out[2];

}

We've tried to troubleshoot this , but it keeps giving us the same error.

Herman Fernández said...

Change simuser word for RUNSIMUSER:
RUNSIMUSER (double t, .......................................)

Herman Fernández said...

_declspec(dllexport)
void RUNSIMUSER(double t,..............................)

Herman Fernández said...

_declspec(dllexport)
void RUNSIMUSER(t, delt, in,.........)

Post a Comment

 

Friends