View unanswered posts | View active topics It is currently Fri Nov 22, 2019 6:16 am






Reply to topic  [ 2 posts ] 
Servos wont respond!!! 
Author Message
Rookie

Joined: Wed Nov 19, 2014 1:28 am
Posts: 2
Post Servos wont respond!!!
Having trouble getting my servos to respond to the button commands, everything else is working as it should. Any suggestions would be helpful. Thank you in advance.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTMotor,  HTMotor)
#pragma config(Hubs,  S2, HTServo,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Motor,  motorA,          Sweeper,       tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          SweeperR,      tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_1,     LeftFront,     tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     RightFront,    tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C2_1,     LeftBack,      tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     RightBack,     tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C3_1,     UpDownL,       tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C3_2,     UpDownR,       tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C4_1,     ArmOut,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C4_2,     ClawOut,       tmotorTetrix, openLoop, reversed)
#pragma config(Servo,  srvo_S2_C1_1,    ClawDoor,             tServoStandard)
#pragma config(Servo,  srvo_S2_C1_2,    Teeth,                tServoStandard)
#pragma config(Servo,  srvo_S2_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

void initializeRobot ()
{
   return;
}

task main()
{
   int  threshold = 15;
   initializeRobot ();

   waitForStart ();

while (true)
{
   getJoystickSettings(joystick);
   if(abs(joystick.joy1_y1) > threshold)
   {
      motor[LeftFront] = joystick.joy1_y1;             // All four motors assigned are to serve the purpose of//
   motor[LeftBack] = joystick.joy1_y1;              //tank drive and move in the basic forward, back, left, and right.//
   motor[RightBack] = joystick.joy1_y1;
   motor[RightFront] = joystick.joy1_y1;

   }
else if(abs(joystick.joy1_y2) > threshold)
{
   motor[LeftFront] = joystick.joy1_y2;            //Here the controls are varied a little for the mechanum wheels//
   motor[RightBack] = joystick.joy1_y2;            //This set up alows for slides to the right and left//
   motor[RightFront] = -joystick.joy1_y2;
   motor[LeftBack] = -joystick.joy1_y2;

}
else if(abs(joystick.joy1_x1) > threshold)
{
      motor[LeftFront] = joystick.joy1_x1;             // All four motors assigned are to serve the purpose of//
   motor[LeftBack] = joystick.joy1_x1;              //tank drive and move in the basic forward, back, left, and right.//
   motor[RightBack] = -joystick.joy1_x1;
   motor[RightFront] = -joystick.joy1_x1;
}
else
{
   motor[LeftFront] = 0;             // All four motors assigned are to serve the purpose of//
   motor[LeftBack] = 0;              //tank drive and move in the basic forward, back, left, and right.//
   motor[RightBack] = 0;
   motor[RightFront] = 0;
}

if(joy1Btn(8))
{
   motor[ClawOut] = 100;
}
else if(joy1Btn(6))
{
   motor[ClawOut] = -100;
}
else
{
   motor[ClawOut] = 0;
}
if(joy1Btn(5))
{
   motor[UpDownL] = 100;
   motor[UpDownR] = 100;
}
else if(joy1Btn(7))
{
   motor[UpDownL] = -100;
   motor[UpDownR] = -100;
}
else
{
   motor[UpDownL] = 0;
   motor[UpDownR] = 0;
}
if(joy1Btn(4))
{
   servo[ClawDoor] = 0;
}
else if(joy1Btn(2))
{
   servo[ClawDoor] = -100;
}
if(joy1Btn(1))
{
   servo[Teeth] = 0;
}
else if(joy1Btn(3))
{
   servo[Teeth] = 127.5;
}
if(joy1Btn(11))
{
   motor[Sweeper] = 100;
   motor[SweeperR] = 100;
}
else if(joy1Btn(12))
{
   motor[Sweeper] = -100;
   motor[SweeperR] = -100;
}
else
{
   motor[Sweeper] = 0;
   motor[SweeperR] = 0;
}
}
}

_________________
Team 4932 driver and programmer
Team 4902 programmer
2013-2015


Wed Nov 26, 2014 12:02 am
Profile
Rookie
User avatar

Joined: Wed Jan 09, 2013 11:48 pm
Posts: 46
Location: Saint Paul, MN
Post Re: Servos wont respond!!!
Two small things that don't matter all that much about your code:
Since servo[] takes an integer, I would change this:
Code:
else if(joy1Btn(3))
{
   servo[Teeth] = 127.5;
}

to this:
Code:
else if(joy1Btn(3))
{
   servo[Teeth] = 127;
}

But the computer should do that automatically for you. The other thing is it's often a good idea to place at the end of the while loop a wait1Msec(50) to let the brain catch up. I haven't noticed any difference honestly, but I have read in multiple places you should do that.

Other than that, your program looks perfectly fine. There are a few things I would check to try and figure out what the problem is. Try writing another program where all it does is move those servos. If they respond properly to that, there might be something wrong with your controller (joystick) or the connection to the NXT. Also check to make sure all the wiring is done properly. If the servo controller doesn't have enough power, it is possible the servos won't respond. It is also a very easy mistake to plug the servos in backwards, I have done that before and they won't work if you do that.

So, my guess would be is there is something going wrong with the wiring judging by how your program for controlling them looks like it should work.

_________________
Head Programmer FTC Team 6699, Tempest

Code:
<Life>
   Fun
</Life>


Wed Nov 26, 2014 1:36 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.