View unanswered posts | View active topics It is currently Tue Sep 16, 2014 1:45 pm






Reply to topic  [ 3 posts ] 
Issue with Servos 
Author Message
Rookie

Joined: Tue Nov 09, 2010 11:19 am
Posts: 2
Post Issue with Servos
Hello,

This is my first post here, and my first year with FTC. I've been attempting to program a servo motor, but I can't get the servos working at all. I've tried both my own code and the included examples for the servos, and I'm fairly sure I've set the configuration correctly (I've got the HiTechnic Motor Controller connected to S1 on the NXT, then the Servo Controller connected to the motor controller), and I've set it like that in the Motor and Sensor configuration window.

The example code I tried is as follows:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    ,                     tServoStandard)
#pragma config(Servo,  srvo_S1_C2_2,    ,                     tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma platform(Tetrix)

task main()
{
  int i;

  while (true)
  {
    for (i = 0; i <= 256; i += 16)
    {
      servo[servo1] = i;
      nxtDisplayTextLine(3, "Servo: %d", i);
      wait1Msec(100);
    }
    for (i = 256; i>=0; i -=16)
    {
      servo[servo1] = i;
      nxtDisplayTextLine(3, "Servo: %d", i);
      wait1Msec(100);
    }
  }
}


The NXT display shows the correct numbers, and I believe the servo is connected to the right port on the servo controller (Chan. 1). However, the servo does not move and has no additional physical resistance.

Any help would be much appreciated.


Tue Nov 09, 2010 11:43 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Issue with Servos
Make sure your servo is connected to channel 1 with the correct pin orientation to the servo controller. BTW, the servo[] array takes values between 0 to 255. So 256 is outside of that range, probably wrap around and considered the same as zero. Also, your code is stepping the servo through various angles allowing only 100 msec for each step. This may be a little too fast for the motor. I use the following code to test my servo:
Code:
task main()
{
    while (true)
    {
        servo[servo1] = 0;    //turn to 0-degree
        wait1Msec(2000);     //wait 2 sec
        servo[servo1] = 128; //turn to 90-degree (assuming full range is 180-degree)
        wait1Msec(2000);     //wait 2 sec
        servo[servo1] = 255; //turn to 180-degree
        wait1Msec(2000);
    }  //repeat this sequence.
}


Tue Nov 09, 2010 7:49 pm
Profile
Rookie

Joined: Tue Nov 09, 2010 11:19 am
Posts: 2
Post Re: Issue with Servos
Appreciate the reply - we just figured it out - our servo controller seems to be messed up in a slightly major way. We've got our hands on areplacement that works fine.


Tue Nov 16, 2010 10:17 am
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.