Go to Post Thank you to all of the mentors, You ARE changing the future. - chellyzee93 [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 17-03-2009, 09:01
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Traction control: How do I tune a PID controller with variable gain?

Hi, We are still programming and we are really just getting started on traction control. I understand the traction control scheme that team 121 is using, however I'm not sure how to tune the PI controller that they say they are using. They say that they have a proportional gain that is proportional to the slip ratio. Does anyone have any experience with tuning such a PI controller? If so, what do you suggest I do?

thanks
  #2   Spotlight this post!  
Unread 17-03-2009, 09:17
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Traction control: How do I tune a PID controller with variable gain?

hmmmm of course you have to work with what sensor feedback you have in your design....but here's one approach out of many. We have not tried this, but here goes:

Let's say you can calculate slip ratio.
1) Pick the ratio you want as the "set point"
2) find the slip ratio you currently have.
3) the difference is your error
4) pick a multiplier (Kp, the proportional gain in controllese)

Kp*error becomes the input to you motors, but limit it to -1.<0.<1.
or...Kp*error could be a delta to the last pass motor pwm (better? worse? dunno)

So, the choice of Kp is critical! too big and you get wildly big swings in pwm (unstable control system) and too small and you get no effect. As a swag, I'd guess that an error of twice the slip would need 100% drive...something like 1./slip_ratio_set_point...just guessing


As for the integral term, (the I in PI) keep a running sum of the error and choose a Ki, the term becomes Ki*(sum_error). Add it to Kp*error for your overall output

Output_to_motor = Kp*error + Ki*(sum_error)

The integral part is tricky. It is good for trimming out long-term biases, but you need to limit how big you want the sum_error to grow or you will experience "integrator wind-up" - really big Integral terms in your output that can adversely effect you controller. Add the fact that this is not a continuously running process - you will be starting and stopping, and and you can guess how wind-up could mess with your driver's head!

My recommendation would be to try only the P part first and add the I if you really have to. Also, Google PID controller...there's a wealth of better descriptions out there.

This approach will always drive you to some slip... interesting...even when you want to stop?!?

Eric
PS heh - our programming is never done 'til our last match at the Championship
__________________

Don't PANIC!
S. P. A. M.

Last edited by EricS-Team180 : 17-03-2009 at 09:32.
  #3   Spotlight this post!  
Unread 17-03-2009, 09:26
Russ Beavis Russ Beavis is offline
Registered User
no team
 
Join Date: Nov 2005
Location: Manchester, NH - DEKA R&D Corp.
Posts: 341
Russ Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond repute
Re: Traction control: How do I tune a PID controller with variable gain?

Are you using LabVIEW? If so, this would be an excellent opportunity to use some controls and indicators on the front panel of your VI when running in debug mode to allow real-time tweaking of gains to determine effect.

In general (very general), you'll always want to set Kp as high as possible (typically until the noise becomes unbearable) and then increase Ki until things go unstable. But I stress VERY GENERAL guidelines.

Russ
  #4   Spotlight this post!  
Unread 17-03-2009, 09:39
Luke Pike's Avatar
Luke Pike Luke Pike is offline
Programmer
FRC #1501 (THRUST)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Huntington
Posts: 114
Luke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to all
Re: Traction control: How do I tune a PID controller with variable gain?

I worked on tuning a PID control right before we shipped the robot. I didn't have time to tune it properly, so it's just a P (proportional) control. However, this produces very satisfying results, so try setting just the P gain and see what you get.

If you're using LabVIEW, it comes with a PID.vi, take a look at the help for how to use it. Good luck!
__________________
Twitter Profile
  #5   Spotlight this post!  
Unread 17-03-2009, 09:45
Rob Rob is offline
Registered User
AKA: Rob
FRC #0131 (CHAOS)
Team Role: Coach
 
Join Date: Mar 2004
Rookie Year: 1996
Location: New Hampshire
Posts: 304
Rob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond reputeRob has a reputation beyond repute
Send a message via AIM to Rob
Re: Traction control: How do I tune a PID controller with variable gain?

Hello,

While I am no expert on our system, I can offer a few pieces of quick advice that will hopefully help you out. First, the advice on tunig PI given above is excellent.

I have two items to add:

