Debugging Hardware Debouncing

Hey Guys,

I have been trying to get my hardware debounce finished so I am able to use it with Hardware interrupts. I have been using the below schematic and have laid it out on a breadboard.

and this is how I have laid it out on my bread board. keep in mind I have regulated a 9v input down to 5v for use on the IC chip and signal. The Ic is a 74ls14 Schmitt trigger inverter and the Cap and resistor values are both at 10uf and 10k respectively.

I keep getting behaviour as if the switch is not debounced and im not sure what I am doing wrong.When the button is pressed the voltage on the outbound pin goes from about 0.15v to around 4.5v (approx). The test sketch should cycle through the array and follow itself back again. I have included my breadboard setup, a video and the code.

any help would be more than appreciated.

Cheers,
Dylan

a video of the behaviour.

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int scrollpin = 10;
int scrollstate = 0;
int scrollindex = 0;
char* menuitemindex[] = {"One", "Two", "Three"};

void setup() {
  runonce();
}

void loop() {
  checkscroll();
  scrollreset();
}

// Custom Functions

void runonce() {
  lcd.begin(16,2);
  lcd.setCursor(0, 0);
  lcd.print("Menu Test");
  lcd.setCursor(0, 1);
  lcd.print("Version 0.1");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Menu");
  lcd.setCursor(0,1);
  lcd.print(menuitemindex[scrollindex]);
}

void checkscroll() {

  scrollstate = digitalRead(scrollpin);
  if (scrollstate == HIGH) {
    scrollindex++;
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Menu");
    lcd.setCursor(0, 1);
    lcd.print(menuitemindex[scrollindex]);
  }
  else {
  }
}

void scrollreset() {
 if (scrollindex >= 3) {
    scrollindex = 0;
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Menu");
    lcd.setCursor(0, 1);
    lcd.print(menuitemindex[scrollindex]); 
  }
}

I keep getting behaviour as if the switch is not debounced

Which would be what?

When the button is pressed the voltage on the outbound pin goes from about 0.15v to around 4.5v (approx).

That's consistent with the design. Are you saying the transition isn't fast enough?

BTW, 10uf is quite excessive for debouncing.

dhenry:

I keep getting behaviour as if the switch is not debounced

Which would be what?

When the button is pressed the voltage on the outbound pin goes from about 0.15v to around 4.5v (approx).

That's consistent with the design. Are you saying the transition isn't fast enough?

BTW, 10uf is quite excessive for debouncing.

  1. as per the video when i press the button it sometimes doesn't change, but then other times it skips a number, things consistent with a bouncing switch.

  2. i tried alot of different values and time constants. are there any values you could suggest that may fix this problem? from the calculations im using a 10k resistor and a 10uf cap would give a 0.1sec time constant.

Cheers.

Some power supply decoupling on the '14 might help, although those breadboards often have enough capacitance to get away with it.


Rob

Discharging a 10uF capacitor directly through a push button is not a good idea. It will cause a high current pulse to flow, which will induce a voltage on the ground line. Add a 100 ohm resistor in series with the push button.

Personally, I would use software debouncing. BTW, is there a particular reason you want to trigger an interrupt when the switch is operated? The only time I use interrupts with push buttons is when I want it to wake up the mcu from sleep mode.

This Video:

came up as an option after watching your video. It recommends a 1K ohm resistor in series as DC42 mentioned.
He even scopes it to show you what the circuit is doing.

  1. as per the video when i press the button it sometimes doesn't change, but then other times it skips a number, things consistent with a bouncing switch.

Tough to see any finger action in a video.

  1. i tried alot of different values and time constants. are there any values you could suggest that may fix this problem? from the calculations im using a 10k resistor and a 10uf cap would give a 0.1sec time constant.

I typically use 10k/0.1u or 100k/0.1u.

dhenry:

  1. as per the video when i press the button it sometimes doesn't change, but then other times it skips a number, things consistent with a bouncing switch.

Tough to see any finger action in a video.

  1. i tried alot of different values and time constants. are there any values you could suggest that may fix this problem? from the calculations im using a 10k resistor and a 10uf cap would give a 0.1sec time constant.

I typically use 10k/0.1u or 100k/0.1u.

using the below calculator those values give me a HUUGGEEEE time constant (1000 sec?)is the calcualtor wrong or is it just me?

http://hughestech.com/rc_calculator/

Cheers

You probably live in some FTL universe?

:slight_smile:

using the below calculator those values give me a HUUGGEEEE time constant (1000 sec?)is the calcualtor wrong or is it just me?

Online RC Time Constant Calculator - Gadget - Open Source Code

Cheers

well I get 1 msec for 10K ohms and .1ufd
and 10 msec for 100k and .1 ufd
with that calculator, where does 1000 sec come from?

Lefty

Have a look at this... MAX6816/17/18 CMOS switch debouncers. No external components except the switches. I have used them with great results

I've looked at that video above and tried the exact circuit that was shown on it with the pull down resistor and I'm still not getting results. Could it have something to do with using the 5v regulator into the 14 and the + rail? I'm somewhat lost for ideas :frowning: