View unanswered posts | View active topics It is currently Thu Apr 24, 2014 2:01 am






Reply to topic  [ 2 posts ] 
Motors not responding correctly. 
Author Message
Rookie

Joined: Thu Feb 06, 2014 7:05 pm
Posts: 1
Post 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?


Thu Feb 06, 2014 7:16 pm
Profile
Rookie

Joined: Thu Dec 01, 2011 12:07 am
Posts: 27
Post Re: Motors not responding correctly.
The first IF statement going down needs to compare with 45 and not 575.
Good luck.


Fri Feb 07, 2014 1:05 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.