LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating buffer

I figure there is a simple solution to this problem but I don't see it so I thought I'd see what you all thought!

 

I'm trying to average data being displayed by a power spectrum.  I want to refresh the display every 5 seconds while keeping a running average of 1 minute.

 

I considered making a buffer to hold the data but I can't seem to find information that is not linked to DAQmx which the board that is being used in a non-NI board.  Plus I don't need a buffer at the data collection time (this is being done already, collecting 5 seconds of data in the buffer), I need it for the power spectrum itself.

 

Obviously I'm pretty new to this so if I've made some obvious mistake let me know!

 

Thanks in advance!

0 Kudos
Message 1 of 8
(3,327 Views)

Hello Dac83,

 

For this application, I would recommend shift registers. Shift register will allow you to create a buffer of data like you explain. Essentially, Shift Registers allows you to pass values between each execution. LabVIEW Help has documents about this called Creating Shift Registers and Using Shift Registers to Remember Iteration Values

 

Along with this information, I have created an example how to use these and I have attached it to this post. I hope this information helps you with it and if you have any more questions about this, feel free to post.


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 2 of 8
(3,301 Views)

Thanks for the help.  I had thought about shift registers but the problem I have with them is this.  The particular task I'm trying to accomplish here is going to be a subVI within a larger program.  I will need this subVI to be called once for each iteration of the main application.  Also my input is a 2-D array though I don't think that will cause any issue.  I can't initialize the shift registers with zeroes since the loop is only called once then stops, then is called again on the next iteration.  This type of action would cause the shift registers to be re-initailized each time the subVI is called...right?

 

But until each input register has an input the averaging just continues to give no output.  I'm not sure how to get around this problem.  Any suggestions or did this even make sense?

 

Thanks again.

0 Kudos
Message 3 of 8
(3,265 Views)

@Dac83 wrote:

Thanks for the help.  I had thought about shift registers but the problem I have with them is this.  The particular task I'm trying to accomplish here is going to be a subVI within a larger program.  I will need this subVI to be called once for each iteration of the main application.  Also my input is a 2-D array though I don't think that will cause any issue.  I can't initialize the shift registers with zeroes since the loop is only called once then stops, then is called again on the next iteration.  This type of action would cause the shift registers to be re-initailized each time the subVI is called...right?

 

But until each input register has an input the averaging just continues to give no output.  I'm not sure how to get around this problem.  Any suggestions or did this even make sense?

 

Thanks again.


Yes, but not if you use an un-initialized SR as I mentoned in this Nugget.

 

Re-entrant versio can also be developed but walk first then run re-entrant.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 8
(3,258 Views)

Hi Ben thanks for the link.  I do have the shift registers unintialized but when I do that there is no output until all of the shift registers have values.  So the first 20 iterations of the program return no output on the power spectrum plot.  After that everything works fine.  Just not sure how to make the first 20 run smoothly.

0 Kudos
Message 5 of 8
(3,248 Views)

I was replying to how to use an Un-initialized SR.

 

Post enough images for us to see what you are asking about and we'll reply as best we can.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 8
(3,238 Views)

Here is the the averaging portion of the program.  It is called from a higher VI.

0 Kudos
Message 7 of 8
(3,230 Views)

@Dac83 wrote:

Here is the the averaging portion of the program.  It is called from a higher VI.


I think I will recomend you go back to that Nugget and try to understand the example included with that Nugget.

 

Using your current approach ( a re-sized SR with a history of 20) would require more code to modify it to make it work (Cae structure that is controlled by yet another SR and the "First Call" function").

 

Watch it run in execution highlighting until you see what is happening. Besides the AE is one of the most powerful constructs in LV so it good to know how htey work and this is a good opertunity to apply the AE ideas.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 8
(3,226 Views)