Wednesday, October 5, 2011

Closed-loop idle

This has taken me a while to figure-out, and I still don't understand how Megasquirt does PID for closed-loop idle.  Here's how mine looks at the moment.



Here are some thoughts on the different fields:

Idle Open Duty % and Idle Closed Duty %.  These set the limit for how high and how low the code will let the duty cycle go.  It will never let the IAC valve move past either value.  It also uses the difference between the two values as a scaling function, so 50-20 will scale and respond differently than 20-90, even though your valve may never go beyond 50%.

Closed Loop PID Gains.  "I" has the most effect on steady-state error, "P" effects how quick it responds.  "D" should prevent overshoot.  These don't always work that way.  I also found that setting idle response when the motor is warm will lead to oscillations when the motor is cold.  It needs to be stable for both!

Min Duty for PID%  This is supposed to be the closed position of the valve, but I don't understand the difference between this and Idle Closed Duty %.   I think it will not go below whichever one is higher of the two so what's the point?

RPM with valve open/closed.  This has little to do with RPMs with the valve closed or open; this should just be galled "Gain".  With a smaller difference between the RPMs the Gain will be higher.  The lower number needs be less than your idle by a few hundred, the higher number higher than idle.  That's it.

PID control interval.  The biggest problem I have with tuning the PID is steady-state error.  I think some of that has to do with the choice of control interval.  The conventional wisdom is that "faster is better", but classic control theory says you shouldn't sample more than about 1/10 - 1/20 of the settling time.  The engine doesn't respond that quickly and if it ramps in 2 seconds and settles in 4 that would give a 200ms sampling time, at the very minimum.  I think lower sampling times just increase the error due to rounding and lack of resolution in integer variables.  With sampling below 80ms, I had terrible steady-state error and could never get idle within 100rpms of target without dramatically increasing I which caused instability.

With 300ms sampling time, I find that idle is better overall with no negative effects.  My idle reaches the target, it has slight overshoot and nice response time.  It's very liveable for day-to-day driving.

EDIT: Since this post I have upgraded to Alpha 14 code, which has revised and more functional PID code. 

3 comments:

  1. can you email me your map? I need a base map for my m54. please email to gvillelube@yahoo.com and what program are you using? tunnerstudio?

    ReplyDelete
  2. MOHEGAN RESORT CASINO - Mapyro
    Find MOHEGAN RESORT 수원 출장마사지 CASINO, 1087 N Hollywood Blvd. S, 진주 출장마사지 Phoenix AZ 85139 phone (480) 480-4646. Store hours. Hours, Accepts Credit Cards, Accepts  여수 출장안마 Rating: 3 · 태백 출장안마 ‎6 reviews · 논산 출장안마 ‎Price range: $

    ReplyDelete