HPFP control strategy

It's all about the code!
Post Reply
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

HPFP control strategy

Post by ssmith »

I'd like to implement the HPFP control strategy. I pushed a first draft of what I think will work: https://github.com/rusefi/rusefi/pull/3453
It is based heavily on an existing standlone ECU control strategy, so I won't claim to have come up with it myself. I did however write all the code.

First, some background on how HPFP works. Note I am not an expert but this is what I found in my research.

There are two basic types of pumps. A solenoid pump, like the Bosch HDP5, works by having a pump be driven by lobes on a camshaft (or something similar). There is another type (used on, say, a BMW N54) but I don't know much about it other than it seems to be much more rare. I think it can be driven by the same type of ECU (for example, Motec does not have separate ECUs for the two pump types) but I'll just ignore this type for now.

For the solenoid type pump, the pump has a certain volume. You can activate the solenoid to request that the pump start pressurizing. Once it reaches a certain pressure, it is effectively self running and won't unlatch until the pump reaches the top. This means that if you are going to activate the pump, you activate it for a certain number of degrees BTDC of the lobe peak. You can't just activate it for the first x% of the lobe, it has to be the last x% of the lobe. Within this pump type there are two different solenoids - normally open (Bosch) and normally closed (Hitachi maybe?). I don't know much about the latter.

Thus activating the solenoid has two functions - replace the fuel consumed by the injectors, and add to the pressure of the rail. We can hopefully calculate the former, but it's really hard to calculate the latter (unless you model the volume of the rail).

Since the solenoid latches itself, you don't have to keep it activated for the whole lobe. You just need to activate it until it latches and then let it do the rest of the work. This means that if you don't know where the lobe top is, and you try to request 100% fuel, you might get 0% fuel if your peak is too early (HPFP falls flat very quickly), or you might get something under 100% fuel if your peak is after (HPFP trends gently down).

Also note that at least Bosch says the solenoids are peak and hold, meaning you really should be driving this using a special circuit. I don't know if you guys did that in your initial experiments; I remember reading on one post that you burned out the driver or something, maybe it was due to either latching it too long (previous paragraph) or allowing too much current (this paragraph). Of course solenoids have dead time / activation delay, so we need a table for that.

So with that out of the way....

The idea is to use the calculation of fuel volume needed by peeking at the fuel injection calculation. We can take this value and look it up in a table that represents how many degrees of the lobe equals how many CC of the pump volume. These are roughly sinusoidal, and I have used that in the past, but I have been told by people with more experience than me that you HAVE to measure the lobe. Personally, I have done both and haven't noticed a difference.

We would also like to add a PI controller on top. Besides accounting for variations in real life fuel delivery and pump rates, it is the only way to actually achieve a given pressure (without modelling the rail volume). But who wants to measure the fuel rail? That'd involve removing it from the engine and .... and I'm lazy. So PI controller it is. HOWEVER, you don't really want the PI controller to work in the degrees domain, as the lobe is nonlinear. So we want to apply the PI correction in the "% pump volume" domain, which means before the %->deg mapping we did in the previous paragraph.

This model based on fuel volume is reasonably good, but it has errors. Yes we could rely on a PI controller to fix that, but in order to reduce the work of the PI controller we add a compensation table. The compensation table is just another adder in the % domain. This table is very easy to tune (just measure the PI controller delta at various load cells and plug it into the table). Personally I am convinced that this table can give you hints on misconfiguration (are your injectors really larger than you think? is the pump volume different than you think? Maybe the lobe peak angle isn't where you think, or maybe the lobe profile isn't what you think) and would like to investigate adding something to analyze the table and suggest changes to other settings, but if you "just want it to run" this table lets you do that very easily.

The code as submitted tries to capture all these factors. It is untested as I didn't want to write a bunch of tests only to be told that a) someone else already did it, or b) you don't like the algorithm, so I figured I'd put it out there for comment. And I do want to review another ECU or two to see if there are more ideas out there - I think Motec has or allows tables for some of the fields that Link keeps as scalars.
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

Forgot to mention, pumps like the HDP5 have a built in valve that bleed off pressure if the rail exceeds a certain amount. On my car with a 200bar typical max pressure, the emergency relief valve is at 250bar. This is necessary not just in case software goes awry, but because fuel expands with heat - I've seen data showing the rail pressure climb from 50bar (typical idle) to 250 just from the heat rising from the motor!

