From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing array by reference into a cluster between subvis

I'm modifying the Continuous Measurement and Logging sample project to work with a new device.

 

During the hardware setup, one of the driver functions sets up an array in memory where the samples will be stored (this is done once, at the beginning). The acquisition loop calls a get_streaming_values functions, that asks the board for the new values so that the array now stores the acquired samples.

 

The problem is that I have to pass the array from the configuration subvi to the acquisition one in such a way that I can get updated values during every iteration of the acquisition loop.

I cannot directly add the array as a new element into the Hardware Resources cluster because this way I would copy the value of the array just after the hardware setup (which initializes it to all zeroes) so I was thinking about some C-like pointer reference/dereference operations.

 

Is there any better/suggested way?

0 Kudos
Message 1 of 5
(2,617 Views)

As long as the Configuration VI is the only place updating the array, I would just use a Global Variable.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(2,567 Views)

Is the driver a DLL? Does it accept a memory buffer as a parameter that it stores, initializes and writes to? If you want to share a memory buffer with a DLL, it's probably best to do this in C and write some interface code for Labview. In my experience, you don't want the driver writing to memory managed by Labview. Also, I'm not sure there is a way to ensure the same buffer is used everywhere without copying. The Data Value Reference does this, but I'm not sure it wouldn't pass a copy into a DLL. I'd have to check. 

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

crossrulz ha scritto:

As long as the Configuration VI is the only place updating the array, I would just use a Global Variable.


I suppose it is not the case, in fact by using a global variable, even in the same VI (just cut the wire and use the variable on both ends) only shows the original values written during the initialization and no actual samples.

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

I think it's better to show you in practice what I want to achieve.

The starting code comes from here. I want to integrate the PicoScope2000aExampleStreaming.vi into the Continuous Acquisition.

The problem is how to split the Channel A wire coming from the StartStreaming block, and entering the acquisition loop.

0 Kudos
Message 5 of 5
(2,525 Views)