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
Re: Debounce
Posted: Sun Mar 02, 2003 2:15 pm
:=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
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