LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use of FGV

Hello everyone, the attached code is an example I'm using FGV to store data in an array.  The timed loop is running at 1Hz and pass the data to the FGV which initialize with an empty array, the new data will be appended to the end, one row per second. I would like to plot each column data every 24 hours. For the next 24 hours, it updates with a new plot. Can anyone teach me how to do this? Thank you very much.  

Download All
0 Kudos
Message 1 of 7
(2,950 Views)

Hi Xiao,

 

It looks like your code already does most of what you want. Can you go into a little more detail as to what you mean by "plot"? As in, do you mean that for each column of the array, you wish one line in a 2D graph? If so, use a Waveform Graph and then right click on it and choose "Transpose Array", then connect it to the Read output.

 

A couple of other notes:

  • You have a race condition with the two loops - if the first starts after the second, then for runs after the first time, the Stop 2 value will still be true. Either use a local variable and a flat sequence structure to reset to false before starting the second (consumer) loop, or find a different way to coordinate the two loops.
  • If you name your Queue, it becomes 'globally' accessible. If this isn't what you need/want, leave it unnamed (in the example, you use a queue wire to connect the loops - if this is always possible, you don't need to name it)
  • I'm not sure how much use Timed Loops are on Windows (but perhaps you're running this on another target, like a RT-OS, in which case, ignore this point). You might be better served with just a Wait (ms) function set to 1000 ms.

GCentral
Message 2 of 7
(2,924 Views)

I did what you said choose transpose array and connect to the output array, it works like waveform chart updating the line at 1Hz for this example, which is fine, but how to make the x-scale sync with current time, I tried to use build waveform function, failed. 

 

 

0 Kudos
Message 3 of 7
(2,895 Views)

If you want to use real timestamps, take a look at the XY-Graph. This takes a variety of inputs - take a look at the Detailed Help via the Context Help window, or right click on the graph and choose help.

 

This is more complicated than the Waveform Chart or Graph, but it can be more useful if you have both X and Y points!


GCentral
0 Kudos
Message 4 of 7
(2,888 Views)

@cbutcher wrote:

If you want to use real timestamps, take a look at the XY-Graph. This takes a variety of inputs - take a look at the Detailed Help via the Context Help window, or right click on the graph and choose help.

 

This is more complicated than the Waveform Chart or Graph, but it can be more useful if you have both X and Y points!


Easier solution: Sporadic Waveform Chart


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 5 of 7
(2,879 Views)

The attached code is a demo, the first column is time, and each column represents one sensor. I use FGV to save the data append to the array. How can I make waveform graph with my time stamp which is the first column value as X-axis? 

Download All
0 Kudos
Message 6 of 7
(2,856 Views)

I am not seeing the point of your Array Global.  You actually just created a race condition with it.  Why not just make a shift register on your consumer loop and use Build Array on that?  Also, do you want your array to grow indefinitely or do you only care about the latest X samples?

 

Other notes:

Learn to use Initialize Array as that will simplify your upper loop some.

Your Build Array should accept all of the 1D arrays and then you can transpose if needed after that.  A lot simpler than having 5 sets of Build Array with 1 input and then Transpose Array for each of those.


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 7 of 7
(2,839 Views)