LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Functional global variable

I'm working on LVRT project acquiring data from cRIO and expansion chassis at 40Hz and put into a queue for later calibration, can anyone show me how to make a functional global variable for all the data then I can get the value to make plots. Thank you very much. Best.

Capture.JPG

0 Kudos
Message 1 of 13
(3,912 Views)

Hi Xiao,

 

how to make a functional global variable for all the data

Store the data in a shift register and you're done…

Do you know how a FGV works? Have you tried to create your own one? Can you attach your code?

 

- What's the point of all those Decimate/BuildArray combinations? When reading the shared variables you should use ReshapeArray, for those ScanEngine scalar values a simple BuildArray should be fine!

- Why don't you use a loop to read the shared variables?

- Why don't you name the ScanEngine variables more descriptive? It's quite irritiating to see you read "AI7" 4 times…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,879 Views)

Its always good to attach code snippet/VI For better results.

 

Functional Global Variable is nothing but holding values in a shift register using (SINGLE RUN WHILE LOOP).

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 13
(3,875 Views)

Xiao@Gemini wrote:

can anyone show me how to make a functional global variable for all the data then I can get the value to make plots.

 


If you want to plot all of the data, then you should be using a Queue to pass the data to another loop.  And if you are then passing that data to a PC, use Network Streams.

 

A Get/Set FGV is nothing more than a more complicated and slow Global Variable.  But those are only good for TAG data (single value, only storing the latest).  What I am inferring that you need is actually a STREAM type of data (fast, lossless data), which a Queue is much better equipped to handle.


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 4 of 13
(3,857 Views)

@PalanivelThiruvenkadam wrote:

Its always good to attach code snippet/VI For better results.

 

Functional Global Variable is nothing but holding values in a shift register using (SINGLE RUN WHILE LOOP).



I like to make FGVs with a feedback node instead of a loop.

fgv.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 13
(3,853 Views)

Actually, I'm using the queue to pass data to another while loop for calibration and plot. Considering a large amount of data (14 waveform charts each have at least 8 plots), I may not be able to set a large chart history buffer to view historical data (I want at least 12 hours history). So, I'm thinking of using FGV to store data and waveform graph to plot it. 

0 Kudos
Message 6 of 13
(3,833 Views)

Xiao@Gemini wrote:

Actually, I'm using the queue to pass data to another while loop for calibration and plot. Considering a large amount of data (14 waveform charts each have at least 8 plots), I may not be able to set a large chart history buffer to view historical data (I want at least 12 hours history). So, I'm thinking of using FGV to store data and waveform graph to plot it. 


Still use the queue.  Let your display loop(s) take care of the history/buffer.  There is a simple VI called Data Queue PtByPt that can hold your history.  But instead of holding all of that data in memory, I would just log it to a file and just read off the data you need.


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
Message 7 of 13
(3,819 Views)

Almost the same (output will be the previous value even when Write is true):

 

FGV.png

 

You can make a FG that hold a history of values (write adds values to arrays, read returns the array(s) and optionally clears them). It will get more complicated then one node and a few wires.

 

Message 8 of 13
(3,788 Views)

I'm using queue to pass data to plot loop with waveform charts to display real time data. I also need to view the historical plot as long as possible at least 12 hours,  40Hz sample rate, the buffer would be 40x60x60x12=1,728,000 for 14 charts. I'm worried about the memory. My colleague suggest me to store the data in functional global and use graph to plot.  

0 Kudos
Message 9 of 13
(3,760 Views)

Xiao@Gemini wrote:

I also need to view the historical plot as long as possible at least 12 hours,  40Hz sample rate, the buffer would be 40x60x60x12=1,728,000 for 14 charts. I'm worried about the memory. 


Well, that does come up to ~185MB.  If also stored in a FGV, that needs doubled.  I would just use the Chart and make life easier on yourself.


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
Message 10 of 13
(3,746 Views)