Smoothing a roughly sinusoidal signal

Hi,
I have position data coming from a high resolution angular position sensor and I need to improve the accuracy of the data by removing a regular sinusoid from it.
The below graph shows three plots of angular position error against time:
MatLab Forum.JPG
  1. The brown plot is the position error which needs to be corrected (ideal is a zero error horizontal line).
  2. The blue plot is the position error of a very high accuracy reference angular position sensor (for testing only and not present in the deployed application).
  3. The green plot is the difference between the brown and blue plots.
Common to both the brown and blue plot is a fast in phase ~2 sec error which can be ignored.
In the brown plot there's a ~24 sec error which I need to remove (the green difference plot more clearly shows this as it removes the faster ~2 sec error). The solution algorithm eventually needs to be deployed to run in realtime on a 32 bit microcontroller.
The dataset is in .csv format which I can post for analysis.
I've Googled various examples which lead me to believe a solution to this problem should be possible. The issue is I don't have sufficient signal processing experience to know how to implement a solution and would be very grateful for any help in solving this problem.
Best wishes,
Richard

Answers (1)

Daniel M
Daniel M on 8 Nov 2019
So are you saying you want to remove the frequency of the blue signal from the brown signal? Fairly easy, just use a notch/bandstop filter. You can find examples on these pages

7 Comments

Thanks for your comment Daniel. In the final application, only the brown encoder data is available. The blue data is from a high accuracy reference encoder on a test rig.
I need to remove the regular 24 sec sinusoid from the brown signal. This is encoder interpolation error. My guess is to fit a function to it, so I can work out where the current encoder position is in the 24 sec cycle and subtract it?
The green plot shows the difference in position error between the reference encoder (blue plot) and the application encoder (brown plot). The green plot only contains encoder errors (the gearbox errors are the same for both encoders, so they vanish). The green plot more clearly shows the 24 sec encoder error which I need to remove.
I'm not sure why you keep saying 24 sec cycle. Are you really talking about a 0.041 Hz underlying frequency? If so, just put it through a high pass filter with a cutoff frequency of 0.1 Hz. Otherwise, I'm not really sure what you're asking. Which signal do you want? What is the relevance of the blue signal?
I apologise if my nomenclature is incorrect - I have no training in signal processing. As I understand it, period and frequency are synonomous, one being the reciprocal of the other?
Does a high pass filter introduce a lag? if so, how can this be eliminated so as to not cause problems with the motion control loop?
I want to take the 0.041 Hz underlying frequency out of the brown signal. The blue signal can be ignored.
It shouldn't cause a lag if you use it with filtfilt. Follow the example on that page above for butter. I couldn't design one for you without seeing the fft of your signals though. Is this data on real-time though, or offline? If in real-time that kind of changes everything.
It's real-time - I guess I should have mentioned that earlier!
Are you using the DSP System toolbox? They have real time filters that you can do on individual samples at a time. But you'll have to look more into it, because I'm not too familiar.
I think I installed the DSP System Toolbox, but I've got no idea what I need to use, and how to use it. I'm hoping someone can point me in the right direction, then I can get productively stuck into the task.

Sign in to comment.

Categories

Asked:

on 7 Nov 2019

Commented:

on 10 Nov 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!