|
vexmche123
Rookie
Joined: Sun Jul 10, 2011 3:34 pm Posts: 30
|
 Ports 5-8 not working...Programming problem?
Hello, I have been having some problems with my touch sensors on my VEX PIC robot. On my robot, I currently have eight touch sensors in the "Analog/Digital" ports (ports 1-8). I have noticed that only the sensors in the first four ports (ports 1-4) work. I have taken the sensors from the first four ports, which I know work, and placed them in ports 5-8, then they do not work. I did the same withthe senosrs in ports 5-8, and placed them in 1-4 and they DO work. I then used the sensors debugger window and saw that with all the senors plugged in, the microcontroller knew that they were being pressed. My question is, is there something special I have to do with the program for the ports 5-8 to work? Or is there something worng with my program? Any ideas or help is GREATLY appreciated. Thanks.
p.s. I intentionally commented out and disconnected the Sonar sensor, so I was dealing with ONLY touch sensors.
Here is my code: #pragma config(Sensor, in1, rearLeft, sensorTouch) #pragma config(Sensor, in2, rearRight, sensorTouch) #pragma config(Sensor, in3, rightsideBack, sensorTouch) #pragma config(Sensor, in4, frontLeft, sensorTouch) #pragma config(Sensor, in5, frontRight, sensorTouch) #pragma config(Sensor, in6, rightsideFront, sensorTouch) #pragma config(Sensor, in7, leftsideFront, sensorTouch) #pragma config(Sensor, in8, leftsideBack, sensorTouch) //#pragma config(Sensor, in9, sonarFront, sensorSONAR, int1) #pragma config(Motor, port1, rightFront, tmotorNormal, openLoop) #pragma config(Motor, port2, leftRear, tmotorNormal, openLoop) #pragma config(Motor, port3, leftFront, tmotorNormal, openLoop) #pragma config(Motor, port4, rightRear, tmotorNormal, openLoop) #pragma config(Motor, port5, arm, tmotorNormal, openLoop) #pragma config(Motor, port6, claw, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
int i; void forward(); void slightRight1(); void slightRight2(); void slightRight3(); void slightLeft1(); void slightLeft2(); void slightLeft3(); void backupRight(); void backupLeft(); void grabObject();
task main() { for(i=0;i<30000;i++) { forward();
if(SensorValue(rearLeft) == 1)//1 { slightRight1(); }//end if
if(SensorValue(rearRight) == 1)//2 { slightLeft1(); }//end if
if(SensorValue(rightsideBack) == 1)//3 { slightLeft2(); }//end if
if(SensorValue(frontLeft) == 1)//4 backupRight(); }//end if
if(SensorValue(frontRight) == 1)//5 { backupLeft(); }//end if
if(SensorValue(rightsideFront) == 1)//6 { slightLeft3(); }//end if
if(SensorValue(leftsideFront) == 1)//7 { slightRight2(); }//end if
if(SensorValue(leftsideBack) == 1)//8 { slightRight3(); }
//if(SensorValue(sonarFront) > 5) //{ //grabObject(); //}//end if and for
}//end main task
//////////////////////////////////////// void forward() { motor[port1] = 40; motor[port2] = 40; motor[port3] = 40; motor[port4] = 40; wait1Msec(1); } //end forward //////////////////////////////////////// void slightRight1() { motor[port1] = -40; motor[port2] = -40; motor[port3] = 40; motor[port4] = 40; wait1Msec(300); }//end slightRight1 void slightRight2() { motor[port1] = -40; motor[port2] = -40; motor[port3] = 40; motor[port4] = 40; wait1Msec(300); }//end slightRight2 void slightRight3() { motor[port1] = -40; motor[port2] = -40; motor[port3] = 40; motor[port4] = 40; wait1Msec(300); }//end slightRight3 ///////////////////////////////////////// void slightLeft1() { motor[port1] = 40; motor[port2] = 40; motor[port3] = -40; motor[port4] = -40; wait1Msec(300); }//end slightLeft ///////////////////////////////////////// void slightLeft2() { motor[port1] = 40; motor[port2] = 40; motor[port3] = -40; motor[port4] = -40; wait1Msec(300); }//end slightLeft2 ///////////////////////////////////////// void slightLeft3() { motor[port1] = 40; motor[port2] = 40; motor[port3] = -40; motor[port4] = -40; wait1Msec(300); }//end slightLeft3 ///////////////////////////////////////// void backupRight() { motor[port1] = -40; motor[port2] = -40; motor[port3] = -40; motor[port4] = -40; wait1Msec(300); ///////slight back up/////////////
motor[port1] = -40; motor[port2] = -40; motor[port3] = 40; motor[port4] = 40; wait1Msec(1000); ///////turn right/////////////
}//end backupRight ///////////////////////////////////////// void backupLeft() { motor[port1] = -40; motor[port2] = -40; motor[port3] = -40; motor[port4] = -40; wait1Msec(300); ///////back up/////////////
motor[port1] = 40; motor[port2] = 40; motor[port3] = -40; motor[port4] = -40; wait1Msec(1000); ///////turn left///////////// }//end backupLeft ///////////////////////////////////////// void grabObject() { motor[port1] = 0; motor[port2] = 0; motor[port3] = 0; motor[port4] = 0; motor[port5] = 0; motor[port6] = 0; wait1Msec(1000);//stops for 1 second
motor[port1] = 0; motor[port2] = 0; motor[port3] = 0; motor[port4] = 0; motor[port5] = -63; motor[port6] = 0; wait1Msec(1000); ////arm comes down
motor[port1] = 0; motor[port2] = 0; motor[port3] = 0; motor[port4] = 0; motor[port5] = 0; motor[port6] = -10;//arm opens slowly wait1Msec(1000);
motor[port1] = 0; motor[port2] = 0; motor[port3] = 0; motor[port4] = 0; motor[port5] = 0; motor[port6] = 10;//arm closes slowly wait1Msec(1000);
motor[port1] = 0; motor[port2] = 0; motor[port3] = 0; motor[port4] = 0; motor[port5] = 63; motor[port6] = 0; wait1Msec(2000); ////arm goes back up }//end grabObject /////////////////////////////////////////
|