From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i make circular buffer using while loop ?


@Yamaeda wrote:

Is this what you're meaning?


Why so complicated?


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 11 of 16
(713 Views)

@crossrulz wrote:

Why so complicated?


 

You might want to slow down that loop on the bottom just a little bit 😄

You also want to set "return elements?" to TRUE.

 

Still I am not sure about the original problem. If the data is just the iteration count, all we need is get the last element and the other 99 can be calculated from first principles in the target loop. A single element lossy queue, even a local variable might be all that's needed.

0 Kudos
Message 12 of 16
(697 Views)

Something like this?  It's unclear from your description what you're trying to accomplish.

 circular buffer.png

 

0 Kudos
Message 13 of 16
(695 Views)

Yes that is more optimized, but less akin to how it was described. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 14 of 16
(692 Views)

Is there an equivalent way to this code implementing a circular buffer, but using a Lossy Stream Channel?  I can't seem to find an equivalent to Get Queue Status: Return Queue Elements that is needed for the second while loop in this code.

 

Things I've tried:

 

1. Setting a Stream Channel writer to fixed size N, timeout=0 and reading N elements with a Read Multiple Channel Reader.

2. Connecting a Lossy Stream to a Read Stream (broken wire)

3. Tag channel with array that is loaded using array functions to shift and append the array in the producer loop (but I'm trying to do this using a stream channel - just want an equivalent to the simplicity of a lossy queue using channel wires)

0 Kudos
Message 15 of 16
(350 Views)

Before worrying about how to do something, think about what you want to do.  So "What do you want to do"?

 

The reason I ask is that I'm having great difficulty imagining a scenario where one needs a (finite, specified-length) Circular Buffer where the Reader "lags" the Writer (by a fixed amount?  by a variable amount?  by a changing amount?).  Of course, a Delay Line is an obvious example, and having such a concrete example, the concrete "solution" suggests itself.

 

[Many moons ago, I read an interesting book on implementing Data Structures such as Queues, Circular Buffers, and other "modern" data constructs using Fortran 4.0.  The Fortran "solution" is an "obvious" simple method for a Delay Line ... ]

 

Please explain (without worrying about the "Hows") what, exactly, is the Task that you are trying to accomplish?  What are the inputs?  What are the hoped-for outputs?  What "variables" link Inputs to Outputs?

 

Bob Schor

0 Kudos
Message 16 of 16
(328 Views)