Go to Post Joining a FIRST team is the beginning of "smart," not the culmination. - klrswift [more]
Home
Go Back   Chief Delphi > Technical > Control System > FRC Control System
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 18-03-2012, 17:00
dtgriscom dtgriscom is offline
Mentor, Team 2713
AKA: Dan Griscom
FRC #2713 (iRaiders)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2008
Location: Melrose, MA
Posts: 14
dtgriscom is an unknown quantity at this point
PID control: need D values > 10000??

We're using CANJaguar and PID control on our robot arm's shoulder joint. The arm is driven by a pair of highly-geared motors, with an encoder directly on the joint. We're having a very tough time getting the right values for PID, and need some help. Specifically, we feel we need some D to prevent oscillation and overshoot, but have had no success getting any value of D to work.

We've been testing different PID values using BDC-Comm, initially with motor power disconnected. We're trying out different values of P, I and D, and watching the motor output voltage as we move the arm. Our P and I experimentation gives us sensible results, but D seems almost non-functional. We test by setting P and I to zero, choosing a value for D, and the moving the arm and watching the motor voltage. Unless we set D above 10000 (yes, ten thousand) the BDC-Comm voltage display never budges from zero. The max value for D (at least in BDC-Comm) is 32767, so that seems really strange.

BDC-Comm testing with motor connected shows that if I have all three terms set to 0, and stop action set to coast then the arm can easily be moved (obviously). I'd expect that I could then use a D value as a brake, resisting any motion. But, I have to bump my D value up to above 5000 before I get any braking action. If I set D to very negative (-10000) I get an apparent reduction in friction.

Why does this require such enormous values of D? It's conceivable that if we could use a D of, say, 100000 we'd be fine, but that won't work in BDC-Comm, and even if they'd work in Java using weird values "because they work" doesn't seem like the right approach.


Thanks,
Dan

Edit: I think I've found the answer, but my three posts to that effect have yet to show up, So, I'm trying this.

Ether pointed me the right way: the problem is our counts-per-second. Arm moves 220 degrees max, directly coupled to a 360 degree per rotation encoder, so that's only 220 counts total. We want control of motions of a few degrees a second, or a few counts a second. Given the PID iteration time of a millisecond, that won't work (and is why D is totally ineffective; P and I are probably hampered as well.) Lesson: we gotta get more counts, probably moving the encoder to an intermediate shaft on our gearbox.
__________________
Daniel Griscom
iRaiders Team 2713
Position: Mentor and Official Team Worrier

Last edited by dtgriscom : 19-03-2012 at 12:28. Reason: Aren't being allowed to post to this thread
Reply With Quote
  #2   Spotlight this post!  
Unread 18-03-2012, 18:41
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 821
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
Re: PID control: need D values > 10000??

Have you tried using the Ziegler-Nichols Method for tuning your PID Controller? I'm not familiar with BDC-Comm. Did you write your own PID code?
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 18-03-2012, 19:14
dtgriscom dtgriscom is offline
Mentor, Team 2713
AKA: Dan Griscom
FRC #2713 (iRaiders)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2008
Location: Melrose, MA
Posts: 14
dtgriscom is an unknown quantity at this point
Re: PID control: need D values > 10000??

BDC-Comm is the TI tool for communicating over CAN bus directly to a Jaguar motor controller. No cRIO or Driver Station involved, which lets us try values quickly and without worrying about possible software bugs (at least outside the Jaguar).

We have a controls expert who was stymied at getting good PID control working due to the ineffective D term. I don't think it's our tuning procedure; it's either a bug in the Jaguar's firmware (which seems unlikely) or a problem in our understanding of the use of PID on the Jaguar (more likely).
__________________
Daniel Griscom
iRaiders Team 2713
Position: Mentor and Official Team Worrier
Reply With Quote
  #4   Spotlight this post!  
Unread 18-03-2012, 19:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,024
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: PID control: need D values > 10000??

Quote:
Originally Posted by dtgriscom View Post
Why does this require such enormous values of D?
According to this post, D is multiplied by the difference in error, not by the (difference in error)/(sample time). Since the PID in the Jag runs at 1000Hz, that factor of 1000 needs to be in your D gain. That's my guess.

What's the resolution (counts per degree) of your encoder, and how fast are you moving the arm (degrees per millisecond) when you're looking for a voltage?


Reply With Quote
  #5   Spotlight this post!  
Unread 18-03-2012, 19:55
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,113
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: PID control: need D values > 10000??

