ROBOTC.net forums
http://www.robotc.net/forums/

Motors not responding correctly.
http://www.robotc.net/forums/viewtopic.php?f=11&t=7882
Page 1 of 1

Author:  RebelRobotics [ Thu Feb 06, 2014 7:16 pm ]
Post subject:  Motors not responding correctly.

We have a robot with a scissor lift on it. It has 2 IEMs powering the lift. Our code for the lift is as follows:

Code:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1,  leftMotorEncoder, sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Sensor, I2C_2,  rightMotorEncoder, sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Motor,  port10,          leftLiftMotor, tmotorVex393, openLoop, encoder, encoderPort, I2C_1, 1000)
#pragma config(Motor,  port1,           rightLiftMotor, tmotorVex393, openLoop, encoder, encoderPort, I2C_2, 1000)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
nMotorEncoder[leftLiftMotor] = 0;
nMotorEncoder[rightLiftMotor] = 0;
while (1==1)
{
//When 8U is pressed send scissor lift up
while (vexRT[Btn8U] == 1)
{
if (nMotorEncoder[leftLiftMotor] < 575)
{
motor[rightLiftMotor] = -127;
motor[leftLiftMotor] = 127;
}
if (nMotorEncoder[leftLiftMotor] >= 575)
{
motor[rightLiftMotor] = 0;
motor[leftLiftMotor] = 0;
}
}
//When 8D is pressed send scissor lift down
while (vexRT[Btn8D] == 1)
{
if (nMotorEncoder[leftLiftMotor] > 575)
{
motor[rightLiftMotor] = 127;
motor[leftLiftMotor] = -127;
}
if (nMotorEncoder[leftLiftMotor] <= 45)
{
motor[rightLiftMotor] = 0;
motor[leftLiftMotor] = 0;
nMotorEncoder[leftLiftMotor] = 0; //Set the encoder to 0 again.
nMotorEncoder[rightLiftMotor] = 0;
}
}
}
}


It would work for one time going up and one time going down, but of course it needs to do that multiple times. The values used (575 and 45) are for our peak, and setting it back down. What is going wrong?

Author:  CARBOT [ Fri Feb 07, 2014 1:05 pm ]
Post subject:  Re: Motors not responding correctly.

The first IF statement going down needs to compare with 45 and not 575.
Good luck.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/