05-06-2020 08:56 PM
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
05-06-2020 09:36 PM - edited 05-07-2020 10:55 AM
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.
05-07-2020 06:11 AM
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.
05-07-2020 09:49 AM
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
05-07-2020 11:02 AM
@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)
05-07-2020 12:30 PM - edited 05-07-2020 12:32 PM
@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...
05-07-2020 12:55 PM
@altenbach wrote:
... write complicated code without resorting to any variety of pasta ...
Maybe stacked sequences could be called Lasagna code. All these hidden layers! 😄
05-07-2020 01:02 PM
@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.
05-08-2020 03:33 AM
@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?
05-08-2020 01:15 PM
Reading this topic is making me hungry.