LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lossy Enqueue Setup

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 4
(2,683 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(2,667 Views)
Solution
Accepted by topic author johnE16

Look at the PtByPt Data Queue VI. 

Example_VI_BD.png

aputman
Message 3 of 4
(2,650 Views)

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

 

lossy queue modified.png

 

complex.png

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 4
(2,634 Views)