LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use circular buffer to determine steady state temperatures

Hi everyone

 

This is a questions that I've searched for over the forums, and even though I have know the theory of how it should work, I cant seem to implement it in my program...

 

Problem: I am measuring the heat generation rate using a calorimeter, and need to determine when the temperature inside the chamber has reached steady state

 

I have 4 TCs inside the chamber reading the temperature, and I am averaging these 4 readings. I know I need to implement a circular buffer to keep about say 100 readings, and then determine the standard dev of the readings to determine whether I have reached steady state. the problem is that I just cant get the circular buffer to fit inside the program. I have attached the schematic of my program and circled where I would like to determine the slope/stdev of the data

 

and sorry, I just started programming on labview, so i am just trying to fumble my way through this program...

 

thanks for your help!!!

 

Kevin

0 Kudos
Message 1 of 12
(4,788 Views)

Implementing a circular buffer in a loop is fairly easy.  Create a shift register on the loop which contains an array with the number of points you want for your buffer.  You will also need an index of where to put the next point so you can replace the element.  You may also want a boolean to signal when the buffer is full.  You can put all of this inside a single cluster in the shift register, or you can use multiple shift registers.  You should be able to find multiple examples of ring/circular buffers in these forums.  Alternately, you can use the Collector Express VI, found in the Signal Manipulation palette.

Message 2 of 12
(4,763 Views)

thanks! I am constantly amazed at the capabilities of LabVIEW and hte amount of people out there who know so much about it!

 

I will try it out, and let you know how I do... so far I am using the collecter and its working how I thought my circular buffer should work... Now i think I can just use the statistics function to findthe stdev of the signal

 

Thanks

Kevin

0 Kudos
Message 3 of 12
(4,747 Views)

I have somewhat of a solution... I found that there is a massive lag in the response of the system, i.e., the readout of the temperature readings are in sync with the time I start running the program, but the collector and the stdev calculation is lagging behind (up to 30 minutes). the program also seems to run a lot slower... 

 

i have attached the program, am I doing something wrong?

 

(note: I set the collector to only 10 samples to decrease waiting time before the loop goes forward)

 

Thanks!

 

Kevin

0 Kudos
Message 4 of 12
(4,734 Views)

There is something which may be causing your slowdown, but you did not include all your subVIs so I could not run the code and verify (I also do not have your hardware setup).  You are using a very simple VI to write your data to disk.  Unfortunately, this VI opens the file, seeks to the end, then closes the file at each iteration.  This is really slow, especially when your file gets long.  You would be far better off opening the file outside the loop and using a shift register to pass the file reference into the loop.  Inside the loop, format and write your data.  When the loop finishes, close your file.  This is much, much faster and should allow you to keep up.  You may want to write a header before you start writing data.  If you need help with this, let us know.  You can get started by opening the VI you are currently using and splitting it apart so the open and close parts are outside the loop and the write parts are in the loop.  You will need to learn some text parsing/handling to do this well, but it is pretty easy.

 

Good luck.

0 Kudos
Message 5 of 12
(4,718 Views)

woudl this be helped if instead of using an external timer and writing to an external file I use the express VI "Write to measurement file" inside the loop?

 

Kevin

0 Kudos
Message 6 of 12
(4,689 Views)

The Express VI is going to be a bit slower than the Write To Spreadsheet File - as long as you want to save the data as text. I really don't know what you mean by an external timer and of course Write to Measurement File writes to an external file so I don't understand your comment about that either.

 

A big part of the slowdown is how you acquiring the data. You set the sample rate to 10S/sec but the DAQ Assistant is set to return 100 samples. That means that you will only get an update every 10 seconds. You then want the last 10 samples from the collector so that will take 100 seconds before you have filled it's buffer.

0 Kudos
Message 7 of 12
(4,683 Views)

Sorry Dennis!

 

Thanks for being so patient and working this through with me... I am new to labview so the syntax is new to me as well...

 

On my program that I uploaded, The external timer is the timer sequence I had implemented outside the while loop

the external file writing was referring to the fact that I opened a file inside the loop, but had it write to a file outside the loop for each iteration of the loop

 

I have uploaded the new file, even though all I changed was take out those aforementioned "writing to external file" and "external timer" part since that is now included in the "write to measurement file" VI

 

regarding acquiring the data...

 

Should I set it to Samples/second, giving me 100 Samples (DAQ) / 100 Samples/second = Second each input?

Not sure if the my logic is correct, and even after reading the detailed help the part was still a little convoluted...

 

Thanks!

 

Kevin

0 Kudos
Message 8 of 12
(4,679 Views)

Your VI doesn't show anything outside of the while loop, so I don't know what external timer sequence you are referring to.

 

Inside your while loop, you don't need those 6 Index Arrays.  You can use one.  If you drag down the bottom of the the Index Array node, you'll get more outputs.  You won't even need to wire up the indices because by default the first one is 0, and any index that doesn't have an input is +1 higher than the index above.  Resize it to 6 outputs and you'll automatically get indices 0 through 5.

0 Kudos
Message 9 of 12
(4,676 Views)

yeah, the program I just uploaded doesnt show any of the "external" features since I decided to use the write express VI, but if you look at the earlier versions of the program (I think the first attachment), it has the external stuff I was referring to...

 

thanks for the tip on the index arrays!

 

Kevin

0 Kudos
Message 10 of 12
(4,671 Views)