DrDAQ

Data logger, oscilloscope, signal generator and more!

DrDAQ is a versatile instrument that connects to the USB port of any PC. Using the supplied PicoScope software it can be used as an oscilloscope, spectrum analyzer and signal generator.

From just

Find out more  

Measuring switch bounce

Introduction

Using an inexpensive PC-based oscilloscope, we can measure the noise that occurs when a mechanical switch changes state. The experiment described here measures the amount of time that a switch takes to settle, and shows one way to reduce the bouncing effect.

switch bounce equipment

Equipment required

  • A PC with PicoScope installed
  • DrDAQ data logger or a PC-based oscilloscope
  • Various switches to test
  • Several sizes of resistor and capacitor
  • 9 V battery
  • Prototyping board
  • Suitable leads and connectors.

Background theory

Nearly all mechanical switches generate some "bounce". That is, for every time they switch pulseare switched, they actually open and close their contacts several times before settling down to their new position. For normal switches, this can last from as little as a fraction of a millisecond (ms), to as long as 50 ms. Only very high quality switches generate little or no bounce.

This is not usually a problem if you are merely turning on a light, but if you are working with logic devices, all these extra bounces can create havoc. For instance, what if every time you pressed a button to increment a counter you actually added several counts to the total?

One way of debouncing a switch is by using an RC network to slow either the rising or falling edge of the event. We can use the fact that the time for a capacitor to recover 63% of its voltage, in seconds, is the product of the resistance in ohms and the capacitance in farads.

(It would be a good idea to perform the experiment Measuring the Value of a Capacitor to gain a better understanding of this phenomenon.)

Practical considerations

While it may be true that switches bounce, it is also true that a person can only push a button or operate a switch a limited number of times per second.  This is the reason why various debouncing methods are practical. As long as the debounce method does not take too long, no one will notice.

Experiment setup

Connect the battery, resistor and switch as shown in the circuit diagram. Attach the scope probe to point A.

The PicoScope software should be set up to sample at 1 ms/div, ±10 V, DC. Trigger to repeat, Ch A, falling at around 6000 mV with a -10% pre-trigger.

Carrying out the experiment

switch circuit

Part A

Actuate the switch several times, and measure the length of "bounce zone", either by eye, or using the scope cursors. Connect up other switches and measure the length of bounce on those as well. Try to test different switches with a broad range of characteristics. Large switches, small switches, buttons that make a tiny "click" when you press them, and ones that don’t. Try simply using a piece of wire instead of a switch. For each switch, write down the main characteristic in a table along with the length of the bounce zone.

switch bounce waveform

Part B

Change PicoScope so that it is sampling at 200 ms/div. And change the trigger to Single. Take the switch that is easiest to actuate, (it is also a good idea to make it a strong one!) and "normally" press it as many times as you can while the scope is recording. Look on the trace and find the two rising or falling edges that are the closest to each other Using the cursors, measure the distance between these two rising or falling edges. (An interesting sub-experiment can be done here by making a list of everyone in the class, how many hours of computer games they play each day and the distance between switch presses.) If the switch is an especially bad one, the bounces may interfere with this part. But most likely, you will not even see the bounces that were so obvious in part A.

multiple switch waveform

Debouncing the switch

Setup

Using one of the switches that is bouncing for less than 1 ms duration, add a 1 µF to the circuit in the position shown. The PicoScope software should be set up as in part A above.

Part C

Capture a switch press as you did in part A. You should see a large improvement. In switch cctfact there should be only one descending edge, and perhaps some smaller "bumps" where the bounces were. Can you explain how this works? Experiment with smaller and larger capacitors to see if the bumps get taller or shorter. Change the scope trigger to Rising and look at the trace generated by releasing the switch (or set the time base to a longer period and capture both press and release on the same screen). The rising edge shape should be familiar to you if you worked through the experiment Measuring the Value of a Capacitor, and it should offer clues as to where the extra switch bounces went.

de-bounced switc

Questions and discussion of results

  1. Did you notice a link between the size of the switch, and the length of its switch bounce?
  2. Was there a link between the number of hours spent at video games and the speed at which you could press the switch?
  3. Do you think there is a link between the best size of the capacitor and the value of the resistor used in the circuit?
  4. What would happen if a very large capacitor was used?
  5. Discuss some other ways in which a switch can be "de-bounced".

Further study

If a TTL counter chip is available, the student may want to connect it up with some LEDs and try clocking it with one of the switches. Then use the de-bounced switch circuit on it to see a graphic example of why de-bouncing switches is necessary in digital applications.

Testimonials

  • The kit (2408B) is of obvious quality, easy to setup and calibrate and the free to download software has a reasonable learning curve. Superb kit, superb support, what more can I say.

    Rop Honnor
  • I have been using my 4224 PicoScope for years. I travel abroad so this has been ideal due to its physical size. Storage of waveforms on my Laptop is very easy allowing me to quickly email waveforms to my Colleagues.

    Andrew
  • Not many USB scopes works on Win & Mac & Linux too, so that proves me that guys from Pico really cares about us, customers. This made my decision much easier when I was looking to buy an USB scope.

    Raul Trifan
  • We have been using Picoscope 6404D for quite some time, and are amazed by its accuracy and powerful emulations while working with numerous signal evaluations.

    J Mohanty
  • PicoLog TC-08: This is a very nice unit that works consistently and reliably.

    Jeff Hulett
  • It is a great scope. I had a weird problem - it did not work on one of my PC’s. Customer service gave me first class service. If I could give 6 stars for customer service - I would do so.

    Niels Larsen
  • Perfect Partner for Development of Encoder controlled Stepper Motor Actuators. Since the included software is really stable, this type of device is a great tool for great tasks!

    Helmut Schoettner
  • A superb piece of equipment worth its weight in gold

    Nigel Clinch
  • So simple to use & beats any other I have ever used hands down.

    John D Samsing
  • Rather than webcam our benchtop scope screen, it was suggested we use a PicoScope to share waveforms via screen share.

    We were a bit hesitant at first … but it worked flawlessly, and everybody is now out shopping for PicoScopes!

    T Lövskog • SVP of Innovation at Additude AB
  • Great functionality in a compact size. I really like moving the mouse pointer to a position and having the Time and Voltage display the values at that point. Calibration equipment is a breeze with that feature.

    Don Horein

PC oscilloscope and data logger products