MS-II Closed Loop Boost Control - PID - Page 3 - Miata Turbo Forum - Boost cars, acquire cats.

Welcome to Miataturbo.net   Members
 


MEGAsquirt A place to collectively sort out this megasquirt gizmo

Reply
 
 
 
LinkBack Thread Tools
Old 01-28-2010, 11:33 AM   #41
Boost Czar
Thread Starter
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,833
Total Cats: 1,786
Default

well with Normal = open 100%, closed 0%, this should = more boost 100%DC, less boost = 0%DC

that's my issues, plain and simple.



And Furthermore, like I've stated a few times, closed MUST be set lower than open else the formula fails and you get negative numbers.

Quote:
Your closed duty and open duty are backwards. Closed loop boost only works with the closed duty lower than the open duty.

If that isn't what you think your valve does, invert the output instead of the open/closed duties.
Quote:
This is the line of code that is causing the issue for you:
Code:
tmp1 =  boost_ctl_duty + (((long)(Kp - Ki + Kd) *
                                     (flash5.boost_ctl_openduty - flash5.boost_ctl_closeduty)) /
                                      100000);
openduty - closeduty is giving you -100 instead of 100... The code assumes a lower duty gives you a higher boost.
Braineack is offline   Reply With Quote
Old 01-28-2010, 11:47 AM   #42
Senior Member
 
Join Date: Mar 2006
Location: Schwarzenberg, Germany
Posts: 1,497
Total Cats: 81
Default

That is what I have set up for my valve too

Closed duty 0%
Open duty 100%

Output polarity inverted.

Control interval 10ms

Solenoid frequency 19.5Hz as I think was proposed for the GM valve.
Zaphod is offline   Reply With Quote
Old 01-28-2010, 11:52 AM   #43
Boost Czar
Thread Starter
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,833
Total Cats: 1,786
Default

Quote:
Originally Posted by Zaphod View Post
That is what I have set up for my valve too

Closed duty 0%
Open duty 100%

Output polarity inverted.

Control interval 10ms

Solenoid frequency 19.5Hz as I think was proposed for the GM valve.
This seems to be the norm on msextra.com and how I have it set. But in my case, based on what ken suggests of the code and my logs, it's backwards for what I need to run.
Braineack is offline   Reply With Quote
Old 01-28-2010, 11:56 AM   #44
Senior Member
iTrader: (6)
 
Join Date: Jul 2007
Location: Cocoa Beach, FL
Posts: 808
Total Cats: 3
Default

Tried swapping your boost controller outputs? If it's doing the opposite of what you want, that could fix it. If one side is 60%, the other is 40%.
TrickerZ is offline   Reply With Quote
Old 01-28-2010, 12:02 PM   #45
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Quote:
Originally Posted by Braineack View Post
the DC% table grays out if you select closed loop,
Hmm, the system would work better if DC% table and PID worked together. In control system parlance, the DC% table would be a lookup table "feedforward plant", and PID is the feedback path.

A **** hot system would slowly change the DC% table over time, which would make it an adaptive system, sort of like long term fuel trim, but in 3D. I suspect this is what the OEs do, which is why say on a Subaru, if you change the exhaust the factory boost control will overshoot at first, then fix itself over the next few runs.
JasonC SBB is offline   Reply With Quote
Old 01-28-2010, 06:31 PM   #46
Boost Czar
Thread Starter
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,833
Total Cats: 1,786
Default

I think I'm done playing with it.

Tried starting over.

P=150 I=0 D=0: wastegate boost (2%DC)

P=120 I=0 D=0: wastegate boost (2%DC)

P=100 I=0 D=0: wastegate boost (2%DC)

P=80 I=0 D=0: wastegate boost (2%DC)

P=30 I=0 D=0: wastegate boost (2%DC)

change Freqency from 19.5Hz to 30Hz.

P=120 I=0 D=0: 15.8psi taper down to wastegate (70%-60%DC)

P=100 I=0 D=0: 14.5psi taper down to wastegate

P=100 I=20 D=0: 14.5psi taper down to wastegate

P=100 I=40 D=0: 14.5psi taper down to wastegate

P=100 I=100 D=0: 17psi overboost.

I'm done. MBC works better.
Braineack is offline   Reply With Quote
Old 01-28-2010, 06:33 PM   #47
Elite Member
iTrader: (11)
 
Join Date: Feb 2009
Posts: 2,982
Total Cats: 10
Default

It's hard to argue with your mbc datalog
miatauser884 is offline   Reply With Quote
Old 01-28-2010, 06:36 PM   #48
Boost Czar
Thread Starter
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,833
Total Cats: 1,786
Default

Quote:
Originally Posted by djp0623 View Post
It's hard to argue with your mbc datalog

no ****?

Braineack is offline   Reply With Quote
Old 01-28-2010, 06:38 PM   #49
Elite Member
iTrader: (11)
 
