what is the question:

I have some time sequences(sampled at 0.5s and 3kHz which means every one of them has 1,500 points) from my force sensor. But I find the signal fluctuates wildly under no load, as photo 1 shows below.force sensor raw data So I just applied FFT to these data and found the frequency domain distribution shows a strange phenomenon as photo2 force sensor data after FFT. As you can see, the more elevated parts are 50 plus multiples of 100 (In my country The frequency of the national grid supply is 50Hz.).

what I expect:

I don't know what caused this because my data from another acceleration sensor show a similar, but less pronounced trend as photo 3.acceleration sensor data after FFT. Because I'm going to rely on the signals captured by the force sensor to do some tasks therefore I need to eliminate this noise from the signals captured back while doing the task.

raw data and my codes:

dataandcode Sincere blessings to all of you who are willing to stop and read this question.


2 Answers 2


I don't know what caused this

Yes you do: "In my country The frequency of the national grid supply is 50Hz." You have electromagnetic interference or crosstalk in your sensor signals.

By far the best method to address this is is to avoid the interference in the first place and make sure the captured data is clean (within the stated specifications of the manufacturers data sheet).

I recommend going through your signal chain one by one (ADC converter, pre-amp, all wiring, sensor, etc) to identify where the interference enter your setup and see if you can identify the root cause (bad cable or connection, poor shielding, ground loop, impedance mismatch, etc).

Fixing is in post processing can be done but its not easy and it will compromise the signal to some extent.

  • $\begingroup$ Thank you for your reply. I will try to figure out what causes this, but should I apply some filters to dampen the noise if I can't? $\endgroup$
    – Erdong111
    Commented May 11 at 12:52
  • $\begingroup$ You can, but that will compromise your signal quality, so it's a delicate tradeoff that depends a lot on your specific requirements and what exactly you want to do with the data. Since it's line noise, your best shot is probably to track the fundamental and the harmonics with a PLL, determine the amplitudes with a least square error estimation and than subtract it out. If you are lucky the phases of the harmonics are constant and than you only need to run a single PLL. Alternative would be a set of notch filters, which is easier to implement but does more damage. Neither method is pretty. $\endgroup$
    – Hilmar
    Commented May 11 at 13:00
  • $\begingroup$ I appreciate your detailed answer and I'll take your suggestions into consideration.👍👍👍👍🤩 $\endgroup$
    – Erdong111
    Commented May 11 at 14:50
  • $\begingroup$ First line of defense: control ground loops in your system. Sometimes another option: use battery power instead of line (AC) power. You may also need better isolation from supply ripple in your analog circuitry. $\endgroup$
    – vml
    Commented May 11 at 16:36
  • $\begingroup$ @vml, thank you very much. I really don't know anything about the hardware side of things, so I'm going to software filter it simply. $\endgroup$
    – Erdong111
    Commented May 12 at 6:57

The simplest filtering options I can think of are the following:

Comb filter

Use a comb filter with a discrete transfer function of $(1+z^{-30})/2$.

The reason this works is the gain is $|\cos(15\omega T)|$, where $\omega$ is frequency [rad/s] and $T$ is the sample interval [s]. Therefore, the gain is zero when the frequency [hz] is $f=(2n+1)50$, where $n$ is an integer, thus it will zero components at 50hz, 150hz, 250hz, etc, which is exactly what you want. However, clearly this doesn't only affect the response at those disturbance frequencies (see below for a comb filter design that minimises this).

Ideal notch filter

If you don't require a real time filtered signal, which perhaps you don't as you are acquiring 0.5s worth of data at a time, then you are already halfway there as you can simply:

  1. Acquire a finite duration signal, as you have.
  2. Transform to the frequency domain, as you have.
  3. Zero the disturbance frequencies you don't want.
  4. Transform back to the time domain.

This is probably going to be as perfect as you can get from a filtering option.

Other options

Anything beyond the previous two options becomes more complex. For example, you could use one notch filter per disturbance frequency (or at least for each of the main disturbances) and make the notches very narrow. However, a simpler and more elegant option in that respect is to design a comb filter that minimally affects the amplitude and phase between the zeros, such as the one I just designed below that achieves that objective as $\beta\to0$ (note that $\beta=1$ corresponds to the comb filter I mentioned above): $$\frac{1+z^{-30}}{(1+z^{-30}) + \beta(1-z^{-30})}$$

  • $\begingroup$ thank you, sir, I will think of it later! $\endgroup$
    – Erdong111
    Commented May 20 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.