View Single Post
  #7   Spotlight this post!  
Unread 22-11-2015, 12:57
Poseidon5817's Avatar
Poseidon5817 Poseidon5817 is offline
Founder and CEO, DeadMemes Studios
AKA: Mitchel Stokes
FRC #5817 (Uni-Rex)
Team Role: Mentor
 
Join Date: Aug 2013
Rookie Year: 2014
Location: Clovis, CA
Posts: 370
Poseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud of
Re: Using encoder with talon SRX

Quote:
Originally Posted by riftware View Post
I think I understand the original posters point - I've struggled with this a bit as a mentor myself. I had found the coding manual last year but never got things working quite right for us. I'm a java developer by trade but robotics is only a hobby and I fear some of the background context that most presume is known in advance is a bit of a hole for me.

Things I didn't see:
- There are encoder classes if I remember right in wpilib. However if we hook the encoder to the talon we don't use them at all right?
- a lot of the built in PID type functionality can't be used if the encoders are hooked to the talon right? The PID classes all expect to get the encoder feedback directly.
- I assume hooking the encoders to the talon directly reduces overhead on the roborio and certainly free's up ports. I'd love to see a post that covers the pro's con's of either scenario and how you might use the wpilib PID controllers when the encoders are hooked directly to the talon srx

I'm going back to reading the talon programming manual again (its been most of a year) and this year we have the luxury of a bench bot we can more easily experiment with so hopefully I'll be in a better position. Last year encoders weren't critical but this year I'm really hoping we can do better in autonomous mode than last year. Other topics that would be interesting for me would be a ramp/brake tutorial for dummies. I have yet to search on that one so maybe it exists. The comment has been made that we accelerate too quickly and stop too quickly so I'm assuming that we need to learn about those.
If you hook the encoders to the talon directly, you don't need to use any of the WPI PID classes at all. All the encoder feedback and output is handled through the talon. For example, this code changes the talon to position mode, sets the feedback device, and sets the PID constants.

Code:
talon.changeControlMode(ControlMode.Position); //Change control mode of talon, default is PercentVbus (-1.0 to 1.0)
talon.setFeedbackDevice(FeedbackDevice.QuadEncoder); //Set the feedback device that is hooked up to the talon
talon.setPID(0.5, 0.001, 0.0); //Set the PID constants (p, i, d)
talon.enableControl(); //Enable PID control on the talon
Then later in your code, you can use the talon.set() method to set the talon's position (or velocity, or percent, etc.)

Code:
talon.set(5000); //Tells the talon to go to 5000 encoder counts, using the preset PID parameters.
As for the ramp/brake stuff, you can set that easily also.

Code:
talon.setVoltageRampRate(rampRate); //Sets the max voltage ramp on the talon
//This affects both starting and stopping
You can also switch control modes and PID parameters later (to allow manual control). Do the exact same as earlier.

Code:
talon.changeControlMode(ControlMode.PercentVbus); //Change control mode of talon, default is PercentVbus (-1.0 to 1.0)
talon.setPID(0.0, 0.0, 0.0); //Set the PID constants (p, i, d)
talon.enableControl(); //Enable PID control on the talon
__________________
My FRC History:

2014 - Team 1671: Central Valley Regional Finalist and Chairman's Award Winner, Sacramento Regional Finalist, Archimedes Quarterfinalist
2015 - Team 1671: Central Valley Regional Semifinalist, Sacramento Regional Semifinalist and Chairman's Award Winner, Newton Winner, Einstein Winner
2016 - Team 5817: Central Valley Regional Finalist and Rookie All-Star, Orange County Regional Quarterfinalist and Rookie All-Star, Newton Division
2017 - Team 5817: Return of the bench grinder


Reply With Quote