Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

how can you easily apply filtering a double precision number that "jumps around" so that is smooth or "averaged" over time

I have some analog inputs from a 9203 card that are very unstable that I want to smooth out in the RT controller.  The FPGA puts out a value of 13107 to 65536 representing 4-20mA, but this number jumps around as much as 1200 counts for some of our sensors (even a 4-20 tester jumps around as much as 120 counts).  How can I filter this count value so that the resulting value is more stable ??  I've tried increasing the sample rate and used a butterworth filter, but changing the rate has no effect and the filter does some good but it seems it could be much better.
0 Kudos
Message 1 of 7
(4,410 Views)
You might just try  doing a simple average on your data.   Try using the "Mean PtByPt.vi".   With this vi you can spcifiy how many data points you want to include in a running average.
SteveA
CLD

-------------------------------------
FPGA/RT/PDA/TP/DSC
-------------------------------------
0 Kudos
Message 2 of 7
(4,402 Views)

Thanks !!  That works like a champ.  I was unaware of that VI, but knew that was what I wanted to do !!  Some of these VI's are hard to find even if you know what you're looking for.

 

Thanks again !!

0 Kudos
Message 3 of 7
(4,400 Views)
I'm glad that worked out for you.... That vi is a kind of buried.
SteveA
CLD

-------------------------------------
FPGA/RT/PDA/TP/DSC
-------------------------------------
0 Kudos
Message 4 of 7
(4,394 Views)
If I were you I would log the data to a file.  Then I would do an FFT to see what frequency the noise is coming in on.  Then you can make your filter match the problem you are seeing.  If the noise is really high (or 50-60 Hz) I would look into shielding your sensor more.  If you want to you could post the data you collect and the community could have fun coming up with filters or suggestions 🙂 

PS- I like working out the signal processing muscle every so often.
"If you want to succeed... Architect" - The Specialist
0 Kudos
Message 5 of 7
(4,391 Views)
The Specialist is right, It's aways a good idea to try and figure out where the noise is coming from.  There is a very good white paper on analog field wiring here:  https://www.ni.com/en/shop/data-acquisition/measurement-fundamentals/field-wiring-and-noise-consider...  This paper address a lot of common (and not so common) problems with analog measurements.
SteveA
CLD

-------------------------------------
FPGA/RT/PDA/TP/DSC
-------------------------------------
0 Kudos
Message 6 of 7
(4,383 Views)

I don't believe the problem is with "noise" at all though.  I've a wide variety of sensors hooked up, even an analog output wired directly to the input card, and I see different levels of stability from different sensors.  My belief is that at 16 bits, the 9203 is a bit more "resolute" than the sensor is able to put out, and that accounts for the fact that this slight variation in current is seen at all.  I've hooked the same sensors up to a PLC whose AI card is 13 bit and the level only jumps 3 or 4 counts out of 8192 on the "good" sensors.  Kind of how if you zoom in with an o-scope that isn't hooked to anything, what first appeared as a flat line becomes a noise pattern.  Does that make sense ??  I've had my NI rep here to look at this issue and he said that this level of stability is "normal". 

I have much more experience with the hardware side of analog signals and I believe that my method of shielding is correct and proper.  Does anyone else have experience with the 9203 that is similar using 4-20 devices ??

Message 7 of 7
(4,377 Views)