View unanswered posts | View active topics It is currently Wed Jul 23, 2014 4:10 pm






Reply to topic  [ 3 posts ] 
Robot doesnt respond to some remote buttons???? 
Author Message
Rookie

Joined: Thu Mar 07, 2013 4:54 pm
Posts: 3
Post 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??????


Wed Mar 13, 2013 2:08 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 556
Post 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.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Wed Mar 13, 2013 2:35 pm
Profile
Rookie

Joined: Thu Mar 07, 2013 4:54 pm
Posts: 3
Post 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!!


Wed Mar 13, 2013 10:27 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.