# How to filter noise of different frequency based on motor power

I am taking torque readings from strain gauges on an actuator and trying to filter the signal to look usable. I have already put in place a median filter that reduces sporadic spikes.

When I have the actuator locked, I can set its power (through PWM duty cycle) to different values and see the torque readings accordingly. In such a situation, I have 0.1Nm of noise. This is acceptable.

However, when I leave the motor unconstrained, and set it to turn at different speeds (again, set it to different powers through PWM duty cycle), I get high noise on the torque sensor readings that seems to have a direct relation with the speed of the motor.

In this image, you can see the readings while the motor goes from fast to slow in 4 quite obvious steps:

(Obviously, since the motor is free running, the torque readings are (should be) a constant 0.)

My question is, how can I filter this data during the operation of the motor? Offline processing is out of the question, and I imagine the filter window can't be too large (as it produces a large latency in reading the current torque value), but perhaps that's inevitable?

I thought about a low pass filter, naturally, which would work great for high speeds of the motor, where the noise frequency is quite high, but as the motor slows down, I would essentially have to look at seconds of history to be able to filter out that low frequency noise, which is just too high to be useful for feedback control.

• what are your system gains? - possibly too high proportional gain. NOTE due to how controller work... they hunt around a speed so there will be a certain level of too and fro – JonRB Oct 7 '15 at 15:11
• So what's the source of this pick up? Is it synchronous with the motor rpm? Maybe you can get rid of the noise at it's source, maybe with some shielding, power supply filtering, – George Herold Oct 7 '15 at 15:13
• Is this simply the motor poles cogging? – user_1818839 Oct 7 '15 at 15:36
• Does the motor work in closed loop control or it is open loop? With PWM you are able to set voltage, not power. – Marko Buršič Oct 7 '15 at 16:11
• @jonrb, are you talking about controller gains or torque readings gain? See next comment regarding the former. – Shahbaz Oct 7 '15 at 16:40

The "noise" you are measuring appears to be related to the rotor velocity as you indicate this was measured while decelerating & equally it can be see there is a decrease in frequency.

What is unknown is whether that frequency is matched to the rotor velocity or some higher harmonic. Knowing the frequency correlation between the rotor and the "noise" would facilite in narrowing down the source.

If there is a desire to filter this unwanted component the one complication is a desire to filter from 0Hz to n rotor frequency. This rules out a low pass filter.

Two options

AC rejection

Below is an equation to remove the AC component. It determines the AC component and then subtracts it from the original signal.

$reject = x - [ x - \frac{1}{N} \sum_{n=0}^{\infty} x ]$

The equivalent difference equation for the DC rejection filter is:

$y_n = 0.999*( ( x_n - x_{n-1})+y_{n-1})$

As with most filters it is a tradeoff between settling time and rejection capability. The 0.999 factor is the key here. This trades off settling time of rejection.

2. Pass through filter. $y_n = 0.999*( ( x_n - x_{n-1})+y_{n-1})$
3. generate the AC rejected version $reject = x_n - y_n$

Taking a ramp of data & superimposing on top of it an increasing in frequency AC component of significant amplitude + some random noise. The tradeoff can be seen below.

NOTE if a complete rejection is required but the settling time is unwanted... there are additional digital tricks to help the filter deal with large delta's

NOTE2: the effectiveness of the 0.9... factor is dependent on the sampling frequency with regards to the signal of interest & unwanted components. The below were done with a Ts of 100us, quite slow

Tracking bandstop filter

If the present speed is known & the harmonic number of the component is equally know, an adaptive bandstop filter can be realised.

I shall hold off on this suggestion as it is a bit more involved an requires additional infomation

• This is interesting. Can you clarify what are x and y in your equation? Is x the reading from the sensor, and y the calculated value? How much delay does this filter introduce? I'll try your filter on Tuesday and let you know (Monday is holiday in Canada) – Shahbaz Oct 9 '15 at 20:35
• I have done a quick edit to describe the digital side a bit more but also some examples (excel generated) – JonRB Oct 10 '15 at 19:29
• I would still say look into the source... it is almost always to reject at the source rather than at the point of utilisation. It could be a real measurement due to torque ripple or it could be pickup in which case screening, twisted pair around your load sensor would be advisable – JonRB Oct 10 '15 at 19:37
• thanks for the clarification! This is awesome. The readings are from strain gauges, with one signal. I know that our new boards will have a ground plane between the signal lines and the motor, so maybe that would reduce the noise. I should also be able to soon try with strain gauges that have two signals, and with the lines passing in parallel, perhaps their difference would cancel out the noise. Either way, this algorithm would be a last resort. – Shahbaz Oct 12 '15 at 14:10
• No problem. I also use this as a last resort (in use right now while correct fix is being implemented. – JonRB Oct 12 '15 at 14:13