How can I smooth accelerometer signal?

Member
Posts: 249
Joined: 2008.10
Post: #1
Hi friends!

I'm programming the accelerometer, which values are between 2.3 and -2.3.
I transform these values between 0 and 480 and I place this value into Y position of a small texture on the screen. The problem is that my texture vibrates a lot. My question is, what kind of filter should I use to smooth the signal (and the texture position)?
There are a few examples with use a High pass filter, is that what I need?
There is an example called AccelerometerGraph that have a high pass filter, and when I activate it, I only the the signal value is displaced, but not smooth.

What do you think?
Thanks a lot for your suggestions. Wink
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Sounds like you want a low-pass filter. The high-pass filter implemented in AccelerometerGraph cancels out the effect of gravity, but still picks up on high frequency movement. It sounds like you want to do the opposite; cancel out the high frequencies to stabilize your input. I don't know the implementation details off the top of my head, but I imagine googling for "low-pass filter" would give you some helpful results.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #3
ThemsAllTook Wrote:Sounds like you want a low-pass filter. The high-pass filter implemented in AccelerometerGraph cancels out the effect of gravity, but still picks up on high frequency movement. It sounds like you want to do the opposite; cancel out the high frequencies to stabilize your input. I don't know the implementation details off the top of my head, but I imagine googling for "low-pass filter" would give you some helpful results.

It makes sense. I will use google, meanwhile, did anyone implement a low-pass filter?

Thanks!

EDIT: it seems here there is a low pass filter:
http://www.newtondynamics.com/forum/view...=14&t=4728
but it seems the same as a high pass filter, is that right?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
A low pass filter is even simpler to implement.

Something like the following will do just fine:
Code:
factor = 0.1
new_value = get_new_value_for_something();
value = new_value*factor + old_value*(1 - factor)
old_value = value

It's just a linear interpolation. What it's doing when factor is near zero is only letting new_value affect the output by a little bit.

There is more complicated filtering you could do, but this will work fine 99% of the time.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #5
Skorche Wrote:A low pass filter is even simpler to implement.

Something like the following will do just fine:
Code:
factor = 0.1
new_value = get_new_value_for_something();
value = new_value*factor + old_value*(1 - factor)
old_value = value

It's just a linear interpolation. What it's doing when factor is near zero is only letting new_value affect the output by a little bit.

There is more complicated filtering you could do, but this will work fine 99% of the time.

Are you sure you are right? I mean,
old_value*(1 - factor)=old_value*(1 - 0.1)=old_value*0.9
Doesn't it mean the old value has a 90% of importance?
Am I right?

Thanks!
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #6
If you call it some 30 times per second it approaches new value pretty fast (assuming new value stays constant).

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #7
Najdorf Wrote:If you call it some 30 times per second it approaches new value pretty fast (assuming new value stays constant).

I did a test on my iphone and it goes really slowly.
But I changed 0.1 by 0.6 and it goes better, as without filter but a bit smoother.

I will some more test.
Thanks
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Game play with the accelerometer Ropeburn 3 2,642 Sep 26, 2010 06:17 PM
Last Post: Ropeburn
  Line Smooth Problem on iPhone Device abelix 1 4,109 Sep 22, 2010 06:28 AM
Last Post: Skorche
  Program received signal: “SIGKILL”. Toontingy 14 5,381 Jun 24, 2010 07:24 PM
Last Post: Frogblast
  accelerometer settings baddapple 0 3,464 Apr 24, 2010 05:39 PM
Last Post: baddapple
  About ParticleSystem and Accelerometer ! Dorald 13 5,379 Apr 2, 2010 10:17 PM
Last Post: alerus