Notices
ECU Flash

PID boost control code

Thread Tools
 
Search this Thread
 
Old May 19, 2008, 12:42 AM
  #16  
EvoM Guru
iTrader: (6)
 
tephra's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Posts: 9,486
Received 66 Likes on 42 Posts
Guys,



In the above what does d and dt mean?

something todo with time obviously, but is d the whole time and dt the change intime since the last time we ran?
Old May 19, 2008, 01:25 AM
  #17  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
d/dt means to differentiate the following term with respect to time, the integral sign (summa, elongated s) followed by the term then dt means to integrate the term following with respect to time.

If this is either too patronising or not explicit enough, please say!

I'll try to look at your code later.

Last edited by jcsbanks; May 19, 2008 at 09:08 AM. Reason: spelling!
Old May 19, 2008, 01:33 AM
  #18  
Evolved Member
iTrader: (17)
 
dudical26's Avatar
 
Join Date: Nov 2005
Location: NNJ
Posts: 2,544
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by tephra
What are you guys thoughts on trying to implement a Futures-PID, ie we guess what boost we will be at in the future by what's happened in the past. That should hopefully reduce the amount of overboost spike we will see @ spoolup.
forgive me if I'm off base here but when the PID controller looks up what the target boost is, does it look up the current target boost or does it look at what the target boost will be a few samples ahead of where it currently is?
Old May 19, 2008, 01:57 AM
  #19  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
It is using present error for P, the sum of previous errors for I, the gradient of the present error for D. The future effect is considered in D because the gradient of the error now implies where it will be next. A reactive system works OK for boost as long as it has a base wastegate duty setting/table or self learns one.
Old May 19, 2008, 05:04 AM
  #20  
EvoM Guru
iTrader: (6)
 
tephra's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Posts: 9,486
Received 66 Likes on 42 Posts
John - bit over my head with that first post.

can you elaborte/give an example?

this is probably real basic stuff, but to me falls into the category of the lecturer saying "pick an artibary number" and me saying '18....?' lol

back to the I bit, my understanding was that I was the sum of all error up until "now" - is that right?

Last edited by tephra; May 19, 2008 at 05:07 AM.
Old May 19, 2008, 05:29 AM
  #21  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
