Go to Post 5:20 - Lots of discussion about how FIRST pretty much wipes out the world of at least one object every year. - Andy Grady [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2013, 10:39
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Servo programming

I'm having trouble trying to program a servo. Everytime I press the button that should make it rotate it does nothing. Any help would be appreciated.

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.SimpleRobot;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class RobotTemplate extends SimpleRobot {

Servo servo = new Servo(5);
Joystick joystick = new Joystick(1);

/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {

}

/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {

if(joystick.getRawButton(3))
{
servo.set(1);
}
else if(joystick.getRawButton(4))
{
servo.set(-1);
}

}

/**
* This function is called once each time the robot enters test mode.
*/
public void test() {

}
}
__________________
Wait, what?

Last edited by Mr.Roboto3335 : 09-02-2013 at 10:40. Reason: The code was a mess
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2013, 11:28
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: Servo programming

Code:
public void operatorControl() {

if(joystick.getRawButton(3))
{
servo.set(1);
} 
else if(joystick.getRawButton(4))
{
servo.set(-1);
}

}
This should be running in a loop. Like this
Code:
while(isOperatorControl()) {
    // Code here
}
__________________
All opinions are my own.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2013, 11:33
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Servo programming

You are absolutely correct. I forgot that statement. Servo still won't work. It doesn't even default when I reset the robot. Wiring?
__________________
Wait, what?

Last edited by Mr.Roboto3335 : 09-02-2013 at 11:40.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2013, 11:43
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Servo programming

Also, Servo.set() takes a value from 0 to 1, rather then -1 to 1 like a motor.

You can also use code tags to keep your formatting when posting code.

Did you install the servo jumper in the digital sidecar?
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2013, 11:48
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Servo programming

Quote:
Originally Posted by Joe Ross View Post
Also, Servo.set() takes a value from 0 to 1, rather then -1 to 1 like a motor.

You can also use code tags to keep your formatting when posting code.

Did you install the servo jumper in the digital sidecar?
No I did not... Found and inserted the jumper and is now working. Thank you!
__________________
Wait, what?

Last edited by Mr.Roboto3335 : 09-02-2013 at 12:04.
Reply With Quote
  #6   Spotlight this post!  
Unread 17-02-2013, 19:24
tmccalister tmccalister is offline
Registered User
FRC #2985
 
Join Date: Jan 2011
Location: TEXAS YEEEHAWWWWW
Posts: 18
tmccalister is an unknown quantity at this point
Re: Servo programming

What is a servo jumper? If you could help me with that just pm me. Thanks
Reply With Quote
  #7   Spotlight this post!  
Unread 17-02-2013, 19:28
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Servo programming

Quote:
Originally Posted by tmccalister View Post
What is a servo jumper? If you could help me with that just pm me. Thanks
Jump to 0:24 in this video:

http://www.youtube.com/watch?v=RF104...me0nC_xUILWCam


Reply With Quote
  #8   Spotlight this post!  
Unread 18-02-2013, 18:36
tmccalister tmccalister is offline
Registered User
FRC #2985
 
Join Date: Jan 2011
Location: TEXAS YEEEHAWWWWW
Posts: 18
tmccalister is an unknown quantity at this point
Re: Servo programming

Quote:
Originally Posted by Ether View Post
What does it look like?
Reply With Quote
  #9   Spotlight this post!  
Unread 18-02-2013, 21:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Servo programming

Quote:
Originally Posted by tmccalister View Post
What does it look like?
It looks like the picture in the 2013 Kit of Parts black tote checklist revB.


Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi