Finally, how I would go about tuning. Please note that I haven't tried this on a real car, the results below are from the simulator. Only try tuning this way if you are comfortable that you know what you are doing and understand the process.
Before starting make sure that syncofs is correctly tuned.
Edit - This process will probably work best with 5.20 on firmware which has had a bug in the integral part of the PI controller fixed.
The first thing to say is that this is not tuning for how a car drives, accelerates or feels, it is aiming at tuning the Iq and Id control loops so that they can best control Iq and Id. This does not depend on the car or gearbox but on the motor and inverter, more specifically the motor inductance, measurement/filter delays and the inverter loop latencies. Now this statement may not be correct, I think it is, but if it is it means that these ki and kp parameters can be tuned with the car, and motor, stationary. The things that affect the tuning are relatively constant and unchanging with motor speed.
So the way I would start tuning is with the car stationary, in gear (if there are gears), handbrake on and footbrake on. The aim is to lock the motor shaft so that it can not rotate. I'd reduce throtcur to a few tens of amps and then monitor Iq and Id on the webpage graph while using the throttle pedal to introduce transients. The low throtcur and handbrake should keep the motor and car stationary but I would keep the other foot on the brake just in case. Whatever you do
do not do this with the motor unloaded (out of gear, clutch down, or on the bench),
if you do there is a very good chance the motor will overspeed and be damaged.
Before starting disable MTPA (lqminusld = 0),disable field weakening (fwki and fwkp = 0) and set ki and kp to zero. With is set like this the throttle should have no effect on Iq and Id as seen on the web plot.
First set kp to a low figure, say 10 and see what effect the throttle has on Iq and Id. You should see something like this:
First ignore the noise on teh plot, I've just artificially added that to make it a bit more realistic and check the tuning process copes with it OK.
Now on the simulator throtcur is set to 0.5 and full throttle is used, that should give 50A. It doesn't only 20ish, this is because the P term gain is too low and so needs a large error to drive the output. Also note the slow rise, this is down to the motor inductance and the low gain.
Now increase Kp, the next plot shows it for 100:
You can see this improves both the risetime and the error.
Now keep increasing, kp=400:
A bit better again.
Increasing to kp=1000:
This looks a bit better again but you can also see that the noise level on the voltage traces is starting to increase. This sis a sign that it is starting to overshoot slightly so personally I would set it back to 400.
Just to illustrate the point increasing to kp=8000:
A big increase in noise for minimal improvement in risetime and error.
So in this case I would settle for a kp of around 400.
Moving to I. Now it's very difficult to see the effect of I on a stationary motor while P is properly tuned so what I suggest is back kp down again to where there is a significant error visible, say kp=100 in the above and then start introducing ki.
Here is the plot for kp=100 and ki=100:
Compared to the earlier kp=100 you can see that the I term is coming in during the pulse to reduce the error and is just about getting there by the end of the 2sec throttle application. Too slow though.
kp=100, ki=400:
Improved but not there yet.
kp=100, ki=800:
About right for me, maybe a bit slow for others.
If you go too far it starts to look like this, kp=100, ki=4000:
The overshoot at the start is a sign that the I term is too big. If you are after ultimate performance then maybe but it's also going to start affecting stability.
So I would set it to kp=400 and ki=800 which gives this:
Good rise time, minimal error and reasonable noise.
MUCH LATER EDIT - It worth noting that later work has now showed that high inductance motors (MGR, Prius, etc) need much more Integral gain than the above suggests in order to cope with the high back EMF voltages that they generate. The above should therefore be considered a lower limit for these motors.
It is also worth noting that the revised simulator now includes all these voltages and so if you know the motor parameters it can be used, in conjunction with the above techniques, to find a starting point for the gains.