It might be nice to add a "oh crap what did I do!" max pressure setting that shut off all the logic if the pressure gets too high. It would guard against integral windup or other configuration errors.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: HPFP control strategy

Post by AndreyB »

Thank you for the PR and nice write up!

While GDI is a bit on hold it's still great to move forward!
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

AndreyB wrote:
Thu Nov 04, 2021 1:35 am
Thank you for the PR and nice write up!

While GDI is a bit on hold it's still great to move forward!
Well... does it have to be on hold? I have code! I'm willing to do the legwork!
Besides, it's a bit of chicken and egg. How would you test GDI hardware without competent control strategies? Why not get one in place?
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

I would like to improve the activation hold time logic. Motec actually has a 3d table for this on RPM and battery voltage. Personally I'm not sure why voltage matters if you have a current control output, but from the sounds of the help file I don't think they do use a peak and hold driver, instead they seem to rely on the user setting PWM parameters to achieve the same thing.

It seems you need to hold the valve long enough for the gas to reach the same pressure as the rail (or maybe higher depending on how the valve works?) and enough to push open the valve (and get it to latch).

According to this: https://physics.stackexchange.com/questions/207637/can-gasoline-be-compressed
compressing gasoline by 2% gets 260 bar. Maybe we can use that formula to determine what % of the pump volume we need to hold it compressed for to account for the pressure increase, then convert that to degrees and add it to the hold time.

I wonder how to model the other factors behind the valve.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: HPFP control strategy

Post by mck1117 »

ssmith wrote:
Thu Nov 04, 2021 12:08 am
Also note that at least Bosch says the solenoids are peak and hold, meaning you really should be driving this using a special circuit. I don't know if you guys did that in your initial experiments; I remember reading on one post that you burned out the driver or something, maybe it was due to either latching it too long (previous paragraph) or allowing too much current (this paragraph).
Yes - the driver hardware we have already working has boost/peak/hold control for the injectors, and peak/hold control for the fuel pump (don't need the 50-80 volt slap to cycle the pump solenoid like you do injectors). See this thread: https://rusefi.com/forum/viewtopic.php?p=38551#p38551
ssmith wrote:
Thu Nov 04, 2021 12:08 am
Of course solenoids have dead time / activation delay, so we need a table for that.
The deadtime is pretty small for high current, low inductance peak-hold driven solenoids. IIRC the common HDEV4/5 injectors have a deadtime of something like 100 us. This is the sort of thing the PI controller is for :) If that doesn't give good enough results, deadtime may be a thing worth adding.
ssmith wrote:
Thu Nov 04, 2021 12:08 am
I have been told by people with more experience than me that you HAVE to measure the lobe
I agree that is probably overkill. This is what the closed loop part is for :P
ssmith wrote:
Thu Nov 04, 2021 12:08 am
HOWEVER, you don't really want the PI controller to work in the degrees domain, as the lobe is nonlinear. So we want to apply the PI correction in the "% pump volume" domain, which means before the %->deg mapping we did in the previous paragraph.
Glad to have somebody else around who has at least some grasp of control systems!
ssmith wrote:
Thu Nov 04, 2021 12:08 am
This model based on fuel volume is reasonably good, but it has errors. Yes we could rely on a PI controller to fix that, but in order to reduce the work of the PI controller we add a compensation table. The compensation table is just another adder in the % domain. This table is very easy to tune (just measure the PI controller delta at various load cells and plug it into the table). Personally I am convinced that this table can give you hints on misconfiguration (are your injectors really larger than you think? is the pump volume different than you think? Maybe the lobe peak angle isn't where you think, or maybe the lobe profile isn't what you think) and would like to investigate adding something to analyze the table and suggest changes to other settings, but if you "just want it to run" this table lets you do that very easily.
I'm not entirely sure this table is required - I would be interested in some real world data without it.

Another important point is that we already have proven fuel pressure compensation logic - so not only would we control the rail pressure to hit target, but we vary the injection pulse to actually deliver the desired fuel given the current pressure. This means that so long as the pressure is high enough to deliver enough fuel, super precise control of the pressure (even during transients) isn't critical.

That's why Andrey's sketchy test of the VW in his driveway worked so well - you can watch the fuel pressure swing wildly in the log, but the engine says running decently.

