ROBOTC.net forums
http://robotc.net/forums/

Servos!! Why wont they work!!
http://robotc.net/forums/viewtopic.php?f=52&t=1189
Page 1 of 1

Author:  Emilhem [ Fri Feb 06, 2009 3:54 pm ]
Post subject:  Servos!! Why wont they work!!

I've tried to program servos for a while now without any success, how do you program a servo and make it work with a joystick and autonomous?
I've checked the battery and all the wires three times but it seems that its not the problem. The "extra" battery symbol is shown on the LCD with full power and we have checked power with other instruments. :(
I tried to use the servo debugger but it doesn't changing any numbers.
The program I used was a sample program that is under this text

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

#include "JoystickDriver.c"

task main()
{
while (true)
{
getJoystickSettings(joystick); //Update Buttons and Joysticks

if(joy1Btn(1) != 0) //If Joy1-Button1 is pressed
{
servoTarget[servo1] = 240; // Move Servo1 to position '240'
}
else //If Joy1-Button1 is NOT pressed
{
servoTarget[servo1] = 50; // Move Servo1 to position '50'
}
}
}

Author:  10nisman94 [ Fri Feb 06, 2009 5:09 pm ]
Post subject:  Re: Servos!! Why wont they work!!

you have no servos identified in motors and sensors setup, you should get a compiler error too.

EDIT: try getting rid of !=0 it works better that way

Author:  Emilhem [ Fri Feb 06, 2009 5:10 pm ]
Post subject:  Re: Servos!! Why wont they work!!

That's not the problem I just copied the sample program.

Author:  chadgeorge [ Fri Feb 06, 2009 5:44 pm ]
Post subject:  Re: Servos!! Why wont they work!!

If you're using exactly the code you posted, then I think 10nisman94 is correct in saying you still need to fillout the servo configuration page.

It should look something like this (assuming the servo controller is the only thing plugged into the NXT portA).

Code:
#pragma config(Hubs,  S1, HTServo,  none,  none,  none)
#pragma config(Servo,  srvo_S1_C1_1,    ServoA,       tServoNormal)
#pragma config(Servo,  srvo_S1_C1_2,    ServoB,       tServoNormal)


then you control the servos like this in autonomous:
Code:
servo[ServoA] = 255;
servo[ServoB] = 0;


or like this in manual:
Code:
servo[ServoA] = joystick.joy1_y1 + 128;
servo[ServoB] = joystick.joy1_y2 + 128;

Author:  Emilhem [ Fri Feb 06, 2009 6:00 pm ]
Post subject:  Re: Servos!! Why wont they work!!

Thanks for the help. Are going to try this on Tuesday. (I don't own the parts so at the next robotics meeting.)

Author:  tfriez [ Wed Feb 11, 2009 1:58 pm ]
Post subject:  Re: Servos!! Why wont they work!!

Servos are non-functional in 1.40... upgrade to 1.46 to get servo support. -> www.ftctraining.com

Author:  Emilhem [ Wed Feb 11, 2009 7:08 pm ]
Post subject:  Re: Servos!! Why wont they work!!

It worked but they was to weak so we have to buy another motor controller. I used 1.46 all the time.
Someone know where to buy less expensive motor controllers? The only price I have seen so far is 79.90.

Author:  G-Unit [ Thu Feb 12, 2009 4:59 pm ]
Post subject:  Re: Servos!! Why wont they work!!

Team G-unit was able to get Servos working with the joystick and button commands with rate control. :bigthumb:
There are three key software prerequisites:
- :arrow: using Robot C 1.46
- :arrow: loading the 1.46 firmware onto the NXT
- :arrow: ensuring that motors and servos are coded with channel designations :
example: srvo_S1_C1_1,
- ample potential, voltage, across the circuit, >12V

Author:  Emilhem [ Thu Feb 12, 2009 5:04 pm ]
Post subject:  Re: Servos!! Why wont they work!!

This is probably finished already if no one have any questions.
Read all the text...I have already had the issue between firmware but I fixed it my self before I even joined RobotC's forum.

Author:  G-Unit [ Fri Feb 13, 2009 9:42 am ]
Post subject:  Re: Servos!! Why wont they work!!

I don't know why yours still aren't working. I would recheck your wiring first. I've read some posts on here saying that the Servo Controllers are the problem but ours seems to be working fine. Don't really know what else to tell you. I'll let you see our code if you want.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     ,              tmotorNone, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     ,              tmotorNone, openLoop)
#pragma config(Servo,  servo1,          servoL,               tServoNormal)
#pragma config(Servo,  servo2,          servoR,               tServoNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
{
  servo[servo1] = 100;
  servo[servo2] = 155;

  wait1Msec(5000);

  while(true)
  {
    getJoystickSettings(joystick);

    servo[servo1] = joystick.joy1_y1 + 127;
    servo[servo2] = (255 - (joystick.joy1_y1 + 127));
  }
}



This is just a program that works our servo attached to our arm. Since the two servos are reversed you have to get oposite readings. It starts by moving our servo to a start position. If you have anyquestions please just ask.

Author:  Emilhem [ Fri Feb 13, 2009 3:55 pm ]
Post subject:  Re: Servos!! Why wont they work!!

READ :poke:
I have already fixed all the issues with help from many helpfully people in this forum.
Thanks anyway. :) :) (Wanted to see the differences between the two smiles that had the same code.)

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/