Electronic Boost Controller forTurboChargedEngine

Hello there,
i´m a new member of the Arduino Community. I searched for a simple Contoller to build my electonic Boost Contoller for my Volvo. I found the Arduino 2k9 Board . So i´ve written my first programm an it works good but i´ve to made some fine tuning on this programm: Here is it Rev 1.0:

/*Electronic Boost Controller for classical Turbo Charged endgines (without an active Boost Control)
 written for an Volvo B230FK an B230FT engine to raise the Boost for a better performance and increase
 horse Power and torque (org 136 HP / 230NM to 190HP and about 290-300NM). 
 Function:
 There must be an specified load  about 50% Load 
 an kncokcounter must have on value under 10 steps till the kock counter is under 10.
 then the boost will be increased on the fixed values in boost map
 On full Throttle an fixed overboost over 0,1 till 02bar will added to the normal boost.
 if there is the knock signal (kockcounter over 10) during the over- and normal-boost the 
 Solenoid will decrease the boost in 0,15bar steps till the knocks will be away
 The boostcontoller will work only over 2000RPM to save the enigne of torque peaks on lovw rpms
 wirtten by Daniel Herr (Germany)  */

int ledPin=13;       // Status LED
int PWMout=10;       //PWM signal for Solenoid driver (IRF540N)
int PWMval=0;          //Variable for PWM-Value 
int loadin=1;        //Analog inptut Loadlevel form AMM (Air-Mass-Meter) it´s an signal 1-5.1Volts
int loadlvl;         // Variable for Loadlevel
int rpmin=0;         //Analog input actual RPM Value
int rpmact;          //Variable for actual RPM Value
int PWMval1;            //puffer Value 1
int PWMval2;            //puffer Value 2
int PWMval3;            //puffer Value 3
int knckin=2;        //digital input from ECU Knocks are detected 
int knck;            //variable for kock procedure
int fts=3;           //digital  input full-throttle switch
int bston=4;         //digital input boost controller active 
int bstst= LOW;      //stata Variable of boost switch
int thrt;            //state of Throttl switch
int knocks=0;        //Knock Counter
int en=1;
//Map for Base Value wich use for the Solenoid PWM signal (rpm20 means 2000 RPM)
//2000-2900RPM
const int rpm20=100;        
const int rpm21=110;        // rpm21=2100 an so on ......
const int rpm22=120;
const int rpm23=130;
const int rpm24=140;
const int rpm25=150;
const int rpm26=160;
const int rpm27=170;
const int rpm28=180;
const int rpm29=190;
//3000-3900RPM
const int rpm30=200;
const int rpm31=210;
const int rpm32=220;
const int rpm33=230;
const int rpm34=240;
const int rpm35=250;
const int rpm36=10;
const int rpm37=20;
const int rpm38=30;
const int rpm39=40;
//4000-4900RPM
const int rpm40=50;
const int rpm41=60;
const int rpm42=70;
const int rpm43=80;
const int rpm44=90;
const int rpm45=100;
const int rpm46=110;
const int rpm47=120;
const int rpm48=130;
const int rpm49=140;
//5000-5900RPM
const int rpm50=150;
const int rpm51=160;
const int rpm52=170;
const int rpm53=180;
const int rpm54=190;
const int rpm55=200;      
const int rpm56=210;
const int rpm57=220;
const int rpm58=230;
const int rpm59=240;      
//6000-65000RPM
const int rpm60=250;
const int rpm61=10;
const int rpm62=20;
const int rpm63=30;
const int rpm64=40;      //.......
const int rpm65=50;      //value for 6500 RPM



void setup(){
  pinMode (ledPin, OUTPUT);
  pinMode (PWMout, OUTPUT);
  pinMode (loadin, INPUT);
  pinMode (rpmin, INPUT);
  pinMode (knckin, INPUT);
  digitalWrite (knckin, LOW);
  pinMode (fts, INPUT);
  pinMode (bston, INPUT);
  Serial.begin(9600);
}

