|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools |
Rating:
|
Display Modes |
|
#3
|
||||
|
||||
|
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. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |