F Elliott
31-12-2013, 18:35
Hi Everyone --- Rookie coach is stumped... :(
We're trying to use our encoders. motorD seems to be controlled but motorE acts as if it is not being controlled.
Using the code below, MotorD turns 1/4 revolution at what appears to be 50% power. MotorD seems to behave as expected if you change its values for nMotorEncoderTarget[motorD] or motor[motorD]. On the other hand, MotorE ALWAYS runs at 100% power and ALWAYS turns several full revolutions before it stops when it finally reaches the set target value (negative) as seen in the NXT Device Control Display debugger window. If you change motorE's power setting it is ignored.
Both encoder wires are plugged into the motor controller so the orange wire faces the motor controller's lettering and are plugged into the motors so orange is left-most when looking at and reading the label on the motor. We have tried swapping motor controllers, the encoder cables, and we've hooked up motorD as mtr_S1_C1_2 and motorE as mtr_S1_C1_1 all with the same result. It does not matter which motor is reversed in the pragma. I've opened up the encoder on motorE and it seems to be installed correctly. We have not swapped the encoders because that would entail pulling off the encoder wheels, which I'm not ready to do.
Any suggestions most appreciated!
#pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, PIDControl, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
nMotorEncoder[motorD] = 0;
nMotorEncoder[motorE] = 0;
nMotorEncoderTarget[motorD] = 720; //Gearing ratio is 1:2 so one revolution is 2880 encoder ticks
nMotorEncoderTarget[motorE] = 720; //@720 ticks both wheels should turn 1/4 revolution
motor[motorD] = 50;
motor[motorE] = 50;
while (nMotorRunState[motorE] != runStateIdle || nMotorRunState[motorD] != runStateIdle)
{
}
motor[motorD] = 0;
motor[motorE] = 0;
wait1Msec(3000);
}
We're trying to use our encoders. motorD seems to be controlled but motorE acts as if it is not being controlled.
Using the code below, MotorD turns 1/4 revolution at what appears to be 50% power. MotorD seems to behave as expected if you change its values for nMotorEncoderTarget[motorD] or motor[motorD]. On the other hand, MotorE ALWAYS runs at 100% power and ALWAYS turns several full revolutions before it stops when it finally reaches the set target value (negative) as seen in the NXT Device Control Display debugger window. If you change motorE's power setting it is ignored.
Both encoder wires are plugged into the motor controller so the orange wire faces the motor controller's lettering and are plugged into the motors so orange is left-most when looking at and reading the label on the motor. We have tried swapping motor controllers, the encoder cables, and we've hooked up motorD as mtr_S1_C1_2 and motorE as mtr_S1_C1_1 all with the same result. It does not matter which motor is reversed in the pragma. I've opened up the encoder on motorE and it seems to be installed correctly. We have not swapped the encoders because that would entail pulling off the encoder wheels, which I'm not ready to do.
Any suggestions most appreciated!
#pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, PIDControl, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
nMotorEncoder[motorD] = 0;
nMotorEncoder[motorE] = 0;
nMotorEncoderTarget[motorD] = 720; //Gearing ratio is 1:2 so one revolution is 2880 encoder ticks
nMotorEncoderTarget[motorE] = 720; //@720 ticks both wheels should turn 1/4 revolution
motor[motorD] = 50;
motor[motorE] = 50;
while (nMotorRunState[motorE] != runStateIdle || nMotorRunState[motorD] != runStateIdle)
{
}
motor[motorD] = 0;
motor[motorE] = 0;
wait1Msec(3000);
}