LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting data pointed to by a pointer into an array

The vi I use returns a pointer to a block of data. The data are unsigned 16-bit integers. Without using a for..do loop, how do I convert the data into an array for input into an intensity graph?

(Note that I presently use a for...do loop that works by incrementing the pointer by 2 bytes each time. But it  takes much time and I want to eliminate using a loop in labview. I suspect built-in functions/using DLLs would be much faster. But I do not know how to go about doing it.)

Thank you for your help.
0 Kudos
Message 1 of 9
(2,969 Views)

Hi,

The vi I use returns a pointer to a block of data  Smiley Surprised  Can you show how a VI returns a pointer

Without using a for..do loop   Smiley Surprised  Why ?
 
I want to eliminate using a loop in labview   Smiley Sad  Again why ?
 
I suspect built-in functions/using DLLs would be much faster  What dll's ?
 
 
Perhaps if you show us the VI things get clearer

Message Edited by K C on 03-09-2006 08:31 AM

0 Kudos
Message 2 of 9
(2,955 Views)
Hello Balakumar,

is the pointer just the offset into your data array? In this case you should use "Index Array". Just calculate the correct index from your offset (you said "2 bytes each time")
like index = 2*offset and grab the two bytes from the array (you can change the IndexArray to give you more than one output, look at the help).
 
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 9
(2,948 Views)

Hi Balakumar,

> The vi I use returns a pointer to a block of data.

If by "pointer" you mean a memory address, then I think you're DLL idea is right on track.  You could efficiently cast (sort of) the pointer into an array.

The attached .zip contains some VIs that may give you some ideas.  In LabVIEW, open the application builder and load CVTDLL.bld.  It compiles CVTDLL.vi into CVTDLL.dll.  CVTDLLCaller calls the DLL - passing it the pointer and returning an array.  The magic will happen in the way the pointer parameter is passed from the VI to the DLL.  I think we need the CLF to think it's supposed to be passing a U32 value, where the DLL thinks it receiving a pointer to an array.  Then it's just a matter of passing the data back out.  There are a bunch of forum contributors who could get this right the first try - "smercurio" and "RolfK" come to mind.

I hope this isn't yet another case where I'm way off track! Smiley Tongue

cheers.
When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 4 of 9
(2,943 Views)
Hi All,

Thank you for your response. However, the problem is unsolved for two reasons:

 1. I could not open Dynamik's vi as it was version 7.1 while the labview I run is a 7.0 (would you please post a version I could open?)

 2. I did not post my vi the last time around: I am remedying this problem by posting my vi. I have marked the location where the pointer is input along with the nested for...do loop that i would like to eliminate.

Any help would be appreciated.

Thank you,
 Bala
0 Kudos
Message 5 of 9
(2,923 Views)
Gentlemen,

 I have solved this issue finally. The vi that did the job is attached with this email for reference.

 I eliminated the nested for...do and used built in functions (along with functions from convrzun.llb available for download from ni.com) and this is much faster. Earlier, it took about a minute to read the data from the camera and convert it into a display. Now, it takes about a second to do the same operation!

Thanks again for your prompt responses,
 Bala
0 Kudos
Message 6 of 9
(2,917 Views)

Hi Bala,

Thanks for the follow-up.

Looking at the posted VI, "GetMemory_byPtr.vi" looks like the one.(?)  It's missing on my machine, but you've provided plenty of search info - I'm gonna chase this down to see how it's done.  That's quite a time savings! 

Thanks/Cheers.

 

When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 7 of 9
(2,912 Views)
Hi Dynamik,

 I am posting the pointers.llb and convrzun.llb files that are required to run the above vi along with this email for completeness.

Bala
Download All
0 Kudos
Message 8 of 9
(2,898 Views)
[a belated] Cool, Thanks!
When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 9 of 9
(2,879 Views)