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

Robot doesnt respond to some remote buttons????
http://robotc.net/forums/viewtopic.php?f=11&t=5610
Page 1 of 1

Author:  ls1_driver [ Wed Mar 13, 2013 2:08 pm ]
Post subject:  Robot doesnt respond to some remote buttons????

My robot is simple in which it has for driving wheels, an arm motor, and a claw motor. The problem is i cant get the claw motor to work even though no errors show up.

heres the code

#pragma config(Motor, port2, FrontRight, tmotorNormal, openLoop)
#pragma config(Motor, port3, BackRight, tmotorNormal, openLoop)
#pragma config(Motor, port4, FrontLeft, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port5, BackLeft, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port6, Lift, tmotorNormal, openLoop)
#pragma config(Motor, port9, Arm, tmotorNormal, openLoop)

task main ()
{

while(1 == 1)
{
motor[FrontRight] = vexRT[Ch3];
motor[FrontLeft] = vexRT[Ch2];
motor[BackRight] = vexRT[Ch3];
motor[BackLeft] = vexRT[Ch2];

if(vexRT[Btn8U] == 1)
{
motor[Arm] = 110;
}
else
{
motor[Arm] = 0;
}
if(vexRT[Btn8D] == 1)
{
motor[Arm] = -110;
}
else
{
motor[Arm] = 0;
}
}

if(vexRT[Btn6U] == 1)
{
motor[Lift] = 110;
}
else
{
motor[Lift] = 0;
}
if(vexRT[Btn6D] == 1)
{
motor[Lift] = -110;
}
else
{
motor[Lift] = 0;
}

}


the lift is the claw motor all other codes work. the buttons correlated with the "Lift" motor dont work. I tried all buttons, motor is good, 3 wire is good, remote is good not sure whats going on??????

Author:  JohnWatson [ Wed Mar 13, 2013 2:35 pm ]
Post subject:  Re: Robot doesnt respond to some remote buttons????

Code:
if(vexRT[Btn6U] == 1)
   {
     motor[Lift] = 110;
   }
else
   {
     motor[Lift] = 0;
   }

if(vexRT[Btn6D] == 1)
   {
     motor[Lift] = -110;
   }
else
   {
     motor[Lift] = 0;
   }


Let's run through the code real quick, and I think the answer will become clear. You want to move the Lift motor up when button 6U is pressed, down when 6D is pressed, and stop it when neither button is pressed, correct? You are definitely on the right track, but have run into one of the common errors when using remote control with buttons; multiple if/else statements controlling the same motor.

For example, let's say you press the 6U button. The first if/else statement checks the state of 6U, turns the motor on if it is pressed, and turns it off if it is not pressed:

Code:
if(vexRT[Btn6U] == 1)
   {
     motor[Lift] = 110;
   }
else
   {
     motor[Lift] = 0;
   }


So far so good; if the 6U button is pressed, the motor will move; if it's not, the motor will stop. Looking at the next set of if/else statements, though, the issue starts to make itself clear:

Code:
if(vexRT[Btn6D] == 1)
   {
     motor[Lift] = -110;
   }
else
   {
     motor[Lift] = 0;
   }


In this case, only button 6U is pressed; since 6D is not pressed, the else statement in this case becomes true, and the motor is immediately shut back off. What you will normally see in this case is jerky, stuttering movement as the motor is continually and quickly turn off and on.

To solve this, you will need to consolidate the two if/else sets into a single if/else if/else set. Fortunately, we have a VEX Cortex Video Trainer Curriculum section dedicated to this exact issue (it even uses the same buttons, 6U and 6D, as you are using. You can find it here, under the 'Remote Control -> Buttons -> Controlling the Arm Part 1-3'. This should solve the issue for you, and can be applied to the 'Arm' section of code as well.

Author:  ls1_driver [ Wed Mar 13, 2013 10:27 pm ]
Post subject:  Re: Robot doesnt respond to some remote buttons????

but the video shows that it would make it jerky. My problem is it won't move at all. Will this still fix it then. Thanks for all your help though!!

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