LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to return 2D arrays from a DLL function using functional panel

Hello,
I have an instrument which measures two values in pairs (level and delay). The amount of pairs are fixed to 25 in each query. Handling of measured values could be easiest to be done in 2D arrays in further processing. My problem is how to return an array from an intrument driver DLL function using functional panel in definition of the function.
My goal is to use the same DLL function from the TestStand, with other words, query the measurement results from the TestStand.
Best Regards,
Petri
0 Kudos
Message 1 of 4
(3,560 Views)
Hello,
The data from the instrument is like below, where four first values represent delay (=one value in decimal) and four last values level (=one value in decimal). It could be easy to point to a table which has two columns and several rows. How to return this table, or a pointer to that, using function panel in definition of the function ? I have to use function panel to convert source code to DLL VISA instrument driver.
/Petri

.
.
.
a6 4a 75 43 00 00 48 c2
fc 87 76 43 00 00 48 c2
51 1d 77 43 00 00 48 c2
a6 aa 79 43 00 00 48 c2
fc 8f 7b 43 00 00 48 c2
fc 17 7d 43 00 00 48 c2
51 75 7d 43 00 00 48 c2
a6 ea 7e 43 00 00 48 c2
a8 7a 80 43 00 00 48 c2
53 19 81 43 00 00 48 c2
a8 e6 81 43 00 00 48 c2
a8 c6 82 43 00 00 48 c2
a8 52 83 43 00 00 48 c2
.
.
.
0 Kudos
Message 2 of 4
(3,533 Views)
Hello Petri!

Here you have the reply + example program I got from an AE in the US:

"It took a couple steps to accomplish returning a 2D array with a function panel. First, I am not clear if he would like the function panel to allocate the memory of if it should be allocated by the calling program. As LabVIEW works best went the array is allocated on the LabVIEW side, I have built the attached fp/project so that the main() function allocates the memory.

To reproduce this project you will need to:

1) Select "Options>>Data Types" while editing the function panel
2) Add a datatype called Array2D and leave it as Intrisic Datatype: None. This will allow us to define our own type for the variable.
3) Add this line to the headerfile to define the Array2D variable:

typedef int Array2D[25][2];

This defines a 25x2 array like the customer needs. Note: This is an array of ints, as it appears from the customers second post that what he really have is a 2D array of 16-bit integers.

After this the fuction panel should function as expected, allowing you to define variables from the panel, etc."

Regards,
Jimmie A.
Applications Engineer, National Instruments
Regards,
Jimmie Adolph
Systems Engineering Manager, National Instruments Northern European Region

0 Kudos
Message 3 of 4
(3,442 Views)
Thank's !

In a case of DLL instrument driver, I suppose the memory allocation is best to do in calling program, like TestStand.

/Petri
0 Kudos
Message 4 of 4
(3,390 Views)