LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Local variables or arrays

I made an initial program where I stored some normalization data (noise (N) and reference (R)) to measure transmission (T) of a optical device in function of wavelength. Each measurement captures a one dimensional array, (Signal, S). Now  T = (S-N)/(R-N).

For a single vi, I used some local variables to store R and N, as a way to plot each measurement instantly in function of time (my time delay between measurements is a few seconds).

 

Now I need to do a multiplexing of this measurement (using an optical multiplexer, where each channel is not identical and each Noise (N) and Reference (R) is not the same (so it is called Ni and Ri).

 

What is the best way to approach this? Local variables seem to be painful way to do so, but since I have a bunch of parameters for each multiplexed channel, it seem to be the easiest way (and now I am not able to move forward).

Is the right way to do this by making a two dimensional array and start appending the data and then just read columns or rows?

 

I used Labview long time ago, and I am not a programmer (I did programs to capture data by GPIB) and some minimal data processing and saving.

 

Thank you,

 

Gaston

 

 

0 Kudos
Message 1 of 12
(3,307 Views)

Local variables belong to a control or indicator. are not for storage, It is not clear what you are trying to do. Can you show us some code skeleton? How does the data get written? Where does it get read later? What is the final size? How often does the data change? etc.

0 Kudos
Message 2 of 12
(3,292 Views)

Those values, R and N, for several channels, should be either an array of clusters or two arrays, or two arrays in a cluster.

Don't use locals, use a shift register to retain values in a loop.

 

Or use a class of course, but that's 'advanced'. The class could live in a shift register.

 

Using locals for data storage will go sour sooner or later. Especially if you use the philosophy for all data in your application.

0 Kudos
Message 3 of 12
(3,238 Views)

Thank you for your answer.

My understanding of local variables is that are to be used when wiring between many frames (like in a staked sequence) is making the vi become messy and difficult to read. Is that right?

I think that in my case, as I have many frames, is the way to transfer data to avoid making a spaghetti monster...

 

Thank you,

 

Gaston

0 Kudos
Message 4 of 12
(3,218 Views)

@GastonBA wrote:

Thank you for your answer.

My understanding of local variables is that are to be used when wiring between many frames (like in a staked sequence) is making the vi become messy and difficult to read. Is that right?

 


The "stacked sequence" is the real monster. It should almost never be used.

 

There are plenty of clean ways to write complicated code without resorting to any variety of pasta, so obviously you are doing something wrong. We can help if you show us your code.

 

(A rich resource on what not to do is collected in the Rube Goldberg code thread. Maybe it can give you some inspiration. :D)

0 Kudos
Message 5 of 12
(3,205 Views)

@GastonBA wrote:

Thank you for your answer.

My understanding of local variables is that are to be used when wiring between many frames (like in a staked sequence) is making the vi become messy and difficult to read. Is that right?

I think that in my case, as I have many frames, is the way to transfer data to avoid making a spaghetti monster...

 

Thank you,

 

Gaston


Local Variables and the Sequence Structure (Stacked or Flat) should be avoided at all costs.

 

IMHO: Except for a couple very limited use cases, the Sequence structure should not be used at all in any new program and should have been deprecated years ago.

 

I think if you gave us a little more detail of the task and posted the code you have so far. Someone here could probably figure out a better way to accomplish it than using Sequences and Locals...

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 12
(3,194 Views)

@altenbach wrote:

... write complicated code without resorting to any variety of pasta ...


Maybe stacked sequences could be called Lasagna code. All these hidden layers!  😄

Message 7 of 12
(3,183 Views)

@altenbach wrote:

@altenbach wrote:

... write complicated code without resorting to any variety of pasta ...


Maybe stacked sequences could be called Lasagna code. All these hidden layers!  😄


Nice!  You should copyright that phrase.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 12
(3,180 Views)

@altenbach wrote:

@altenbach wrote:

... write complicated code without resorting to any variety of pasta ...


Maybe stacked sequences could be called Lasagna code. All these hidden layers!  😄


N parallel while loops 'doing their thing' could be ravioli code?

Message 9 of 12
(3,096 Views)

Reading this topic is making me hungry.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 12
(3,076 Views)