View Single Post
  #19   Spotlight this post!  
Unread 24-11-2015, 21:27
riftware riftware is offline
Parent Mentor
AKA: Andrew Chandler
FRC #0031
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2011
Location: Tulsa
Posts: 27
riftware is an unknown quantity at this point
Re: Using encoder with talon SRX

Quote:
Originally Posted by ozrien View Post
Hey riftware,

ClosedLoopErr is what is multiplied by Kp, and is equal to your target - current sensor position (or velocity if that's selected). Since you are using quad encoder, then there is 4XCPR units per rotation where CPR=countsPerRotation. Talon is always in 4X mode.

Integral accum sums closedLoopErr every 1ms.
dErr is the change in ClosedLoopErr per 1ms.
Ok so let me expose the massive understanding issue I have.
I want to travel 10' on one wheel.
1: Asuming a 6" wheel diameter I get a circumfrence of 18.84 inches I believe this means I will need to travel 6.36 revolutions.
2: I am using the e4p-360 encoder so its 360 ticks per revolution, except that its quadrature so I multiply that by 4 meaning we really see 1440 counts per revolution. Based on that I think I want a target of +9158.4 (or negative if I'm going backwards.

3: (a little hazier here) - Do I need to include current position or is that implied? My concern is I don't want to do whatever it takes to get to count 5000, I want to add or subtract 5000 to where I am now - or do I need to reset the counter to 0 first?
Code:
int currentPosition = talon.getEncPosition();
talon.set((currentPosition + 9158));
4: PID - P is the constant that gets multiplied by the error (initially the error is 9158 when we start?). Is there a good rule of thumb for picking a P on a drive system as opposed to something like an Arm?
'I' is the Integral - a smaller value gives faster control? - Is there a range to work within or a rough rule of thumb?
'D' is the derivative which if I understood correctly helps prevent overshoot? Higher value reacts faster?


I've tried the numbers from both previous examples and I'm going to continue to try them, but what I don't understand is how they were chosen.

Also in all of this is there a way to indicate an acceptable error margin? Like +/- 5 inches or something?

Finally - when I call this command is there a way for me to set how fast I want to travel (like 1/2 speed or something?)

Last edited by riftware : 24-11-2015 at 21:31.
Reply With Quote