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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs ELEC2645 Project - Week 20
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Former Member
  • Date Created: 14 Mar 2016 12:08 AM Date Created
  • Views 687 views
  • Likes 1 like
  • Comments 4 comments
Related
Recommended

ELEC2645 Project - Week 20

Former Member
Former Member
14 Mar 2016

ELEC2645 - Embedded Systems Project - 'Sensor-matic!'

 

The aim of the project is to create an interface between a distance and a temperature sensor and an LCD screen.

 

Noise Cancellation In The SRF02 Sensor

 

Purpose:

 

  • The SRF02 Distance Sensor is subject to interference when taking readings.
  • The readings can fluctuate massively - even when the sensor is held in one position against a stationary solid object (i.e. a wall).
  • Typically, the fluctuates jumped up by 200+ cm.
  • This effect was observed at multiple distances suggesting the interference is random as opposed to systematic.

 

Method:

 

  • The problem can be tackled in a number of different approaches.
  • The easiest method is to simply calculate an average.
  • This method requires that 'X' amount of readings are taken every iteration and summed together.
  • The total sum is divided by the 'X'.
  • This reduces the significance of random errors (although doesn't eliminate them).

 

Code:

 

  • The initial total distance (int totalDistance) is set to equal zero.
  • The number of readings (previously 'X') was selected to be 10.
  • A 'For Loop' counts through 10 readings per iteration and each time.
  • The value of the distance at each stage is added to the totalDistance variable.
  • The final total is divided by 10 to give an output distance.

 

// Cancelling Out Sensor Noise Fluctuations

 

            int totalDistance = 0; // Create a Total Function

 

            for (int iteration = 0; iteration < 10; iteration++) { // Loop Through 10 Iterations

 

                    totalDistance = totalDistance + srf02.getDistanceCm();

                   

                lcd.refresh();

            }

 

Results:

 

  • The output is shown on the Nokia LCD screen.
  • The output is less susceptible to interference - the variations are much closer to the truth value.
  • A very high value would still cause an inaccurate reading - the code can be improved to solve this problem.

 

Improvements:

 

  • Cumulative/Rolling Average - Rather than 10 readings being taken and then the average found. A cumulative average continuously calculates the average based on the current ten numbers in an array/sample space. On the eleventh reading, the first one is neglected and a new average is found. The process repeats by discarding the 'firsts' element in the array and entering in the 'tenth' and recalculating.

 

  • Current Method inc. Rejection - The current method of determining the average can be implemented however to determine more accurate values, extra code could be implemented which rejects a distance which is above/below by 30% of the previous. In order to make sure the average is unaffected, the rejected distance would need to be replaced with another value - perhaps the distance of the previous reading.
  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 9 years ago in reply to mcb1 +1
    Thank you for the sound advice! I will work on that today and fingers crossed it should correct itself. Jack
Parents
  • jw0752
    jw0752 over 9 years ago

    Hi Jack,

    I like your project. I deleted a previous comment as I made the mistake of thinking your distance sensor was analog and when I learned other wise my advice for stabilizing the reading was no longer applicable.

    John

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 9 years ago in reply to jw0752

    Thank you John, I should have probably specified more clearly.

     

    Jack

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Former Member
    Former Member over 9 years ago in reply to jw0752

    Thank you John, I should have probably specified more clearly.

     

    Jack

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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