Go to Post "If a student CAN do it, a student SHOULD do it." - Mr. Lim [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2014, 21:10
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
How to Program a Servo

Hello - Im the head programmer/electronics guy at LF Robotics. I am the only one of my kind on the team and this is my first year so I have absolutely NO experience so PLEASE bear with me.

I want to have a servo that by the touch of say button four on the joystick will rotate 45 degrees to the right and once it reaches that point will return to its original position.

I am using Command Based Java in Netbeans.

I know how to do simple things with it - like I said this is my first year.

ANY help will be GREATLY appreciated - THANKS!
  #2   Spotlight this post!  
Unread 24-01-2014, 21:53
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: How to Program a Servo

Hello again! I would recommend asking all your questions in one thread please. It makes the life of people who are trying to help you much easier xD
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
  #3   Spotlight this post!  
Unread 25-01-2014, 00:38
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 191
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: How to Program a Servo

If you can use robot builder to create your subsystem and commands. Robot builder is create for beginners. Always make sure to review the code it generates and try to understand what it is doing.

The basic approach (no code. I'm a C++ guru and am not confident I would not provide broken java code.).

Create a subsystem and add a Servo to it or add a Servo object to an appropriate existing subsystem.

Solution A

Create a command that moves the servo to position 1.
Create a command that moves the servo to position 2.
Create a command group that adds sequentially:
--MoveServoToPos1Command
--WaitCommand(timeItTakesForServoToRotate45Deg)
--MoveServoToPos2Command
Assign command group to a joystick button.

Solution B
Create a command that moves the servo to position 1 and then waits the timeItTakesForServoToRotate45Deg and then moves the servo to position 2.

The choice is up to you how much you want to break the problem down. 1 command will work but a command group of discrete commands would be more flexible.
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

  #4   Spotlight this post!  
Unread 25-01-2014, 14:05
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: How to Program a Servo

Okay - THANKS - I think I got it figured out now.
Closed Thread


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 02:46.

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