|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Robodox Guide to velocity control using PID
Hello,
Many many many teams utilized a shooter wheel design this year and could have benefitted greatly from a guide on how to utilize the WPILibrary PIDController function for velocity control. That is exactly the purpose of this guide, however late in the season it is, it can still help teams in the future and those of use ( like myself) who just couldn't go without getting it done anyways. Happy to answer any questions or address any concerns. Enjoy. |
|
#2
|
||||
|
||||
|
Re: Robodox Guide to velocity control using PID
I've been thinking of a different way to control the velocity of a spinner using PWM and the basic GetRate() function of an encoder. It starts of with a while loop and the shooter motor.
Code:
while(encoder->GetRate() <= setpoint) {jag->Set(i); i+= .001}
Note: We used CANJaguars this year and plugged the encoder into the Jaguar itself to use the Speed PID feature. |
|
#3
|
||||
|
||||
|
Re: Robodox Guide to velocity control using PID
As far as I know and recall, GetRate() returns data per second.
|
|
#4
|
||||
|
||||
|
Re: Robodox Guide to velocity control using PID
I'll modify my formula and see if I can use it with the CANJaguar PWM feature and using the GetSpeed() function. I'll do it as soon as I possibly can. We can always use Ether's method of the "bang bang" control style.
|
|
#5
|
||||
|
||||
|
Re: Robodox Guide to velocity control using PID
Quote:
In our code we work with radians per second as the preferred unit of measurment, and we do not need to normalize to use PID... I did however rewrite the PID class from 2011 to something more direct that does not use any threading. Instead the main loop is timed and each time change call uses a delta time parameter (double in units of seconds). And this gets factored in for the error computation. This will take care of uneven time-slices which is why the threading was used. Finally on the averaging... don't use a smooth blend type of average because this will introduce extra latency on your actual time. Instead use either a priority queue or a fixed number averager (or both) also use the kalman filter... I use all three of these... to combat the worst case encoder noisy-ness... like when the shaking of the motor caused the encoder to bust out of its casing and lose values per revolution. The re-written PID controller source is here: http://www.termstech.com/files/Archi...Controller.zip The averagers are also in here in the Misc.h file |
|
#6
|
||||
|
||||
|
Re: Robodox Guide to velocity control using PID
I'd be interested in seeing your test plan, test setup, and test results, if you would be willing to share them.
|
|
#7
|
||||
|
||||
|
Re: Robodox Guide to velocity control using PID
Quote:
http://www.termstech.com/articles/PID_Kalman.html This is due for an update on the latest and greatest achievements that show how to beat latency with some tested velocity graphs. I'll get to that eventually, but what is there now is still worth a read. Going here: http://www.termstech.com/articles/ Has a list of all the articles I've written... check out "getting encoders to work", "Gettting arm to work", and "Weight Mass? what's the difference?" On a side note not yet written there is a new technique I call "use the force" this gets me the 0ms latency, and I've got this working for speed control, but eventually wish to get this for fixed point... I'll explain this one in these articles at some point. Here's a sneak peak of it: http://www.termstech.com/files/RateG...kForceTest.gif |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|