First: Be sure that your slip ratio is being calculated correctly. You need to normalize the encoder counts that you get from your drive wheel to be the same that you get from your follower wheel. Often the follower wheel is much smaller than the drive wheel, so you may get more encoder counts per linear distance traveled from the follower that you get out of your drive wheel. (I hope you are using a follower wheel, if you are using an accelerometer you may have problems with noise from vibrations).

Second: Be sure to tune the control gains in a controlled practice environment. If the system is improperly tuned it can hurt your driving performance badly, making the machine tough for your driver to operate. Tunig the gains is a trail and error intensive process where you want to be able to make small changes and then test, lather, rinse and repeat. If you are making changes in your pit between matches then you will likely get unprdictable performance in your matches. Your best bet would be to try and block out some time on the practice field, or maybe somewhere in the pit where you can set up a few sheets fo the floor material to test driving on.

Good luck, I hope your system works well for you!
  #6   Spotlight this post!  
Unread 17-03-2009, 09:55
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Traction control: How do I tune a PID controller with variable gain?

We were using a similar setup to 121 for version 1 of our traction control code. The only sensory was 4 encoders (2 on driven wheels, 2 on "follower" wheels). I am pretty sure some of the more controllable systems have logic to throttle on current spikes, but I digress... The logic was basically to hold slip to 0 on each wheel when the robot is stopped, allow a little slip on launch, and allow a bunch of slip on turns.

Before you get into tuning the controller, I would analyze your feedback. If the resolution isn't good enough, you will end up with some noise in slip ratio between cycles. This effect will be made even worse if you are taking percent slip (Vw-Vf/Vw), as you are pushing something big (encoder velocity) into something small (dividing by a velocity), then blowing it up (multiplying by Kp). The end result of this will be uncontrollable "bucking" by your drive wheels. Some nested filters (one on slip ratio, one on motor output) should be able to fix this, but this will involve just another level of tuning.

The method we used to tune our controller was to take off from a stop, and adjust the P gain until acceleration was optimized. We used a set length and timers to do this. We didn't have enough time to optimize I, but I would probably drive the robot into a large weight and adjust the I gain enough so it can slow down the wheels enough to push it, without overshooting or "bucking". The I term in this controller, as I understand it, exists for situations just like these where an unexpected external force is applied to the base. Your I gain should be very small in comparison to the P gain. (I want to say about 10^3ish smaller, but I could be wrong)

Good luck.

Last edited by Tom Bottiglieri : 17-03-2009 at 09:57.
  #7   Spotlight this post!  
Unread 17-03-2009, 10:37
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,078
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: Traction control: How do I tune a PID controller with variable gain?

Quote:
Originally Posted by Tom Bottiglieri View Post
We were using a similar setup to 121 for version 1 of our traction control code. The only sensory was 4 encoders (2 on driven wheels, 2 on "follower" wheels). I am pretty sure some of the more controllable systems have logic to throttle on current spikes, but I digress... The logic was basically to hold slip to 0 on each wheel when the robot is stopped, allow a little slip on launch, and allow a bunch of slip on turns.

Before you get into tuning the controller, I would analyze your feedback. If the resolution isn't good enough, you will end up with some noise in slip ratio between cycles. This effect will be made even worse if you are taking percent slip (Vw-Vf/Vw), as you are pushing something big (encoder velocity) into something small (dividing by a velocity), then blowing it up (multiplying by Kp). The end result of this will be uncontrollable "bucking" by your drive wheels. Some nested filters (one on slip ratio, one on motor output) should be able to fix this, but this will involve just another level of tuning.

The method we used to tune our controller was to take off from a stop, and adjust the P gain until acceleration was optimized. We used a set length and timers to do this. We didn't have enough time to optimize I, but I would probably drive the robot into a large weight and adjust the I gain enough so it can slow down the wheels enough to push it, without overshooting or "bucking". The I term in this controller, as I understand it, exists for situations just like these where an unexpected external force is applied to the base. Your I gain should be very small in comparison to the P gain. (I want to say about 10^3ish smaller, but I could be wrong)

