Lab HJ06-08 Switch-Bounce Filter, Version A                S215  081006
OEES 215
20 points

Back to Main Page
 
Write a program based on the flowchart.

Explanation
Sometimes inputs (such as those from switches) do not change cleanly from 0 to 1 or 1 to 0. As shown in the timing diagram below, in0 goes up and down a couple of times before finally staying high. It also goes up and down a couple of times before staying low. If in0 is coming from a switch, we would say that there is a switch-bounce problem. When you look at a fine-enough time scale, all switches have a certain amount of bounce.



When Delay is high in the above diagram, the delay is running.

The above diagram shows one way of handling switch bounce. Here's what's happening in the diagram:
  • At first, in0 is low. 
  • When it goes high on the edge of the first blip, a delay is started.
  • After the delay has timed out, we look at in0 again. Because it is still high, we make out0 high. If it had been low after the time-out, we would have left out0 low.
    • The blips occurring while the delay is running are ignored.
  • When in0 finally goes low and stays low (in the right half of the timing diagram), this transition is also preceded by blips. 
  • At the first point that in0 goes low (in the right half of the diagram), we make out0 go low.
  • On the rising edge of the blip that occurs next, we start the delay running.
  • When the delay has timed out, in0 is low, so we leave out0 low.
 
Back to Main Page