MEGAsquirt A place to collectively sort out this megasquirt gizmo

MS-II Closed Loop Boost Control - PID

Thread Tools
 
Search this Thread
 
Old 01-28-2010, 10:33 AM
  #41  
Boost Czar
Thread Starter
iTrader: (62)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,490
Total Cats: 4,079
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.

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.
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  
Old 01-28-2010, 10:47 AM
  #42  
Elite Member
 
Zaphod's Avatar
 
Join Date: Mar 2006
Location: Schwarzenberg, Germany
Posts: 1,553
Total Cats: 101
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  
Old 01-28-2010, 10:52 AM
  #43  
Boost Czar
Thread Starter
iTrader: (62)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,490
Total Cats: 4,079
Default

Originally Posted by Zaphod
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  
Old 01-28-2010, 10:56 AM
  #44  
Senior Member
iTrader: (6)
 
TrickerZ's Avatar
 
Join Date: Jul 2007
Location: Cocoa Beach, FL
Posts: 850
Total Cats: 16
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  
Old 01-28-2010, 11:02 AM
  #45  
Elite Member
 
JasonC SBB's Avatar
 
Join Date: Jul 2005
Posts: 6,420
Total Cats: 84
Default

Originally Posted by Braineack
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  
Old 01-28-2010, 05:31 PM
  #46  
Boost Czar
Thread Starter
iTrader: (62)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,490
Total Cats: 4,079
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  
Old 01-28-2010, 05:33 PM
  #47  
Elite Member
iTrader: (11)
 
miatauser884's Avatar
 
Join Date: Feb 2009
Posts: 2,959
Total Cats: 11
Default

It's hard to argue with your mbc datalog
miatauser884 is offline  
Old 01-28-2010, 05:36 PM
  #48  
Boost Czar
Thread Starter
iTrader: (62)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,490
Total Cats: 4,079
Default

Originally Posted by djp0623
It's hard to argue with your mbc datalog

no ****?

Braineack is offline  
Old 01-28-2010, 05:38 PM
  #49  
Elite Member
iTrader: (11)
 
miatauser884's Avatar
 
Join Date: Feb 2009
Posts: 2,959
Total Cats: 11
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  
Old 01-28-2010, 09:21 PM
  #50  
Junior Member
 
muythaibxr's Avatar
 
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  
Old 01-29-2010, 03:08 AM
  #51  
Elite Member
 
Zaphod's Avatar
 
Join Date: Mar 2006
Location: Schwarzenberg, Germany
Posts: 1,553
Total Cats: 101
Default

Originally Posted by muythaibxr
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  
Old 01-29-2010, 03:14 AM
  #52  
Elite Member
iTrader: (10)
 
Reverant's Avatar
 
Join Date: Jun 2006
Location: Athens, Greece
Posts: 5,976
Total Cats: 355
Default

Originally Posted by muythaibxr
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  
Old 01-29-2010, 05:34 AM
  #53  
Elite Member
iTrader: (1)
 
richyvrlimited's Avatar
 
Join Date: Jun 2006
Location: Warrington/Birmingham
Posts: 2,642
Total Cats: 42
Default

Brain, take Ken up on his offer!

My god that's good service
richyvrlimited is offline  
Old 01-29-2010, 10:24 AM
  #54  
Junior Member
 
muythaibxr's Avatar
 
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  
Old 01-29-2010, 10:33 AM
  #55  
Elite Member
iTrader: (1)
 
richyvrlimited's Avatar
 
Join Date: Jun 2006
Location: Warrington/Birmingham
Posts: 2,642
Total Cats: 42
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  
Old 01-29-2010, 10:35 AM
  #56  
Junior Member
 
muythaibxr's Avatar
 
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  
Old 01-29-2010, 11:03 AM
  #57  
Elite Member
 
Zaphod's Avatar
 
Join Date: Mar 2006
Location: Schwarzenberg, Germany
Posts: 1,553
Total Cats: 101
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  
Old 01-29-2010, 04:16 PM
  #58  
Boost Czar
Thread Starter
iTrader: (62)
 
Braineack's Avatar
 
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,490
Total Cats: 4,079
Default

Originally Posted by muythaibxr
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  
Old 01-29-2010, 04:49 PM
  #59  
Elite Member
 
JasonC SBB's Avatar
 
Join Date: Jul 2005
Posts: 6,420
Total Cats: 84
Default

Good stuff.

Originally Posted by muythaibxr
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 05:02 PM.
JasonC SBB is offline  
Old 01-29-2010, 05:23 PM
  #60  
Elite Member
iTrader: (10)
 
Reverant's Avatar
 
Join Date: Jun 2006
Location: Athens, Greece
Posts: 5,976
Total Cats: 355
Default

Originally Posted by JasonC SBB
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  


Quick Reply: MS-II Closed Loop Boost Control - PID



All times are GMT -4. The time now is 12:06 AM.