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.
Calling DLL from Profilab
Calling DLL from Profilab
- Dateianhänge
-
- RELAYDLL-DevC++ source.zip
- (11.63 KiB) 400-mal heruntergeladen
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........
-
- Beiträge: 22
- Registriert: Dienstag 21. Oktober 2008, 18:18
Re: Calling DLL from Profilab
Hallo PowerSoft
The Answer is simple
See the Sample.
Best regards
Karsten
The Answer is simple
See the Sample.
Best regards
Karsten
- Dateianhänge
-
- RELAYDLL-DevC++ source.zip
- (11.29 KiB) 377-mal heruntergeladen
Re: Calling DLL from Profilab
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
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 ........
-
- Beiträge: 22
- Registriert: Dienstag 21. Oktober 2008, 18:18
Re: Calling DLL from Profilab
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
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) 367-mal heruntergeladen
Re: Calling DLL from Profilab
Hello,
Thanks for the help.
I had no idee that you had changed the source code.
It was great and helpfull.
Jan Kromhout
Hellevoetsluis-NL
Thanks for the help.
I had no idee that you had changed the source code.
It was great and helpfull.
Jan Kromhout
Hellevoetsluis-NL
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........
Re: Calling DLL from Profilab
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]; //????????????????????
}
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 ........
Re: Calling DLL from Profilab
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
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 ........