LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass a value to a dll under labview

I have to build a dll under cvi and use it under labview. my problem is to pass a value to this dll from labview.
But when I use it, labview return an error code and close the software...
I can return value from the dll to labwiew but not the contrary. can you help me please.
I am a beginner and I am sorry for my english...
0 Kudos
Message 1 of 11
(3,526 Views)
Hello /*draven*/,

in most of these cases the settings for the Calling-Convention, the datatypes or pointer<->value are wrong. Please check the settings in the CallLibraryFunction - dialogbox and compare the generated "Function - Prototype" with your dll - sourcecode.

hope it helps

chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 11
(3,526 Views)
Thanks for your answer!!!!!!!!!
I don't think it's a calling convention beceause When I use the box "call a dll" in labview and I select my dll, I can see all functions I have create in the dll (just the extern functions). for the datatype, I use int or unsigned int and sometimes char. and I can receive this value in labwiew...

but for the pointer that's certainly my problem
this is the sourcecode of my function. I drive a digital to analogue converter and I want to select the exit (There is 4 exit 0x00,01,10,11 )and a voltage (0 to 255 in décimal):
void __stdcall dac_sortie_tension (int sortie, int tension)
{
outp(LPT1+0x000,4); /* not important*/
outp(LPT1+0x400,sortie);
outp(LPT1+0x000,2); /* ecriture de l'adresse2*/

outp(LPT1+0x400,0x00); /* not important*/
outp(LPT1+0x000,3); /* not important*/
outp(LPT1+0x400,tension);/*write voltage*/
}
if I use a constant to "sortie" & "tension" it's OK...
I try to use this:
void __stdcall dac_sortie_tension (int *sortie, int *tension)
but it's the same...
0 Kudos
Message 3 of 11
(3,526 Views)
Hi

Sorry, i don't want to annoy you:
have you selected the correct calling convention in the "call dll" - dialog? the default for a new node is "C", but you must use "stdcall (WINAPI)" for your function declaration.

Bye
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 4 of 11
(3,526 Views)
Hey don't be "sorry"
I thank you for your answer and I hope you can continue to Help me!!!!
I don't understand "annoy " can you explain please.
for my problem I try your solution. that's not OK but the software haven't close!!!
in progress!!!!
I have see that:
when I select the fonction in labview, I can see them
but there isn't argument' ("sortie" & "tension") and I have a void like this:
void fonction (void)
what is the problem..
I can give argument to the function but there aren't used...
0 Kudos
Message 5 of 11
(3,526 Views)
sorry arguments are ok...

I use the pointer to exit and voltage
"*sortie" a "*voltage"...
it is good?
0 Kudos
Message 6 of 11
(3,526 Views)
/*draven*/ wrote:

> but for the pointer that's certainly my problem
> this is the sourcecode of my function. I drive a digital to analogue
> converter and I want to select the exit (There is 4 exit 0x00,01,10,11
> )and a voltage (0 to 255 in décimal):
> void __stdcall dac_sortie_tension (int sortie, int tension)
> {
> outp(LPT1+0x000,4); /* not important*/
> outp(LPT1+0x400,sortie);
> outp(LPT1+0x000,2); /* ecriture de l'adresse2*/
> outp(LPT1+0x400,0x00); /* not important*/
> outp(LPT1+0x000,3); /* not important*/
> outp(LPT1+0x400,tension);/*write voltage*/
> }

Unless you run on Windows 9x or ME you cannot use outp or inp at all. An
application is not allowed to access hardware directly under any Windows
NT type version as well as Lin
ux and other modern OSes. It will simply
generate a general protection fault error and in LabVIEW 6.1 and higher
this will result in a LabVIEW dialog telling you to shutdown LabVIEW.
Before LabVIEW 6.1 you get a Windows dialog not even giving you the
chance to choose if you want to restart LabVIEw.

If you try to do this under Windows NT/2000/XP/2003 you need a device
driver to access those ports. LabVIEW comes already with the according
functions called InPort and OutPort in the Advanced function palatte.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 11
(3,526 Views)
Hi rolfk!
thanks for your answer

I have Windows 2000 pro.
under cvi I can access to parallele port!
I can control led relay d.a.c. & a.d.c. and a little electrical motor.

my problem is on the passage of a value to a dll from labview...
can you help me please 🙂
0 Kudos
Message 8 of 11
(3,526 Views)
/*draven*/ wrote:
> Hi rolfk!
> thanks for your answer
>
> I have Windows 2000 pro.
> under cvi I can access to parallele port!
> I can control led relay d.a.c. & a.d.c. and a little electrical motor.
>
> my problem is on the passage of a value to a dll from labview...
> can you help me please 🙂

Well use the InPort.vi and OutPort.vi VIs from the Advanced->IO Port
palette. They use the CVI port IO device driver you use in CVI. No need
to have a DLL at all to do port access.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 9 of 11
(3,526 Views)
/*draven*/ wrote:

> my problem is on the passage of a value to a dll from labview...
> can you help me please 🙂

And the function you show for sure can't have many possible problems in
parameter passing. I mean what can you possibly configure wrong with two
numeric integer values?

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 10 of 11
(3,526 Views)