Go to Post Let this be a lesson to everyone to never make changes to manufacturing drawings without issuing a new rev of the drawing itself... - Cory [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 02-02-2017, 18:42
thecoopster20 thecoopster20 is offline
4th Year Programmer - Java
FRC #3602 (Robomos)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2014
Location: Escanaba, MI
Posts: 27
thecoopster20 is an unknown quantity at this point
Anyone Have Servo Example Code?

I'm trying to get a linear actuator we got to work. We're using command based and I'd like to see some examples of how to get these things to move. I plugged it in and it extended to its max length, but using .Set() I can't seem to get it to work.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2017, 19:49
forbes's Avatar
forbes forbes is offline
Software developer
AKA: Evan Forbes
FRC #3507 (Ubotics), 694 (StuyPulse)
Team Role: Mentor
 
Join Date: Apr 2013
Rookie Year: 2012
Location: New York City
Posts: 161
forbes is a splendid one to beholdforbes is a splendid one to beholdforbes is a splendid one to beholdforbes is a splendid one to beholdforbes is a splendid one to beholdforbes is a splendid one to beholdforbes is a splendid one to beholdforbes is a splendid one to behold
Re: Anyone Have Servo Example Code?

The javadoc explains how it works pretty well. Can you post your code?

And the servo is definitely plugged in the correct way around?
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2017, 20:37
thecoopster20 thecoopster20 is offline
4th Year Programmer - Java
FRC #3602 (Robomos)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2014
Location: Escanaba, MI
Posts: 27
thecoopster20 is an unknown quantity at this point
Re: Anyone Have Servo Example Code?

The servo is definitely plugged in right, black is ground and white is signal. I have tried multiple command variations that just call a function I setup in the actuator's subsystem where it does servo.set(double). Is this something that only needs to be called once or does this need to be executed for a certain amount of time in order to work?
Reply With Quote
  #4   Spotlight this post!  
Unread 03-02-2017, 19:22
MattBrown MattBrown is offline
Registered User
AKA: Matt Brown
FRC #1501 (T.H.R.U.S.T.)
Team Role: Mentor
 
Join Date: Feb 2016
Rookie Year: 2014
Location: Indiana
Posts: 2
MattBrown is an unknown quantity at this point
Re: Anyone Have Servo Example Code?

This may sound obvious, but we had the same problem. We were testing with the rio powered up but not "enabled" so the PWM ports were disabled. Make sure you have enabled the robot/rio and then try moving the actuator.
Reply With Quote
  #5   Spotlight this post!  
Unread 03-02-2017, 21:35
thecoopster20 thecoopster20 is offline
4th Year Programmer - Java
FRC #3602 (Robomos)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2014
Location: Escanaba, MI
Posts: 27
thecoopster20 is an unknown quantity at this point
Re: Anyone Have Servo Example Code?

Trust me, I made sure the robot was enabled.
Reply With Quote
  #6   Spotlight this post!  
Unread 03-02-2017, 22:09
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 446
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Anyone Have Servo Example Code?

Here's an example subsystem from our 2014 robot which used some fingers on the end of servos to keep the ball centered over our catapult: Subsystem;
https://github.com/Team2168/2014_Mai...allTapper.java
Commands: https://github.com/Team2168/2014_Mai...ommands/tapper

And an example from 2016 for controlling hood position:
Subsystem:
https://github.com/Team2168/2016_Mai...ooterHood.java
Command: https://github.com/Team2168/2016_Mai...odToAngle.java

The code is a little rough around he edges, but it's fairly well commented and it's all been used in match, so should work unless the Servo class has been changed.
__________________
http://team2168.org

Last edited by otherguy : 03-02-2017 at 22:15.
Reply With Quote
  #7   Spotlight this post!  
Unread 04-02-2017, 00:42
thecoopster20 thecoopster20 is offline
4th Year Programmer - Java
FRC #3602 (Robomos)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2014
Location: Escanaba, MI
Posts: 27
thecoopster20 is an unknown quantity at this point
Re: Anyone Have Servo Example Code?

Awesome, appreciate it.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-02-2017, 21:54
thecoopster20 thecoopster20 is offline
4th Year Programmer - Java
FRC #3602 (Robomos)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2014
Location: Escanaba, MI
Posts: 27
thecoopster20 is an unknown quantity at this point
Re: Anyone Have Servo Example Code?

Alright, so today I managed to get the L-16 working perfectly, here are my findings:

-The datasheet for this actuator contains an important piece of information: a PWM pulse width of 2ms fully extends the actuator, and a PWM pulse width of 1ms fully retracts the actuator. The default Max/Min pulse widths for a servo in WPILib is 2.4ms and .6ms, respectively. Be sure to use the setBounds function to ensure that the max and min widths are set for the L-16.

-The basic set function does not seem to work for whatever reason. Using setSpeed(1) and setSpeed(-1) properly calls setMaxPWM and setMinPWM wheres set(1) and set(0) do not properly call them.

-In your commands nothing has to be executed repeatedly. Just call your setSpeed function in the command's init and the actuator takes care of the rest.

Now that the software is working, these are actually fantastic tools. Just wish that there was more documentation for getting these things to work properly.
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 13:17.

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