This post: https://rusefi.com/forum/viewtopic.php?p=38819#p38819

Has this log:
image.png
image.png (47.35 KiB) Viewed 6039 times
That big swing at the left is from 114 all the way down to 7.1 bar, in 2.4 seconds.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: HPFP control strategy

Post by mck1117 »

ssmith wrote:
Thu Nov 04, 2021 1:43 am
I would like to improve the activation hold time logic. Motec actually has a 3d table for this on RPM and battery voltage. Personally I'm not sure why voltage matters if you have a current control output, but from the sounds of the help file I don't think they do use a peak and hold driver, instead they seem to rely on the user setting PWM parameters to achieve the same thing.
With the driver chip already required to run the injectors, we get free current control of the pump, so the voltage certainly doesn't matter. In fact, I've seen OEM calibrations that don't do ANY variable deadtime compensation on the injectors, and just use a fixed value, even with variable pressure.
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

mck1117 wrote:
Thu Nov 04, 2021 2:18 am
ssmith wrote:
Thu Nov 04, 2021 12:08 am
Of course solenoids have dead time / activation delay, so we need a table for that.
The deadtime is pretty small for high current, low inductance peak-hold driven solenoids. IIRC the common HDEV4/5 injectors have a deadtime of something like 100 us. This is the sort of thing the PI controller is for :) If that doesn't give good enough results, deadtime may be a thing worth adding.
I was actually talking about deadtime for the hpfp solenoid. I was leaving out any discussion of injectors at this point. But yes, IME I just set the deadtime for the injectors to 0 and it works fine. Any attempt I've made to measure them (change rail pressure, compare injector duration before and after for the same lambda) has led me to 0, which seems wrong, but it works for me.
mck1117 wrote:
ssmith wrote:
Thu Nov 04, 2021 12:08 am
This model based on fuel volume is reasonably good, but it has errors. Yes we could rely on a PI controller to fix that, but in order to reduce the work of the PI controller we add a compensation table. The compensation table is just another adder in the % domain. This table is very easy to tune (just measure the PI controller delta at various load cells and plug it into the table). Personally I am convinced that this table can give you hints on misconfiguration (are your injectors really larger than you think? is the pump volume different than you think? Maybe the lobe peak angle isn't where you think, or maybe the lobe profile isn't what you think) and would like to investigate adding something to analyze the table and suggest changes to other settings, but if you "just want it to run" this table lets you do that very easily.
I'm not entirely sure this table is required - I would be interested in some real world data without it.
Maybe I didn't explain well. What it gets you is "fixing" your model without fixing the model. I.e. you need to measure all these things (pump lobe degree ATDC, profile, injector rate, pump volume, etc), and if they don't match, this table can actually fix it pretty well. Yeah it means that the computed % pump volume may not be correct, which means the PI controller isn't strictly operating in the % domain, but it if your other numbers are close enough without being perfect, this table helps make it perfect. I've seen the result on my engine, again configured more by guess than measurement, and this table makes pressure control very smooth.
mck1117 wrote: Another important point is that we already have proven fuel pressure compensation logic - so not only would we control the rail pressure to hit target, but we vary the injection pulse to actually deliver the desired fuel given the current pressure. This means that so long as the pressure is high enough to deliver enough fuel, super precise control of the pressure (even during transients) isn't critical.

That's why Andrey's sketchy test of the VW in his driveway worked so well - you can watch the fuel pressure swing wildly in the log, but the engine says running decently.
Yeah, my experience has been the same, though you do need the higher pressures to be able to inject the right amount of fuel as RPM goes up (less time to inject). Also I have wondered if the compensation should model cylinder air pressure as you can be injecting fuel even during the compression stroke but that may be more effort than it's worth. Plus you'd need to know stroke and rod length in order to calculate the piston speed, and my engine is an offset crank (184 degrees rotation down 176 degrees up!!) so that'd be an additional factor to model.
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

