JRK 21V3 on Throttle Body -PID Tuning

Hi, I am competing in the Formula Hybrid competition. We are building a hybrid, so we would like electronic control over our engine. The stock electronic throttle we purchased has a DC motor that turns the throttle body through a couple of gears. A potentiometer gives the error feedback signal to the JRK. The system was originally used with an ECU but we can’t use it,so we’re using the JRK. I have the system connected and working to a degree, but I have two issues. Both of which I believe are related to PID control. At this point I am testing everything with the USB interface connected, no real world signal has been fed to it.

First, I have tuned the system to work at a specific commanded position. The overshoot is low, settling time low, and it’s stabile. However, when i change to a different position, i lose stability. I played with the PID values for three hours, getting better results, but still ending up with regions of instability. I ended last night with values of 35/2^4 , 967/2^14 and 16/2^5. I don’t have access to the program right now, so i don’t remember if the second and third numbers are I or D.

Second, if I set position to 20%, and then set it to 60%, sometimes the motor position will change to maybe 30% even though the plots show desired position changing to 60%. It doesn’t even make an attempt to go higher. There is no overshoot while going to 30%, it just drives a small arbitrary amount above the previous command and stops. If I instead command 20%, press stop motor, and then command 60% everything will work as expected. I haven’t been able to pin down exactly when this occurs. Lets say I start with 10% first and then drive to 70%; those values may not cause the same problem, it may drive perfectly from 10 to 70. It’s more common for it to mess up than it is to drive properly though. I can try to get a screenshot of the plots when this occurs if that would be helpful. Essentially, sometimes when changing from one position to another, the motor will only drive a small amount and then stop despite the plot still showing a large error.

Hopefully some of that made sense. Any help on either issue would be greatly appreciated!
Thanks!

The occasional instability you see might be the result of bad PID parameters. What kind of methods did you use to choose the PID parameters? The “Setting up your System” section of the jrk user’s guide has a step-by-step procedure for choosing PID parameters and you should try following it if you haven’t yet:
pololu.com/docs/0J38/5

As for your second problem, I would like to see some plots showing this happening. The jrk basically shows you all the steps of the PID calculation in the plots window, so if you understand how the PID calculation works you should be able to tell what’s going wrong:

  1. When the jrk is in this odd state, your Scaled Feedback and Target should differ by a few thousand. If they are close, then either your input, input scaling, feedback, or feedback scaling is not what you expected it to be.
  2. Since the Scaled Feedback and Target differ by a large amount, the Error should be big, and the Integral should be increasing. If that is not the case, then maybe you are using one of the settings that limits the size of the Integral.
  3. Since Error and Integral are big, the Duty Cycle Target should be big (~600). If not, then your PID parameters are too small.
  4. Since the Duty Cycle Target is big, the Duty Cycle should be big (~600). If not, then you have enabled some limits on the motor that are preventing it from moving.
  5. Since the Duty Cycle is big, the motor should be moving. If not, then maybe your motor is stuck somehow or there is a loose connection. You could look at the Current reading on the plot to get a clue about what’s going on. Make sure the jrk is not reporting any errors.

–David

Great response! That’s really help, thanks. I did not follow the steps in the manual, so hopefully that will get me somewhere. I also didn’t realize I could add parameters to the plots, so that’s great. I’ll try to see what I can find out tonight.
Thanks again
–Travis