Go to Post FIRST is an amazing combination of principles that, when applied to the world, has had a monstrous effect on the way High School students learn, think, and relate to others. - Amanda M [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 48 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 20-01-2010, 08:33
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Velocity-based PID with the WPILib PIDController Class

Warnings
Disclaimer: All I know about PID loops I learned through the Wikipedia page and tweaking the several that we had on our robot last year.

Safety note: Always test PIDs on a stand first. Sometimes you can have very unpredictable results, and you don't want a 60-150lb robot flying off at full speed into equipment or people.

Content
You'll probably need an I term to help you accumulate more power.

Think of the definition of a PID loop:

Output = P + I + D
P = error * kP
I = sum(past errors) + kI*error
D = not too important in this case.

In this case, your error is 5000 (10000 - 5000) and your kP is 0.00014. Since your kI and kD is zero, your output is 5000 * 0.00014 = 0.7. If a motor power of 0.7 ends up equaling the amount of drag in your drive system, then your robot will not accelerate any further. If you set a (very small) kI, then your I term will grow as long as you're not hitting your setpoint, which means your motors will speed up until the setpoint is hit.

Of course, if your setpoint isn't hittable (physical max speed is 8000 ticks/sec, maybe) then you'll probably have problems slowing them back down, but that's a tweakable thing.

An I term will also help you with low-speed stuff. Right now, if you set a setpoint of 1000 ticks/sec, that'll translate to a motor power of 0.14. If a motor power of 0.14 translates to 2000 ticks/sec on the robot, then you'll have a new output of -0.14, which might translate to -2000 ticks/sec, which will then give a motor power of 0.42 on your next cycle, and you see in this simple example you've got oscillation. An I term will allow you to reduce your P term and will at least smoothen the oscillations.

Another tweak might be to increase the frequency of the PID loop, which I believe you can do in its constructor. Faster updates might reduce oscillations, depending on the update rate of the encoders and cRio.

Last edited by Bongle : 20-01-2010 at 08:43.
Reply With Quote
 


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
PIDController class (PIDSource/PIDOutput interfaces?) Jared Russell C/C++ 3 11-01-2009 09:49
PID for velocity control SuperBK Programming 13 04-02-2008 23:16
What constants are u using for high velocity PID Salik Syed Programming 3 18-02-2006 23:22
Problems Using PID for Velocity Astronouth7303 Programming 6 10-02-2006 09:00
Manual Velocity PID, anyone successful? Chris_Elston Programming 20 31-01-2006 20:51


All times are GMT -5. The time now is 14:13.

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