LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real time low pass filtering

Solved!
Go to solution

Respected Mr. GerdW,

Sorry. I am replying to you again. I made a code as you attached, and run that. The result was the same (like you). But in my real code, the problem remained the same. I have rewired my code but can't understand whats the problem. Code and graph both are attached. 

 

Download All
0 Kudos
Message 21 of 33
(1,519 Views)

Hi Milon,

 

as I don't have any DAQmx hardware with me I have to replace your DAQmx function by a signal generation function as shown in my previous message: no problems then with filtering a signal…

 

Correction: you are setting a very low cutoff frequency. Is this setting realistic?

When I simulate a 10Hz signal with added noise and use a cutoff frequency of 25Hz everything is fine!

Maybe you could try one more time with some higher frequency limit?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 22 of 33
(1,508 Views)

Respected Mr. GerdW,

I am using a 100Hz (100data per second) data rate. According to your suggestion, I used 3 low cutoff frequencies (5, 10, 15). The graph is attached here. Previously mentioned fluctuations are also visible in the 15Hz cutoff. By the way,
I am facing another problem with DAQmx. During using DAQmx, after 20 or 30 minutes the code automatically stopped. It shows error 200273. I searched about this error but can't get any solution. I have attached the code here.

Would you please check and give a suggestion?

 

Download All
0 Kudos
Message 23 of 33
(1,488 Views)

Hi Milon,

 

I am facing another problem with DAQmx. During using DAQmx, after 20 or 30 minutes the code automatically stopped. It shows error 200273. I searched about this error but can't get any solution.

Some smaller issues:

- When using "continuous samples" mode you should NOT set the "number of samples" input at DAQmxTiming function. (Read the LabVIEW help!)

- Why do you fiddle with DAQmx buffer at all?

- You should not use an additional wait function in the loop when you request fixed amount of samples with DAQmxRead.

- You are doing a lot of processing in the same loop as your DAQmxRead: this may lead to DAQmx buffering problems in the long run. Think about a producer-consumer scheme… (Especially when you try to create an Excel file in the loop with each iteration!)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 24 of 33
(1,484 Views)

Here's a problem I see.  You are collecting 100 samples at a rate of 100 Hz, so 1 second's worth of data.  Your dT would be .01 (1/100th of a second).  But because you are using N samples N channels, you are getting a 2D array.  (Why not use 1-D array of waveforms?).  You are processing that array, but you lost the timing information associated with your acquisition and would have existed in the waveform.  You've effectively turned your data's dT in 1 second.

 

So when you do filtering and apply 5 Hz, but act on an array, 5 Hz doesn't mean anything because the function doesn't know that the data came in at a .01 second dT.  It thinks it came in at a 1 second dT!

Message 25 of 33
(1,459 Views)

Respected Mr. RavensFan,

Greetings. I modified the 2D array into 1-D waveforms but the graph looks strange and also filters (Low pass and Savitzky-Golay) doesn't work. Picture attached.

 

Actually, I want to use a PID controller in my research. For that, I need real-time measurement. But I couldn't get an accurate amount of data. Specifically, sometimes I got 20~60 data to instate of 100 and time missing ( like 5/10/15 sec). First I used DAQassist, but some people suggested to use DAQmx for better performance and solve all missing problem. I have attached a DAQmx code here also. The problems remained the same...

Download All
0 Kudos
Message 26 of 33
(1,454 Views)

Your picture shows a partial of your block diagram.  It doesn't show how your graph looks strange or how the filters don't work.  Just that you have the waveform data type.

 

There is a coercion dot for the where the waveforms go into those filters.  So those waveforms are probably getting coerced to an an array and losing the timing information.  You didn't attach the subVI smooth[h]ing.vi, so I don't know what is going on in there.  My guess is that the control on the connector panel is still an array and not a waveform.

 

The actual VI you attached is still using 2-D arrays (I see you've added channels and a producer/consumer loop), but it doesn't reflect the waveform that you showed in your partial picture.

 

What does the word "instate" mean?  Wait a minute, did you mean "instead", because then that sentence makes sense.  It doesn't make sense why you'd be getting less samples than you asked for.  I suggest running your VI with more code looking at array lengths or waveform lengths to be sure that is actually true.

Message 27 of 33
(1,450 Views)

Respected Mr. RavensFan,

1. I apologize for my poor English. I wanted to mean, compared with the previous signal type, it was different. Previously, the Lowpass and Savitzky-Golay filtered signals were also shown in the waveform graph but this time (1-D wfm) didn't.....

2. I have attached the smoothing subVI here. Would you check again, please? 

3. An error is shown during passing 1-D wfm through the queue. Actually, I don't know how to fix that. 

4.  "I suggest running your VI with more code looking at array lengths or waveform lengths to be sure that is actually true." - I didn't understand this sentence. 

I have attached all the necessary codes here. I just want to fix the time and sampling rate problem.

0 Kudos
Message 28 of 33
(1,437 Views)

If your subVI is set up to have array inputs and outputs like the one you attached does, than of course you going to get a coercion dot if you wire in a waveform.  Now that SG filter is written to handle 1-D arrays.  I've never used it before, so I don't know much about it.   But then I just read the detailed help on it and I see it doesn't do any filtering based on frequencies, it just does a smoothing similar to a "boxcar" type averaging based on the data around it.  So it doesn't need timing information.  If you use that with a waveform, what you need to do is use Get Waveform Components to get the 1-D array out of it, use the SG filter, then use Bundle waveform components to place the new filtered 1-D array back into the original waveform.

 

Ion%20sensing%20DAQmx-1_BD

 

I see your 1-D wfm.jpg picture has the waveform.  But I don't see that code in any of the VI's you attached.  And I don't see any queues in the VI's you attached.  So I can't answer "An error is shown during passing 1-D wfm through the queue."  Attach a VI that shows a 1-D wfm and the error.

 

"4.  "I suggest running your VI with more code looking at array lengths or waveform lengths to be sure that is actually true." - I didn't understand this sentence. "

I mean drop some more functions and indicator on the diagram.  Look at Array Lengths with the "Array Length" function.  Waveform duration with the "Wfm Duration.vi" in the Waveform palette.  That or use Get Waveform components to get the raw Y array and do an array length on that.  You said you are sometimes getting shorter arrays, so use the tools at your disposal to show the lengths of the array and prove there is a problem and where it might be occurring.

Message 29 of 33
(1,425 Views)

Respected Mr. RavensFan,

I apologize for my continuous reply. I have attached the modified code using 1-D wfm (Real-time signal filtering.vi). But it only runs 8 minutes and then automatically stopped. The waveform graph condition remained the same (picture attached). 

 

Actually, I want to use "channels and a producer/consumer loop", code attached (DAQmx.vi). It never stopped but time missing and the sampling rate is the main problem. I tried to use 1-D wfm here also but doesn't work (maybe I don't know).

 

Another new problem, I got data (value) variations between DAQassist and DAQmx. Picture attached. I can't understand why it's happening...

0 Kudos
Message 30 of 33
(1,417 Views)