Good luck.
Good advice. There are some numerical issues with trying to maintain a constant slip ratio. Anytime you are dividing by a sensor reading, I get queasy. As a result, a % slip ratio is unbounded. It could easily be 0 or infinity. You can detect these cases, but like Tom said, expect a very jittery drive as a result. And that's before trying to solve the problem of turning...

Instead of % slip, trying to limit absolute slip (ex: I want my wheels to go no faster than 1 foot/sec more than my follower wheels) leads to much simpler code that is almost as effective. Or, come up with a "hybrid" approach that uses absolute slip up to a certain point, then percent slip beyond that. This helps you avoid the nastiness of one or both of your encoders giving you a 0 speed.
  #8   Spotlight this post!  
Unread 18-03-2009, 10:54
Adam Y.'s Avatar
Adam Y. Adam Y. is offline
Adam Y.
no team (?????)
 
Join Date: Mar 2002
Location: Long Island
Posts: 1,979
Adam Y. is a splendid one to beholdAdam Y. is a splendid one to beholdAdam Y. is a splendid one to beholdAdam Y. is a splendid one to beholdAdam Y. is a splendid one to beholdAdam Y. is a splendid one to beholdAdam Y. is a splendid one to behold
Send a message via AIM to Adam Y.
Re: Traction control: How do I tune a PID controller with variable gain?

Quote:
Originally Posted by Tom Bottiglieri View Post
The I term in this controller, as I understand it, exists for situations just like these where an unexpected external force is applied to the base. Your I gain should be very small in comparison to the P gain. (I want to say about 10^3ish smaller, but I could be wrong)
The main purpose of the I term is for changing the system type and in turn changing the steady state error of the system.
__________________
If either a public officer or any one else saw a person attempting to cross a bridge which had been ascertained to be unsafe, and there were no time to warn him of his danger, they might seize him and turn him back without any real infringement of his liberty; for liberty consists in doing what one desires, and he does not desire to fall into the river. -Mill
  #9   Spotlight this post!  
Unread 19-03-2009, 08:16
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Traction control: How do I tune a PID controller with variable gain?

Thank you so much for your responses! Here is more information of our setup.

We are using 4 encoders: 2 on the gearboxes and another 2 on follower wheels. We are also using Labview and its PID libraries.

My approach is to allow a certain amount of slip upon launch by letting the driver command the motors directly, then if the slip ratio goes higher than a specific value the traction control will activate and motor commands will come from the traction control part of the code to bring the slip ratio down under that margin. Once it is under that margin, then the driver can control the motors directly again.

When the robot is at a stop (gearbox velocity=slip ratio=0) the traction control is forced to be off.

Anyways, how does this approach sound? Am I on the right track? I would like to keep my code as simple as possible so that I can arrive at a traction control solution the fastest.

I attached a screenshot of my code.

FYI: PS=port side, SB=starboard. The traction control enable controls a select with the joystick feed in the false case and the traction control feed in the true case.
Attached Thumbnails
Click image for larger version

Name:	traction_control code.jpg
Views:	134
Size:	69.5 KB
ID:	7705  
  #10   Spotlight this post!  
Unread 19-03-2009, 11:21
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Traction control: How do I tune a PID controller with variable gain?

Quote:
Originally Posted by windell747 View Post
Once it is under that margin, then the driver can control the motors directly again.
I'm curious... Will the system shuck as you hand control back and forth between your traction control mode and and driver direct mode?
__________________

Don't PANIC!
S. P. A. M.
  #11   Spotlight this post!  
Unread 19-03-2009, 11:31
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Traction control: How do I tune a PID controller with variable gain?

Quote:
Originally Posted by windell747 View Post
Thank you so much for your responses! Here is more information of our setup.

We are using 4 encoders: 2 on the gearboxes and another 2 on follower wheels. We are also using Labview and its PID libraries.

My approach is to allow a certain amount of slip upon launch by letting the driver command the motors directly, then if the slip ratio goes higher than a specific value the traction control will activate and motor commands will come from the traction control part of the code to bring the slip ratio down under that margin. Once it is under that margin, then the driver can control the motors directly again.

When the robot is at a stop (gearbox velocity=slip ratio=0) the traction control is forced to be off.

Anyways, how does this approach sound? Am I on the right track? I would like to keep my code as simple as possible so that I can arrive at a traction control solution the fastest.