Join Date: Feb 2009
Posts: 2,982
Total Cats: 10
Default

I just sent an email to Ben at diy to see if they have anything figured out. If not, then I'm going to make the $15 ebc. I'm tired of triggering the fuel cutoff due to overboosting. It's a shame, my old link and gm boost solenoid worked really well.
miatauser884 is offline   Reply With Quote
Old 01-28-2010, 10:21 PM   #50
Junior Member
 
Join Date: May 2007
Location: Columbia, MD
Posts: 248
Total Cats: 0
Default

1) Please read the boost control documentation I posted at msextra.

2) I did not use the duty table for feedforward before entering PID, but doing that would be pretty easy. I didn't do it because I was thinking that setting it to start with a closed wastegate and then open it only as much as necessary would result in reaching the target more quickly. So far from the logs of successful tunes that I've seen, this has held true.

Regardless, several people have gotten the current code working perfectly. Wes Kiser (has lots of experience tuning commercial systems such as Motec and Pectel) was telling me that it was easier to tune the MS PID system to get a good boost curve than it was on the commercial systems. I'm confident that the algorithm works.

3) I wrote the algorithm in terms of the wastegate and not the valve. 0% duty means closed wastegate means more boost. 100% duty means open wastegate means less boost. When boost is falling you should see duty falling if PID is tuned right, which is what your older logs were showing (that just wasn't making boost increase at all).

If higher duty means more boost on your setup, change the invert setting (seems like you already did this, but judging from your settings, decreasing P decreased initial boost. Decreasing P should cause the algorithm to react less strongly to changing boost, and cause the initial boost to peak higher. This is how the type of PID loop I implemented works. I'm going to give the option of a different type soon which will act more like a traditional PID loop).

4) Since you don't live too far from me, I'd be more than happy to meet up one day in the near future and help you with it (if you don't mind of course). I stand behind the code. It works, if I can't make it work as-is on your engine and setup, I'll figure out why and fix it. If it comes down to that, I could make those changes right on my laptop, rebuild the firmware, and upload it and we could test the effects in real-time. I've offered to do the same for idle but nobody has taken me up on it so far.

Ken
muythaibxr is offline   Reply With Quote
Old 01-29-2010, 04:08 AM   #51
Senior Member
 
Join Date: Mar 2006
Location: Schwarzenberg, Germany
Posts: 1,497
Total Cats: 81
Default

Quote:
Originally Posted by muythaibxr View Post
1)
4) Since you don't live too far from me, I'd be more than happy to meet up one day in the near future and help you with it (if you don't mind of course). I stand behind the code. It works, if I can't make it work as-is on your engine and setup, I'll figure out why and fix it. If it comes down to that, I could make those changes right on my laptop, rebuild the firmware, and upload it and we could test the effects in real-time. I've offered to do the same for idle but nobody has taken me up on it so far.

Ken
@Brain - would be good if you would accept this - I (we?) would surely like to see the outcome of this...
Zaphod is offline   Reply With Quote
Old 01-29-2010, 04:14 AM   #52
Supporting Vendor
iTrader: (10)
 
Reverant's Avatar
 
Join Date: Jun 2006
Location: Athens, Greece
Posts: 5,440
Total Cats: 198
Default

Quote:
Originally Posted by muythaibxr View Post
4) Since you don't live too far from me, I'd be more than happy to meet up one day in the near future and help you with it (if you don't mind of course). I stand behind the code.

Ken
Not even commercial companies do that. How can we ever thank you or pay you back for everything you and James have done?

Jim
Reverant is offline   Reply With Quote
Old 01-29-2010, 06:34 AM   #53
Elite Member
iTrader: (1)
 
Join Date: Jun 2006
Location: Warrington/Birmingham
Posts: 2,658
Total Cats: 39
Default

Brain, take Ken up on his offer!

My god that's good service
richyvrlimited is offline   Reply With Quote
Old 01-29-2010, 11:24 AM   #54
Junior Member
 
Join Date: May 2007
Location: Columbia, MD
Posts: 248
Total Cats: 0
Default

I don't think of it as helping just one person... I think of it as "I want to make it work, and if it doesn't, I want to fix it." That helps everyone doesn't it?

That said, I know of several who have gotten it to work. That's not to say it can't work better though, and I have some ideas for making it do just that. This includes an idea that should allow me to use a feedforward table (optionally) and still get the benefits I was trying to get of not using one.

The main reason I write the code is that I like seeing peoples' engines run better because of my work. That's the payment. That said I take other currencies as well, such as beer

Ken
muythaibxr is offline   Reply With Quote
Old 01-29-2010, 11:33 AM   #55
Elite Member
iTrader: (1)
 
Join Date: Jun 2006
Location: Warrington/Birmingham
Posts: 2,658
Total Cats: 39
Default

I'm being selfish, I'm far too far away for you to come and look at my car, but if you look at Brains and see something helpful/obvious/an issue, it'll help me
richyvrlimited is offline   Reply With Quote
Old 01-29-2010, 11:35 AM   #56
Junior Member
 
Join Date: May 2007
Location: Columbia, MD
Posts: 248
Total Cats: 0
Default

Actually, another comment... Based on what happened when you tuned, I'm betting you were very close to having it working.

40% I term dropped off in boost, and 100% overboosted (probably due to oscillation).

My next step would've been to try 70%... then if there's too much boost, drop it to 55%, too little, increase it to 85% (binary search) until you home in on the right value.

Then I'd slightly lower the P term until it overshoots a bit when it first reaches the target, and then tweak the D term to get rid of that overshoot.

Ken
muythaibxr is offline   Reply With Quote
Old 01-29-2010, 12:03 PM   #57
Senior Member
 
Join Date: Mar 2006
Location: Schwarzenberg, Germany
Posts: 1,497
Total Cats: 81
Default

What would make the endresult something quite similar to may actual (not perfect) settings (105,48,150) though I thing my D term is rediculous too high.
Zaphod is offline   Reply With Quote
Old 01-29-2010, 05:16 PM   #58
Boost Czar
Thread Starter
iTrader: (61)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 72,833
Total Cats: 1,786
Default

Quote:
Originally Posted by muythaibxr View Post
Actually, another comment... Based on what happened when you tuned, I'm betting you were very close to having it working.

40% I term dropped off in boost, and 100% overboosted (probably due to oscillation).

My next step would've been to try 70%... then if there's too much boost, drop it to 55%, too little, increase it to 85% (binary search) until you home in on the right value.

Then I'd slightly lower the P term until it overshoots a bit when it first reaches the target, and then tweak the D term to get rid of that overshoot.

Ken

I'll post the logs later of what it looked like when I tried it out. I'm putting the car away again until it gets warmer out again and I'll probably take you up on your offer.

I did notice that in both cases (inverted and normal) that the DC% on the log was dropping off towards redline.
Braineack is offline   Reply With Quote
Old 01-29-2010, 05:49 PM   #59
Elite Member
 
Join Date: Jul 2005
Posts: 6,454
Total Cats: 80
Default

Good stuff.

Quote:
Originally Posted by muythaibxr View Post
2) I did not use the duty table for feedforward before entering PID, but doing that would be pretty easy. I didn't do it because I was thinking that setting it to start with a closed wastegate and then open it only as much as necessary would result in reaching the target more quickly.
If you have a feedforward and PID, in the above scenario, the 'P' term should be large enough to drive the duty cycle to zero. The D will prevent overshoot and the 'I' will drive the steady state error to zero.

