LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

circular buffer

I am using circular buffer as provided here to store 2D array of DBL data.

Is there a way to have multiple buffer of same type? Need three circular buffer of DBL type to acquire and save data to its respective circular buffers.

Reason to store the data separate from each module is to use the respective buffer during analysis.

Any suggestions, thanks.

0 Kudos
Message 1 of 14
(2,667 Views)

I would advise copying the code to have 3 different VIs to hold the circular buffers.


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

I haven't looked at the VIs there, but there is another way to have a circular buffer - create a queue of a fixed size and use the lossy enqueue function to add data to it. You would create N buffers simply by creating N queues. To read the current data from the buffer, you would use the queue status function with T wired to the return elements input.


___________________
Try to take over the world!
Message 3 of 14
(2,646 Views)

How will the read pointer increment when using lossy enqueue implementation?

There are three threads that reads the circular buffer data and when all three has read then increment the read pointer.

 

0 Kudos
Message 4 of 14
(2,639 Views)

Read pointer?  Do you want to keep the data after it was read?  If not, a simple Dequeue Element would work.


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

I believe so, I am acquiring data for all channels(16) and saving to buffer. When the buffer is full to some value then it is passed to another thread to process.

In the process loop it also gets the list box entries as selected by user. If there are three channels in list box say ch0, ch4 and ch0

The buffer data needs to be iterate untill the end of list box items have reached. Ch0 occurs twice so the data for the same timestamp needs to be written twice in data structure for its respective row. Data structure is a array where each array index coresponds to list box row.

Please let me know if there is a better approach to get circular buffer without read pointer for this and not miss any data point.

thanks.

0 Kudos
Message 6 of 14
(2,630 Views)

tst suggestion is good. You can create as many number of queues depending on your need and for reading just use the Queue status instead of dequeue. When you do this way you don't loose the element when you read and also you can read all the elements in 1 shot instead of doing dequeue until you reach empty. Also since its a lossy enqueue you don't have to worry about memory leak.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 7 of 14
(2,625 Views)

If you don't want to miss data, then don't use a circular buffer. You can use a regular queue for each channel. Just enqueue the data on one end and dequeue (or flush, if you want a single read) on the other end. There are probably some queue examples in the example finder (Help>>Find Examples), so you should look at those.


___________________
Try to take over the world!
0 Kudos
Message 8 of 14
(2,598 Views)

This is sounding more and more like what you really want is a Producer/Consumer architecture with many consumers.  Use a different queue for each consumer.


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 9 of 14
(2,585 Views)

Using the lossy queue as circular buffer did not work.

Just wondering if use of crcular buffer (the NI example made for array) over queue is better or just use of normal queues?

0 Kudos
Message 10 of 14
(2,565 Views)