void loop(){
  bstst=digitalRead(bston);      //Request Boost Controller switched on? 
  bstst=HIGH;                  //Override Swich Contact for testing
  knck=digitalRead(knckin);        //Is there a Knock Signal ?
  thrt=digitalRead(fts);          // Throttle Fullspeed switch on?
  thrt=0;
  if (knck==1){                    // If Knock Signal detected counter was increase by 1
    knocks=++knocks;
  }
  else if (knck==0 && knocks >=1){          // If no Knock Signal detected and counter is bigger then 0 increase Counter by 1 unit
    knocks=--knocks;
  }
  //loadlvl=analogRead(loadin);    // Read Engine Load Signal
  loadlvl=600;                     // Override Load Signal for testing
  rpmact=analogRead(rpmin);
  rpmact=map(rpmact, 0 , 1023, 1 ,65);
  // if (rpmact <=19) PWMval=0;
  // if (thrt==1 && rpmact <=19) PWMval=255;
  if (knocks < 20 && en==1 && (loadlvl >=520 || thrt==1)) {
    switch (rpmact) {
    default:
      PWMval=0;
      break;
    case 20:
      PWMval=rpm20;
      break;  
    case 21:
      PWMval=rpm21;
      break;
    case 22:
      PWMval=rpm22;
      break;    
    case 23:
      PWMval=rpm23;
      break;
    case 24:
      PWMval=rpm24;
      break;
    case 25:
      PWMval=rpm25;
      break;
    case 26:
      PWMval=rpm26;
      break;
    case 27:
      PWMval=rpm27;
      break;
    case 28:
      PWMval=rpm28;
      break;
    case 29:
      PWMval=rpm29;
      break;
    case 30:
      PWMval=rpm30;
      break;
    case 31:
      PWMval=rpm31;
      break;
    case 32:
      PWMval=rpm32;
      break;    
    case 33:
      PWMval=rpm33;
      break;
    case 34:
      PWMval=rpm34;
      break;
    case 35:
      PWMval=rpm35;
      break;
    case 36:
      PWMval=rpm36;
      break;
    case 37:
      PWMval=rpm37;
      break;
    case 38:
      PWMval=rpm38;
      break;
    case 39:
      PWMval=rpm39;
      break;
    case 40:
      PWMval=rpm40;
      break;
    case 41:
      PWMval=rpm41;
      break;
    case 42:
      PWMval=rpm42;
      break;    
    case 43:
      PWMval=rpm43;
      break;
    case 44:
      PWMval=rpm44;
      break;
    case 45:
      PWMval=rpm45;
      break;
    case 46:
      PWMval=rpm46;
      break;
    case 47:
      PWMval=rpm47;
      break;
    case 48:
      PWMval=rpm48;
      break;
    case 49:
      PWMval=rpm49;
      break;
    case 50:
      PWMval=rpm50;
      break;
    case 51:
      PWMval=rpm51;
      break;
    case 52:
      PWMval=rpm52;
      break;    
    case 53:
      PWMval=rpm53;
      break;
    case 54:
      PWMval=rpm54;
      break;
    case 55:
      PWMval=rpm55;
      break;
    case 56:
      PWMval=rpm56;
      break;
    case 57:
      PWMval=rpm57;
      break;
    case 58:
      PWMval=rpm58;
      break;
    case 59:
      PWMval=rpm59;
      break;
    case 60:
      PWMval=rpm60;
      break;
    case 61:
      PWMval=rpm61;
      break;
    case 62:
      PWMval=rpm62;
      break;    
    case 63:
      PWMval=rpm63;
      break;
    case 64:
      PWMval=rpm64;
      break;
    case 65:
      PWMval=rpm65;
      break;
    }
  PWMval1=PWMval;  
}
    else if (knocks >=20 && PWMval1 >=10)
  {
    PWMval1=PWMval1-=10 ;
  en=0;  
  }
  else if (knocks <=20 && PWMval1 < PWMval)
  {
  PWMval1=PWMval1+=10;
  if (PWMval1==PWMval){
    en=1;
    }
  }

  analogWrite (PWMout,PWMval1);


  Serial.print("Drehzalistwert: ");
  Serial.println(rpmact);
  Serial.print("Klopfwert: ");
  Serial.println(knocks);
  Serial.print("PWM Wert: ");
  Serial.println(PWMval1);
  Serial.print("Klopfeingang: ");
  Serial.println(knck);
  delay (100);
  if (PWMval >= 30){
    digitalWrite (ledPin, HIGH);
  }
  else{ 
    digitalWrite (ledPin, LOW);
  }

}

...someone will be by, shortly, to remind you about using the code block tags around your code blocks...

...oh, wait! I just did that! :wink:

What did you mean. Explain

I mean that, when you're citing code examples, rather than pasting it into the editor directly, you should put the [ code ] and [ /code ] brackets around it so that it shows up

// ...like this
//
void startup() {
// initialize stuff...
}

void loop() {
//  do stuff...
}

...in a nice monospaced font, instead of all crammed into the message body in a hard-to-read proportional font.

