I've been hacking together a basic water-injection system for Arduino.
The latest project source is kept at:
djlyon / mpgx2 Vapour workbench / source — bitbucket.org
Here's the original code. It's a template for a PDE. It will go into a code generator later.
Basically, dependent on rpm and injector-pulse-length, you will want to change
up and down the value going to your electric water pump with a misting nozzle.
//-----------------------------------------------
//
// mpgx2 Water Injection Template
//
// based upon the script located at:
//
//
Arduino playground - ReadingRPM
//
//-----------------------------------------------
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;
unsigned int WI_PWM_PIN = 3 // The PIN that our Injector pump is on
void setup()
{
Serial.begin(9600);
attachInterrupt(0, rpm_fun, RISING);
rpmcount = 0;
rpm = 0;
timeold = 0;
}
void loop()
{
if (rpmcount >= 20) {
// Update RPM every 20 counts, increase this for better
// RPM resolution, decrease for faster update
rpm = 30*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
Serial.println(rpm,DEC);
// Update the Water-Injection pump
pwm_level = calc_wi_pumpspeed(rpm,fuel_flow);
// Write that value to the water pump pwm
analogWrite(WI_PWM_PIN, val);
}
}
void rpm_fun()
{
rpmcount++;
// Each rotation, this interrupt function is run twice
}
int calc_wi_pumpspeed(int rpm) {
// Customise the water level to the rpm (and later the injector
// pulse length
val = map(val, 0, 1023, 0, 25);
return val
}