View unanswered posts | View active topics It is currently Sat May 26, 2018 4:00 pm

 Page 1 of 1 [ 9 posts ]
 Print view Previous topic | Next topic
Robot Trouble
Author Message
Rookie

Joined: Mon Nov 07, 2011 2:01 pm
Posts: 5
Robot Trouble
Having trouble codeing my teams robot for VEX. The arms and gripping device are not following command to the Duel joystick controller. They continue to move even after the buttons are released . If anyone can help me PLEASE HELP

Mon Nov 07, 2011 2:06 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Robot Trouble
The more detail that you give, the more help that you will get. What exactly do you want the robot to do? What have you already tried? Post the code that you have tried so we can see if that is the source of the problem.

_________________
sudo rm -rf /

Mon Nov 07, 2011 2:29 pm
Rookie

Joined: Mon Nov 07, 2011 2:01 pm
Posts: 5
Re: Robot Trouble
i want to make it to where if you release the button it stops and if you press the button it goes

while (true)
{
{
int threshold = 10; // helps to eliminate 'noise' from a joystick that isn't perfectly at (0,0)
// feel free to change this to match your needs.

while(1 == 1)
{
if(abs(vexRT[Ch3]) > threshold) // If the left joystick is greater than or less than the threshold:
{
motor[leftMotor] = (vexRT[Ch3]); // Left Joystick Y value / 2.
}
else // If the left joystick is within the threshold:
{
motor[leftMotor] = 0; // Stop the left motor (cancel noise)
}

if(abs(vexRT[Ch2]) > threshold) // If the right joystick is greater than or less than the threshold:

motor[rightMotor] = (vexRT[Ch2]); // Right Joystick Y value / 2.

else // If the right joystick is within the threshold:
{
motor[rightMotor] = 0; // Stop the right motor (cancel noise)
}
while(vexRT[Btn5D] == 1){
motor[port2] = 127;
motor[port9] = -127;
}

while(vexRT[Btn5U] == 1){
motor[port2] = -127;
motor[port9] = 127;}

while(vexRT[Btn6D] == 1){
motor[port8] = 60;

}

while(vexRT[Btn6U] == 1){
motor[port8] = -60;

}

Mon Nov 07, 2011 2:57 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Robot Trouble
Fist of all, lets put your code into properly spaced formatting so that it's easier to see what is in the scope of what:
 Code:while (true){  {    int threshold = 10; // helps to eliminate 'noise' from a joystick that isn't perfectly at (0,0)    // feel free to change this to match your needs.    while(1 == 1)    {      if(abs(vexRT[Ch3]) > threshold) // If the left joystick is greater than or less than the threshold:      {        motor[leftMotor] = (vexRT[Ch3]); // Left Joystick Y value / 2.      }      else // If the left joystick is within the threshold:      {        motor[leftMotor] = 0; // Stop the left motor (cancel noise)      }      if(abs(vexRT[Ch2]) > threshold) // If the right joystick is greater than or less than the threshold:      motor[rightMotor] = (vexRT[Ch2]); // Right Joystick Y value / 2.      else // If the right joystick is within the threshold:      {        motor[rightMotor] = 0; // Stop the right motor (cancel noise)      }      while(vexRT[Btn5D] == 1){        motor[port2] = 127;        motor[port9] = -127;      }      while(vexRT[Btn5U] == 1){      motor[port2] = -127;      motor[port9] = 127;}      while(vexRT[Btn6D] == 1){        motor[port8] = 60;      }      while(vexRT[Btn6U] == 1){        motor[port8] = -60;      }

The reason that your motors do not stop when you release the button, is because you never tell your motors to stop. The motors will keep doing what you told them to do last until you tell them otherwise. You have to explicitly set them to 0 when the button is released. Also, you may want to look into why you have two while loops.
Just as a side note, after looking at this code, I have to wonder if more than one person worked on this, as you have different coding customs in the same piece of code. Not that there is anything wrong with that, but it might be easier to understand if everything in a single program is formatted the same way.

_________________
sudo rm -rf /

Mon Nov 07, 2011 5:47 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Robot Trouble
Fist of all, lets put your code into properly spaced formatting so that it's easier to see what is in the scope of what:
 Code:while (true){  {    int threshold = 10; // helps to eliminate 'noise' from a joystick that isn't perfectly at (0,0)    // feel free to change this to match your needs.    while(1 == 1)    {      if(abs(vexRT[Ch3]) > threshold) // If the left joystick is greater than or less than the threshold:      {        motor[leftMotor] = (vexRT[Ch3]); // Left Joystick Y value / 2.      }      else // If the left joystick is within the threshold:      {        motor[leftMotor] = 0; // Stop the left motor (cancel noise)      }      if(abs(vexRT[Ch2]) > threshold) // If the right joystick is greater than or less than the threshold:      motor[rightMotor] = (vexRT[Ch2]); // Right Joystick Y value / 2.      else // If the right joystick is within the threshold:      {        motor[rightMotor] = 0; // Stop the right motor (cancel noise)      }      while(vexRT[Btn5D] == 1){        motor[port2] = 127;        motor[port9] = -127;      }      while(vexRT[Btn5U] == 1){      motor[port2] = -127;      motor[port9] = 127;}      while(vexRT[Btn6D] == 1){        motor[port8] = 60;      }      while(vexRT[Btn6U] == 1){        motor[port8] = -60;      }

The reason that your motors do not stop when you release the button, is because you never tell your motors to stop. The motors will keep doing what you told them to do last until you tell them otherwise. You have to explicitly set them to 0 when the button is released. Also, you may want to look into why you have two while loops.
Just as a side note, after looking at this code, I have to wonder if more than one person worked on this, as you have different coding customs in the same piece of code. Not that there is anything wrong with that, but it might be easier to understand if everything in a single program is formatted the same way.

_________________
sudo rm -rf /

Mon Nov 07, 2011 5:47 pm
Rookie

Joined: Mon Nov 07, 2011 2:01 pm
Posts: 5
Re: Robot Trouble
More than one person worked on this and thank you for helping

Mon Nov 07, 2011 5:52 pm
Rookie

Joined: Mon Nov 07, 2011 2:01 pm
Posts: 5
Re: Robot Trouble
would it be too much to ask someone to edit my code to make buttons 5U and 5D and 6U and 6D stop when buttons not being pressed. we don't have any programmers on our team.

Mon Nov 07, 2011 8:33 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Robot Trouble
Try replacing this part of your code:
 Code:while(vexRT[Btn5D] == 1){        motor[port2] = 127;        motor[port9] = -127;      }      while(vexRT[Btn5U] == 1){      motor[port2] = -127;      motor[port9] = 127;}      while(vexRT[Btn6D] == 1){        motor[port8] = 60;      }      while(vexRT[Btn6U] == 1){        motor[port8] = -60;      }

With this:
 Code:      if(vexRT[Btn5D] == 1){        motor[port2] = 127;        motor[port9] = -127;      }      else if(vexRT[Btn5U] == 1){        motor[port2] = -127;        motor[port9] = 127;      }      else{        motor[port2] = 0;        motor[port9] = 0;      }      if(vexRT[Btn6D] == 1){        motor[port8] = 60;      }      else if(vexRT[Btn6U] == 1){        motor[port8] = -60;      }      else{        motor[port8] = 0;      }

_________________
sudo rm -rf /

Mon Nov 07, 2011 9:59 pm
Rookie

Joined: Mon Nov 07, 2011 2:01 pm
Posts: 5
Re: Robot Trouble
Thank you alot this will help alot.

Mon Nov 07, 2011 10:04 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 9 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning

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