04-15-2010 02:51 PM
Thanks for the response, they were very helpful. I'm fairly new to the labview game:)
I was wondering though if there is a good technique to take a discrete average in labview? Meaning, say I am continuously sampling a signal, I want to average the value of the first twenty samples, then the next twenty, and so on without including any of the previous data points in the subsequent averages. Thanks
04-15-2010 03:04 PM
One way to do this would be through the use of multiple shift registers. I've done this in the past. But it wasn't very neat code, and I don't imagine it's the most efficient way to do things. It did work though.
I didn't initialize the shift register here....you should do that.
Another option would be to use a circular buffer that only stores X number of points. http://zone.ni.com/devzone/cda/epd/p/id/5883 http://decibel.ni.com/content/docs/DOC-3414
04-15-2010 03:20 PM
csbvs wrote:Thanks for the response, they were very helpful. I'm fairly new to the labview game:)
I was wondering though if there is a good technique to take a discrete average in labview? Meaning, say I am continuously sampling a signal, I want to average the value of the first twenty samples, then the next twenty, and so on without including any of the previous data points in the subsequent averages. Thanks
Here is a way to specify how many samples to take the average of. Once the avg is taken, the array is emptied and another sampling will be gathered until the number of samples is reached, and so on.
The false case just has a wire from input to output.
04-16-2010 07:07 AM
05-18-2011 02:22 PM
I wired exactly what you wrote, but it is now giving me an error for bad terminal ?
This is my first time using labview 2010 for controller design
Any comments are greatly appreciated
Thanks,
05-19-2011 07:53 PM - edited 05-19-2011 07:57 PM
@sadfasdfsd wrote:
I wired exactly what you wrote, but it is now giving me an error for bad terminal ?
This is my first time using labview 2010 for controller design
Any comments are greatly appreciated
Thanks,
Your code is not exactly as mine. I'm using an array of DBL and you are using the History of the Waveform Chart. Even the colors are different. If you read the Details section of the Error List window, you will see that the data types don't match. The output of Waveform Chart History is not an array of numerics. You need to extract the array of numeric values from the waveform chart. There is a funtion in the waveform palette that will extract, T0, dT, and Y from the waveform. Use the Y output to wire into the Mean function.
Also you have a race condition. Don't use the property node. It will get read before the waveform chart is updated because there is no data dependency there. As soon as the code starts, the History will output its value, even before a history if formed. Your code should have some type of loop to gather data into the waveform chart. Wire the output of your subtraction funtion to the loop edge and set indexing enabled. This will produce an array of numbers and you can wire this into the Mean function. You should look at my code again and study every part of it.
05-19-2011 11:10 PM
The other difference is that tbob used the Mean function.
Scrambled letters, you used the Mean point by point function. Since it it does the calculations one point at a time, it only takes a scalar input, thus your error message.
05-20-2011 06:51 PM
@Ravens Fan wrote:
The other difference is that tbob used the Mean function.
Scrambled letters, you used the Mean point by point function. Since it it does the calculations one point at a time, it only takes a scalar input, thus your error message.
good catch, RF. I didn't even notice that myself.
01-27-2013 01:04 PM
10-01-2015 05:34 PM
This worked great.. better than other solutions and a quick fix. I just had to convert the data from waveform chart into double. Thanks Broken_Arrow