PID control discussion

Official FreeEMS vanilla firmware development, the heart and soul of the system!
gearhead
LQFP112 - Up with the play
Posts: 120
Joined: Sun Feb 03, 2008 9:30 pm
Location: Chicago, USA

Re: PID control discussion

Post by gearhead »

The one thing to consider is what Ken said. He calls it setting DC directly. What it needs to do is know the max and min output values and start its loop with these values. If there is a bias curve or if a known good value is used as a starting point is not really that important.

A portable PID loop could be written like this, IMO. Basically pass a SV, PV and the appropriate constants (Kp, Ki, Kd) and let it respond with a 'percentage' as ken calls it or a proportionality that is resolved back up in the main code to generate an output value that makes sense for the reason the loop is called.

One thing I learned from reading the Saab Trionic tuning guide and from some personal experimentation is that the Kp, Ki, Kd may not be 'constants'. Due to whatever else is going on, these may vary according to a separate variable (MAT or CLT for example). If these values are passed to a subroutine, this complication can also be accommodated if necessary.

Gearhead
Jean-Louis
TO92 - Vaguely active
Posts: 1
Joined: Fri Oct 28, 2011 3:30 pm

Re: PID control discussion

Post by Jean-Louis »

Hey,
I think :oops: that there is some problems whith the implementation :
1) long constants should be long (L)...
2) it's better to do a center point derivative approximation to minimize the high frequency noise (ztrans_idle_error_array[0] - ztrans_idle_error_array[2] )
3) its not a good idea to have PID_SCALE_FACTOR = 125. 128 is better because the compiler optimize the divide whith shifts
4) it's better to apply the PID_SCALE_FACTOR after the final add, and if its possible, with a correct rounding...
5) i think that if tmp1 is a 16bit integer, there is no need to disable the interrupts
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PID control discussion

Post by Fred »

Jean-Louis, sorry for the delay in approving your post! And, thanks for your feedback! :-)
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Faststang
TO220 - Visibile
Posts: 4
Joined: Thu Dec 22, 2011 6:52 pm

Re: PID control discussion

Post by Faststang »

AbeFM wrote:The two places they use it, which are reasonable places if not great, are boost solenoid control and idle control.
All late model (1999+?) returnless fuel systems use PID control for the fuel pump.
Faststang
TO220 - Visibile
Posts: 4
Joined: Thu Dec 22, 2011 6:52 pm

Re: PID control discussion

Post by Faststang »

Fred wrote: "dashpot" whatever the fuck that is
I believe the term was taken from an old mechanical device commonly called dashpot.
http://en.wikipedia.org/wiki/Dashpot

Based on my tuning experience dashpot delays IAC movement and causes the rpm to slowly settle in to it's idle setpoint when decelerating. Increasing dashpot also seems to increase the time required for rpm to initially start dropping to setpoint. I also notice, on Fords, it hovers about 500rpm higher then idle setpoint for a longer period of time before ultimately dropping to idle rpm setpoint. Frankly, IMHO, it sucks and works poorly, at least on the Ford engines I have played with. PID, without overshoot, would probably be a better solution as dashpot doesn't seem to work well or make any discernable difference except for adding time delay before settling into idle. Only problem is that you need to be an engineer to tune a PID properly. It isn't easy, those that can't tune it, just don't know, but it does work. I needed to enlist the help of an engineer at WeaponX, to help with PID for my aftermarket 255lph fuel pump after watching the wild fuel pressure swings after installing a Fuel Rail Pressure sensor, nightmare! His comment was, every loop will tune differently depending on the losses "feedforward tables" in the system. So some typical methods won't work 110% every time unless those feedforward loops are good and are set in stone.
gearhead
LQFP112 - Up with the play
Posts: 120
Joined: Sun Feb 03, 2008 9:30 pm
Location: Chicago, USA

Re: PID control discussion

Post by gearhead »

Faststang wrote:
AbeFM wrote:The two places they use it, which are reasonable places if not great, are boost solenoid control and idle control.
All late model (1999+?) returnless fuel systems use PID control for the fuel pump.
Don't forget clo2 as well. Only when you use a wide band sensor, though.

Basically any control loop with a target can use pid. Sometimes all that is needed is pi. Sometimes pid is required.

Gearhead
Post Reply