05-05-2015 08:18 PM
Hey guys. I am having a problem using a dll built in labview in my C code. I first made a labview program that read analog current signals from 7 analog pins and stored them in an array. I then have a variable which is the index you want to locate (Each time the function is called I want to read only one current value from the array) and then put this current value into a numeric indicator which is the output I want.
It worked fine in labview, but after I build a DLL from it and call the function in my c code it always returns 0 instead of the reading of the pin. Even when I put constant values in the array, when I call the function I still get 0. I also made a labview program that just returned a constant number when run, and when I built that into a DLL and called the function in my C code it still only outputted 0.
I am very confused how this is happening. I have connected the numeric indicator to the connector pane and when I build the DLL it claims I am getting a function which is:
double Test1(double Index)
Where "double index" is the index of the array I want to read out, and the return value is the numeric indicator which contains the value at that index.
I call the funcition in my C code like so:
#include "SharedLib.h" //This is the header file for the DLL. I also include to .lib, .ini, .alias and .dll files
#pragma comment(lib, "SharedLib.lib")
double i=0; //just for an example I am accessing the 0th index of the array, which I set to a constant value
values= Test1(i); //this will always return 0, regardless of what the index is
I guess my major question is how is it possible to get the function from the labview built DLL to run in the C code but only eery return 0? I can show you all my Labview code, but as I have tried multiple functions to try to get a non-zero value to no availI think I am missing something else that is not regardng the actual labview code. Thanks so much!
Solved! Go to Solution.
05-05-2015 08:38 PM
05-06-2015 02:44 AM - edited 05-06-2015 02:44 AM
Aside from defning the index as an integer as Dennis pointed out, it would be helpful to attach the actual code (both the LabVIEW project and VI to create the DLL as well as your C code). From what you describe there seems to be something you do that is different than what you tell us.
05-06-2015 05:57 PM
The Indexing with a double seems to be ok in Labview. I did figure out the problem though. The labview functions were in fact working, I was just printing incorrectly. I was being really stupid and my printf statement was printf("%d",value) not printf("%lf, value) which is what you need for doubles, and it caused it to always print out 0. Thanks for you ur help though guys,