New hobbyist debounce question

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi,

   

I recently discovered PSOC after playing with arduino for the past 6 months or so.  I'm JUST a hobbiest and have NO formal training in anything like this.  I have some basic questions if someone can help me.  I want to debounce 5 buttons and have each button do it's own thing.  They are N.O. buttons connected to ground.  I made 2 pictures to see which is the correct way to do it.  I couldn't figure out if I could use 1 debounce routine for all 5 buttons or had to have 5 separate ones.  I was also unsure of what Hz or MHz etc to set the clock and reading a datasheet is still mostly Greek to me. 😞  Which way should i do it based on these pictures?

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

Both versions are principially the same, although the second is easier to route. Some things you should care for:

   
        
  • Configure the input pins as "Resistive pull up" and "Initially Drive State" to high.
  •     
  • Remove the NOT gates, it is easier to do in code.
  •     
  • Use a single StateRegister component with 5 inputs
  •     
  • Connect the pins (wire) with wires to the debouncer.
  •     
  • Use the d-output only
  •     
  • Configure the debouncer to act on falling edge only
  •     
  • Set the frequency of the clock to the switch bounce-time which is about 10 ms (good switches). Frequency is 100Hz
  •     
  • Lastly: Do read the datasheet Knowledge may help you, not knowing does not.
  •    
   

 

   

Bob

View solution in original post

0 Likes
8 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

Both versions are principially the same, although the second is easier to route. Some things you should care for:

   
        
  • Configure the input pins as "Resistive pull up" and "Initially Drive State" to high.
  •     
  • Remove the NOT gates, it is easier to do in code.
  •     
  • Use a single StateRegister component with 5 inputs
  •     
  • Connect the pins (wire) with wires to the debouncer.
  •     
  • Use the d-output only
  •     
  • Configure the debouncer to act on falling edge only
  •     
  • Set the frequency of the clock to the switch bounce-time which is about 10 ms (good switches). Frequency is 100Hz
  •     
  • Lastly: Do read the datasheet Knowledge may help you, not knowing does not.
  •    
   

 

   

Bob

0 Likes
Anonymous
Not applicable

We've been doing all our debounces through code.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Bob,

   

I just got off work and I was THRILLED to see such a great detailed answer.  I am reading the datasheets, but it usually leaves me with more questions than answers when I'm done.  I can't believe how powerful this IDE and Product is with programmable GPIO.  I have yet to figure out how to find or select LF clock but I may have wrong device selected for my pioneer kit.  I'm reading but I haven't found my answer yet.  I see frequency divider, but I'll keep reading.  Here is my new picture.  Thanks so much Bob for such a constructive post.

   

You can see the clock error in the pic I'm working on.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Bob,

   

Thanks for the hand holding.  I'm already wishing the community was as big as arduino, and probably would be if they knew how awesome this thing is.  Sometimes finding current examples has proved difficult.  I've attached the project. 

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You will have to extend the project with your needed functionality .

   

 

   

Happy coding
Bob

Anonymous
Not applicable

Bob,

   

Thanks for showing me this.  I'm doing some reading on that component now.  I would have never found this on my own.  I'm going to read over the pdf for the timer and get familiar.  Thank you.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome.

   


Bob

0 Likes