what's going on here? MS3-pro PID boost control tuning

Tuning concepts, methods, tips etc.

Moderators: jsmcortina, muythaibxr

Post Reply
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

Hey all, trying to take a stab here at dialing in some pid boost control. I ran open-loop without much tuning/issues but i want to now work on the closed-loop tuning to maximize spool and power throughout the rev range. I tried going through threads and reading and getting as much info as I can before starting so at this point I think I have an good grip on how it all works. Now to just apply it! :mrgreen:


First question, I run a 1bar(14.7psi) wastegate spring and want to target 16-17psi, but have overboost protection set for about 18psi. Is this margin too small for the code to work effectively?

I'll give a rundown of my setup quickly:

BMW m52b30 turbo, Comp turbo 6465 turbo
ms3-pro DIY pnp
1.3.2(a) firmware
MAC 3-port solenoid, I googled to find most run the valve at 26Hz
I played with control intervals but for now keeping it at 100ms. good? bad?
I also turned the slider down to 0. Where's a good starting point? 100? 200?
Min duty:0%
Max duty:100%
Lower limit delta I've set for 45kpa. Thoughts?

I've been following what most say and have been playing with P alone to hit the target. right now its:
P =120
I = 0
D = 0

I've also enabled the inital duty table and entered some duty #s based on my Open-loop table. attached a pic of them.

After having noise issues i finally was able to get a log and i'm getting a lot of oscillation, when I turn P down to about 100 or so however It never tries to reach the target. I also notice that the DC drops to 0 then back up while in boost. Does this have to do with P? or the control interval? I've tried some I to help the oscillation but nothing seems to fix it. Could it also have to do with the small difference between spring pressure and the desired pressure?

I will attach my log and MSQ,

here is the log:

https://www.dropbox.com/s/vbqic9s81aqoz ... 1.msl?dl=0
muythaibxr
Site Admin
Posts: 8230
Joined: Thu Oct 14, 2004 12:48 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by muythaibxr »

Depending on the version of the firmware, tuning P only will never reach the target. This is expected behavior in any firmware other than the 1.4 alphas. Your best bet is to go back to basic mode and tune the sensitivity slider to get you to the target with minimal overshoot and minimal oscillation. Then you can start with PID gains of 100 across the board and tweak from there.
Megasquirt is not for use on pollution controlled vehicles. Any advice I give is for off road use only.
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

Thanks for the tip! I actually remember briefly playing with basic mode and hitting my boost target in a short log I accidentally overwrote. I will try it out and post logs/questions here.
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

So I went out of town for a long 1hr drive each way, playing with the slider to see if I can get the boost coming on smoother. Here's before & after I stopped at a rest stop, reviewed logs and made some changes:


I think from here I can switch to advanced mode and start tweaking the PID parameters from here? Looking at the graph the code once engaged slowly raises the boost up to the target, I want to hit the target sooner when In boost. Do I start with P alone or P & I? From what I understand P to reach target, and I to keep it there.

i will do this and post results!
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

So I started playing with the P= I= D= terms, I'm getting little to no oscillation but doing some reading and looking at the thread with the introduction of this new boost control code my setup isnt right just yet. For one i'm not getting the "inital overshoot" at my target boost. One other strange thing I noticed, I was targeting 215kpa which according to this page: http://www.megamanual.com/v22manual/mturbo.htm is 16.5psi. I've hit 16.5psi but the logs show I'm still under target until I hit 17-18psi (overboost protection.) for now I've lowered my final target to 213kpa. I'm guessing because the code thinks it's under target that is the reason why it always raises the boost in the higher RPMs in a pull like this:
boostcuthit.png
I'm running with P=120, I=50, D =10

I'm running 10ms control interval. Is it too low? when I run higher I get bigger oscillation waves I find. I'm running a 26h valve and using an online calculator I got 38ms. This sound right? the latest TS manual recommends 50-100ms. I also have minimum duty set to 15% and max 86% becuase I found below 15% no changes to the boost were made.

