LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed size shift register

Solved!
Go to solution

Hi all

 

I am making a time critical labview code and trying to optimise it to the maximum extend possible. There are cases in which i need to buffer say around 50 elements and then analyse the pattern. I use shift registers for these. But they buffer all the values, from the start, where as i need only past 50 elements. I think, my code will run faster if this problem is solved. Is there any efficient method to store only the past n number of elements?

 


Thanks

Arya

0 Kudos
Message 1 of 5
(3,665 Views)
Solution
Accepted by topic author arya1

Hi Arya,

 

look at the code in PtByPtQueue to get an impression of what to do…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(3,657 Views)

Arya,

 

a shift register only stores multiple values if you pull down the left side to display multiple elements. So a standard shift register stores only a single value. Period.

 

I assume that you have an array as shift register element and build up elements IN the array (using "Build Array"?). If so, you have to implement some code to limit the number of elements.

I recommend you to go for a circular buffer as concept.

 

Other option would be to use a queue limited to 50 elements.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 5
(3,656 Views)

I'm guessing that you are appending your values to an array that is sent through the shift register.

 

What you would want to look at is fixed size queues. Drop an "Obtain Queue" before your loop, wire in your fixed size of 50 and the type you are using, pass this queue into your loop and populate it using the "Lossy Enqueue" function. This queue will contain up to 50 elements, and then always the last 50. After your loop, use the "Release Queue" function, which returns "Remaining Elements" which will be the (up to) last 50 elements in your loop.



CLA
www.dvel.se
0 Kudos
Message 4 of 5
(3,649 Views)

Hi

 

Thank you so much for the quick reply. I will try the methods suggested by you all. I am familiar with queue, but unfamiliar with circular buffers. I will read up about it and try that too..

 

@ M_Peeker, @ Norbert, thats right. I am using insert element into array for the same.

 

Arya

0 Kudos
Message 5 of 5
(3,642 Views)