I attached a screenshot of my code.

FYI: PS=port side, SB=starboard. The traction control enable controls a select with the joystick feed in the false case and the traction control feed in the true case.
Your slip will be out of the threshold most of the time with the current algorithm. Unless the joystick values are ramped or rate change limited, you will experience jitter as the slip passes in and out the threshold. This will happen very often. (The slip will drop, wheels will spin out, rinse, repeat.)

I would run the joystick through something like this http://www.chiefdelphi.com/forums/sh...55&postcount=3 before pumping them into your algorithm.

You can overshoot on the ramp gain a bit to allow for a bit of slip in launch, and the slip threshold should catch exceptions when you run into stuff on the field.
  #12   Spotlight this post!  
Unread 19-03-2009, 14:47
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 803
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Traction control: How do I tune a PID controller with variable gain?

Quote:
Originally Posted by Tom Bottiglieri View Post
Your slip will be out of the threshold most of the time with the current algorithm. Unless the joystick values are ramped or rate change limited, you will experience jitter as the slip passes in and out the threshold. This will happen very often. (The slip will drop, wheels will spin out, rinse, repeat.)
Having helped program a bot who's traction control system works by just reacting to slip, I would disagree. It is better if you have some code to try to prevent slipping by ramping up the output power, but it is not necessary. You can add the ramping code in after you get the basic algorithm working and decide that you want more.
  #13   Spotlight this post!  
Unread 20-03-2009, 16:48
Cuse's Avatar
Cuse Cuse is offline
Registered User
AKA: Matt Mancuso
FRC #0175 (Buzz Robotics)
Team Role: Alumni
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Enfield, CT
Posts: 22
Cuse is an unknown quantity at this point
Re: Traction control: How do I tune a PID controller with variable gain?

Quote:
Originally Posted by windell747 View Post
Thank you so much for your responses! Here is more information of our setup.

We are using 4 encoders: 2 on the gearboxes and another 2 on follower wheels. We are also using Labview and its PID libraries.

My approach is to allow a certain amount of slip upon launch by letting the driver command the motors directly, then if the slip ratio goes higher than a specific value the traction control will activate and motor commands will come from the traction control part of the code to bring the slip ratio down under that margin. Once it is under that margin, then the driver can control the motors directly again.

When the robot is at a stop (gearbox velocity=slip ratio=0) the traction control is forced to be off.

Anyways, how does this approach sound? Am I on the right track? I would like to keep my code as simple as possible so that I can arrive at a traction control solution the fastest.

I attached a screenshot of my code.

FYI: PS=port side, SB=starboard. The traction control enable controls a select with the joystick feed in the false case and the traction control feed in the true case.
You have no setpoint?
__________________

  #14   Spotlight this post!  
Unread 20-03-2009, 22:34
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Traction control: How do I tune a PID controller with variable gain?

Ya, I realized that after I was testing the code. Thanks! I am testing the code now and will post the revision for your feedback probably in several hours.
  #15   Spotlight this post!  
Unread 21-03-2009, 00:09
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Traction control: How do I tune a PID controller with variable gain?

Hi, Well I've done some testing of the code and for some reason, the values from the PID controllers aren't being passed into the TeleOp Execute loop to add to the joystick values. I submitted another question to the Labview forum about this

I decided to modify my correction method from a few posts ago to having the PID output always modify the joystick output sent to the controller based on the slip ratio calculated. I attached a pdf of my code so that you can see what I mean.

1) How does this sound? Is there a better way?

2) I noticed that the slip ratio goes to infinity a lot, how do you guys deal with the infinity case since it will drive the PID crazy?
Attached Files
File Type: pdf traction_control2.pdf (134.8 KB, 86 views)
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
Traction contron w/ multichannel PID control rohoRaider NI LabVIEW 2 17-02-2009 20:41
Using PID for traction control (help!) ellisk Programming 2 07-02-2009 14:05
PID traction Control dpeterson3 C/C++ 5 26-01-2009 21:11
Demo: Simple robot arm with a PID controller mtomczak Programming 1 17-01-2008 02:17
How to tune a PID loop? steve d Programming 3 11-02-2007 20:49


All times are GMT -5. The time now is 09:45.

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