To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 6557
6556  |  6558
Subject: 
software debouncing (was Re: touch sensors aren't just switches (was Re: ideas for a RIS 2.0
Newsgroups: 
lugnet.robotics
Date: 
Wed, 25 Aug 1999 22:00:36 GMT
Viewed: 
587 times
  
One VERY easy method is to take successive samples at an interval
greater than the switch bounce (from the spec sheet for the switch)
and just make sure you have two identical readings before processing
it as a state change...

In lugnet.robotics, lego-robotics@crynwr.com (Jim Thomas) writes:
[...] Debouncing multiplexed switches in software is more
difficult than you proposed unless you make some limiting assumptions.

The way I debounce is by using a simulated RC network ("RC" stands for
resistor-capacitor). RC networks exhibit a "decaying exponential" response to
an input waveform. Here is an example of how to simulate an RC network:

averagereading = 0;
while (true) {
  Sleep(1); /* take readings every 1/100 second */

  rawreading = SensorInput();

  /* The "+ 2" is for rounding */
  /* Change "4" and "5" to "10" and "11" to make it respond more slowly */
  averagereading = ((4 * averagereading) + rawreading + 2) / 5;

  if (averagereading > THRESHOLD1) {
    /* beep */
  } else if (averagereading < THRESHOLD2) {
    /* burp */
  }
}



Message is in Reply To:
  RE: touch sensors aren't just switches (was Re: ideas for a RIS 2.0
 
I believe what we have got here is two solutions. 1) replace the Lego hardware with better microswitches 2) Make a multiplexor capable to work well with the Lego touch sensors Either one will work. I think I would rather make the multiplexor than (...) (25 years ago, 25-Aug-99, to lugnet.robotics)

3 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR