View Single Post
  #4   Spotlight this post!  
Unread 18-02-2008, 12:54
PhilM PhilM is offline
Registered User
FRC #0937
 
Join Date: Jan 2007
Location: Shawnee Mission North High School
Posts: 4
PhilM is an unknown quantity at this point
Re: IR sensor corruption help

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.
Quote:
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;
}