Quote:
Originally Posted by dtgriscom View Post
The max value for D (at least in BDC-Comm) is 32767, so that seems really strange
I would assume this maximum exists because the D value is stored in 16 bits. (2^16)/2 = 32768


And I have a question. When you have a functioning system, what are your other values? Because it's possible that your P could be too low, as well. (but Ether's idea above me looks right, as well)
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #6   Spotlight this post!  
Unread 18-03-2012, 20:58
dtgriscom dtgriscom is offline
Mentor, Team 2713
AKA: Dan Griscom
FRC #2713 (iRaiders)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2008
Location: Melrose, MA
Posts: 14
dtgriscom is an unknown quantity at this point
Re: PID control: need D values > 10000??

Quote:
Quote:
The max value for D (at least in BDC-Comm) is 32767, so that seems really strange
I would assume this maximum exists because the D value is stored in 16 bits. (2^16)/2 = 32768
Sorry I wasn't clear: the exact maximum is unsurprising (in a binary world), but that it is so close to the useful value (and may even be lower than the best value) was surprising.

Quote:
According to this post, D is multiplied by the difference in error, not by the (difference in error)/(sample time). Since the PID in the Jag runs at 1000Hz, that factor of 1000 needs to be in your D gain. That's my guess.

What's the resolution (counts per degree) of your encoder, and how fast are you moving the arm (degrees per millisecond) when you're looking for a voltage?
I think you've hit upon the answer. We're using a 360 count/rev encoder (one count per degree) which is connected directly to the shoulder joint. We'd like good regulation with the arm moving a maximum of 220 degrees or counts per second, which is about .2 counts per PID iteration. Even with 4x encoding, that's less than one count per PID iteration. Regulation needs to continue down to less than 10 degrees or counts per second, or about 1 count every 100 PID iterations. That's gotta be problematic.

Our two motors drive Banebot 16:1 gearboxes, which are both plugged into a single 6:1 Andymark Toughbox driving the shoulder. Moving the encoder to the output of one of the Banebot gearboxes would cut the required D term by a factor of six, which might be enough. Moving the encoder to the shaft of one of the motors would be even better, but I don't think that's possible with our motors.

Lesson: if you want reasonable PID control, you need to have a reasonable number of counts per second on your encoder.


Thanks, all!
Dan
__________________
Daniel Griscom
iRaiders Team 2713
Position: Mentor and Official Team Worrier
Reply With Quote
  #7   Spotlight this post!  
Unread 19-03-2012, 10:41
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,899
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: PID control: need D values > 10000??

The D (derivative) term helps to compensate for short term disturbances. Its effect decays over time. It can have a destabilizing influence on the loop. It is generally the last term to determined if it is used at all. Generally a properly tuned loop will have a little overshoot & oscillation decaying to 0 in 2-4 oscillations. I am not sure how you tune a loop without the load connected.

The jags use a 32 fixed point integer for the constants--16.16. one bit for sign, 15 bits lefts of the decimal point, 16 bit right of the decimal point.
Reply With Quote
  #8   Spotlight this post!  
Unread 19-03-2012, 11:05
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,169
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: PID control: need D values > 10000??

I don't know much about the Jaguar/CAN PID implementation but I can tell you that your system will act very differently with the load attached. The control loop is electro-mechanical. The numbers you get w/o a load are nearly useless and perhaps why D has little or no effect.

HTH
__________________
Fast, cheap or working - pick any two!
Reply With Quote
  #9   Spotlight this post!  
Unread 19-03-2012, 11:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,024
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: PID control: need D values > 10000??



My reading of the OP's post is that he is not trying to tune the system without a load. He is observing the effect of the P, I, and D gains in order to confirm that they do what he would expect. And he is questioning what he is observing.

Quote:
We've been testing different PID values using BDC-Comm, initially with motor power disconnected. We're trying out different values of P, I and D, and watching the motor output voltage as we move the arm. Our P and I experimentation gives us sensible results, but D seems almost non-functional. We test by setting P and I to zero, choosing a value for D, and the moving the arm and watching the motor voltage.

BDC-Comm testing with motor connected shows that if I have all three terms set to 0, and stop action set to coast then the arm can easily be moved (obviously). I'd expect that I could then use a D value as a brake, resisting any motion.

Reply With Quote
  #10   Spotlight this post!  
Unread 19-03-2012, 11:24
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,024
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: PID control: need D values > 10000??

