07-29-2019 01:45 PM
Hello,
I am using an XY Graph to plot one pair of X and Y coordinates that are constantly changing every 1/10 second. I want to add a tracer to that graph that will follow my X, Y dot around for 1 second. I am attempting to do so by building an array of the ten most recent values of X and Y coordinates using the Lossy Enqueue function. I have created identical independent queues and arrays for the X and Y coordinates.
Currently, my output for one set of coordinates, the Elements array, returns as the same array as my input data: a 1D array with one constantly changing value at index 0. Elements also holds zeros at index 1 through one less than the value I set N to in the for loop. In this case, zeroes fill indices 1 through 9 (N=10, 10 -1=9).
My goal is to have Elements hold the 10 most recent X and Y coordinates from my input array, following the FIFO principle.
I am new to Labview, so I appreciate any advice/explanation out there. Thanks.
John
Solved! Go to Solution.
07-29-2019 01:59 PM - edited 07-29-2019 02:10 PM
Hi John,
I am new to Labview, so I appreciate any advice/explanation out there. Thanks.
When you are new then you should take note of that "Training resources" section in the header of the LabVIEW board…
In this case, zeroes fill indices 1 through 9 (N=10, 10 -1=9).
Because you use that shift register: in the first iteration you store your new value to the queue, in the other 9 iterations you place the previous "overflow value" back into the queue (which happens to be zero)…
What's the point of trying to stuff the same value 10 times into the queue?
One more big remark:
Don't attach images of code. Attach code, real code!
07-29-2019 02:09 PM
Look at the PtByPt Data Queue VI.
07-29-2019 02:24 PM - edited 07-29-2019 02:26 PM
I see GerdW beat me to an explanation. Below is some modified code that should help you understand the behavior. Queue size is 10, loop runs 25 times, each time enqueuing the iteration count 'i'. Think about it carefully and make sure you understand why the output arrays are exactly what they are.
Next: a somewhat more advanced tip courtesy of altenbach. You can express your XY coordinates in complex number terms. (Each X,Y pair converts to a single complex value, via the function "Re/Im to Complex".) Then you can keep a single lossy queue of these complex values that the XY Graph already knows how to plot.
-Kevin P