LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Low Pass Filter on Array Components

I have existing code which reports a large quantity of sensor outputs, read at a single time step, in a single array (available as a global variable).  Without altering that code, I want to apply a low pass filter to the signals on each sensor.  I have had moderate success pulling a single value out of the array and filtering it (have to calculate timestep and build waveform), but I haven't figured out how to do this systematically to the entire array.  The array can be >2000 values and I would like to apply the same type of filter to each element from one time step to the next.

 

I have a similar problem applying other filters, such as basic moving average.  I can apply a moving average to an array, of course, but it averages element to element, not one array value to the next.

 

Is the any exising method, or perhaps elegant use of a for loop to accomplish this?

0 Kudos
Message 1 of 5
(4,665 Views)

Please show us some code. Are you trying to filter as the data is acquired (ptbypt) or once you have all data?

0 Kudos
Message 2 of 5
(4,644 Views)

The array is continuously written to a global variable at a varying sample rate.

 

I'm effectively "sampling" that variable at each iteration of a while loop and attempting to apply to low pass filter from one loop to the next as the data is acquired.  Goal is to display and record the data only at certrain points and with the filter applied.

 

I'll post a sanitized screen capture when I get back down to the lab.

 

 

0 Kudos
Message 3 of 5
(4,641 Views)

Filter.PNG

 

That code will allow me to place a moving average on the individual value.  If I attempt to do the same with the full array, I will get an average across sensors, not an average over time on each sensor.  I haven't figured out any feasible way to emply a true low pass filter (preferred to moving average) across either a single sensor or the complete set given my input.

0 Kudos
Message 4 of 5
(4,619 Views)

First, think about the filter process. Most of the filters in LabVIEW operate on uniformly sampled data. If there is much timing jitter in your acquisition process, you cannot just apply a filter VI and expect to get good results.

 

Second, global variables are generally not the preferred method of passing changing data.  Look into queues.

 

After dealing with those issues, I would probably Initiaiize a 2D array of data. Using Replace Array Subset, I would update one row at a time when a new 1D array of sensor data points was available. Then each column in the 2D array represents all the data for one sensor. You could use Index Array with the column input wired or Transpose 2D Array and then autoindex with a for loop to get data to filter.

 

Lynn

0 Kudos
Message 5 of 5
(4,603 Views)