Você está na página 1de 7

TUTORIAL: CRIANDO DLLs NO PSIM

1 PASSO:
Ir at o diretrio onde est instalado o PSIM, abrir a pasta custom dll;
Abrir o arquivo dll-rms e salv-lo em uma pasta, por exemplo teste.

2 PASSO:
Abir a pasta msvc_dll e copiar o arquivo msvc_dll.c para a pasta teste.

3 PASSO:
Abrir o programa visual-c++, e criar um novo projeto

4 PASSO:
Dar um nome para o projeto e escolher a opo Win32 Project.

Clicar ok

Clicar em next.

Em Application type selecionar a opo DLL e na opo Additional options selecionar Empty
Project e clicar em Finish.

5 PASSO:

Ir ao menu Project e selecionar a opo Add existing item...

Selecionar o arquivo msvc_dll.c e clicar em add.

6 PASSO

Um duplo clique no arquivo msvc_dll.c abrir o arquivo de exemplo dado pelo PSIM, o qual deve ser
usado como referncia para as variveis a serem usadas. preciso lembrar que:
You need to have the following variables :
t: Time, passed from PSIM, by value
delt: Time step, passed from PSIM, by value

in: input array, passed from PSIM, by reference


out: output array, sent back to PSIM (Note: the values of out[*] can be modified in
PSIM)
The function name has to be __declspec(dllexport) void simuser (t, delt, in, out).
You may change the variable names (say from "t" to "Time"). But DO NOT change the
function name, number of variables, variable type, and sequence.
The maximum length of the input and output array "in" and "out" is 30.
Global variables above the function simuser (t,delt,in,out) are not allowed!!!

7 PASSO:
No menu Build selecionar a opo Build teste.

Agora a dll j esta criada.

8 PASSO:
Para testar o funcionamento da DLL preciso copiar a DLL criada para o diretrio onde esta o arquivo
dll-rms.sch, o mesmo est no diretrio teste/Debug/teste.dll.

Aps copiar o arquivo e colar no diretrio teste junto ao arquivo dll-rms.sch.

Abrir o arquivo dll-rms.sch do psim, dar um duplo clique no bloco DLL e na caixa File name
alterar o nome de test_msvc_dll.dll para teste.dll. Rodar o programa no psim e verificar o funcionamento
da dll.

Você também pode gostar