First off let me apologize up front for the lack of details and specifics. I do understand that it will limit the ability of anyone to respond but I feel I just need a push in the right direction. I do have a BSEE but I have not done any filtering or DSP since college over 25 years ago so I am rusty to say the least.
I am developing a prototype system that goes on a helicopter and I am trying to implement a filter to minimize the effects of the primary frequencies of the aircraft. In a perfect world I would have a data set and then I could model a filter and test the result. In this case I don't have any real data and I need to implement a filter that can be easily tuned or adjusted during my limited aircraft demonstration time. In other words, I've developed a system and I get a few days to try it out so I will be able to tweak the design between flights but I need to have the design more-or-less finalized before I'm able to get any real-world data.
My A/D unit is sending data to my processor at approximately 100 to 110Hz via UDP (Ethernet). My software receives and logs all packets but my algorithm (and to-be-implemented-filter) runs at 2 Hz. The frequencies of the aircraft are 4.3, 8.6, and 17.3 Hz. Software language is Python if that matters, and I see there are some nice filter libraries available.
I would appreciate some generic feedback on what approach to use for filter (type of filter) and any other recommendations anyone can provide given the scant details.
Thank you in advance!
You just need notch filters centered at your frequencies you want to eliminate - I assume by "minimize" you mean to cut them out. If you are trying to find signal at those frequencies you want a band pass filter (look up Goertzel algorithm). Another name is "band stop" filter. There are hundreds of ways to implement these, so pick something that's already in the library. At 100 Hz sample rate it should be piece of cake.
You need to provide a little more information. 1) Is your objective to remove them from audio? 2) If so, audio transmitted to earphones, or sent out a microphone? 3) Why do you have to get rid these tones? 4) What is the function of the filter you are designing, to pass the frequencies, possibly as reference noise, or remove the frequencies? 5) Are you designing 1 filter or 3?
As always, more information opens the door to better answers.
Does that mean that your software will buffer the data then process 50 points?
In python, a library such as scipy is more than enough. You can use "lfilter" to process each data block. Note that you will have to grab the internal delays value returned by the function to give them to next call to make sure that the your filter keeps its state between each call.
I would also go for a notch filter. SciPy can also help you design one with the correct cutoff frequency. Careful with notch filters, they in fact resonate at the frequency you do not want but with a phase of 180, cancelling want you do not want. If your oscillation stops suddenly, then your filter will start to create the unwanted frequencies. This phenomenon will be worst with high Q factor. I don't expects it to be a problem for a big mechanical system such as an helicopter.
You can have a look at what BetaFlight is doing. Betaflight is an open source drone control software. It has the capability to filter out noise motor caused by the motor. Its basically a notch filter that tracks the motor speed. There's a lot of drone enthusiast that like to discuss the subject on the web. You may find this interesting :)
The application is not for audio and each sensor will have it's own filter. Apologies for not making that clear but audio never occurred to me. The system has about a dozen sensors that measure force. So the ideal result is to eliminate any noise or interference from vibration. I apologize that I cannot share more details at this time, but I will say that the applied force is not brief or momentary or transitory in duration, but fairly constant and consistent over time.
The software is setup to use the 50th and 100th sample every second. We could easily change the software to use process all samples but the application will still run at 2Hz.
What is your sample rate? I couldn't ascertain it from the information above.
The sensor is sampling at 100Hz, but the software only uses the 50th and 100th samples.
Got it to fs = 100 Hz.
In addition to the other comments, I want to offer this for thought...
If your ADC is sampling at 100 Hz, it likely has an antialiasing filter set to 50Hz. If you subsample that stream at 2 Hz, everything from 1 - 50 Hz is going to being aliased into your 1 Hz band.
That means that the helo components are going to end up at these frequencies...
- 4.3 Hz -> 0.3 Hz
- 8.6 Hz -> 0.6 Hz
- 17.3 Hz -> 0.7 Hz
...in your subsampled (fs=2 Hz) stream.
Even if your force signal frequency range is different than those, without a lower anti-aliasing filter, you can't necessarily know that some other stray 1 - 50 Hz component isn't going to land on your desired signal. Without knowing that, you are more-or-less forced to filter at the higher rate.
An alternative is including an additional analog filter ahead of your ADC. If your force signal is near DC, put high order switched-capacitor lowpass filter in there with a cutoff just above your force upper limit. If you need everything but the helo components, one clock and three SC notch filters would do it.
Hope this helps.
Thank you, it sure does. You are in line with what I have found elsewhere that I will definitely need to process all of the samples. The key is that after others have pointed out here is that since this is not part of a closed loop control system a weighted moving average filter using all of the samples will probably get the job done.
Thank you all for your input.
You will absolutely need to process all samples to filter out the frequencies that you want to remove. You can't remove a signal of 4Hz with a sample rate of 2Hz, you violate the Nyquist criteria (f > fs/2). I would recommend to keep a good margin to avoid dealing with edge case. Say fs: > 10x f
Is the signal you are modifying to remove spectral components at 4.3, 8.6, and 17.2 Hz
part of the flight control system? If it is the transport delays caused by the filtering
process will tend to make the control signal stale, which is the same thing as saying make
the control loops unstable. Be careful about building impressive filters to house clean the
signal spectrum at the expense of inserting undesired delays in the feedback path. All filters
in this application must be minimum phase, low order filters. Amazing FIR filters have no business
in this application.
More information about the application of the filters would be useful.
It is not for flight controls and it is not part of any control loop.