04-04-2014 01:04 PM - edited 04-04-2014 01:05 PM
*About half way down my Main Program I have my scales that I'm talking about.
I have a scale that uses a load cell for measurement. It outputs a signal in mV that I then use a formula node to convert the signal into pounds. I've gotten all of that, but I can't figure out how to filter the noise. I've done a lot of research and from what I've seen, I'm assuming a butterworth filter would be my best bet (I think). The problem is I'm not sure how to convert my scalar output from the formula node into the 1D array of the input to the filter. Am I correct in using the Butterworth Filter? If so, how do I connect it properly?
I also have two other ideas I've tried. I have "Sample Compression" and "Filter", from the Express tab in Functions, on my main VI as well. I'm not sure if either of these two ideas might work better.
04-04-2014 01:24 PM
You need to accumulate the points into an array. You also need to tell the filter VI about the timing of the points in the array.
1. I doubt that the timing is very accurate. Given all the things going on in that loop, the intervals between data points likely varies. The filter VIs all assume and require that the datapoints be equally spaced in time.
2. While it is good that you are using a state machine architecture, you should probably have several states in place of the one "Main Program" state. I did not look closely at the program - the diagram is too big, but multiple parallel loops may be better than trying to do everything in one.
3. Having an event structure inside one state of a state machine can be a recipe for disaster. If someone operates one of the controls for which Value Changed events are defined while the state machine is in a different state, the front panel could be locked up.
Lynn
04-04-2014 01:56 PM
1. So I was correct in trying to use the Butterworth Filter? Just out of curiosity, why wouldn't the "Signal Compression" VI be my best bet. It seems like that one would work best.
2. The reason I have all of the things in one state is because I want all of the things happening at the exact same time. If I put everything in different states, won't they all occur at different times?
3. That event structure is there solely for me to test the output voltages individually. I plan on removing it before I actually finish up my coding.
At the very bottom I have a small timed State Machine. Is this ok to have inside of my larger state machine? I wanted to use the sequence structure, but you can't stop those. I read a state machine could do the same thing and also be stoped by a button.
04-04-2014 02:51 PM
You may want to try using a point-by-point filter. They are located under Signal Processing -> Point By Point -> Filter PtByPt . Butterworth is likely fine. Make sure you initialize it only once when your software starts up, using First Call? function.
-Chris
04-04-2014 04:11 PM
I did not address the filter issue earlier.
Before looking for a filter or any other signal processing algorithm, it is important to characterize the noise. Is it white noise, pink noise, 1/f noise, or some kind of interference (such as power line frequency)? Does the noise vary significantly over time? Is it correlated with the signal? What is the minimum signal to noise ratio?
Next, look at the hardware parts of the system. Can the noise be reduced before being digitized? In your case check the scale manual. Many scales already do some filtering or averaging before generating an output. Is that filtering adjustable, possibly by changing the sampling rate?
Now you also need to characterize the desired signal. How does its bandwidth and amplitude compare to those of the noise? Does the signal have a complicated waveform which is important to the measurement or are simple DC or RMS measurements adequate? How many cycles of the signal are available for analysis at any particular time (for AC signals)?
What will you be doing with the results of the measurements? What effect does noise have on that? Are there certain kinds of errors which are more important than others? For example an excessive peak value might cause the system to damage expensive equipment while an error due to too aggressive averaging might only reduce efficiency by 1%.
After you have this information gathered, then you can begin to determine what kind of signal processing is most appropriate to reduce the noise. Sometimes a low pass filter is suitable, but in other cases it can be useless or even harmful.
Lynn