Shop OBEX P1 Docs P2 Docs Learn Events
Software filtering of sensor raw data — Parallax Forums

Software filtering of sensor raw data

roboticsrobotics Posts: 90
edited 2010-06-27 03:46 in Propeller 1
Hi,

I have a mechanical linear displacement sensor that obtains digital numeric position data. The data values obtained constantly fluctuate around each sensor position making the data hard to use. I would appreciate if I could be directed to some basic introductory resources where I can create a basic/simple software filter whereby the filtered data can be used on-the-fly in other calculations.

In advance, many thanks!

Comments

  • roboticsrobotics Posts: 90
    edited 2010-06-26 07:39
    Hi,

    Thank you for your response.

    As an example, a sensor position of 10 may continuously oscillate as 10, 9, 11, 11, 10, 9, 11, etc. I am totally new to filtering, so if I could program in Spin a simple filter that I understand rather than using someone else's object, this would be preferred.
  • roboticsrobotics Posts: 90
    edited 2010-06-26 08:09
    Bill,

    Thank you!
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 08:17
    This is a common technique

    ··········· X := (X*7 + newx) /8

    i.e. you take 1/8 of the new value each time you get a sensor reading. Depending on how much you want to filter

    you can use different numbers e.g. 3 and 4 is less filtering, 15 and 16 is more filtering
  • roboticsrobotics Posts: 90
    edited 2010-06-26 09:00
    Thank you!

    Much appreciated
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-26 14:49
    BTW, the two approaches suggested, in the order presented, are known as FIR (finite impulse response) and IIR (infinite impulse response) low pass filters, due to the persistent effects individual readings have on the result.

    -Phil
  • roboticsrobotics Posts: 90
    edited 2010-06-26 15:50
    Hi Phil,

    I appreciate you mentioning this so I can do some additional research!
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-06-26 15:59
    This reference is for the Basic Stamp but can be applied to the Prop easily.

    http://www.emesystems.com/BS2math5.htm

    John Abshier
  • roboticsrobotics Posts: 90
    edited 2010-06-26 16:58
    Hi John,

    Many thanks for taking the time to include this Excellent reference. It has a lot of information that I hadn't known about or considered.

    Have a great day!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-26 18:01
    Here's another thread that may help: http://forums.parallax.com/showthread.php?p=759589.

    -Phil
  • roboticsrobotics Posts: 90
    edited 2010-06-26 18:27
    Phil,

    That's a really great link with valuable information. Many thanks for your help.
  • BRBR Posts: 92
    edited 2010-06-26 21:49
    Here's another thread with a variety of filter examples
  • roboticsrobotics Posts: 90
    edited 2010-06-27 03:46
    Hi,

    That's a really great link with lots of goodies! My sincere thanks.
Sign In or Register to comment.