Calling DLL from Profilab

Antworten
PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Calling DLL from Profilab

Beitrag von PowerSoft » Montag 10. Oktober 2011, 19:06

Hello,

As starting to make an own DLL I choose to construct a Relay.
There are 5 inputs. One for setting the relay on/of, and 4 inputs.
The switch is doing with an if statement.

if INput[5] > 2,5 then
{
// activate relay
}
else
{
// deactivate relay
}

Simple I copy the input[] to an output[], but this is'nt working.
Should a save the old status when leaving the dll?

Can someone help me with this simpleblock.
I include the profilab model and the source file for the DEV compiler.

Thanks allot.
;)
Dateianhänge
RELAYDLL-DevC++ source.zip
(11.63 KiB) 260-mal heruntergeladen
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

weisskarsten
Beiträge: 22
Registriert: Dienstag 21. Oktober 2008, 18:18

Re: Calling DLL from Profilab

Beitrag von weisskarsten » Montag 10. Oktober 2011, 21:28

Hallo PowerSoft

The Answer is simple
See the Sample.

Best regards
Karsten
Dateianhänge
RELAYDLL-DevC++ source.zip
(11.29 KiB) 242-mal heruntergeladen

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: Calling DLL from Profilab

Beitrag von PowerSoft » Dienstag 11. Oktober 2011, 05:17

Thanks for the quick answer.

That is precisely the problem.
I have carefully studied the example, then this routine was written.
The only thing I'm not sure , do I need the PUser [] to save the old status of the signals?

Thanks allot for the help

Jan Kromhout
Hellevoetsluis-NL
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

weisskarsten
Beiträge: 22
Registriert: Dienstag 21. Oktober 2008, 18:18

Re: Calling DLL from Profilab

Beitrag von weisskarsten » Dienstag 11. Oktober 2011, 08:21

Hallo
I'm not sure that you mean.
I have change the Example again. Every Time then you press the Butten the Signals change on the Output.

Best Regards
K.Weiss
Dateianhänge
RELAYDLL-DevC++ source_1.zip
(11.51 KiB) 235-mal heruntergeladen

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: Calling DLL from Profilab

Beitrag von PowerSoft » Dienstag 11. Oktober 2011, 15:50

Hello,

Thanks for the help.
I had no idee that you had changed the source code. :o
It was great and helpfull.


Jan Kromhout
Hellevoetsluis-NL 8-)
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: Calling DLL from Profilab

Beitrag von PowerSoft » Dienstag 11. Oktober 2011, 19:11

Hello,

It is not reactiong like a relay.
I modified the model with only one input(analog) and two outputs(anolog) and one binary select.
It is the same layout as the relay in PL. I include my code
What is going wrong?

Thanks in advance.
Jan kromhout
Hellevoetsluis-NL

//Aufruf von PROFILAB,hier steht die eigentliche Funktion der DLL
//
DLLEXPORT void _stdcall CCalculate(double *PInput, double *POutput, double *PUser)
{
int i;
if (PInput[1] > 2.5) // Push button=high?
{
if (PUser[1] < 2.5) //??????????????? why
{
if (PUser[2] > 2.5) //Relay is activated
{
POutput[1]=PInput[0]; // Relay is activated A1=high,A0=low
POutput[0]=0;
PUser[2] = 0;
}
else // Relay is deactivated A1=low, A1=high
{
POutput[0]=PInput[0];
POutput[1]=0;
PUser[2] = 5; ??????
}
}

}

PUser[1] = PInput[0]; //????????????????????
}
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: Calling DLL from Profilab

Beitrag von PowerSoft » Montag 7. November 2011, 21:16

Hello,


After long testing and writing code it is still not working.
This simple code of the relay has two states depends on the value of SEL.
The realy has two outputs A0 and A1

In plain english I can write

if SEL=0 then
A0=E (=5 Volt)
A1=0 (=0 Volt)
else //SEL=5 Volt
A0=0 (=0 Volt)
A1=1 (=5 Volt)
end if

In C is this no problem for me, but I can get it work with the variable PInput,POutput and PUser.
Please can someone help me with this simple realy, so I have a better understanding how the DLL is working.

Thanks in advance.

Jan Kromhout
Hellevoetsluis-NL
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

Antworten

Zurück zu „DLL-Programmierung“