Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6581239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:07:40+00:00 2026-05-25T16:07:40+00:00

Lately I am involved in processing data from sensors from different devices. These sensors

  • 0

Lately I am involved in processing data from sensors from different devices. These sensors consist of accelerometers, gyroscopes, magnetometers etc. It all started when I wanted to isolate the gravitational force and stumbled upon this link (code from android android_frameworks_base / services / sensorservice / SecondOrderLowPassFilter.cpp ):

/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdint.h>
#include <sys/types.h>
#include <math.h>

#include <cutils/log.h>

#include "SecondOrderLowPassFilter.h"

// ---------------------------------------------------------------------------

namespace android {
// ---------------------------------------------------------------------------

SecondOrderLowPassFilter::SecondOrderLowPassFilter(float Q, float fc)
    : iQ(1.0f / Q), fc(fc)
{
}

void SecondOrderLowPassFilter::setSamplingPeriod(float dT)
{
    K = tanf(float(M_PI) * fc * dT);
    iD = 1.0f / (K*K + K*iQ + 1);
    a0 = K*K*iD;
    a1 = 2.0f * a0;
    b1 = 2.0f*(K*K - 1)*iD;
    b2 = (K*K - K*iQ + 1)*iD;
}

// ---------------------------------------------------------------------------

BiquadFilter::BiquadFilter(const SecondOrderLowPassFilter& s)
    : s(s)
{
}

float BiquadFilter::init(float x)
{
    x1 = x2 = x;
    y1 = y2 = x;
    return x;
}

float BiquadFilter::operator()(float x)
{
    float y = (x + x2)*s.a0 + x1*s.a1 - y1*s.b1 - y2*s.b2;
    x2 = x1;
    y2 = y1;
    x1 = x;
    y1 = y;
    return y;
}

// ---------------------------------------------------------------------------

CascadedBiquadFilter::CascadedBiquadFilter(const SecondOrderLowPassFilter& s)
    : mA(s), mB(s)
{
}

float CascadedBiquadFilter::init(float x)
{
    mA.init(x);
    mB.init(x);
    return x;
}

float CascadedBiquadFilter::operator()(float x)
{
    return mB(mA(x));
}

// ---------------------------------------------------------------------------
}; // namespace android

While that code does work quite well I feel like I need to understand some basics about the filter philosophy in general. For example maybe I need to change something in that filter.

I started reading on Wikipedia (Kalman, Low-Pass, …) but I still feel like I need to feel/touch this theory better before starting to modify someone else’s code.

So I’m asking you, SO users, what can I read in order to have a more than general idea about filters? Any link, resource, documentation will be good.

Also: I have an engineer degree but didn’t quite study filters except for some Fourier transformations (DFT) when studying signal processing. Math should not be a big issue.

I’m asking this question because I saw there are MANY questions related to filters.

Thanks a lot,

Iulian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:07:41+00:00Added an answer on May 25, 2026 at 4:07 pm

    I found a less complicated introduction at dspguide in the following chapters:

    • Chapter 14: Introduction to Digital Filters
    • Chapter 15: Moving Average Filters
    • Chapter 16: Windowed-Sinc Filters
    • Chapter 17: Custom Filters
    • Chapter 19: Recursive Filters
    • Chapter 20: Chebyshev Filters
    • Chapter 21: Filter Comparison

    More interesting answers here on dsp stackexchange.


    PS: I made this a wiki so people can add their resources (contributions are welcome).


    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read numerous discussions lately about different forms of security for mobile devices outside
Lately I had to change some code on older systems where not all of
Lately all modern programming languages have a definitive web site to support, distribute, learn
I've been getting more and more involved in C /C++ programming lately and have
Lately, I've been reading much about constructors from the well-received C++ FAQ . One
Lately we've been having issues on entity framework saving data objects even though we
All, Wanted to get a few thoughts on this. Lately I am becoming more
Lately, bringing the help window from Visual Studio is taking a long time. Even
I've been designing quite a few Windows Forms applications lately (data-entry apps, office integration,
I've got an MVC application written with Zend Framework that pulls data from an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.