A properly designed feedforward + feedback system will significantly outperform a feedback only system. The reason your design works better than others is because the other systems suck and MS rocks.

Not to toot my own horn, but I have done lots of feedback loop design at work including electromechanical systems such as PM motor motion control.

In addition to the above, the system should have:

A 3D table of desired boost target, with RPM and TPS as the axes.
A 3D table feedforward duty cycle, with RPM and boost target as axes.
P I and D gain values.
Ways of controlling 'I' "windup" - e.g. zero out the integrator value whenever boost is > 3 psi above or below the target
Ditto for the 'D' term - it should only go nonzero when within say 2 psi of the target - the reason for this is so it doesn't limit the rate of rise of boost until it is close to the target and there is actual danger of overshooting.

Then the way to tune the system is to fill in the 2 3D tables until boost is close to target (say within 2 psi). Then adjust P,I, and D to hit target fast without overshoot.

Last edited by JasonC SBB; 01-29-2010 at 06:02 PM.
JasonC SBB is offline   Reply With Quote
Old 01-29-2010, 06:23 PM   #60
Supporting Vendor
iTrader: (10)
 
Reverant's Avatar
 
Join Date: Jun 2006
Location: Athens, Greece
Posts: 5,440
Total Cats: 198
Default

Quote:
Originally Posted by JasonC SBB View Post
In addition to the above, the system should have:

A 3D table of desired boost target, with RPM and TPS as the axes.
A 3D table feedforward duty cycle, with RPM and boost target as axes.
P I and D gain values.
Ditto for PWM closed-loop idle.

Jim
Reverant is offline   Reply With Quote
 
 
Reply

Related Topics
Thread Thread Starter Forum Replies Last Post
Project Gemini - Turbo Civic on the Cheap Full_Tilt_Boogie Build Threads 57 07-19-2017 05:11 PM
Another Cast Manifold Corky Bell Prefabbed Turbo Kits 18 11-22-2016 10:01 PM
Going back to stock. Need some 1.6 parts. Trent WTB 2 10-01-2015 01:15 PM
Time to start learning and play with tuning The Gleas MEGAsquirt 3 10-01-2015 10:30 AM
Bad head gasket or ? shooterschmidty Engine Performance 8 09-30-2015 11:28 PM


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 04:54 AM.