Quote:
Originally Posted by FrankJ View Post
The jags use a 32 fixed point integer for the constants--16.16. one bit for sign, 15 bits lefts of the decimal point, 16 bit right of the decimal point.
I'm not necessarily disagreeing, but where did you get this information?


Reply With Quote
  #11   Spotlight this post!  
Unread 19-03-2012, 11:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,024
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: PID control: need D values > 10000??


For a position PID, the D term looks at how fast the process variable is moving toward or away from the setpoint, and whether the process variable is above or below the setpoint.

For a fixed setpoint, the effect of the D term on the PID output is such that it acts as a speed-dependent "brake" whenever the process variable is moving toward or away from the setpoint.


Reply With Quote
  #12   Spotlight this post!  
Unread 19-03-2012, 12:13
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,899
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: PID control: need D values > 10000??

Quote:
I'm not necessarily disagreeing, but where did you get this information?
From the TI 2012 FAQ on the jags Question 41 addresses it. The file name is spma033a.pdf.

I used to tune flow & pressure control loops. Admittedly the transfer function for a position or velocity loop might look different. I generally found the process measurement value to be noisy enough to make the derivative term useless. Obviously others have found it useful since it is a lot easier to find PID controllers rather than PI controllers.
Reply With Quote
  #13   Spotlight this post!  
Unread 19-03-2012, 12:16
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,024
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: PID control: need D values > 10000??

Quote:
Originally Posted by FrankJ View Post
From the TI 2012 FAQ on the jags Question 41 addresses it. The file name is spma033a.pdf.
Thanks!

Quote:
I generally found the process measurement value to be noisy enough to make the derivative term useless.
Yup. GIGO


Reply With Quote
  #14   Spotlight this post!  
Unread 19-03-2012, 12:30
Cal578 Cal578 is offline
Passionate FIRST-er, CD donor
AKA: Gerry
FRC #0578 (Red Raider Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Rochester, NY
Posts: 255
Cal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant future
Re: PID control: need D values > 10000??

Quote:
Originally Posted by FrankJ View Post
... I generally found the process measurement value to be noisy enough to make the derivative term useless...
Depending on the kind of noise (amplitude and frequency components relative to the control cycle), sometimes a small filter on the input can allow the derivative term to still improve the response time. Not as good as eliminating the noise, but might be better than not using the derivative at all.
Quote:
Originally Posted by FrankJ View Post
...it is a lot easier to find PID controllers rather than PI controllers.
It is about as easy to make a generic PID controller as PI, and then the user has the option of setting the D term to zero, resulting in a PI controller. So, from a marketing point of view, it makes sense to make the PID controller whether most people use the D or not.
__________________
Cal
R3: Red Raider Robotics (FRC Team 578)
Fairport, NY, USA
www.FairportRobotics.org
2016 Finger Lakes Regional: Semifinalist on Alliance 7 (1128, 2010, 578)
2016 NYC Regional: Finalist on Alliance 3 (3419, 578, 3017), 4th seed team, Team Spirit Award
2015 Finger Lakes Regional: 8-3-0 in qualification, 7th seed, Quarterfinalist
2014 NY Tech Valley Regional: 8-4-0 in qualification, 13th seed, Semifinalist
2013 Finger Lakes Regional: 4-5-0 in qualification, 26th seed, Alliance 6, 1-2 in tournament
2012 Buckeye Regional: Gracious Professionalism Award, 7-3-0, 14th seed
2011 Finger Lakes Regional: Engineering Inspiration Award
Reply With Quote
  #15   Spotlight this post!  
Unread 19-03-2012, 12:48
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,024
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: PID control: need D values > 10000??

Quote:
Originally Posted by FrankJ View Post
From the TI 2012 FAQ on the jags Question 41 addresses it. The file name is spma033a.pdf.
Excerpt from Q41:
Quote:
Most fixed-point values used in the motor controller are contained in a 32-bit integer and are a 16.16 format.
It doesn't explicitly say that the D gain is fixed point, or if it is fixed-point, if it is 16:16.

Here's an excerpt from the Jag firmware source code that I linked to in an earlier post:
Code:
// Compute the new control value.
//
llOutput = (((long long)psState->lPGain * (long long)lError) +
            ((long long)psState->lIGain *
             (long long)psState->lIntegrator) +
            ((long long)psState->lDGain *
             (long long)(lError - psState->lPrevError)));
I'm not a C++ guru. I can't tell from that snippet what data type DGain is. The naming convention may be a clue though. There's a leading "l" in the lDGain variable name.


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 19:10.

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