MS-II Closed Loop Boost Control - PID
#41
Boost Czar
Thread Starter
iTrader: (62)
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,501
Total Cats: 4,080
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.
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.
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:
openduty - closeduty is giving you -100 instead of 100... The code assumes a lower duty gives you a higher boost.
Code:
tmp1 = boost_ctl_duty + (((long)(Kp - Ki + Kd) * (flash5.boost_ctl_openduty - flash5.boost_ctl_closeduty)) / 100000);
#45
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.
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.
#46
Boost Czar
Thread Starter
iTrader: (62)
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,501
Total Cats: 4,080
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.
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.
#50
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
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
#51
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
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
#54
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
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
#56
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
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
#58
Boost Czar
Thread Starter
iTrader: (62)
Join Date: May 2005
Location: Chantilly, VA
Posts: 79,501
Total Cats: 4,080
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
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.
#59
Good stuff.
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.
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.
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.