View unanswered posts | View active topics It is currently Thu May 23, 2013 6:33 am






Reply to topic  [ 7 posts ] 
Coding for Servos 
Author Message
Rookie

Joined: Wed Oct 12, 2011 9:24 am
Posts: 3
Post Coding for Servos
Hi, I've been working on coding with RobotC recently and successfully got the motors to work. However, I was not able to get the servos to work. I have tried to code it in the simplest way such as:

Code:
#pragma config(Hubs,  S1, HTServo,  none,     none,     none)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Servo,  srvo_S1_C1_1,    servo1,               tServoContinuousRotation)
#pragma config(Servo,  srvo_S1_C1_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  servo[servo1] = 255;
  wait1Msec(3000);
  servo[servo1] = 0;
  wait1Msec(3000);
}


Is there something wrong in my code? I have everything connected in the right place. Please give your inputs, thank you all in advance for your supports.


Wed Oct 12, 2011 9:32 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 495
Post Re: Coding for Servos
What happens when you try this:
Code:
task main(){
  while(true){
    servo[servo1] = 255;
  }
}


Does the servo go all the way up?

_________________
sudo rm -rf /


Wed Oct 12, 2011 10:23 am
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 137
Post Re: Coding for Servos
Using the servo debugger window is also an easy way to check for hardware/wiring problems vs. bad code.

One common problem I see a lot of FTC rookies make is to plug the servo wire into the controller backwards. Make sure you line the yellow wire up facing the top of the controller per the Y R B labeling on the servo controller. Also, you may want to double check that you have power to the controller & your pragmas are correct.


Wed Oct 12, 2011 10:57 am
Profile
Rookie

Joined: Wed Oct 12, 2011 9:24 am
Posts: 3
Post Re: Coding for Servos
magicode wrote:
What happens when you try this:
Code:
task main(){
  while(true){
    servo[servo1] = 255;
  }
}


Does the servo go all the way up?


i tried copy&pasting, and nothing happened =\ i tried using both continuous and not continuous servos but neither of them seemed to work.


l0jec wrote:
sing the servo debugger window is also an easy way to check for hardware/wiring problems vs. bad code.

One common problem I see a lot of FTC rookies make is to plug the servo wire into the controller backwards. Make sure you line the yellow wire up facing the top of the controller per the Y R B labeling on the servo controller. Also, you may want to double check that you have power to the controller & your pragmas are correct.


the debugger option under "robot" tab does not let me click anything, and i don't think it's a hardware/wiring problem because we have everything hooked up. I double checked that the yellow wire is facing the top of the controller, and it still didn't work


Wed Oct 12, 2011 12:10 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 137
Post Re: Coding for Servos
I also just reread your pragmas....
Quote:
Code:
#pragma config(Servo,  srvo_S1_C1_1,    servo1,               tServoContinuousRotation)

Is your servo a standard servo or a continuous rotation servo? You have it configured as a continuous rotation servo.

As far as your wiring and hardware, did you use a multi-meter to check that the controller is in fact getting power? Note that low 12v batteries can also trip you up.


Thu Oct 13, 2011 8:22 am
Profile
Rookie

Joined: Wed Oct 12, 2011 9:24 am
Posts: 3
Post Re: Coding for Servos
l0jec wrote:
I also just reread your pragmas....
Quote:
Code:
#pragma config(Servo,  srvo_S1_C1_1,    servo1,               tServoContinuousRotation)

Is your servo a standard servo or a continuous rotation servo? You have it configured as a continuous rotation servo.

As far as your wiring and hardware, did you use a multi-meter to check that the controller is in fact getting power? Note that low 12v batteries can also trip you up.


i have tried both standard and continuous servos with the corresponding configurations, and neither have worked. the battery is full of juice; the servo controller lights up brightly red. i don't understand why the servos are not working T-T


Thu Oct 13, 2011 9:11 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 495
Post Re: Coding for Servos
Wait a second. Take a look at this part of your code:
Code:
#pragma config(Hubs,  S1, HTServo,  none,     none,     none)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)

Do you have a Servo controller plugged into S1 or a sensorMux?

_________________
sudo rm -rf /


Thu Oct 13, 2011 9:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: MariosRobot and 4 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.