Hi everybody,
Our team is new to VEX this year, and we are trying hard to figure out the programming as we go. Most of our teams are trying to integrate 3-wire servos into our arm mechanisms. These are the regular servos, not the IMEs. We want to be able to control these servos on our button remotes as well. However, the closest we have managed only provides about a 20-30 degree range of motion.
A few questions:
- Do you have to use a pot or encoder in order for the servo to work correctly? If so, is there a resource that I can refer to see how these tie together?
- Is there a way to program this so that the arm will hold in place after the button is depressed? (It currently returns to its original position after the button is depressed)
- I have attached the code as it is right now. What are we doing wrong? Can you please show us just a general default code for servos to be used on a controller?
Thank you for your help!!!
#pragma config(Motor, port2, backRight, tmotorVex393TurboSpeed_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port5, motorArm2, tmotorServoStandard, openLoop)
#pragma config(Motor, port6, motorArm, tmotorServoStandard, openLoop)
#pragma config(Motor, port8, motorMan, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, frontLeft, tmotorVex393TurboSpeed_MC29, openLoop, driveLeft)
#pragma config(Motor, port10, backLeft, tmotorVex393TurboSpeed_HBridge, openLoop, driveLeft)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task main()
{
while(1 == 1)
{
motor[frontRight] = vexRT[Ch2]; // front right motor move forward if joystick pushed forward
motor[backRight] = vexRT[Ch2]; // back right motor move forward if joystick pushed forward
motor[backLeft] = vexRT[Ch3]; // back left motor move forward if joystick is pushed forward
motor[frontLeft] = vexRT[Ch3]; // front left motor move forward if joystick is pushed forward
if(vexRT[Btn6D]==1)
{
setservo[motorArm] = 100; // arm moves up if button 6 U is pushed
motor[motorArm2] = 100; // arm moves up if button 6 u is pushed
}
else if(vexRT[Btn6U] == 1)
{
motor[motorArm] = -100; // arm moves down if button 6 D is pushed
motor[motorArm2] = -100; // arm moves down if button 6 D is pushed
}
else
{
motor[motorArm] = 0; //arm stops if button is not pressed
motor[motorArm2] = 0; //arm stops if button is not pressed
}
if(vexRT[Btn5U]==1)
{
motor[motorMan] = 127; //manipulator moves up if button 5 U is pushed
}
else if(vexRT[Btn5D]==1)
{
motor[motorMan] = -127; //manipulator moves down if button 5 d is pushed
}
else
{
motor[motorMan] = 0; //manipulator stops if button is not pressed
}
}
}