LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Histogramming

Solved!
Go to solution

I have been trying to develop a code that can histogram data on the order of 1,000 data per second.  It's pretty simple to use the histogram function to display a histogram that looks like it's processing all the data. But, to ensure that the code exectues at a constant speed for the duration of the data acquisition, I also programmed the code to dispaly the number of iterations per second (ips). Even after a five or so seconds, the ips is much lower than the ips in the first couple seconds.

 

So, in order to troubleshoot, I simplified the program and began using a random number generator as my data source. With this simplification, the ips still continues to consistently decrease in a short period of time. I am not sure if the problem is LabVIEW's histogram function or if it's the way I'm assembling the array that serves as the input for the histogram function. I have a feeling my programming is inefficient and resource-heavy, but I'm not sure how to fix it. I'll attach my random number histogram, so you can see what I've done. I appreciate any help I can get.

0 Kudos
Message 1 of 4
(2,732 Views)

You have a couple problems.

 

1.  You are constantly resizing the array since you are endlessly building new elements on to the array.  As LabVIEW runs out of memory for the current array, it needs to find a new, larger, continiguous piece of memory to move the array into and add the new elements.

 

2.   The array is getting bigger, and you are reprocessing the whole array each time through the loop.  With a histogram, you'd be better off doing a histogram on smaller portions of the array, and adding the results together after the fact.

0 Kudos
Message 2 of 4
(2,717 Views)

So that makes sense and answers my question about my resource-heavy code. Thank you. So what I have in mind is histogramming the first 500 numbers, and setting that array aside. Then histogramming the next 500 numbers, and adding that array to the previous array, and so on and so forth. However, I'm not sure how to continually histogram consecutive portions of the data and add the results together. I'm including a vi that will histogram 500 random numbers at a time. The problem is that it doesn't retain the previous data histogrammed array. After each loop, it begins from scratch. I've programmed a few other ways to set the size of the data to be histogrammed at one time, but I'm not sure if this vi is the best one. I appreciate the help!

 

Derick

0 Kudos
Message 3 of 4
(2,680 Views)
Solution
Accepted by topic author dkopp
Add the arrays together and store them in the shift register.  Don't bundle it with your X array until you are ready to display on the graph.
0 Kudos
Message 4 of 4
(2,656 Views)