Go to Post This is real. This is hard. This, is FIRST. - sanddrag [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 27-01-2006, 20:06
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Question Problems Using PID for Velocity

We have a PID control loop to control velocity of a motor. We have the tooth counter giving us our current velocity, and an OI analog input giving us our target. The code is written such that the motor can never go backwards. (The tooth counters are giving us a speed of about 0-18, we're hoping to increase that range a little.)

The problem is that, when using only a P loop, it oscillates violently at mid- to low-speeds. Meaning that it revs up, then stops, revs up then stops, etc. (Victor set to coast.)

Anyone seen this before in their own code? Any recomendations on using PID for velocity->velocity control loops?
  #2   Spotlight this post!  
Unread 27-01-2006, 20:33
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: Problems Using PID for Velocity

We saw exactly that behavior last year with a simpleminded attempt at closed-loop speed control. Adding the D term is absolutely the most reasonable way to resolve the oscillation.

It can be resolved with a much quicker control loop, but you'll definitely have issues measuring the speed if you try it that way.
  #3   Spotlight this post!  
Unread 27-01-2006, 20:43
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: Problems Using PID for Velocity

Quote:
Originally Posted by Alan Anderson
We saw exactly that behavior last year with a simpleminded attempt at closed-loop speed control. Adding the D term is absolutely the most reasonable way to resolve the oscillation.

It can be resolved with a much quicker control loop, but you'll definitely have issues measuring the speed if you try it that way.
Yea, I agree. PD is pretty much the most common way to go about velocity control.

- Set Kd to 0.
- Increase Kp slowly until the robot starts to oscillate around its setpoint. Watch the oscillations, are they dying down, or staying consistent?
- - + If yes, then set Kp to about 30% of its current value.
- - + If no, then Kp is set way too high, for some reason. Reduce it by 60%, and watch for the oscillations again. When the oscillations are reasonable (staying about constant, or dying away, and aren't too violent), then move to the next step.
- Increase Kd slowly until the robot "snaps" to its setpoint.
- If the robot "snaps" eventually, but there is some error between where it snaps, and the desired setpoint (and you can't live with this error), then you have to add in a bit of Ki.
- Ki is usally ends up being 1/Kd. I don't like Ki for velocity control purposes, but you can fiddle with it if you want.
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003
  #4   Spotlight this post!  
Unread 27-01-2006, 21:15
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Problems Using PID for Velocity

Quote:
Originally Posted by Joel J.
Yea, I agree. PD is pretty much the most common way to go about velocity control.
Ok. Good to know. (TODO: Comment out inetegral-handling code.)

Quote:
Originally Posted by Joel J.
- Set Kd to 0.
- Increase Kp slowly until the robot starts to oscillate around its setpoint. Watch the oscillations, are they dying down, or staying consistent?
- - + If yes, then set Kp to about 30% of its current value.
- - + If no, then Kp is set way too high, for some reason. Reduce it by 60%, and watch for the oscillations again. When the oscillations are reasonable (staying about constant, or dying away, and aren't too violent), then move to the next step.
- Increase Kd slowly until the robot "snaps" to its setpoint.
- If the robot "snaps" eventually, but there is some error between where it snaps, and the desired setpoint (and you can't live with this error), then you have to add in a bit of Ki.
- Ki is usally ends up being 1/Kd. I don't like Ki for velocity control purposes, but you can fiddle with it if you want.
After reading through the ambiguity in #2 there, I found that changing my constants from Kp = 1, Ki = Kd = 0, divisor =1 to divisor = 3 cleared the problem right up, and (under no load), it now works great!
  #5   Spotlight this post!  
Unread 27-01-2006, 21:17
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: Problems Using PID for Velocity

Ahaha. Ambiguity follows me around, it seems. Glad its up and working.
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003
  #6   Spotlight this post!  
Unread 10-02-2006, 08:53
Steve Warner Steve Warner is offline
Controls / Programming
FRC #0234 (Cyber Blue)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Indiana
Posts: 43
Steve Warner is an unknown quantity at this point
Re: Problems Using PID for Velocity

We are using the PID code as it was originally provided. As the velocity approaches the target value, the error approaches zero and the corresponding pwm value will also go to zero. This seems to hold the velocity at about half of the commanded value, which makes sense. Have other teams had this problem and how have you gotten around it? Also in the tuning example from Joel J., what do you do with DIV_V?
  #7   Spotlight this post!  
Unread 10-02-2006, 09:00
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,080
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Problems Using PID for Velocity

Increase the I term to eliminate steady-state error.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Concept of PID explained ConKbot of Doom Technical Discussion 11 27-01-2008 00:11
Anyone Else Having Problems with Q&A on FIRST? Windwarrior General Forum 6 25-01-2006 10:54
PID cmd_drive can't drive straight? gnormhurst Programming 4 18-02-2005 01:54
All-Time PID Drive with Hall-effects: Coming along very nicely jdong Programming 6 05-02-2005 19:39
PC problems. . . opnickc IT / Communications 5 12-01-2005 16:53


All times are GMT -5. The time now is 14: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