element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs ELEC2645 Project - Week 20
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Former Member
  • Date Created: 14 Mar 2016 12:08 AM Date Created
  • Views 315 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 7 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
  • Former Member
    Former Member over 7 years ago in reply to mcb1

    Thank you for the sound advice! I will work on that today and fingers crossed it should correct itself.

     

    Jack

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 7 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
  • mcb1
    mcb1 over 7 years ago

    Jack

    I fought variations for a couple of weeks, and tried various software fixes.

     

    It turned out that power was the cause with the Neopixels generating some form of fluctuation that was enough to upset the readings.

    My blog is here

    Ultrasonic Reversing Monitor

    Ultrasonic Reversing Monitor  Part2

     

    Despite having advised many posters in the past about the need to add large value capacitors across the supply, I fell into the same trap thinking that a neopixel doesn't draw much current.

     

    After adding the capacitor, the readings were rock steady.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jw0752
    jw0752 over 7 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
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 © 2023 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