CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Debounce

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
slahiri
Guest







Debounce
PostPosted: Sun Mar 02, 2003 10:35 am     Reply with quote

Guys,
I am looking for good Debounce routine Or just use delay_ms(100) after an event. Just to let you know, you guys are very helpful.
Thanks.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12274
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Debounce
PostPosted: Sun Mar 02, 2003 2:15 pm     Reply with quote

:=Guys,
:= I am looking for good Debounce routine Or just use delay_ms(100) after an event. Just to let you know, you guys are very helpful.
:=Thanks.

Use this in a loop that you pass through many times per second. Basicly scanning the inputs a a fast rate. Adjust the values that show +-15 to adjust the debounc period. This is great for real time applications where you dont want to use a delay anywhere because that is just dead time. This is very resistant to electronic noise.

int1 C0;
signed int8 debounce_counter_C0;

if (input(PIN_C0))
{ if ( ++debounce_counter_C0 > 15 )
{ C0= 1;
debounce_counter_C0 = 15;
}
else
{ if ( --debounce_counter_C0 < -15 )
{ C0 = 0;
debounce_counter_C0 = -15;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12281
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group