Go to Post Do I think the bar is too high? I think impossible dreams and lofty goals are a key part of FIRST; the "top" being extremely far away only pushes people farther. - Chris is me [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 31-03-2016, 14:56
Jeringo Jeringo is offline
Registered User
FRC #4749
 
Join Date: Jan 2016
Location: Atlanta
Posts: 10
Jeringo is an unknown quantity at this point
understanding position control with encoders

Greetings I am trying to program for a shooter that has a variable tilt from anywhere between 0 and 80 degrees. we are using a talonSRX with an encoder on it (http://www.vexrobotics.com/217-5046.html). My question is how exactly does position control work? We have set the feedback device to Quad Encoder and changed the control mode to position. From there we set the encoder counts per rev to many numbers currently 45, set the encoder position to 0. Now here is where the confusing part comes in Do I need to use SetPID and if so how do I use it. Is there a way to set the max velocity or slow the motor down? Is there any good way to calibrate the code so that I can set(10) and get 10 degrees? Thanks.
  #2   Spotlight this post!  
Unread 31-03-2016, 15:25
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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: understanding position control with encoders

Quote:
Originally Posted by Jeringo View Post
My question is how exactly does position control work?
While you are waiting for other responses, download the Talon SRX Software Reference Manual from the manufacturer's website. Everything you need to know is in there, including examples.

Also these:

http://link.vex.com/vexpro/pdf/217-5046-instructions

http://link.vex.com/vexpro/pdf/217-5049-user-guide



Last edited by Ether : 31-03-2016 at 16:08.
  #3   Spotlight this post!  
Unread 31-03-2016, 15:26
Camilo86's Avatar
Camilo86 Camilo86 is offline
Registered User
AKA: camilo
FRC #0125 (Nutrons)
Team Role: Programmer
 
Join Date: Jun 2013
Rookie Year: 2012
Location: Boston
Posts: 21
Camilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of light
Re: understanding position control with encoders

What you need to do is create a command that initializes the talon's srx PID. Since you have it in position mode, the setPoint is going to be the distance you want the arm to go to. You will need to set a constant that relates degrees to ticks. You can use the configEncoderCodesPerRev() to do so (this is assuming the encoders are connected directly to the talon srx). We do something similar. https://github.com/FRC125/NU16/blob/...sitionCmd.java
__________________
Hopper finalist 2015
Dean's List winner 2015
  #4   Spotlight this post!  
Unread 31-03-2016, 15:28
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: understanding position control with encoders

Quote:
Originally Posted by Jeringo View Post
Greetings I am trying to program for a shooter that has a variable tilt from anywhere between 0 and 80 degrees. we are using a talonSRX with an encoder on it (http://www.vexrobotics.com/217-5046.html). My question is how exactly does position control work? We have set the feedback device to Quad Encoder and changed the control mode to position. From there we set the encoder counts per rev to many numbers currently 45, set the encoder position to 0. Now here is where the confusing part comes in Do I need to use SetPID and if so how do I use it. Is there a way to set the max velocity or slow the motor down? Is there any good way to calibrate the code so that I can set(10) and get 10 degrees? Thanks.
It's probably too late, but for future reference you're often better off using a potentiometer or absolute encoder for a task where you need to use a motor to move something to a specific position.

The key challenge here (which it appears you've identified) is that you need a consistent zero position in order for the encoder to work reliably (eg, if you want to say "go to X"). Often, this is a consistent starting position (where the shooter is at rest) or you can use a limit switch to identify the position more precisely. Once this is good...

Then you have to do two things. First, you need to set the P, I, D parameters (setPID). You can either call setPID, or you can set it via the web dashboard. Often, you can get by with just a P (search for forums for more about PID tuning). I usually just set P to an arbitrary number (1), and keep incrementing it until it starts moving, then I adjust the value using binary search until it gets to where the value is reliable. There are more precise ways to do this, the TalonSRX reference manual has some examples.

For limiting the speed of the arm, check out the closed loop ramp rate, which can be set via the web dashboard or via setCloseLoopRampRate.

There are a bunch of code examples that CTRE provides, I recommend checking them out: https://github.com/CrossTheRoadElec/FRC-Examples . Additionally, the TalonSRX softwware reference manual has a lot of good explanation+documentation available.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #5   Spotlight this post!  
Unread 31-03-2016, 15:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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: understanding position control with encoders

Quote:
Originally Posted by virtuald View Post
It's probably too late, but for future reference you're often better off using a potentiometer or absolute encoder
...
Attached Thumbnails
Click image for larger version

Name:	capture_004_31032016_145908.png
Views:	96
Size:	33.7 KB
ID:	20501  
  #6   Spotlight this post!  
Unread 31-03-2016, 16:38
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: understanding position control with encoders

Quote:
Originally Posted by Ether View Post
...
That sounds like an awesome product, didn't realize it existed.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #7   Spotlight this post!  
Unread 31-03-2016, 16:40
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: understanding position control with encoders

Oh. Ha. Ok. Yes, it is an absolute encoder. Ignore what I said then. As I sadi above, didn't realize that it existed, so when I saw 'encoder' without absolute I made assumptions.

Kids, this is why you don't assume. Otherwise, Ether points out your follies.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #8   Spotlight this post!  
Unread 31-03-2016, 16:49
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: understanding position control with encoders

Quote:
Originally Posted by virtuald View Post
That sounds like an awesome product, didn't realize it existed.
It's the encoder the original poster identified as what he is using. Ether has a habit of offering up raw information without extra explanation. I think he wants to give the reader the opportunity to figure out why it might be relevant.
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 20:37.

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