What needs to be changed from here to get that inital overshoot? inital duty? I'm working through the logs I have (10+) and tweaking the inital duty table.


In the middle of this post I've done a LOT of reading and made a lot of setting changes to pretty much everything. I think this gives me a better base to start tuning the boost control with. I'm going to go back to putting all the gains to 0 and dial in the slider again + inital duty table. from what I understand those two should get me pretty darn close and then tweaking the gains from there will iron out anything left.
JAM
Master MS/Extra'er
Posts: 626
Joined: Sun Jan 22, 2006 7:58 pm
Location: Cincinatti,OH

Re: what's going on here? MS3-pro PID boost control tuning

Post by JAM »

muythaibxr wrote:Depending on the version of the firmware, tuning P only will never reach the target. This is expected behavior in any firmware other than the 1.4 alphas. Your best bet is to go back to basic mode and tune the sensitivity slider to get you to the target with minimal overshoot and minimal oscillation. Then you can start with PID gains of 100 across the board and tweak from there.
Sorry to jump in this is a little off topic-

Is this the same method for tuning idle with slider^^

i like the sensitivity slider on boost and idle. Is this something that can or will be added to VVT tuning?
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

So, I've got it dialed in pretty good! Now that I've got a firmer understanding of the system and how it works I'll make a tiny step by-step. Hopefully somebody else can benefit from it or it can be used in MS documentation which would be awesome :yeah!:
16vboost
Master MS/Extra'er
Posts: 478
Joined: Thu Apr 22, 2010 9:10 pm
Location: Miami, FL

Re: what's going on here? MS3-pro PID boost control tuning

Post by 16vboost »

I think the new code deserves a re-write of the tuning instructions. With this recent code I've spent more time tuning the initial value table than the PID constants. From looking at your logs it seems that your initial values are too low.

On another thread, someone suggested setting PID to 0,0,0 and tuning the initial value table and "boost control lower limit delta" until boost can be reached when entering boost control at any RPM. Then adding in PID to keep the controller on boost. I'd lower your lower limit delta a bit too, maybe to 30 kPa. Just so that the boost is closer to target when you enter boost control. For faster spools and over shoot, you may want to increase it.

Also, the only way to eliminate oscillations is to lower the PID terms. If you need more duty cycle, get it from the initial value table.

-Alex
Zaphod
Master MS/Extra'er
Posts: 390
Joined: Thu Aug 14, 2008 11:38 pm
Location: Germany

Re: what's going on here? MS3-pro PID boost control tuning

Post by Zaphod »

I also would love to have a boost control "How to tune" with the new code - I set up my Bias table quite good now and would like to know what the correct way for tuning the PIDs now is...

I did ask for this already a while ago...
http://www.msextra.com/forums/viewtopic ... 01#p405005

So please - could we get a stickie topic "How to tune the new boost control algorithm" ? - I know that there are advices in some threads, but it's quite difficult to search through all those pages of different knowledge.
--------------------------------
fun is not a straight line

Image

Sven
http://www.mx-5club-sachsen.de
http://miata.cardomain.com/id/svenmx5
NB-1998-1,6-Garrett T25 HGP Turbo Stage I
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

This is how I would go about it after reading a few threads and knowing what I know now about the code:

-Setup boost target table