mck1117 wrote:
Thu Nov 04, 2021 2:19 am
ssmith wrote:
Thu Nov 04, 2021 1:43 am
I would like to improve the activation hold time logic. Motec actually has a 3d table for this on RPM and battery voltage. Personally I'm not sure why voltage matters if you have a current control output, but from the sounds of the help file I don't think they do use a peak and hold driver, instead they seem to rely on the user setting PWM parameters to achieve the same thing.
With the driver chip already required to run the injectors, we get free current control of the pump, so the voltage certainly doesn't matter. In fact, I've seen OEM calibrations that don't do ANY variable deadtime compensation on the injectors, and just use a fixed value, even with variable pressure.
Again, this was in reference to HPFP solenoid, which is affected by voltage drops (at least until you reach peak current). But yes I agree that with injectors you shouldn't need voltage compensation.
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

ssmith wrote:
Thu Nov 04, 2021 2:43 am
mck1117 wrote:
ssmith wrote:
Thu Nov 04, 2021 12:08 am
This model based on fuel volume is reasonably good, but it has errors. Yes we could rely on a PI controller to fix that, but in order to reduce the work of the PI controller we add a compensation table. The compensation table is just another adder in the % domain. This table is very easy to tune (just measure the PI controller delta at various load cells and plug it into the table). Personally I am convinced that this table can give you hints on misconfiguration (are your injectors really larger than you think? is the pump volume different than you think? Maybe the lobe peak angle isn't where you think, or maybe the lobe profile isn't what you think) and would like to investigate adding something to analyze the table and suggest changes to other settings, but if you "just want it to run" this table lets you do that very easily.
I'm not entirely sure this table is required - I would be interested in some real world data without it.
Maybe I didn't explain well. What it gets you is "fixing" your model without fixing the model. I.e. you need to measure all these things (pump lobe degree ATDC, profile, injector rate, pump volume, etc), and if they don't match, this table can actually fix it pretty well. Yeah it means that the computed % pump volume may not be correct, which means the PI controller isn't strictly operating in the % domain, but it if your other numbers are close enough without being perfect, this table helps make it perfect. I've seen the result on my engine, again configured more by guess than measurement, and this table makes pressure control very smooth.
Actually this is an argument that the PI controller should work in the cc/lobe domain, not the % domain. Then it can take advantage of the compensation table to provide extra linearization.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: HPFP control strategy

Post by mck1117 »

ssmith wrote:
Thu Nov 04, 2021 2:43 am
I've seen the result on my engine, again configured more by guess than measurement, and this table makes pressure control very smooth.
I KNEW I'd seen this idea somewhere! The OEM tune for my Focus had a "Pump VE" table, dependent upon RPM and rail pressure:
image.png
image.png (71.37 KiB) Viewed 6028 times
I guess that's exactly the compensation table you're thinking of, but pressure dependent not load dependent, since that's the thing that's actually different as far as the pump is concerned.
ssmith wrote:
Thu Nov 04, 2021 2:43 am
Yeah, my experience has been the same, though you do need the higher pressures to be able to inject the right amount of fuel as RPM goes up (less time to inject). Also I have wondered if the compensation should model cylinder air pressure as you can be injecting fuel even during the compression stroke but that may be more effort than it's worth. Plus you'd need to know stroke and rod length in order to calculate the piston speed, and my engine is an offset crank (184 degrees rotation down 176 degrees up!!) so that'd be an additional factor to model.
Yes, the pressure of course has to be sufficient, but +-10% or whatever for a transient is no problem at all.
ssmith wrote:
Thu Nov 04, 2021 2:44 am
Again, this was in reference to HPFP solenoid, which is affected by voltage drops (at least until you reach peak current). But yes I agree that with injectors you shouldn't need voltage compensation.
I know - but the only thing that the system voltage impacts is the slope of the rising edge of the current through the solenoid. The inductance and resistance are both relatively low, so it's going to be sharpish even at low voltage.
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

Oh I forgot to mention decay rate. The HPFP has no way to lower rail pressure other than the emergency relief valve or injecting fuel. So if the target pressure rapidly decreases, you need some logic to say "no, that's not really achievable, lets only lower the pressure by a certain amount compared to last time." That works well enough. Though I'm curious if we could make it a little better by understanding when the injectors are off completely (due to overrun?) and not decrease the target at all then. It may or may not be worth the extra tuning step though.
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

mck1117 wrote:
Thu Nov 04, 2021 3:30 am
ssmith wrote:
Thu Nov 04, 2021 2:43 am
I've seen the result on my engine, again configured more by guess than measurement, and this table makes pressure control very smooth.
I KNEW I'd seen this idea somewhere! The OEM tune for my Focus had a "Pump VE" table, dependent upon RPM and rail pressure:

