View Single Post
  #4   Spotlight this post!  
Unread 25-01-2008, 17:55
fstumpo's Avatar
fstumpo fstumpo is offline
Question Everything!
FRC #1640 (SAB-BOT-AGE)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Downingtown
Posts: 9
fstumpo is an unknown quantity at this point
Thumbs up Re: How to wire the IR on the RC?

Not sure what you are seeing on your Vex but here's some code from out testing unit. The check for rc_dig_14 is just a way to run this code only if a jumper is in 14.

My printf is returning all zeros, unless an IR cmd button is pressed.

printf("c1: %d c2: %d c3: %d c4: %d\r", (int)rc_dig_in03,(int)rc_dig_in04,(int)rc_dig_in05 ,(int)rc_dig_in06);

if (rc_dig_in14) //no jumper
{
if (rc_dig_in03)
ir_cmd = CMD0;
else if (rc_dig_in04)
ir_cmd = CMD1;
else if (rc_dig_in05)
ir_cmd = CMD2;
else if (rc_dig_in06)
ir_cmd = CMD3;

switch (ir_cmd)
{
case CMD0: //Forward
pwm02 = (unsigned char) 254;
pwm03 = (unsigned char) 50; //Adjusted for Faster Motor
break;
case CMD1: //Turn Right
pwm02 = 0 + RT_SPEED_ADJ - 20; //Adjusted for slower motor
pwm03 = 0 + RT_SPEED_ADJ;
break;
case CMD2: //Turn Left
pwm02 = 254 - LT_SPEED_ADJ;
pwm03 = 254 - LT_SPEED_ADJ;
break;
case CMD3: //Stop
pwm02 = 127;
pwm03 = 127;
break;
}
}

I have each of the appropriate rainbow cable wires going to the signal pin (white) and I daisy chained the grounds (black) with pins 3 and 4 from the rainbow cable.

I have a toggle sw to control the power to the IR unit, so if the Vex Power in on, then I switch on the IR unit, I get initial 1's then zeroes. If I already have the IR power on, then power on the Vex, I get zeroes from the beginning.