From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter analog input signal?

Solved!
Go to solution

Hey guys, LabView novice here.  I have a 5DOF IMU (3-axis accelerometer, 2-axis gyro), and I'm trying to filter and manipulate the analog signal it is outputting using LabView.  I expanded the simple "Analog Read Pin" example that came with LIFA so that it will graph all 5 values, but I'm having trouble applying filters.

I have the feeling it's a data type issue, as I am fairly confused about the difference between regular data, dynamic data, waveforms, arrays, etc.. when it comes to the filter.  I simply want a low-pass filter to filter out the noise from vibration.  Any help would be greatly appreciated.  I attached my VI.

0 Kudos
Message 1 of 15
(39,613 Views)

The easiest method to use to filter your signal is an Express "Filter" .  Found at Express > Signal Analysis > Filter.  To use the filter you need to convert the Analog Pin Double data type to  an Expres Dynamic data type using a "Convert to Dynamic Data2' function. 

If you look in the last message in the Converting Analog Input to Frequency" thread there is an example, "Analog ReadPinVers2.VI, that uses the Express "Tone" VI.   Maybe this will help you. 

Double is a regular data type.

All of the Expres VIs require Dynamic data.

Waveforms data type, WDT, is data that includes timing information.

hrh1818

Message 2 of 15
(25,371 Views)

Thanks for the help!  So I started back with the basic Analog Read Pin again just to try to get it working with one pin first.  I converted the double to dynamic data and fed that into an express filter.  The filter is a lowpass butterworth 3rd order with a cutoff frequency of 10hz. When I run it I get this error:

---

Error -20023 occurred at Filter->LabVIEW Interface for Arduino.lvlib:Arduino Analog Read Pin.vi

Possible reason(s):

Analysis:  The following conditions must be met:  0 < f_low <= f_high <= fs/2.

---

This sounds like a Nyquist criterion issue, however, I don't even know what the sampling frequency is as there was no option to set that anywhere.  The baud rate is set to 115200 but I don't know how to change the sampling rate.

It works if I set the cutoff frequency to anything under 0.5Hz, indicating that the sampling frequency is at 1Hz, but that can't be true because the output is being displayed much faster than that when I don't have the filter in there.

Any thoughts?

0 Kudos
Message 3 of 15
(25,371 Views)
Solution
Accepted by topic author kroymander

I gave you some bad advice.  The Express "Filter" VI won't work in this application.  The Expres VI requires timing information to be included in the data. If no timing data is included the Express "Filter" VI assumes the sample rate is 1 sample per second.  Furthermore it is designed to filter data a block at a time.  It is not designed to filter data continuously like an analog filter.

Labview does have Point by Point Filters.  See Functions Palette > Signal Processing > Point by Point > Filters > Butterworth.  You will need to open the front panel of the Butterworth Icon to set the filter parameters. Or you could add controls to your Main VI front panel to set frequently used parameters.  Be sure to read the Context Help for this filter.

Attached is a low pass filter example and an analog speed test VI.  The speed test measures how long it takes to sample an analog signal 1000 times.

Use the data to estmate your computers analog sample rate.

hrh1818

Download All
Message 4 of 15
(25,371 Views)

That worked beautifully!  Thanks a lot.  I had to play around with the cutoff frequencies for a while to get it to work well, but it turned out great.  I attached a snapshot of the raw vs. filtered data.

0 Kudos
Message 5 of 15
(25,371 Views)

Hi

hrh1818

Can you please convert the examples for LB2010? I need to improve the filtering of the sharp IR sensor, now i have a noise near 1cm even with a capacitor between Vcc and GND.

Best

CPalha

0 Kudos
Message 6 of 15
(25,372 Views)

Here are those two files saved for LabVIEW 2009.

Download All
0 Kudos
Message 7 of 15
(25,372 Views)

Thanks for the fast answear.

CPalha

0 Kudos
Message 8 of 15
(25,372 Views)

how do you get the graph?can you show me the arduino program and also labview program?

0 Kudos
Message 9 of 15
(25,372 Views)

i'm sorry but i'm facing this problem...when i'm running the program,it got green arrow and nothing display at the graph...pliz help me .tq

Untitled.png

0 Kudos
Message 10 of 15
(25,371 Views)