Purpose of the cap in this RC Debouncer circuit...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stj
    Great Sage 齊天大聖
    • Dec 2009
    • 30977
    • Albion

    #21
    Re: Purpose of the cap in this RC Debouncer circuit...

    you have it the wrong way around,
    pullup resistors keep the input high until you connect them to ground - like with a button.

    if your button grounds the input, enable the pullups

    Comment

    • Spork Schivago
      Badcaps Legend
      • Mar 2012
      • 4734
      • United States of America

      #22
      Re: Purpose of the cap in this RC Debouncer circuit...

      Originally posted by stj
      you have it the wrong way around,
      pullup resistors keep the input high until you connect them to ground - like with a button.

      if your button grounds the input, enable the pullups
      I'm sorry, you're right. They are and have been enabled. I just had it backwards in my head for some reason!


      I decided to abandoned William Dillon's debouncer code and just go for a very simply poll the input, when we see a pin go low, register a push, wait 200 ms or so, if the button is still low, loop until it goes back high, and then continue. It's not very advanced and I'm sure there's probably some unforeseen problems that might pop up, but it seems to work my really fast button mashing and everything. I've tested it by making 4 LEDs light up in binary. One button counts up, the other counts down. No matter how fast I push the button, it seems to work just fine.
      -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

      Comment

      • stj
        Great Sage 齊天大聖
        • Dec 2009
        • 30977
        • Albion

        #23
        Re: Purpose of the cap in this RC Debouncer circuit...

        here is a 2button led dimmer i made years ago.
        i never had to debounce it.

        ;*********************************************************************************************
        list p=12F629 ; list directive to define processor
        #include <P12F629.INC> ; processor specific variable definitions
        errorlevel -302 ; suppress message 302 from list file

        __CONFIG _CP_ON & _WDT_OFF & _MCLRE_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

        #define Speed 0x08
        #define PWM GPIO,0
        #define Switch1 GPIO,1
        #define Switch2 GPIO,2
        #define IFNZ btfss STATUS,Z
        #define IFZ btfsc STATUS,Z
        #define BANK0 bcf STATUS,RP0
        #define BANK1 bsf STATUS,RP0
        #define BeginPWM PWMFlags,0

        cblock 0x20
        RunDelay ; running speed of mainloop
        IntCount
        Dutycycle ; Holds duty cycle for PWM
        w_temp ; variable used for context saving
        status_temp ; variable used for context saving
        pclath_temp ; variable used for context saving
        PWMFlags ; variable used for software flags
        endc
        ;******************************************************************************
        ;
        ;Code starts to run from here

        Reset
        goto Main

        nop
        nop
        nop

        Interrupt
        goto ISRPWM



        ;******************************************************************************
        ;
        ; Main code section starts to run from here
        Main
        movwf OSCCAL
        call InitPWM
        call initGPIO
        movlw Speed
        movwf RunDelay

        ; The main program loop starts here. The process of PWM signal
        ; generation is driven by Timer0 interrupts. A software flag
        ; called 'BeginBWM' is set in the Timer0 ISR at the start of
        ; a new PWM period.

        MainLoop
        btfss BeginPWM
        goto MainLoop
        bcf BeginPWM

        decfsz RunDelay
        goto MainLoop
        movlw Speed
        movwf RunDelay


        btfss Switch1 ;check the switch & goto Ramp if on.
        goto Ramp_up
        btfss Switch2 ;check the switch & goto Ramp if on.
        goto Ramp_down
        goto MainLoop

        Ramp_down
        movlw 0x00
        addwf Dutycycle,W
        IFNZ
        decf Dutycycle,1
        goto MainLoop

        Ramp_up
        movlw 0x1f
        subwf Dutycycle,W
        IFNZ
        incf Dutycycle,1
        goto MainLoop

        ;******************************************************************************
        ISRPWM
        movwf w_temp ; save off current W register contents
        movf STATUS,w ; move status register into W register
        movwf status_temp ; save off contents of STATUS register

        ; Write TMR0 to setup next interrupt interval
        movlw .99
        movwf TMR0
        ;State Machine for PWM starts from here
        DecIntCount ;Decrement IntCount Register
        decfsz IntCount,F ;decrement IntCount register and if it is zero then make the output pin high
        goto Channel ;if IntCount register is not zero then go to chk the dutycycle of the signal
        ; If IntCount is 0, then it is time to start a new PWM signal period.
        BeginPeriod
        bcf PWM ; Set PWM output pin low

        movlw .32 ; Initialize IntCount to 32
        movwf IntCount
        bsf BeginPWM ; Set flag for main software loop

        goto ExitISR ; Goto end of ISR code


        ; If it is not the beginning of the PWM period, we need to compare each
        ; dutycycle to the value of IntCount. This is done by performing a
        ; subtraction and checking to see whether the result is 0. When a match
        ; occurs, the output pin for the PWM channel is set to 0.
        Channel
        movf Dutycycle,W
        subwf IntCount,W ;Is IntCount - DutyCycle = 0?
        IFZ
        bsf PWM ;Yes, set output pin to 1


        ;ISR RestoreData
        ExitISR
        bcf INTCON,T0IF ;clear the T0IF bit in the INTCON register
        movf status_temp,w ; retrieve copy of STATUS register
        movwf STATUS ; restore pre-isr STATUS register contents
        swapf w_temp,f
        swapf w_temp,w ; restore pre-isr W register contents
        retfie ; return from interrupt
        ;******************************************************************************
        InitPWM ;Initialization for software PWM

        BANK1 ;Select the RAM memory bank 1
        ;Timer0 assignment
        movlw b'01000001' ;Select the internal clock & /4 prescaler
        ;0------- GPIO Pull-up Enable bit
        ;-1------ Interrupt on rising edge of INT pin
        ;--0----- T0CS->0. Select Timer mode and Internal instruction cycle clock (CLKOUT)
        ;---0---- T0SE->0. Select falling edge on T0CK1 pin
        ;----0--- PSA->0. Select Timer0 module for Prescaler
        ;-----001 PS2:PS0->001. Select 1:4 Prescaler rate
        movwf OPTION_REG ;move the value of work register into OPTION register

        BANK0 ;Select the RAM memory bank 0
        ;Interrupts Initialization
        movlw b'10100000' ;Enable global and Timer0 interrupts
        movwf INTCON

        ;Other Variable Initialization
        movlw .32
        movwf IntCount ; Initialize IntCount to 32

        ;Variables to hold duty cycle values
        movlw .00
        movwf Dutycycle

        return
        ;******************************************************************************

        initGPIO
        BANK1
        movlw b'11111110' ;Make GP0 as output and GP1-7 as input
        movwf TRISIO
        movlw b'00110110'
        movwf WPU
        movlw b'00000000'
        movwf IOC

        BANK0
        movlw b'00000111' ;comparater off
        movwf CMCON
        CLRF GPIO ;Initialize I/O port

        return
        ;******************************************************************************
        END

        Comment

        • keeney123
          Lauren
          • Sep 2014
          • 2536
          • United States

          #24
          Re: Purpose of the cap in this RC Debouncer circuit...

          Originally posted by Spork Schivago
          I'm sorry, you're right. They are and have been enabled. I just had it backwards in my head for some reason!


          I decided to abandoned William Dillon's debouncer code and just go for a very simply poll the input, when we see a pin go low, register a push, wait 200 ms or so, if the button is still low, loop until it goes back high, and then continue. It's not very advanced and I'm sure there's probably some unforeseen problems that might pop up, but it seems to work my really fast button mashing and everything. I've tested it by making 4 LEDs light up in binary. One button counts up, the other counts down. No matter how fast I push the button, it seems to work just fine.
          The important words here are Pull UP and Pull Down.

          Comment

          • Spork Schivago
            Badcaps Legend
            • Mar 2012
            • 4734
            • United States of America

            #25
            Re: Purpose of the cap in this RC Debouncer circuit...

            Originally posted by keeney123
            The important words here are Pull UP and Pull Down.
            Let's see if I got it right without having to look it up. Pull Up resistors pull the voltage high, right? The pull-downs pull them to ground, right? But I don't remember why I needed them enabled on the PIC now. I want to say it was for when the switch was open the pin wouldn't be left floating. I think I remember how it was bad to leave an input floating. So I enable the internal weak pull-up resistor, it pulls the pin HIGH and whenever my push buttons close, they pull it down LOW. Is that about right?
            -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

            Comment

            • Spork Schivago
              Badcaps Legend
              • Mar 2012
              • 4734
              • United States of America

              #26
              Re: Purpose of the cap in this RC Debouncer circuit...

              Originally posted by stj
              here is a 2button led dimmer i made years ago.
              i never had to debounce it.

              ;*********************************************************************************************
              list p=12F629 ; list directive to define processor
              #include <P12F629.INC> ; processor specific variable definitions
              errorlevel -302 ; suppress message 302 from list file

              __CONFIG _CP_ON & _WDT_OFF & _MCLRE_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

              #define Speed 0x08
              #define PWM GPIO,0
              #define Switch1 GPIO,1
              #define Switch2 GPIO,2
              #define IFNZ btfss STATUS,Z
              #define IFZ btfsc STATUS,Z
              #define BANK0 bcf STATUS,RP0
              #define BANK1 bsf STATUS,RP0
              #define BeginPWM PWMFlags,0

              cblock 0x20
              RunDelay ; running speed of mainloop
              IntCount
              Dutycycle ; Holds duty cycle for PWM
              w_temp ; variable used for context saving
              status_temp ; variable used for context saving
              pclath_temp ; variable used for context saving
              PWMFlags ; variable used for software flags
              endc
              ;******************************************************************************
              ;
              ;Code starts to run from here

              Reset
              goto Main

              nop
              nop
              nop

              Interrupt
              goto ISRPWM



              ;******************************************************************************
              ;
              ; Main code section starts to run from here
              Main
              movwf OSCCAL
              call InitPWM
              call initGPIO
              movlw Speed
              movwf RunDelay

              ; The main program loop starts here. The process of PWM signal
              ; generation is driven by Timer0 interrupts. A software flag
              ; called 'BeginBWM' is set in the Timer0 ISR at the start of
              ; a new PWM period.

              MainLoop
              btfss BeginPWM
              goto MainLoop
              bcf BeginPWM

              decfsz RunDelay
              goto MainLoop
              movlw Speed
              movwf RunDelay


              btfss Switch1 ;check the switch & goto Ramp if on.
              goto Ramp_up
              btfss Switch2 ;check the switch & goto Ramp if on.
              goto Ramp_down
              goto MainLoop

              Ramp_down
              movlw 0x00
              addwf Dutycycle,W
              IFNZ
              decf Dutycycle,1
              goto MainLoop

              Ramp_up
              movlw 0x1f
              subwf Dutycycle,W
              IFNZ
              incf Dutycycle,1
              goto MainLoop

              ;******************************************************************************
              ISRPWM
              movwf w_temp ; save off current W register contents
              movf STATUS,w ; move status register into W register
              movwf status_temp ; save off contents of STATUS register

              ; Write TMR0 to setup next interrupt interval
              movlw .99
              movwf TMR0
              ;State Machine for PWM starts from here
              DecIntCount ;Decrement IntCount Register
              decfsz IntCount,F ;decrement IntCount register and if it is zero then make the output pin high
              goto Channel ;if IntCount register is not zero then go to chk the dutycycle of the signal
              ; If IntCount is 0, then it is time to start a new PWM signal period.
              BeginPeriod
              bcf PWM ; Set PWM output pin low

              movlw .32 ; Initialize IntCount to 32
              movwf IntCount
              bsf BeginPWM ; Set flag for main software loop

              goto ExitISR ; Goto end of ISR code


              ; If it is not the beginning of the PWM period, we need to compare each
              ; dutycycle to the value of IntCount. This is done by performing a
              ; subtraction and checking to see whether the result is 0. When a match
              ; occurs, the output pin for the PWM channel is set to 0.
              Channel
              movf Dutycycle,W
              subwf IntCount,W ;Is IntCount - DutyCycle = 0?
              IFZ
              bsf PWM ;Yes, set output pin to 1


              ;ISR RestoreData
              ExitISR
              bcf INTCON,T0IF ;clear the T0IF bit in the INTCON register
              movf status_temp,w ; retrieve copy of STATUS register
              movwf STATUS ; restore pre-isr STATUS register contents
              swapf w_temp,f
              swapf w_temp,w ; restore pre-isr W register contents
              retfie ; return from interrupt
              ;******************************************************************************
              InitPWM ;Initialization for software PWM

              BANK1 ;Select the RAM memory bank 1
              ;Timer0 assignment
              movlw b'01000001' ;Select the internal clock & /4 prescaler
              ;0------- GPIO Pull-up Enable bit
              ;-1------ Interrupt on rising edge of INT pin
              ;--0----- T0CS->0. Select Timer mode and Internal instruction cycle clock (CLKOUT)
              ;---0---- T0SE->0. Select falling edge on T0CK1 pin
              ;----0--- PSA->0. Select Timer0 module for Prescaler
              ;-----001 PS2:PS0->001. Select 1:4 Prescaler rate
              movwf OPTION_REG ;move the value of work register into OPTION register

              BANK0 ;Select the RAM memory bank 0
              ;Interrupts Initialization
              movlw b'10100000' ;Enable global and Timer0 interrupts
              movwf INTCON

              ;Other Variable Initialization
              movlw .32
              movwf IntCount ; Initialize IntCount to 32

              ;Variables to hold duty cycle values
              movlw .00
              movwf Dutycycle

              return
              ;******************************************************************************

              initGPIO
              BANK1
              movlw b'11111110' ;Make GP0 as output and GP1-7 as input
              movwf TRISIO
              movlw b'00110110'
              movwf WPU
              movlw b'00000000'
              movwf IOC

              BANK0
              movlw b'00000111' ;comparater off
              movwf CMCON
              CLRF GPIO ;Initialize I/O port

              return
              ;******************************************************************************
              END
              Thanks for sharing Stj. I'll post my source after I post this question. Why didn't you have to debounce it? My understanding was pretty much all switches bounce, some more than others. SMD type ones and the smaller ones seem to bounce less than the old school ones (like the push button ones that click when you push them for a Desktop's reset button for example). Did you use hardware to prevent it from bouncing?
              -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

              Comment

              • Spork Schivago
                Badcaps Legend
                • Mar 2012
                • 4734
                • United States of America

                #27
                Re: Purpose of the cap in this RC Debouncer circuit...

                Code:
                /*
                 * Project: Blinking LED
                 * File:  main.c
                 * Author: Spork Schivago
                 *
                 * Notice: Licensed under Creative Commons
                 *     Attribution 4.0 International (CC BY 4.0)
                 *     http://creativecommons.org/licenses/by/4.0/
                 *
                 * Version: 0.1
                 * 
                 * Notes:  Simple C program to control a PIC16F628A. The PIC
                 *     will make 4 LEDs blink for a certain amount of time.
                 *     The first LED blinks for a certain amount of time, then
                 *     the second LED, the third, the fourth and it repeats.
                 * 
                 * Created on December 18, 2015, 6:59 PM
                 */
                
                /* Set the clock frequency of the microcontroller
                 * to 4MHz so we can use the various delay() functions.
                 */
                #define _XTAL_FREQ 4000000
                
                /* #pragma config statements should precede project file includes.
                 * Use project enums instead of #define for ON and OFF.
                 */
                
                /* Configuration Bits. */
                #pragma config FOSC = INTOSCIO /* Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN). */
                #pragma config WDTE = OFF    /* Watchdog Timer Enable bit (WDT disabled). */
                #pragma config PWRTE = ON    /* Power-up Timer Enable bit (PWRT enabled). */
                #pragma config MCLRE = OFF   /* RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD). */
                #pragma config BOREN = ON    /* Brown-out Detect Enable bit (BOD enabled). */
                #pragma config LVP = ON     /* Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming). */
                #pragma config CPD = OFF    /* Data EE Memory Code Protection bit (Data memory code protection off). */
                #pragma config CP = OFF     /* Flash Program Memory Code Protection bit (Code protection off). */
                
                #include <xc.h>
                #include <stdint.h>
                
                /* Setup some preprocessor definitions so we can 
                 * keep track of the various pins a bit easier.
                 * RA0 is LED1, RA1 is LED2, RA2 is LED3 and 
                 * RA3 is LED4.
                 */
                #define LED1  0b00000001     /* bitmask for pin RA0. */
                #define LED2  0b00000010     /* bitmask for pin RA1. */
                #define LED3  0b00000100     /* bitmask for pin RA2. */
                #define LED4  0b00001000     /* bitmask for pin RA3. */
                
                #define BTN_UP 0b00000001     /* bitmask for pin RB0. */
                #define BTN_DWN 0b00000010     /* bitmask for pin RB1. */
                
                volatile uint8_t sPORTA=0;     /* Shadow register to hold the state of pin
                                   * to prevent RMW problem. 
                                   */
                
                void init (void);
                void blink_led (unsigned char led_bit, unsigned long time_ms);
                void toggle_led (unsigned char led_bit);
                void delay_ms(unsigned long milliseconds);
                
                void main(void) {
                  uint8_t temp;
                  uint8_t count = 0;
                  
                  init();
                
                  /* Blink all four LEDs once to show the user they're working. */
                  blink_led (LED1, 200);
                  blink_led (LED2, 200);
                  blink_led (LED3, 200);
                  blink_led (LED4, 200);
                
                  while(1) {
                    if(~PORTB & BTN_UP) {
                      count++;           /* Increment counter. */
                      if(count==16) count = 0;   /* We only have 4 LEDs so when we reach 16, reset. */
                      sPORTA = count;        /* Store count value in memory. */
                      PORTA = sPORTA;        /* Update PORTA with the shadow register contents. */
                      delay_ms(200);        /* Delay to give switch a chance to stop bouncing. */
                      if(~PORTB & BTN_UP) {
                        while(~PORTB & BTN_UP);  /* Loop until it's depressed. */
                      }
                    }
                    else if(~PORTB & BTN_DWN) {    /* The user pressed the second button. */
                      count--;           /* Decrement counter. */
                      if(count==255) count = 0;   /* Since we're unsigned, negative will be 255. */
                      sPORTA = count;        /* Store count value in memory. */
                      PORTA = sPORTA;        /* Update PORTA with the shadow register contents. */
                      delay_ms(200);        /* Delay to give switch a chance to stop bouncing. */
                      if(~PORTB & BTN_DWN) {    /* If button is still pressed... */
                        while(~PORTB & BTN_DWN); /* Loop until it's depressed. */
                      }
                    }
                  }
                }
                
                /* Function to turn the LEDs on and off every second. */
                void blink_led (unsigned char led_bit, unsigned long time_ms) {  
                  sPORTA |= led_bit; /* Modify the shadow register (to prevent RMW). */
                  PORTA = sPORTA;   /* Update PORTA with the shadow register to turn ON the LED. */
                  delay_ms(time_ms); /* Wait 1s. */
                  
                  sPORTA &= ~led_bit; /* Modify the shadow register. */
                  PORTA = sPORTA;   /* Update PORTA with the shadow register to turn OFF the LED. */
                }
                
                void toggle_led (unsigned char led_bit) {
                  sPORTA ^= led_bit; /* Toggle the bit stored in led_bit. */
                  PORTA = sPORTA;   /* Update PORTA with the shadow register contents. */
                }
                
                void delay_ms(unsigned long milliseconds) {
                  while(milliseconds > 0) {
                    __delay_ms(1);
                    milliseconds--;
                  }
                }
                /* Function to setup the various control registers
                 * and set the direction of the various I/O pins
                 */
                void init(void) {
                  CMCON = 0x07;    /* Turn comparators off and enable pins
                             * for I/O functions CM<2:0> = 0b111
                             */
                
                  OPTION_REGbits.nRBPU = 0;    /* Enable the weak pull-up resistors on PORTB. */
                
                  
                  /* Set the directions of the various pins 
                   * by manipulating the tri-state registers
                   */
                  /*   pin number
                   *    76543210
                   */
                  TRISA = 0b00000000;       /* Set all PORTA pins to output. */
                  TRISB = 0b00000011;       /* Set ports RB0:1 to inputs. */
                  
                  PORTA = 0;           /* Set all PORTA bits to low by default. */  
                  PORTB = 1;           /* Set all PORTB bits to high by default. */
                }
                Sorry for all the comments. Just makes it a bit easier for me to remember stuff. My next step is to replace the blinking LEDs with a 3.5 segment display that I have. It's a 28-pin and on the side of it, it says:
                ARK
                SP400561N 1413

                I've found other 3-segment LED displays but I haven't been able to find the datasheet for this specific one. I've found ones that look identical but are made by different companies. I wonder how much they differ...could I use a datasheet for one with the same physical measurements, number of pins, etc? The package this was in says 3-Digit Common-Cathode Numeric Display x1
                -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                Comment

                • Spork Schivago
                  Badcaps Legend
                  • Mar 2012
                  • 4734
                  • United States of America

                  #28
                  Re: Purpose of the cap in this RC Debouncer circuit...

                  I found it! The website had the wrong picture listed but right datasheet! They listed some weird 10-digit LED display but I clicked the datasheet link and it really is the 3.5 digit one I have. I wonder how hard it's going to be to control. Lot of pins and I'm running out of room on my little breadboard. Might need to invest in a larger one or daisy chain a few of them together!
                  -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                  Comment

                  • stj
                    Great Sage 齊天大聖
                    • Dec 2009
                    • 30977
                    • Albion

                    #29
                    Re: Purpose of the cap in this RC Debouncer circuit...

                    Originally posted by Spork Schivago
                    Let's see if I got it right without having to look it up. Pull Up resistors pull the voltage high, right? The pull-downs pull them to ground, right? But I don't remember why I needed them enabled on the PIC now. I want to say it was for when the switch was open the pin wouldn't be left floating. I think I remember how it was bad to leave an input floating. So I enable the internal weak pull-up resistor, it pulls the pin HIGH and whenever my push buttons close, they pull it down LOW. Is that about right?
                    that's it.
                    the resistor is to stop the pin floating and should bias in the oposing direction to the switch.

                    Comment

                    • stj
                      Great Sage 齊天大聖
                      • Dec 2009
                      • 30977
                      • Albion

                      #30
                      Re: Purpose of the cap in this RC Debouncer circuit...

                      Originally posted by Spork Schivago
                      Thanks for sharing Stj. I'll post my source after I post this question. Why didn't you have to debounce it? My understanding was pretty much all switches bounce, some more than others. SMD type ones and the smaller ones seem to bounce less than the old school ones (like the push button ones that click when you push them for a Desktop's reset button for example). Did you use hardware to prevent it from bouncing?
                      the pic isnt really fast enough to notice a bounce - atleast the 4Mhz ones arent.

                      Comment

                      • stj
                        Great Sage 齊天大聖
                        • Dec 2009
                        • 30977
                        • Albion

                        #31
                        Re: Purpose of the cap in this RC Debouncer circuit...

                        Originally posted by Spork Schivago
                        I found it! The website had the wrong picture listed but right datasheet! They listed some weird 10-digit LED display but I clicked the datasheet link and it really is the 3.5 digit one I have. I wonder how hard it's going to be to control. Lot of pins and I'm running out of room on my little breadboard. Might need to invest in a larger one or daisy chain a few of them together!
                        11 pins for that.
                        7segments + decimal point
                        3 select lines for the digits.
                        and you need to constantly scan through the 3 digits to keep them from flickering.

                        that's why i prefer intelligent displays - consider an lcd with the hitchi 44780 interface instead
                        you only need about 7 pins and you can get one out of some junk like an old fax machine.

                        Comment

                        • Spork Schivago
                          Badcaps Legend
                          • Mar 2012
                          • 4734
                          • United States of America

                          #32
                          Re: Purpose of the cap in this RC Debouncer circuit...

                          Originally posted by stj
                          that's it.
                          the resistor is to stop the pin floating and should bias in the oposing direction to the switch.
                          So, even if I'm not using a pin, should I always set it to output or tie it into ground or something so it's not floating? Or do I just want them not floating when I'm using them later on, like with a switch, for example?
                          -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                          Comment

                          • Spork Schivago
                            Badcaps Legend
                            • Mar 2012
                            • 4734
                            • United States of America

                            #33
                            Re: Purpose of the cap in this RC Debouncer circuit...

                            Originally posted by stj
                            the pic isnt really fast enough to notice a bounce - atleast the 4Mhz ones arent.
                            Wow. Must of been a good switch. My PIC16F628A I got running at 4MHz and I notice a lot of bouncing. I'm using a very old reset switch for a desktop PC and then a newer one from some Make: It electronics kit. The newer one doesn't bounce very much at all but the other one sure does! I mean there's still a bounce with the newer one. I need a 200 ms delay to guarantee it doesn't bounce at all. That number works for the other one as well. 100 ms for the new one catches almost all the bounce but once in a great while, a bounce was getting through. I just put a 200 ms delay in and fixed all problems.
                            -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                            Comment

                            • Spork Schivago
                              Badcaps Legend
                              • Mar 2012
                              • 4734
                              • United States of America

                              #34
                              Re: Purpose of the cap in this RC Debouncer circuit...

                              Originally posted by stj
                              11 pins for that.
                              7segments + decimal point
                              3 select lines for the digits.
                              and you need to constantly scan through the 3 digits to keep them from flickering.

                              that's why i prefer intelligent displays - consider an lcd with the hitchi 44780 interface instead
                              you only need about 7 pins and you can get one out of some junk like an old fax machine.
                              Right, this is just me building up to the touch screen display I plan to use. First project was to make 4 LEDs blink. Then I added buttons and made them toggle. Then I made it so when I pushed the buttons, they'd light up in binary how many times I pushed them. Now I'm going to replace the LEDs with that 24-pin 3.5 digit display. Then I'll add the Hitachi 44780 clone I have (a KS0066 I think it's called). Then I'll probably add an LCD screen and then finally, an LCD touch screen.
                              -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                              Comment

                              • keeney123
                                Lauren
                                • Sep 2014
                                • 2536
                                • United States

                                #35
                                Re: Purpose of the cap in this RC Debouncer circuit...

                                I think you got it now. I think Stj will be able to take you the rest of the way.

                                Comment

                                • stj
                                  Great Sage 齊天大聖
                                  • Dec 2009
                                  • 30977
                                  • Albion

                                  #36
                                  Re: Purpose of the cap in this RC Debouncer circuit...

                                  unused pins, you should set to inputs with pullups enabled imo.
                                  some people like to set them as outputs, but i dont like that incase you short one to a power rail!

                                  those switches used on pc front-panels are shit - as you found out!
                                  but clicky switches like used on dvd players and stuff are pretty good.

                                  btw.
                                  http://www.microchip.com/forums/m122006.aspx

                                  Comment

                                  • Spork Schivago
                                    Badcaps Legend
                                    • Mar 2012
                                    • 4734
                                    • United States of America

                                    #37
                                    Re: Purpose of the cap in this RC Debouncer circuit...

                                    Thanks guys. I know the KS0066 isn't the best one out there but it's the one that got sent with the kit. It's okay though, it's just a temporary thing. I believe I'm probably going to skip the 7-segment LED counter. I was thinking about it and looking around the net, I found some cd40110b counter ICs. I could daisy chain a few together and hook the buttons directly up to the x digit, 7-segment display. There'd be no need to actually use the PIC. I mean I guess I could just use the PIC to produce a clock pulse to get it to count by itself. I guess that could be kind of fun. Maybe it's time to get back to the KS0066 stuff.

                                    Still a little confused with the timer stuff. Do you know what pre-scaler means Stj? Is it just something that controls how many clicks are in a second for the timers?
                                    -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                                    Comment

                                    • stj
                                      Great Sage 齊天大聖
                                      • Dec 2009
                                      • 30977
                                      • Albion

                                      #38
                                      Re: Purpose of the cap in this RC Debouncer circuit...

                                      prescaler divides the main clock down to lower the range of the internal counters.

                                      Comment

                                      • Spork Schivago
                                        Badcaps Legend
                                        • Mar 2012
                                        • 4734
                                        • United States of America

                                        #39
                                        Re: Purpose of the cap in this RC Debouncer circuit...

                                        Originally posted by stj
                                        prescaler divides the main clock down to lower the range of the internal counters.
                                        That's what I thought. So, if I had a timer setup, I could adjust the prescaler so one clock tick was one second? It wouldn't affect how many instructions the PIC was processing per second though, right? Just the timer?

                                        If my PIC supports multiple timers, can I have different prescaler settings per timer? Or is it just pretty much one setting for all timers?

                                        Thanks for all the help Stj! I couldn't imagine trying to learn this and figure this all out by simply reading the datasheet! You and Keeney123 have been a great help!
                                        -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

                                        Comment

                                        • stj
                                          Great Sage 齊天大聖
                                          • Dec 2009
                                          • 30977
                                          • Albion

                                          #40
                                          Re: Purpose of the cap in this RC Debouncer circuit...

                                          you really do need to read the datasheet - all 5-10meg of it.
                                          there is a prescaler on the clock, and atleast one for the counters.


                                          the one on the clock may interest you, you can divide-down the clock to slow down the chip and reduce it's power consumption - good for battery circuits.

                                          Comment

                                          Related Topics

                                          Collapse

                                          Working...