View unanswered posts | View active topics It is currently Fri Sep 19, 2014 10:56 am

Reply to topic  [ 4 posts ] 
Can't get my servos to move 
Author Message

Joined: Sat Dec 07, 2013 1:08 pm
Posts: 8
Post Can't get my servos to move
Hey All, I'm writing an autonomous program and I'm having a little problem with my servos near the end of the code.
I preset the servos at the beginning before anything else and leave them like this for the whole program until the end when my bucket drops the cube into a basket.

Here is my code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTMotor,  HTServo)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     irSensor,       sensorHiTechnicIRSeeker1200)
#pragma config(Motor,  motorA,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  motorB,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  motorC,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motorF,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     motorG,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C3_1,     motorH,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C3_2,     motorI,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C4_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C4_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()

  servo[servo1] = 170.4;  //Set Sensors to a 45 degree turn upwards
  servo[servo2] = 42.6;

  while(SensorValue[irSensor] < 5) // while the irSeeker is less than 5
     if(SensorValue[irSensor] < 5)
        motor[motorD] = 50; // move forward at half speed
        motor[motorE] = 50;
     else // if greater than 5
       motor[motorD] = 0; // stop
       motor[motorE] = 0;

  motor[motorD] = -50; // move backwards
  motor[motorE] = -50;

  motor[motorD] = 100; // turn right
  motor[motorE] = -100;
  wait10Msec(130); // for 1 1/3 second
  motor[motorD] = 0; // stop
  motor[motorE] = 0;

  motor[motorF] = 100; // extend tier 1 of lift
  motor[motorG] = 100;
  wait10Msec(500); // for 5 seconds
  motor[motorF] = 0; // stop
  motor[motorG] = 0;

  motor[motorH] = 100; // extend tier 2 of lift
  motor[motorI] = 100;
  wait10Msec(250); // for 2 1/2 seconds
  motor[motorH] = 0; // stop
  motor[motorI] = 0;

  motor[motorD] = 100; // move forward
  motor[motorE] = 100;
  wait10Msec(50); // for half a second
  motor[motorD] = 0; // stop
  motor[motorE] = 0;

  servo[servo1] = 0; //servos dump cube into box
  servo[servo2] = 256;


the last command has the servos dump the cube out of my cube grabber but when I run the program on the field it doesn't do anything but stays in the set position at the beginning. Can someone explain why they won't move?

Thanks a ton!

Thu Feb 20, 2014 4:32 pm
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 104
Post Re: Can't get my servos to move
They won't move because the robot doesn't know they exist. In the Motor and Sensors setup window, under the Servos tab, you need to configure your servos as either standard servos or a continuous rotation servos. It sounds like you're using standard servos. By the way, servos can only take integer values, not decimal values as their positions. :wink:

Burning Lights Programming
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
Check out our team website at

Thu Feb 20, 2014 4:37 pm

Joined: Sat Dec 07, 2013 1:08 pm
Posts: 8
Post Re: Can't get my servos to move
Thanks for the tip but it still won't change the position of the servos

Thu Feb 20, 2014 4:50 pm
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 578
Post Re: Can't get my servos to move
What you are essentially telling the servos to do is (quickly) 'turn to positions 0 and 256, and turn off'. The problem is that the program ends before the servos have had enough time to move to the specified positions. Try putting a small wait1MSec command at the end for a second or two (you will need to tweak the value) and see if that helps.

  servo[servo1] = 0; //servos dump cube into box
  servo[servo2] = 256;


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

Thu Feb 20, 2014 5:04 pm
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.