View Full Version : IR sensor corruption help
We have a problem with our IR chip. For some reason the fourth button we assigned to the IR chip is messing up. When we turn on our autnomous code using a paperclip in the competition spot in the controler, the fourth button's command starts going on it's own. The remote we have set up was not pointed at the sensor, and nothing was pressed. We quickly removed the paperclip, and things worked again tried it again, same thing happened.
So we tested again by commenting out what button four did on the program. The other three buttons and their reactions worked just fine. We put the missing part of the program back in and BAM! Same problem.
Then someone looked up the update from FIRST, and it said that the IR chip was becoming faulty under circumstances we had been doing. (Leaving the battery plugged in all the time and leaving it hooked up to the robot)
Is the IR chip our problem with the program, and is there any way to fix it?
Or is our problem with our program and the IR chip should be perfectly fine?
Please Help!
~Team 0937
psy_wombats
18-02-2008, 12:38
If you're taking values incorrectly from the IR sensor, the fourth may be the last one being updated. The IR sensor returns zero if a button is hit and 1 if it is not. 0 is also the unattached value. I suggest first posting your code or shuffling the order of your ifs/cases and see if another button is being triggered. If the fourth button still triggers, your sensor may not be wired right.
The Lucas
18-02-2008, 12:51
I suspect the fourth output from the IR sensor is not electrically connected to the digital input and thus always reading 1 in the program. Check your electrical connection with a multimeter
The programming leader here thinks that the order will have nothing to do with it. But we just started our lunch break, so when we get out of it, I'll change it and try that.
We also tried moving the IR chip's input from rc_dig_in04 to rc_dig_in05, but it's still causing the same problem.
Here's the autnomous code in question.
if(rc_dig_in01 == 1 && rc_dig_in02 == 1 && rc_dig_in03 == 1)
{
EStop = 1;
Lap = TLt = TMd = TRt = 0;
printf("Chip Disconnected, Stopping system\n");
}
else if(rc_dig_in01 == 1)
{
Lap = 1;
TLt = TRt = TMd = 0;
printf("Activating Lap\n");
}
else if(rc_dig_in02 == 1)
{
TMd = 1;
Lap = TRt = TLt = 0;
printf("Activating Trackball Middle\n");
}
else if(rc_dig_in03 == 1)
{
TLt = 1;
Lap = TMd = TRt = 0;
printf("Activating Trackball Left\n");
}
else if(rc_dig_in05 == 1)
{
// May be infected. If so, do not use! T-virus
TRt = 1;
Lap = TMd = TLt = 0;
printf("Activating Trackball Right\n");
}
// Subroutines
if (Lap == 1)
{
// Run Laps
pwm02 = pwm04 = pwm05 = 127;
if(Timer_Lap < 273)
{
printf("Drive Straight\n");
pwm15 = pwm16 = 254;
pwm13 = pwm14 = 254*0.9;
Timer_Lap++;
}
else if(Timer_Lap < 378)
{
printf("Turn Left\n");
pwm13 = pwm14 = 254;
pwm15 = pwm16 = 160;
Timer_Lap++;
}
else
{
printf("Half Lap Finished\n");
Timer_Lap = 0;
}
}
if (TLt == 1)
{
// Trackball on Left
pwm04 = pwm05 = 127;
if(Timer_TLt < 18)
{
pwm15 = pwm16 = 0;
pwm13 = pwm14 = 254;
Timer_TLt++;
}
else if(Timer_TLt < 24)
{
pwm13 = pwm14 = pwm15 = pwm16 = 254;
Timer_TLt++;
}
else if(Timer_TLt < 42)
{
pwm13 = pwm14 = 0;
pwm15 = pwm16 = 254;
Timer_TLt++;
}
else if(Timer_TLt < 112)
{
pwm13 = pwm14 = pwm15 = pwm16 = 127;
pwm02 = 100;
printf("Arm Rising\n");
Timer_TLt++;
}
else if(Timer_TLt < 182)
{
pwm02 = 175;
printf("Arm Falling\n");
Timer_TLt++;
}
else
{
pwm02 = 127;
printf("Complete\n");
Timer_TLt = 0;
TLt = 0;
}
}
if (TMd == 1)
{
// Trackball in Middle
pwm04 = pwm05 = 127;
pwm13 = pwm14 = pwm15 = pwm16 = 127;
if(Timer_TMd < 70)
{
pwm02 = 100;
printf("Arm Rising\n");
Timer_TMd++;
}
else if(Timer_TMd < 140)
{
pwm02 = 175;
printf("Arm Falling\n");
Timer_TMd++;
}
else
{
pwm02 = 127;
printf("Complete\n");
Timer_TMd = 0;
TMd = 0;
}
}
if (TRt == 1)
{
// Trackball on Right
pwm04 = pwm05 = 127;
if(Timer_TRt < 18)
{
pwm15 = pwm16 = 254;
pwm13 = pwm14 = 0;
Timer_TRt++;
}
else if(Timer_TRt < 24)
{
pwm13 = pwm14 = pwm15 = pwm16 = 254;
Timer_TRt++;
}
else if(Timer_TRt < 42)
{
pwm13 = pwm14 = 254;
pwm15 = pwm16 = 0;
Timer_TRt++;
}
else if(Timer_TRt < 112)
{
pwm13 = pwm14 = pwm15 = pwm16 = 127;
pwm02 = 100;
printf("Arm Rising\n");
Timer_TRt++;
}
else if(Timer_TRt < 182)
{
pwm02 = 175;
printf("Arm Falling\n");
Timer_TRt++;
}
else
{
pwm02 = 127;
printf("Complete\n");
Timer_TRt = 0;
TRt = 0;
}
}
if (EStop == 1)
{
// Stop Everything!
pwm02 = pwm04 = pwm05 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
}
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.