if you cannot remember the proper encoding method to post code in the forum, just click the icon above the message entry box with the [#] symbol in it... it will add the proper start and end tags for you, automatically, and place your cursor between them so that when you paste your code block from your clipboard, it'll automatically show up in the code block on the finished message.

:sunglasses:

Shortly i will extend my project with an diplay 2*16 Rows and some buttons to change values

Hello,

what solenoid are you using? A "N75" ? Is the PWM Out Frequency working for that or do you need to change it that it fits the solenoid?

Got some shematics?? The Solenoid / RPM and Knock sensor would be realy interesting :slight_smile:

And you could get a real lookup map, with linear interpolation, got the code fragments here: GitHub - designer2k2/multidisplay: The MultiDisplay Project, An opensource datalogger, boost controller and display for cars

got something similiar working on and the boostcontroller is planned but to get some inputs on that would ease my work :slight_smile:

You are an austrian an i´m german also lets talk german via e-Mail
Dnl (dot)Hrr (ät) gmx (dot)de
also
skype

danielherr1980

did anyone ever came out of this ?
my friend just bought a 500$ electronic boost controller for his RB26 and I think it can be done with a 12$ arduino and a 5$ solenoid air valve !

its included into my multidisplay: N75, Boost Controller - MDForum

bofh is running his corrado with that :sunglasses:

I think the name "multidisplay" is a bit of an understatement

at some point you will probably drive the injectors, and have a 434mhz RF input, remote starting, a gps & gprs for anti-theft and recovery, RFID key fob to replace the ignition key, and ion sensing for knock prevention !! and probably other things :wink:

btw instead of using an solenoid valve to control vacuum from the intake manifold to the wastegate pneumatic actuators, why not use a linear actuator and directly actuate the wastegates ?
also is there a way to sense turbo shaft speed ? (halls effect sensor near the impeller maybe ?)

"is there a way to sense turbo shaft speed?"
30 years ago in the engine lab we would remove the standard nut and install a magnetic nut on the compressor wheel side. Forgot to take some off prior to $tarting of field testing. make sure you use a torque wrench. :slight_smile:

max speed was around 100K rpm, depending on wheel design, for a turbo that was used on a 400hp class 8 truck engine. Much bigger wheel size then any you will find on a street car.

how would you read it ?

I suppose a halls effect sensor would be too slow ?
100krpm is 1.7 kHz also an halls effect sensor would disturb the airflow ?

mag p/u "hose" clamped to the outside of the compressor inlet inline with the magnetic nut.

I would guess the turbo on a car with a lot smaller wheel exceeds 100Krpm at full power/airflow.

Now the Project is much bigger than on the beginning at the top of these thread now i use an max127 for analogread (better precision) an an 40*2 Display and big boostmap * and correct the boost at max Load also the max Injetion time is diplayed and if the maxtime is reached the boost increase. Its possible to drive always at 100% power.Also the Lambda is displayed The Spinuptime of the charger is much faster.
The Code is about 10.5kB big!

do you monitor the inlet manifold temperature also? Are you altitude correcting/monitoring (absolute preesure) to avoid $$##%#$ when crossing a high altitude pass?

Or just looking at the anti-knock sensor and rolling back the boost/timing as needed?

thanks -- no need to know -- just wondering from my paid fun (work) years ago.

kindest,
-b

You don´t need the air temparature, If you interpete the AMM signal. The AMM measure the mainfold air with an correcture of temperature. In my Case i measure the Absolute air pressure with an MPX4250AP form freescale. An PID-Regulator measure the diffrence bettween Map and real Pressure an correct them with increase or decrease the PWM Value for the solenoid.
My inputs to the controller are:
-AMM (5V max load)
-Injector time (analog Filtered)
-Lambda
-Absoulte Air Pressure in Mainfold
-RPM over LM2907
-Knocksensor

With these sensor you always see what happened at the engine so you can react very fast (5ms Cylce time!!!)

volvodani, would you share your code?

bofh made it with the pid libary, that consumes a lot of space but gives perfect control and the boost stability is impressive...

There some bugs and i have to clean up the code it is dvided in 6 parts and without the comments on the right place noone would understand :wink:

I hope you would share it !

many people only want to share it when it's "nice enough to be seen by others" but then never quite reach that point and the precious information never gets out

I am going to make one of these in the not so distant future (as part of a larger engine management system) and this would help me re-invent the wheel a little less !

are you using a solenoid valve that is just between the intake manifold vacuum and the wastegate pneumatic actuators ?
or do you use a solenoid for direct actuation of the wastegate ?

my friend's commercially made electronic boost controller controls a 3-port solenoid valve (not sure what is the internal configuration yet) so it's just restricting vacuum electrically, and I guess there is a "vacuum tank" on the 3rd port

also I think everyone doing car-related arduino hacking should get together to coordinate the efforts because I think there is a lot of "re-inventing the wheel" going on between projects

shodan, i would like such a meeting/forum/whatever too!!!

for the boost thing, you neet a proportional valve (on VW / Audi / Seat / Skoda cars its always N75 named).
you drive it with 12V PWM, and the duty defines ho much boost you put on the wastegate.
(the valve is supplied by your manifold pressure, so it will only work when you have boost)
PWM frequency is mostly around 30Hz and you will need a Mosfet stage capable of at least 5A to drive the valve smoothly...