amcclure
Rookie
Joined: Wed Oct 20, 2010 12:30 pm Posts: 4
|
 IC2 nMotorEncoder Encoder problem
We are trying to use the new IC2 Encoders on both 393 and 269 motors and we are having problems. On the 269 motors we want to us a auto straightening but one of the encoders reads negative and we can not figure out how to make it positive so we can compare encoders. Our second problem is that we can not get the "ArmEncoder" to count to 1500 and stop. It will keep going. Attached is the code (sorry it is long).
#pragma config(I2C_Usage, I2C1, i2cSensors) #pragma config(Sensor, in1, R, sensorLineFollower) #pragma config(Sensor, in2, L, sensorLineFollower) #pragma config(Sensor, dgtl12, autobutton, sensorTouch) #pragma config(Sensor, I2C_1, leftIEM, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_2, rightIEM, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_3, rightarmIEM, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_4, , sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Motor, port1, Armleft, tmotorVex393, openLoop, reversed) #pragma config(Motor, port2, Leftfront, tmotorVex269, openLoop, reversed, encoder, encoderPort, I2C_1, 1000) #pragma config(Motor, port3, Leftrear, tmotorVex269, openLoop, reversed) #pragma config(Motor, port4, Scoopleft, tmotorVex393, openLoop, reversed) #pragma config(Motor, port7, Scoopright, tmotorVex393, openLoop, encoder, encoderPort, I2C_4, 1000) #pragma config(Motor, port8, Rightrear, tmotorVex269, openLoop) #pragma config(Motor, port9, Rightfront, tmotorVex269, openLoop, encoder, encoderPort, I2C_2, 1000) #pragma config(Motor, port10, Armright, tmotorVex393, openLoop, reversed, encoder, encoderPort, I2C_3, 1000) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void forward() { nMotorEncoder[Rightfront] = 0; nMotorEncoder[Leftfront] = 0; while(nMotorEncoder[Leftfront] > -700) {
motor[Rightfront] = 63; motor[Rightrear] = 63; motor[Leftfront] = 63; motor[Leftrear] = 63; }
motor[Rightfront] = 0; motor[Rightrear] = 0; motor[Leftfront] = 0; motor[Leftrear] = 0;
}
void backwards () { nMotorEncoder[Rightfront] = 0; nMotorEncoder[Leftfront] = 0;
while(nMotorEncoder[Leftfront] < 1000) { motor[Rightfront] = -63; motor[Rightrear] = -63; motor[Leftfront] = -63; motor[Leftrear] = -63; } } void armup() { nMotorEncoder[Armright] = 0;
while(nMotorEncoder[Armright] < 1) { motor[Armleft]=63; motor[Armright]=63; } }
void clean() { motor[Rightfront] = 0; motor[Rightrear] = 0; motor[Leftfront] = 0; motor[Leftrear] = 0; }
task main () {
forward();
armup();
}
|