element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smarter Life
  • Challenges & Projects
  • Design Challenges
  • Smarter Life
  • More
  • Cancel
Smarter Life
Blog SteadyClip, An Economical Camera Gimbal – Part 13: Filtering Data
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jliu83
  • Date Created: 2 Jan 2014 6:49 PM Date Created
  • Views 793 views
  • Likes 1 like
  • Comments 4 comments
  • steady_clip
  • smarter_life_challenge
  • smarter_life
  • dsp
  • filter
  • iir
Related
Recommended

SteadyClip, An Economical Camera Gimbal – Part 13: Filtering Data

jliu83
jliu83
2 Jan 2014

With the IMU working, I am now focusing my efforts on getting clean data, with an emphasis on simple to implement filters.  That said, filtering is a dirty business, and it’s something that I am not too familiar with.

 

In any case, my plans for filtering are simple: high pass the gyro data to get rid of the drift, low pass the accelerometer and magnetometer data to remove the jerking inaccuracies.  Hopefully, the data that comes out will be good enough for image stabilization. Unfortunately, I don’t have the proper software for simulating a nice FIR or IIR filter.  I think an IIR higher than a 2nd order might be too much computation for 3 axis worth of data on a Cortex-M0 and relatively difficult to implement, though I am only basing this on a hunch and previous DSP experience on small microcontrollers.  FIR might be a feasible option, but again, I’ll have to look into the software that can calculate the proper coefficients.

 

The simplest of these filters is a first order high pass and low pass filter.  You can think of them as a special case of the IIR filter with a single coefficient.  These are easy to implement, with minimal phase delay.

 

There’s no need to go into the derivations, and some basic information is available via Wikipedia (high-pass, low-pass).  A cut off frequency is chosen using the following equation:

f = 1/(2*pi*tau)

 

Solving for tau:

tau = 1/(2*pi*f)

 

Next, we pick an alpha value using a sample period (dt) and tau, then implement an equation for sampled digital data, where y is the filtered data, and x is the input data. For the high pass:

alpha = tau/(tau + dt)

y[i] = alpha * y[i – 1] + alpha * (x[i] – x[i – 1])

 

For the low pass:

alpha = dt/(tau + dt)

y[i] = alpha * x[i] + (1 – alpha)*y[i – 1]

 

You are easily tell this is a case of the IIR since we are using previous output data (y[i – 1]). An FIR will use previous inputs, with not feedback from previous outputs.  I decided to do a quick and dirty model of the filters on Excel.  The Excel file is attached on this post.  I didn’t have Matlab installed, so the only plot I have is the time domain response.  Below is a screen shot:

 

image

 

The blue signal is the original simulated data.  It is a 1Hz sine plus a 100Hz sine along with a DC bias.  The red line is the high pass filter, and the green line is the low pass filter.  Cutoff frequency is set to 10Hz for both the high pass and low pass filters.  There are several things worth noting.

 

There is noticeable phase shift in the data.  This is expected since the filtering uses data from a previous output.  The response has to be delayed.  The hope is that the phase shift is small enough that the response to the motors not greatly affected.

 

DC bias is almost completely removed using the high pass filter.  Of course this is on simulated data, so we won’t know how good the bias removal is until we can insert some real data into the filters.

 

Low pass signal has plenty of noise.  Perhaps it is worth looking into a 2nd order IIR for the accelerometer.  I don’t know yet how well the motors will response to the filtered data, so I will postpone designing a 2nd order IIR (like a 2nd order Butterworth) until I get the motors working.

 

So it seems like there’s still a lot of work to do.  I will try to squeeze some real data as opposed to simulated data through the filters to see how they respond shortly.  This is going to come down to the wire.  I haven’t even looked into how to drive the motors yet.

Attachments:
SteadyClip_BlogPost13_FilterTest.xlsxSteadyClip_BlogPost13_FilterTest.xlsx
  • Sign in to reply
  • jliu83
    jliu83 over 11 years ago in reply to DAB

    So my problem with this approach is the discounting of the additional effects that the filter can have on your data.  Sure it might work, but I disagree with the approach.


    For example, what happens to the cut off frequency when the sampling frequency is changed? 

    What is the effect of the phase delay with respect of frequency response?

    Is the non-linearity of the phase delay enough to give me bad data (though for a FIR filter, the phase delay is always linear)? 

    What if my ideal running filter response for a given cutoff frequency can only be achieve with fractional samples rather than integer number of samples?

    How do you even set a cutoff frequency using a running average filter?

     

    If you are just averaging, then those questions may be overlooked.  Anecdotal evidence of it working in the past does not mean that this is the best approach, as someone else can also have an anecdotal evidence that it did not work.  For these reasons, a more in depth analysis of the system must be performed.  This is why I am devoting additional efforts to the filter design and not simply using a average.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 11 years ago in reply to jliu83

    You would be surprised how effective a simple running filter can  be.

    I used them to smooth out the inputs for driving a FLIR camera in a helicopter in flight.

    So I feel pretty confident that they could help you with a stationary camera mount.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jliu83
    jliu83 over 11 years ago in reply to DAB

    Averaging is a form of an FIR filter.  I would imagine that the performance is not that great, as the coefficients are chosen without too much though (the coefficients to each sample is simple 1/n, with n as the number of samples).  Additional attention should be put into phase delay and the actual signal attenuation for the frequencies in question, and ultimately the reason for not choosing a simple running average.  This will determine the responsiveness of system.

     

    Of course more testing should be done before determining if such a filter is sufficient, but from previous projects, simple methods like averaging on IMU data was not enough to get the type of response that's desirable.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 11 years ago

    When it comes to data filtering, I try to keep it simple.

    I would first try a simple running average filter.  Your sample size helps to smooth out a lot of high frequency change and lets you capture true trend movement.

    Accelerometers can provide a lot of noise depending upon their sensitivity.

    Look at the levels you can tolerate in movement.  Then you can setup your basic movement measurements to keep your overall focus on a steady picture.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube