LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

allocating 2d array in labVIEW and passing it to DLL function to get data

Solved!
Go to solution

Hello Everyone!

 

I have been searching a lot in this subject but a can't find any solutions. Please find attached the vi i am trying to get data from a 32 channel device,

100000 samples per channel with 14-bit resolution. And please also find attached the header file for my dll.(in the header it is the GetBuffers function).

It is not much data, it is little more then 6 MB but in the Task Manager LAbVIEW eats about 30 MB more memory then it should. Is there any explanations why?

Because there would be much more data in one channel(million samples or more)

 

So i am trying to preallocate a 2D array for the data but when i am trying to execute my vi LabVIEW crashes.

 

Could you help please?

 

Best regards,

Tomzi

Download All
0 Kudos
Message 1 of 5
(2,677 Views)
Solution
Accepted by topic author Tomzi

Dear Tomzi!

 

To allocate data for an array in LabVIEW, you always have to initialize it, as in to have a you have to have a valid input on cell (x-,y-1) to have an array size of (x,y). It's usually best to use the Initialize Array function for this purpose.

 

There are to ways of passing  2D arrays to DLLs, you cand find examples of both in Examples > Communicating with External Applications > Using External Code > Integrating DLLs > Call DLL.vi. Basically, LabVIEW can only pass 2D arrays as a big 1D array, so you'll need to pass the array size too properly index it. If you pass 2D array handles it's best to use the typedef that LabVIEW generates for you, something along the lines of 

/* LabVIEW created typedef */
typedef struct {
	int32 dimSizes[2];
	double elt[1];
	} TD1;
typedef TD1 **TD1Hdl;

Hope this helps.

 

Best regards:

 

Andrew Valko

NI Hungary

Andrew Valko
National Instruments Hungary
Message 2 of 5
(2,659 Views)

 

Yes, i helped a lot! Thank you very much. I did not now i have to make a huge 1D array to pass data. I hope this will solve my problem.

I'll try it let you now the results!

 

 

Best regards,

Tamás Szabolics

0 Kudos
Message 3 of 5
(2,654 Views)

Your suggestion solved my problem thank you very much!

 

Best regards,
Tamás Szabolics

0 Kudos
Message 4 of 5
(2,643 Views)

Glad to be of assistance. Best of luck with your application!

 

Regards:

 

Andrew Valko

 

Andrew Valko
National Instruments Hungary
0 Kudos
Message 5 of 5
(2,641 Views)