image.png

I guess that's exactly the compensation table you're thinking of, but pressure dependent not load dependent, since that's the thing that's actually different as far as the pump is concerned.
Oh now that is really interesting. I haven't seen a table like that on aftermarket ECUs. It would definitely be worth figuring out how to incorporate that as it adds a new axis which in theory should allow much more accurate tuning.
mck1117 wrote:
Thu Nov 04, 2021 3:30 am
ssmith wrote:
Thu Nov 04, 2021 2:43 am
Yeah, my experience has been the same, though you do need the higher pressures to be able to inject the right amount of fuel as RPM goes up (less time to inject). Also I have wondered if the compensation should model cylinder air pressure as you can be injecting fuel even during the compression stroke but that may be more effort than it's worth. Plus you'd need to know stroke and rod length in order to calculate the piston speed, and my engine is an offset crank (184 degrees rotation down 176 degrees up!!) so that'd be an additional factor to model.
Yes, the pressure of course has to be sufficient, but +-10% or whatever for a transient is no problem at all.
It's hacky and I don't want hacky. I want a nice steady rail pressure.

mck1117 wrote:
Thu Nov 04, 2021 3:30 am
ssmith wrote:
Thu Nov 04, 2021 2:44 am
Again, this was in reference to HPFP solenoid, which is affected by voltage drops (at least until you reach peak current). But yes I agree that with injectors you shouldn't need voltage compensation.
I know - but the only thing that the system voltage impacts is the slope of the rising edge of the current through the solenoid. The inductance and resistance are both relatively low, so it's going to be sharpish even at low voltage.
So deadtime tables are more for saturated injectors than peak/hold solenoids? All I know is the tables included in Link and Motec GDI basemaps have a substantial deadtime curve included. Personally I haven't tuned mine as either the voltage is low to start (in which case anything to get started works) or I'm at a steady 13.6-14.0V when running.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: HPFP control strategy

Post by mck1117 »

ssmith wrote:
Thu Nov 04, 2021 3:40 am
Oh I forgot to mention decay rate. The HPFP has no way to lower rail pressure other than the emergency relief valve or injecting fuel. So if the target pressure rapidly decreases, you need some logic to say "no, that's not really achievable, lets only lower the pressure by a certain amount compared to last time." That works well enough. Though I'm curious if we could make it a little better by understanding when the injectors are off completely (due to overrun?) and not decrease the target at all then. It may or may not be worth the extra tuning step though.
I know for a fact my Focus didn't do that. It dropped the target as fast as it wanted to, and just let the pressure come down as fuel was injected (or not come down if DFCO was active!).

Blue is target, red is actual. White is injector pulse width:
image.png
image.png (67.13 KiB) Viewed 6025 times
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: HPFP control strategy

Post by mck1117 »

Here's an example of the pressure staying flat while injection is suspended:
image.png
image.png (47.24 KiB) Viewed 6025 times
ssmith
Posts: 92
Joined: Sun Oct 17, 2021 10:21 pm

Re: HPFP control strategy

Post by ssmith »

mck1117 wrote:
Thu Nov 04, 2021 3:52 am
ssmith wrote:
Thu Nov 04, 2021 3:40 am
Oh I forgot to mention decay rate. The HPFP has no way to lower rail pressure other than the emergency relief valve or injecting fuel. So if the target pressure rapidly decreases, you need some logic to say "no, that's not really achievable, lets only lower the pressure by a certain amount compared to last time." That works well enough. Though I'm curious if we could make it a little better by understanding when the injectors are off completely (due to overrun?) and not decrease the target at all then. It may or may not be worth the extra tuning step though.
I know for a fact my Focus didn't do that. It dropped the target as fast as it wanted to, and just let the pressure come down as fuel was injected (or not come down if DFCO was active!).

Blue is target, red is actual. White is injector pulse width:

image.png
Interesting. Well I guess 'need' is overstating it ;-) How about nice to have? It prevents integral winddown, which can be nice for when you get back on it.

I never mentioned it explicitly but in the code I wrote, I simply clamp the integral against the range of control (0%-100% of actual pump request). So if the math says you need 20%, the integral is limited to -20% to 80%.
Post Reply