If you've not done calculus, then the symbols are confusing to start with. It is summarising the sorts of equations you've been putting together (still need to look at your code when I'm home)...

D:

The d/dt basically means "gradient". So 20kPa error this time, 50kPa error last time, interval is 0.01s, then we have 3000kPa/s. If error is calculated as setpoint-boost then we are spooling up and getting near to target. So a negative D (differential gain) would reduce our duty cycle and damp the forthcoming overshoot. Perhaps a sensible gain here would be -0.002%s/kPa which in this case would give a wastegate duty cycle adjustment of -6%. Obviously if you change the units you change the gain. I would probably combine all the constants to make quick integer math that takes the raw MAP ADC and spits out the WGDC.

I:
The integral bit means to add up all the errors and it could have been running for some time, so take say a 0.5 second period. If the average error over this time period has been 10kPa then the sum of all these errors is 0.5s*10kPa=5kPas. Perhaps here an I gain of +1%/kPas would be about right so that it would add 5% WGDC. Again units will change depending on how you code it.
Old May 19, 2008, 05:45 AM
  #22  
EvoM Guru
iTrader: (6)
 
tephra's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Posts: 9,486
Received 66 Likes on 42 Posts
I was finding that the Iterm was the main driver for WGDC.

Initially P drop the WGDC, but as the error got smaller then ofcourse the P became irrelevant, so I was needed to maintain the previously set WGDC..

I have a demo xls which I am testing the algorithm in - I will send it to u tommorow..
Old May 19, 2008, 05:52 AM
  #23  
EvoM Guru
iTrader: (6)
 
tephra's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Posts: 9,486
Received 66 Likes on 42 Posts
also my algorithm multiplies Pgain by the Pterm only, rather than by the whole thing... not sure why his algorithm and mine are different, i got mine from someone else originally.

tomorrow I will update the XLS and see how his one goes

XLS sent

Last edited by tephra; May 19, 2008 at 06:04 AM.
Old May 19, 2008, 05:59 AM
  #24  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
There are a variety of ways to do it, but I would prefer to keep the P,I,D gains separate for clarity, then like above you can imagine the range you need.
Old May 19, 2008, 07:48 AM
  #25  
Evolving Member
 
JoeBee's Avatar
 
Join Date: Sep 2006
Location: Germany
Posts: 152
Likes: 0
Received 0 Likes on 0 Posts
Good old mathematics. I hear my teacher: "Sometimes you will need this stuff..."

Differential Calculus (Analysis) gives you the gradient of the function at this point. (Or better, at a very small amount of time. This is the meaning of the d/dt header.
In Software you normaly use the difference between the actual and the last messured value (this gives you the small amount of time). The higher this difference is, the higher is the gradient and the regualator regulates more aggressive.
Old May 19, 2008, 09:07 AM
  #26  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Dave, code & spreadsheet look good.

I think you will want a minimum TPS and/or minimum boost threshold as well as minimum RPM. This will stop integrator windup. I think you also need to avoid updating the total error whilst you are at min or max duty cycle. Don't reset it like I did in my code (I think we should only reset if RPM, TPS or MAP drop below the control range), just don't make it worse (windup).

Just realised as well that you might not need a base wastegate duty cycle table like I mentioned before if you use PI together. If you use P alone initially then it won't get near to target because the P contribution will reduce as the error reduces. With a base wastegate duty cycle I could get away with just some P, no I or D.

I think the P is going to kick the duty cycle near to what it needs, then the I is going to home in on the target, with D if we use it being used to damp oscillations that may result from adequate PI used to reach the target quickly. I think this is also what you were saying above about the reliance on I...

This could be very interesting, although as dan l I think pointed out the ECU is already effectively using a variant of PI - the integral gain looked up from the TBEC table is based on the error, so it is integration with variable gain.

Last edited by jcsbanks; May 19, 2008 at 09:34 AM.
Old May 19, 2008, 01:52 PM
  #27  
Account Disabled
iTrader: (3)
 
dan l's Avatar
 
Join Date: Apr 2006
Location: USA
Posts: 1,029
Likes: 0
Received 0 Likes on 0 Posts
I think the base wastegate lookup table with PID is the way to go. I've used some PID's that had what they called "fuzzy logic" where it guessed where things were going based on the past. It got complicated and could get downright out of hand if the system didn't act the same way every time.

I'm still in the early stages of using the current boost control system but am pleased so far. The stock turbo is, from a control standpoint, absolutely insane to control. In industry I've never had to deal with something so quick. The lookup table is clutch here.

Anyways I've been looking at the Boost Error Correction table as my psuedo D with P built in. The more you are off the more you can correct. When you get closer to target you get less gain from D. Wheras true D would be how much you were off from the target from T1 to T2.

My assumption is that the WGDC Correction Intervel is our I. It seems to act like a timer so if your 2psi low for the timing interval then a correction is made via lookup in the BEC table. Wheras true I would be area under the curve for the timing intervel.

I am running MUCH less BEC values that mrfred. My car was overshooting then undershooting badly until I lessened the values. Now I'm going to try to increase my I (timing interval) to "soften" the quickness with which the ecu trys to reel boost back in. In any control system that I've struggled with eliminating D or lessening it a lot has always yielded impressive results. Unfortunately we are not controlling stable things like flow in a water pipe or filling a vat with a liquid. That stuff was easy compared to this!

EDIT:

A direct quote from my professor in college was to eliminate D in a quick control system such as controlling temperature in a small room or oven. This would directly apply to controlling boost.

Last edited by dan l; May 19, 2008 at 01:55 PM.
Old May 19, 2008, 02:02 PM
  #28  
Account Disabled
iTrader: (3)
 
dan l's Avatar
 
Join Date: Apr 2006
Location: USA
Posts: 1,029
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by jcsbanks

This could be very interesting, although as dan l I think pointed out the ECU is already effectively using a variant of PI - the integral gain looked up from the TBEC table is based on the error, so it is integration with variable gain.

I think it is a little more than this though because integration would be the area under the curve (or total error) from T1 to T2. The BEC table is just a dumb "doh were off 2.1 psi" table. I wish it was a "yo billy bob we are off 9.38psi from T1 to T2". Right now we have the BEC table and correction interval tables interacting because one is not a full I and the other a full D. This will be confusing for some users. I hope I'm wrong, correct me if I am. I'm not looking at code, just how the car is reacting in the hour I've had messing with it.
Old May 19, 2008, 02:32 PM
  #29  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Well my experience with the Evo's system is also brief because the only time I've used it is on stage 1 type cars with twin solenoids and they make about the right boost with both solenoids at 100%. I also haven't got logging of all these correction factors and duty cycles. The bigger stuff I've done with AVC-Rs.

Looking at mrfred's graphs it looked like it was ramping the duty up or down each iteration depending on the TBEC lookup - ie it had a memory/was integrating - but in a time sliced fashion rather than sampling the area between each sample analog style. I didn't think it was simply adding the base value to the TBEC value which would be a P only system and importantly would not remove offsets. I did not see anything I thought was D in there (but I do on the AVC-R where the duty will dip as boost rises quickly).

I have a lot more seat time with the GC8 Subaru system, which appears to behave the same - you could see that integrating with variable gain depending on the error. I may be making wrong assumptions that the Evo's system is also doing this though and seeing what I want to see...

Last edited by jcsbanks; May 19, 2008 at 02:34 PM.
Old May 19, 2008, 02:57 PM
  #30  
Account Disabled
iTrader: (3)
 
dan l's Avatar
 
Join Date: Apr 2006
Location: USA
Posts: 1,029
Likes: 0
Received 0 Likes on 0 Posts
I think it may simply add the TBEC value to the BWDC but it WILL remove offsets because it is an inverse relationship. IE: if your over boosting it will decrease boost and vice vearsa. It seems to act such that if your are off of your target for a certain amount of time then it will apply the TBEC value.

I'm probably remembering incorrectly (college was years ago) but isn't the D in a PID system actually 1/D? So what your sayi8ng about the AVCR would be correct in that D would be larger as boost builds quickly but 1/D would be a smaller value applied to the control. Thus D would be larger with nearly steady state boost from T1 to T2 but would be small on on boost surge. This would help minimize the effects of building boost quickly and overshooting your target boost. However you also run the risk of a sharp boost change after reaching target boost causing massive instability. So basically D might be needed but use it as sparingly as possible.

After you reach target boost I takes over for the most part anyways (or at least it should for a steady system).

EDIT:

After looking real quick you can make your D negative or inverse. Whatever you choose for your system.

Last edited by dan l; May 19, 2008 at 03:05 PM.


Quick Reply: PID boost control code



All times are GMT -7. The time now is 10:01 AM.