SLimBo - thanks for posting this thread and your concerns - I am definately bringing my spare sensors and my edu bot RC- which has the same code for looking for the IR signals, and it turns on an LED on a digital output
so I can use it to scan the field at the buckeye regional (our next event) and see if the beacons are working and solid
im posting my scanner code - its about as simple as you can get - it looks at the INTR flags for rc_dig_in01 and 2, which are INT2 and 3 - those flags get set when the input pin see a change in state, which would normally trigger an interrupt
but we dont use the interrupts - we dont enable them - all we want to know is if those pins are toggleing - and we wait till we see them toggle on three SW loops in a row - then we say - YEP! that sensor is flooded by the beacon:
if anyone wants to use the IR sensors and interrupts have scared you off, try this code - its simple:
Code:
/*driver mode scan for IR beacons - used for testing beacons*/
if (INTCON3bits.INT2IF) /*578 interrupt flag polling */
{
INTCON3bits.INT2IF=0; /*clear the intr flag*/
if (DirFilterL==2) DiSeeL=1; /*IR seen when intr2 3 times in a row*/
else DirFilterL = DirFilterL+1;
}
else
{
DiSeeL=0; /*turn it off when no intr*/
DirFilterL=0;
}
if (INTCON3bits.INT3IF)
{
INTCON3bits.INT3IF=0; /*clear the R intr flag*/
if (DirFilterR==2) DiSeeR=1; /*IR seen when you see the intr3 3 times*/
else DirFilterR=DirFilterR+1;
}
else
{
DiSeeR=0; /*turn it off when no intr*/
DirFilterR=0;
}