LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to pass an array of waveforms inbetween VIs

In my VI I am developing I have multiple data sources that output a single waveform. I group these waveforms togeather to make a wave form array. The user selects which waveform they would like to display and they are displayed on a graph on a different form. Right now I have each different graph VI generating the whole array and displaying the selected element.

My question is, this seems to be not efficent because I am generating data in 3 spots. I would think it would be better to generate it in one spot and then pass only the need data to the three graph VIs. What is the best way todo this? A global variable? Queue? Any suggestions?
0 Kudos
Message 1 of 24
(3,595 Views)
You're probably tired of hearing me say this, but the global function idea is the best.

A global variable makes a COPY of the data each time you read it. That takes time, and memory. If each of 3 window reads the global, and picks out a channel, then you've made 3 copies of the original data. Depending on your data size, that may or may not be a problem.

A queue means that once you read the data, it's lost from the queue. If window A reads from the queue, that data chunk is not in the queue any longer, so Window B can't read that same data.

If the main window generates the data and deposits it in a global function, then each window can ask the global function for a specific channel to display.

DATA STORAGE.vi:
Inputs:
WRITE/read (bool
ean)
DATA IN (2-D array of DBL, for example)
Channel Index (I32)
Outputs:
DATA OUT: 1-D array of DBL (or waveform, maybe).

Code:
WHILE
If WRITE/read
Store DATA IN in a shift reg.
else
Pass Shift reg IN to Shift reg Out.
Pick out channel via CHANNEL INDEX
Pass selected data to DATA OUT.
Loop NEVER.

The purpose of the loop is just to have a shift reg. It doesn't really loop - it executes once per call.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 24
(3,595 Views)
I guess my only question is, with this global function it will simply be a VI that is not reentrant that I will stick on every plot and the main form. Correct? Also for the real program I will be aquiring data from an external system which will continuously be sending data to LabVIEW. So I would have the main form contiously aquiring this data and writing to the global function? Thank you so much.
0 Kudos
Message 3 of 24
(3,595 Views)
this global function it will simply be a VI
Correct.

that is not reentrant
Correct.

that I will stick on every plot
Correct.

and the main form.
Correct.

So I would have the main form contiously aquiring this data and writing to the global function? 
Correct.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 24
(3,595 Views)
just for the record. you rule!
0 Kudos
Message 5 of 24
(3,595 Views)
Its not a problem that 3 different VIs are reading from the same non-reentrant VI and one is writing to it all at the same time? That wont cause any weird issues?
0 Kudos
Message 6 of 24
(3,595 Views)
No. Do NOT make it re-entrant.
Your read and write operations should be quick.
Assuming you don't have any issues about exact synchronicity between the windows, you're good to go.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 7 of 24
(3,595 Views)
What are the chances that 9 different forms wont have any problems with synchronicity? Should I jsut make different time delays in the loops or something?
0 Kudos
Message 8 of 24
(3,595 Views)
The "problem" I mentioned won't be from the code itself. It will work just fine, insofar as it won't crash or puke or anything.
But I don't know your requirements.

The (potential) problem comes from this:

Suppose the DAQ posts new data every 1000 mSec.
Suppose each window replots every 1000 mSec.
Unless you synchronize things, you have the potential for one window to show data from the latest DAQ operation, and another to show data from the time before.

In other words, the execution order might go:
1... Window A replots from Data Source.
2... Main updates Data Source with new data.
3... Window B replots from Data Source.

So the data shown in window A was not taken at the same ti
me as the data shown in window B.

Whether that's a problem in your situation or not - I can't say.

I have a solution, if you need it.
Guess what? It involves occurrences !
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 9 of 24
(3,595 Views)
I can guess how you used the occurrences. Is there a reason you choose to use occurences of Notifiers, I have read that it is recommended that one uses Notifiers over occurences.
0 Kudos
Message 10 of 24
(3,595 Views)