2012: Tuning the Jaguar's Speed Control PID Loop

There is a lot of background information here:

I am continuing this discussion in a new thread for the 2012 season, and would like to limit it to the specific methodologies you’ve used to tune your JAGUAR’S Speed Control PID Loop, and its pros/cons.

Method 1:
Use P-Only control, and tune the P constant until you achieve a stable loop at 50% of your setpoint. Leave I and D as ZERO. Do not touch them, do not pass go, do not collect $200. Now set your setpoints at TWICE the magnitude you actually desire. Profit.

Pros:
Simple to tune, and gives you a stable response.

Cons:
Far from ideal response. You will likely have offset and/or oscillations around your 50% target. You cannot take advantage of I or D because they depend on P being able to take to your setpoint.

Method2: Use a PI control, and tune the I gain the way you would “normally” tune the P gain. Then tune the “P” gain the way you would “normally” tune the D gain.

Why? Because the drivetrain plant does not contain an integrator when the input to the plant is voltage and the output (that you are trying to control) is speed.

We did a fair amount of work with Method 2 today as proposed by Ether.

We obtained fairly stable results, and would argue that they are overall better than Method 1.

There appears to be a major weakness with Method 2 however.

The I-term appears to be capped. Theoretically, even a small I-term should cause the speed control loop to reach its setpoint eventually. It might take a long time, but it should reach the setpoint, given enough time.

It does not.

What we’re seeing is the maximum speed we can achieve is directly proportional to the I constant.

This is unfortunate, because we have been able to find some I-constants which appear to work beautifully, however since the I-term is capped, we can never quite achieve our top speed.

Capping the I-term is usually a great way to ensure our PIDs don’t wind up too much, however in this case, it’s inhibiting us from ever getting to our top speed.

After another day of working on this…

I’m back to my opinion from 2011:

The Jaguars desperately need a Feed-Forward implementation in its speed control PID loop.

Everything else we’ve tried has seemed like a messy workaround which just won’t give us as tight control as we want for either our drivetrain or shooter.

Are there any active Jaguar firmware developers from TI who are on ChiefDelphi who we can reach out to?

Right now, this feature is a) what is stopping me from recommending the Jags to our area’s mid to upper tier teams, and b) a pretty standard speed control feature, which should be included in any speed PID controller worth its weight.

Hello all, I am the Control System Engineering for Team 2168 the Aluminum Falcons.

Its going to be very hard to lock down a method of tuning the PID gains without fully understanding the implementation of the Controller in the Jag.

No two PID implementations are equal, and depending on weather the PID controller is an Ideal, Series, or Parallel implementation greatly affects how to go about tuning them.

For example, in the ideal case changing P has an effect on both I and D, where as in a parallel implementation, each term can be independently tuned.

Does anyone know if this implementation has been made available? Last time I looked the documentation was no where to be found.

I am going to spend more time this season reverse engineering the Jags and understanding the implementation, as my team does use CAN and I would likes to move my control loops off the CRIO… I will post my results.

However in the mean time, I have been working on a complete video walk through to show a simple way to tune the gains of a PID controller using Matlab and Simulink.

All the videos are not up yet, but the most important one is, the video which shows how to tune the gains. The video, m-files and .mdl files, and complete labview project are also available from our team website at:

http://team2168.org/index.php/resources/programming/217-pid-control-tutorial

The custom PID controller I use is also provided to be used by any team who so desires, all I ask is that you give credit to us, if you do use it. Even though the files are provided in labview, I will soon also provide a Java implementation.

The example in the video covers tuning position control gains but it is easy to extend the method for speed control on your own. In the next few days I will be posting an official walk through for tuning speed control gains as well.

Please check it out, and post any feedback you may have.

-Kevin

The jaguar source code is available, but not the easiest thing to find. http://www.ti.com/tool/rdk-bdc24-cd

The code isn’t the easiest to find but maybe my post in the aforementioned thread can help:

I applaud what you are trying to do - as an engineer, I strongly dislike the guess and check method. I downloaded your files, but am getting a “bad link” error in simulink for the PID Controller. I am using version 2008b will all toolboxes loaded. Also, your Matlab model appears to be setup for position, any intent to upgrade for speed mode?

I took a different path to a closed form solution. I am using Team 1640 - Sab-BOT-age Drivetrain Model to predict the step responce for various drive trains, using Astrom’s (less overshoot than Ziegler-Nichols) equations to calculate P-I-D then as Either said - loading the calculated D into Jag P, calculated P into Jag I and 0 into Jag D. We are getting reasonable performance on the testbot. We intend to poll the Jaguars for step response data using voltage and PID control and compare results but things always take longer than you expect. This was all done with Excel spreadsheets - which i can share if you like.

I don’t see the source code anywhere in that zip file. Lots of PDFs, but no code tree. Is it hidden in one of the application programs or PDFs?

I told you it’s tricky :wink:

Install RDK-BDC24-CD-683\Software\StellarisWare\SW-RDK-BDC24-8264.exe. The code will then be in C:\StellarisWare\boards\rdk-bdc24\qs-bdc24

That would explain why the source files didn’t show up on my Mac.

I believe you can change the “.exe” extension to a “.zip”. It is a self extracting zip file, so by doing this you can manually unzip it.

-David

Thanks for the info. It turns out that you have to run the Windows installer program, which builds the source code tree as part of the install process. Typical Windowsness. I carried the file to my Windows box in the workshop and had much more luck.

My day job involves work on telescopes run by Linux computers, so I have gotten used to finding source code without executing an app first.

I suspect I am not the only Windows user who would rather have a ZIP file that I can manually open than an “installer” the actions of which are unknown until it is run. Who knows what it is going to “install” and what settings it will change and whether it is going to need admin privileges etc etc.

EDIT: for Windows users, you can avoid running the “installer” EXE file and instead inspect and then extract (with folder structure) the contents of the “installer” EXE file using the free app 7-zip. Does anyone know of a similar app for Linux?
*
*

I don’t know is this is possible without completely breaking the Jag’s comm protocol, but a flexible way to implement that would be updated Jag firmware which supports a second input command to the Jag (in addition to the setpoint) so that the user could use a lookup table or nonlinear equation or other arbitrary processing (based perhaps on open-loop experimental measurements) to create that “feedforward” command.

Until and unless the Jag firmware changes, moving the controller completely out of the Jag allows this flexibility, as some have suggested on other threads. An example is attached.
*
*





Did changing the extension to “.zip” not work (like I stated above)? I just confirmed that on my windows machine I am able to unzip the full folder tree with no issues using the default windows “Open with Compressed Folders…” explorer option.

Yes, that works. Sorry, I don’t know how I missed your earlier post.

A note on the download page that it is simply a self-extracting ZIP
might spare future downloaders a moment or two of apprehension :slight_smile:
*
*

At this rate, I would be happy with a linear feed forward, where:

Output = Kff * setpoint + Kp * error + Ki * integral + Kd * derivative

All this would require is the ability to pass another constant (Kff) along to the Jag.

Even if the linear response isn’t perfect, the PID loop will likely be responsive enough to make up the difference.

Yeah, I was taking that as a given, but dreaming of a better way:-) Your suggestion I think would be minimally invasive; a simple change that wouldn’t break anything.
*
*

I just used “unzip” but it depends on the distro.