-Basic setup for your solenoid. control interval, min/max duty,frequency etc. (IMPORTANT TO GET THESE SETTINGS RIGHT SO YOU'RE NOT CHASING YOUR TAIL)

-Set lower limit delta(as 16vboost suggested may be best set this up while setting up initial duty table)

-Setup initial duty table. Very very important to getting the code working well! Do so by selecting advanced mode, setting the gains to 0 and filling the table, check logs and see what duty % gives you what boost when you enter PID control at that target/RPM load. With the gains all set to 0 you can see directly how the initial duty table is affecting things.

-To setup the slider after you have your initial duty table setup go back to basic mode or fill in p=100 I=100 D=100 and adjust the sensitivity until you have semi-decent probably not perfect boost control with little to no oscillation.

-Once the silder is set, You're getting a bit of "initial overshoot" around your boost target and the code is responding the way it should then you can start fine tuning the gains if needed. I won't get into how each of the gains work as i'm not concrete on that and played around for the most part.







16vboost I agree with you that once I understood I spent a lot of time tweaking the initial duty table. I'm still sometimes hitting my overboost protection which is 2.5psi over my target at high rpms once already past the boost threshold. With my ball bearing turbo it really likes to 'light up' really quickly at high rpms (ex. 3rd gear 5000rpm and then going WOT) a bit too fast for the code to catch it. I really really don't want to but I may have to raise my lower limit delta kpa, it's currently at 40kpa. I love the way it spools up it's really a difference maker but it doesn't always have enough time to react to fast spool. I will try 50kpa hoping I don't feel a big difference!


here's a log I just did showing the code holding my 16.5psi target pretty closely:
closedloopboost.png


I'm thinking from here adjusting the lower limit delta will reduce the initial overshoot under all conditions. I've tweaked with the gains and ended up with P=6 I=25 D=5.
16vboost
Master MS/Extra'er
Posts: 478
Joined: Thu Apr 22, 2010 9:10 pm
Location: Miami, FL

Re: what's going on here? MS3-pro PID boost control tuning

Post by 16vboost »

Here are my thoughts on controlling overshoot (in order) (for MS2 3.3.2 with initial duty table)

1. Tune the value in the initial duty table for the RPM where the code is entering boost control (and overshooting)
2. Add "D" term until you fix the overshoot or mess something else up
3. Increase lower limit delta
4. Lower your control interval

So E30_Driv3r, I think you should try adding D at this point. Then, if needed increase lower limit delta and possibly raise your control interval. For the sake of the thread here's my understanding of what the PID terms do.

PID controls the solenoid output based on the boost error (Target - MAP) like this: DutyCycle = P*error + I*(accumulated error over time) - D*(rate of change of error)

P - Proportional term, Is multiplied by the boost error at any point in time so the further you are from your target the more P will work to change the duty cycle at that point in time. If you set P too high you will have oscillations and the only way to avoid them is to lower P (or I).

I - Integral term, is multiplied by the "Integral" of the error over time. In other words, the longer you're away from your target, the higher the error over time will be. I has the effect of getting you to target if you're really close. Also, too much I will cause oscillation. You can either lower I or P to reduce them.

D - Derivative term, is multiplied by the "Derivative" of the error. Or how fast the error is changing. So if you're coming up to your target fast, D will have the effect of lowering duty cycle. Think of it as being multiplied by MAPdot. This is intended to avoid overshoot before it happens. It kinda predicts the future by seeing how fast you're moving towards your target.

That being said, look at my log below. It shows the effect of "D" in reducing the solenoid duty cycle just before getting to target. D is causing that dip in the duty cycle when entering boost control. It will momentarily lower the duty cycle lower than what's in the table.
Image

But in your case, since you have a 14 lb wastegate spring, I'm not sure that avoiding overshoot will be that easy if your target is 16.5 psi. I would definately set the min duty cycle from 15% to 0%. I think the manual is somewhat dated on that. It may not have an effect, but I don't see why you wouldn't want pressure to go to the solenoid 100% when trying to lower boost.

-Alex
Zaphod
Master MS/Extra'er
Posts: 390
Joined: Thu Aug 14, 2008 11:38 pm
Location: Germany

Re: what's going on here? MS3-pro PID boost control tuning

Post by Zaphod »

@ 16vboost - very impressive boost control log! Nearly no changes in boost duty over the whole full TPS period. Really seems to show the advantages of the new boost control!

How do you handle the tuning after setting up the Inital duty Bias table?

- set the slider in basic mode until the control seems reasonable,
- how do you go on with setting the PIDs then?
--------------------------------
fun is not a straight line

Image

Sven
http://www.mx-5club-sachsen.de
http://miata.cardomain.com/id/svenmx5
NB-1998-1,6-Garrett T25 HGP Turbo Stage I
E30_Driv3r
Experienced MS/Extra'er
Posts: 193
Joined: Sun Dec 14, 2008 5:31 pm

Re: what's going on here? MS3-pro PID boost control tuning

Post by E30_Driv3r »

16vboost I appreciate you adding in your thoughts on the tuning process, the more info the merrier! You did a better job laying it all out than me :mrgreen: great example of boost control in that log screenshot too :yeah!:

I was considering adding more D to fight overshoot but I was scared of skewing things up. But now I think I will do that as you said until something happens and last resort increase the lower limit delta. As for the duty range I based it off this site where the approx. duty range of my valve i'm using is listed at my frequency. I figured narrowing the range would help accuracy if it is known 0%-14% duty has no affect on raising the boost but having it set to 0% would help in lowering boost quicker possibly if needed. Now that I've got a better working initial duty table I can probably set it to 0 and 100. I may give it a try.

http://www.circuitse7en.net/page26.php

go to bottom of page you'll see the chart



http://www.sengpielaudio.com/calculator-period.htm

another useful link I found in another thread to find the control interval (ms) based on the frequency. Only cause I had a helluva time finding out what mine was!
16vboost
Master MS/Extra'er
Posts: 478
Joined: Thu Apr 22, 2010 9:10 pm
Location: Miami, FL

Re: what's going on here? MS3-pro PID boost control tuning

Post by 16vboost »

Zaphod wrote:How do you handle the tuning after setting up the Inital duty Bias table?

- set the slider in basic mode until the control seems reasonable,
- how do you go on with setting the PIDs then?
Thanks you. So I re-read the thread title and I'm a little embarrassed because my advise was for MS2 boost control and not MS3. From my understanding MS2 uses the "initial duty table" and MS3 uses a "bias" table. I don't have any experience with MS3 and the "bias" table. I know they work differently.

But I think the slider and PID terms work the same. This quote is from another thread http://www.msextra.com/forums/viewtopic ... 9&start=60
muythaibxr wrote:The sensitivity slider controls the sensitivity of the algorithm. Higher means faster response from PID overall. Lower means slower response from PID overall. In basic mode, the code just sets the PID gains to 100-100-100. Advanced mode allows you to change them. The behavior of the slider does not change whether in basic or advanced mode.
So the slider just multiplies (sorta) your PID values. So low PID values and high sensitivity slider values would be the same as high PID values and low sensitivity slider values. Adjust the slider so that your PID values are using the full range between 0-200. For me, I have the slider set at zero and PID at 11,32,39. That's as high as I can set them but I have enough tuning range for good control. You may have to skip basic mode if you have the slider all the way down and things are still oscillating.

For control interval, I've run everything from 10ms to 150ms. And that's with a 19.5 Hz solenoid frequency (51ms period). Right now I have it set to 100 which is almost 2 solenoid periods. I've found that longer control intervals tend to smooth out the response of the code (especially with high D terms) at the expense of being slower to catch an overshoot.

For solenoid duty cycle, I ran my DIY autotune solenoid at 39 Hz for a while because I thought I read that somewhere and it was un-tunable. On my own experimentation I found that 19.5 Hz worked for me. That was my biggest improvement in boost control by far. If starting over, I'd probably start off low in open boost mode and ramp up the frequency until things got ugly and then back down to where they worked.
E30_Driv3r wrote:As for the duty range I based it off this site where the approx. duty range of my valve i'm using is listed at my frequency. I figured narrowing the range would help accuracy if it is known 0%-14% duty has no affect on raising the boost
This is exactly correct and that's the point of the min/max duty cycle values. They scale the duty cycle outputs to give you better control. I guess I would just do my own testing before using values from the internet. If 14% really does nothing, and you're at boost target at 17%, I'd be concerned. Maybe a softer wastegate spring is needed. But try tuning it first.

At some point, I may start compiling different screen shots of boost logs and start writing captions on what's wrong with them and what to try. This has been the hardest part for me to learn so it might be worth sharing.

-Alex
Post Reply