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..."
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..."

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 1 of 4
(2,253 Views)
/*draven*/;

You need to configure the function manually. Once you select the dll and select the function, select the button Add a Parameter After. You can change the name of the parameter to sortie, keep the Data Type as long and then change the Pass field to Pointer to Value. Click again the Add a Parameter After button and do the same for the your variable "tension".

For more information about calling external code in LabVIEW, refer to the following document (which should be also included with LabVIEW):

Using External Code in LabVIEW

Instructions on-line are here:

An Overview of Accessing DLLs or Shared Libraries from LabVIEW

Check also examples here:

Communicating with External Applications

Regards;
Enrique Vargas
www.visecurity.com
www.vartortech.com
Message 2 of 4
(2,253 Views)
Thank You enrique
I just finish to test your solution and...

IT'S GOOD!!!!!!!!!!!!!!!!!!!!!!!

thank you for all!!!!!!!!!!!!!!!

good bye!!!
0 Kudos
Message 3 of 4
(2,253 Views)
data types is long and pass field is pointer to value
0 Kudos
Message 4 of 4
(2,253 Views)