View unanswered posts | View active topics It is currently Thu Oct 23, 2014 2:47 am






Reply to topic  [ 9 posts ] 
Servos 
Author Message
Rookie

Joined: Thu Oct 21, 2010 4:58 pm
Posts: 1
Post Servos
I cant get the servos to work the button we are using automatically goes to one as soon as the program starts. I dont know how to make it start at zero then make it go to one once I push the button. heres the program

dave = vexRT[btn6U];

if ((dave) == 1)
{
motor(servo1) = 172;
}
else
{
motor(servo1) = 255;
}


Thu Oct 21, 2010 5:07 pm
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: Servos
Are you using ROBOTC 2.30? All of the buttons on the VEXnet Joysticks should start out at 0.

Servo values range from -127 to 127.

Also, you could just check if the button is equal to 0, instead of 1.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Thu Oct 21, 2010 5:13 pm
Profile
Rookie

Joined: Fri Oct 29, 2010 12:30 pm
Posts: 1
Post Re: Servos
Here is a program that I used to get some servos working. Make sure u change the MotorName to the name of your servo.


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


The only problem I see with the servo now is that it likes to glitch and shake when I am holding down one of the buttons. Does anyone know how to fix this?

Josh Hohne
Waltrip HS Robotics


Fri Oct 29, 2010 1:20 pm
Profile
Expert

Joined: Mon Mar 15, 2010 4:24 pm
Posts: 124
Post Re: Servos
Josh, the problem is with the structure of your if statements. If one button is pressed and not the other, the motor will first be set to 63, then will be immediately set to 0. Or it will first be set to 0, then will be immediately set to -63. A better way to do it is:

Code:
if(vexRT[Btn6U] == 1)
{
  motor[MotorName] = 63;
}
else if(vexRT[Btn6D] == 1)
{
  motor[MotorName] = -63;
}
else
{
  motor[MotorName] = 0;
}


Now this will work this way:
Neither button pressed = motor set to 0
Up button pressed, Down button not pressed = motor set to 63
Up button pressed, and Down button pressed = motor set to 63
Up button not pressed, Down button pressed = motor set to -63

Shouldn't jitter any more.

cu,
Gary


Fri Oct 29, 2010 5:16 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Servos
You don't even need the else servo = 0 statement. If you are not giving the servo a value, it will automatically go to zero.

_________________
sudo rm -rf /


Fri Nov 05, 2010 7:53 am
Profile
Expert

Joined: Mon Mar 15, 2010 4:24 pm
Posts: 124
Post Re: Servos
magicode wrote:
You don't even need the else servo = 0 statement. If you are not giving the servo a value, it will automatically go to zero.


I presume this is happening in a loop, so it may be set to 63 when a button is pressed, then a little while later when the buttons are released, it needs to be set to 0. Once you've set it to 63 it will stay at 63 until you tell it to do something else.

cu,
Gary


Fri Nov 05, 2010 11:41 am
Profile
Rookie

Joined: Wed Jun 15, 2011 11:27 am
Posts: 2
Post Re: Servos
Where can I find information about how to program the joy stick.
Thank you.
manuel


Wed Jun 15, 2011 11:41 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: Servos
http://www.education.rec.ri.cmu.edu/pro ... index.html

Try here, in the remote control section.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Wed Jun 15, 2011 11:55 am
Profile
Rookie

Joined: Wed Jun 15, 2011 11:27 am
Posts: 2
Post Re: Servos
jbflot wrote:
http://www.education.rec.ri.cmu.edu/products/teaching_robotc_cortex/index.html

Try here, in the remote control section.

Thank you.


Wed Jun 15, 2011 11:57 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 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.