PID solenoid air pressure control

Shafto

Senior Member
I've starting building a electronic control for a solenoid valve to control the wastegate actuator on my turbo charger, which diverts exhaust gasses around the turbine when open, lowering the manifold pressure, or "boost" as it's known.

I know many cringe at the picaxe in the car situation, but this is not a road car. I've used other picaxe projects for monitoring temps and pressure and run them from the same 5V line that the vehicle ECU uses, mounted inside the ECU box, with no problems for years. The ECU itself has already been modified, the EPROM chip removed, and a flash chip installed that is programmed from my laptop through the OBDII port.


Goal of project: To reduce the time it takes to reach the desired boost level and reduce overshoot.

First off, for those interested, here's a great explanation of how a turbocharging system in an IC engine works.

http://auto.howstuffworks.com/turbo1.htm

The part I am trying to control, the wastegate, uses a spring that is set to a certain pressure, in my car it's a 10psi spring. If I hook a vacuum line from my intake manifold (being pressurized by the turbo) to the wastegate directly it will open in a lazy fashion and hold pressure at around 10psi, but it will start opening before 10psi, and thus it will build boost slowly. The goal is to hold the wastegate closed by not letting is see the boost pressure signal until the exact moment you want it to slam open, and you use a spring only stiff enough to hold the wastegate closed during peak exhaust pressures at high revs. This way when the solenoid lets the valve see the pressure, say 16psi, it will react very quickly on the 10psi spring to open the valve.

The system I describe is basically how it comes from the factory, but the solenoid control in the ECU isn't accessible to me to be able to adjust the boost pressures. Many other turbocharged vehicles will use a "manual boost controller" to overcome the adjustability issue by using an adjustable ball and spring valve to hide the boost signal from the wastegate until the spring in the manual boost controller is overcome by the boost pressure. This works, but it's somewhat similar to just using the wastegate spring only adjustable, it will open slowly, and most of the time, will spike 1-3psi above your desired setting for a short period of time.

I read the wiki about PID control a few months ago just because I stumbled across it and was interested. I now have a perfect opportunity to learn how to build a PID controller for a real life situation and I've been reading a bunch more.

Using the laptop hooked up to the OBDII port, I can log the MAP (manifold absolute pressure) sensor that I have hooked up to an unused ECU input, so I will be able to see the boost pressure curve over time and compare it the standard control method, and also be able to tune the PID gains for the fastest pressure build with minimal overshoot.

The Factory system uses a 2port valve that bleeds pressure through a restrictor, so the wastegate still always sees some boost pressure, not ideal. The valve I will be using is a 3 port valve. Here's a diagram to show the difference between the two.






I also notice the stock valve is normally open, and thus must be active all time to keep the wastegate closed, which it is most of the time, so the solenoid is active until the wastegate needs to open, which isn't unless you're pedaling it good. The only reason I can think of it that if the solenoid failed it would be open, and therefore the engine wouldn't turn into a bomb from being over-pressured by the turbo. I plan to use the valve in a normally closed configuration, I'll be using another solenoid though, as a fail safe to open the wastegate with a hobbs switch input from over pressure. It will also open if the ECU senses detonation in the engine through the knock sensor.

So, now that you have all the background on the project, here's what I've got so far:

The MAP sensor is a 0-5V analogue signal that is 0-3BAR of absolute pressure, so the first bar is vacuum, not pressure. Since I'm used to dealing with pressure as PSI, I included the conversion in the code. This is kind of pseudo code though, since I can't use negative numbers and such, I'm first just trying to wrap my head around the way everything is going to work before I figure out the exact way I need to write everything, I'm pretty new with code.

Code:
symbol PSItarget = 16                                           'target pressure rating

let 3BARin = b0                                                 '0-5V 3BAR MAP input (Manifold Absolute Pressure)

let Vtarget = b1                                                'target voltage that correlates to the target psi (for ease of use)

let Vtarget = PSItarget * 10/145 * 167/100 + 167/100 * 51       'convert PSItarget to voltage target (16psi / 14.5 = 1.1bar * 1.67 (1bar in voltage) + 1.67 (psig to psi) * 55 (8bit conversion)

let error = b2                                                  'proportional error in PID process

let previous_error = b3                                         'previous error for integral calculation

let integral = b4                                               'integral error

let derivative = b5                                             'derivative error

let output_correction = b6                                      'corrective PWM measures to open or close valve

symbol Kp = ?                                                   'proportional gain

symbol Ki = ?                                                   'integral gain

symbol Kd = ?                                                   'derivative gain

symbol dt = ?                                                   'wait time

let b7 = current_output                                         'current PWM output to valve

PWMout 2,49,current_output                                      'start PWM (0-180 for 0-90% duty, Normally Closed 20,000hz)

current_output = 0
previous_error = 0
integral = 0




MAIN:

error = Vtarget - 3BARin 
                                        
integral = integral + error*dt 
                                  
derivative = error - previous_error/dt
                           
output_correction = Kp*error + Ki*integral + Kd*derivative  
                
previous_error = error

current_output + output_correction = current_output

PWMduty,current_output

pause dt


goto main
So am I at least on the right track? I'm hoping the controller will work good without any feed forward data, because if I had to make a table it would have to be 3D with target duty cycles vs rpm vs engine load, and would complicate things a lot.

Also the solenoid wants a 20Hz signal, not 20,000Hz, but again.. something I will figure out as I go. I know there are a few different ways to go about slow PWM, I was thinking the easiest may just be to lower it enough that I can capture it with pulsein with another picaxe and divide it by whatever I need to and the use pulseout to get 20Hz.

So, I'm not too far along on the implementation, but I sure have done a lot of reading and thinking so far, and I think I'm at the stage where I'd like some feedback, and I know this is the best place for it!

Thanks guys.
 
Last edited:
Top