Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Remove debounce on IR Sensor

Status
Not open for further replies.

zr125

Newbie level 6
Joined
Feb 16, 2011
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,369
How do i remove debounce? it is not a swtich debounce. my source code are as follow.

unsigned int IR1,IR2;

void main(){

TRISA = 0xFF;
ADCON1 = 0x00;
TRISD = 0x00;
UART1_Init(9600); // Initialize UART module at 9600 bps
delay_ms(100); // Wait for UART module to stabilize

for(;;){
IR1 = Adc_Read(1);
IR2 = Adc_Read(2);

if (IR1<930){
PORTD.F2 = 1;
delay_ms(200);
UART1_Write_Text("a");}

else if (IR2<930){
PORTD.F1 = 1;
delay_ms(200);
UART1_Write_Text("b");}

else {
PORTD = 0x00;
delay_ms(200);}}}

its about ir sensor, when then sensor is trigger, it sends data thru uart. it supposed to be in sequence, either IR1-->IR2 or IR2-->IR1.

my problem is when sensor trigger, it send bounce data like i want it to send "a" then "b" but instead, it send double or triple "a" then "b". how do i set it to send "a" once only, then "b" and vice versa.
 

Either your ir sensor is keeping output the same value than u expected or ur adc buffer keeps the same value when u come to the loop again. have more delay or limiit ir sensing output or clear the adc buffer....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top