advice needed for arduino as diesel injection brain...

Panther95:
Are there any update's about using Arduino with common rail?

Not working yet, have been a bit busy with other aspects of the machine but did come somewhat closer.
Currently the electronics for the PWM driver for the pump pressure and the alternator are being made and the alternator housing is finished.
Also have some testing to do since my new injectors are slightly different from my previous ones.

My previous project with timer stuff and injector drivers in it can be found at: http://www.minimumrisk.nl/articles.php?lng=nl&pg=270

Last code looks like this:

/*
  Cuprum-2.0 simplified 1-3-4-2 cylinder common rail injection system for Arduino Mega.
  
  Using interrupts for timing injections cycle, a timing disc (alternator) is mounted to camshaft.
  Throttle position is read from potentiometer.
  
  Base rule for the system is that we want all fuel injected at 10 crank degree before TDP:
  - timer 2 gives pulse for cylinder 1
  - wait (180 degrees in uS at current rpm) - injection time - (10 degrees in uS at current rpm)
  
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground, output will be 0-1023.
  Attach timing signals to external interrupts: cyl1 pin 3, cyl2 pin 21, cyl3 pin 20 and cyl4 pin 19.
  Attach injector drivers: cyl1 pin 4, cyl2 pin 5, cyl3 pin 6 and cyl4 pin 7.
*/

// setup pin for throttle potentiometer:
int ThrottlePin = A0;
unsigned long ThrottleValue = 0;
unsigned long ThrottleDuration = 0;
// base idle injectiontime is 100uS
unsigned long IdleDuration = 100;
// define throttle calibration values:
// we like to inject from -45 to -10 TDP making 35 degree injection duration max.
// crank duration in uS: (1000000/(rpm/60))/360*35
// at 10K rpm that is 583uS since the throttle has 1023 steps 1023/583=1.75
float ThrottleCalib = 1.75;
// define injection delay
unsigned long InjectionDelay = 0;
// define microsecond timeframe between 2 injects = duration 90 degree camshaft/ 180 degree crankshaft
unsigned long TimeFrame = 0;
unsigned long TimeOld = 0;
unsigned long Delay = 0;
// setup timer pins for interrupts:
int cyl1 = 1;
int cyl2 = 2;
int cyl3 = 3;
int cyl4 = 4;
volatile int state = LOW;
// setup pins for injector drivers:
int inj1 = 4;
int inj2 = 5;
int inj3 = 6;
int inj4 = 7; 

void setup()
{
  // initialize the digital injector pins as an output:
  pinMode(inj1, OUTPUT);     
  pinMode(inj2, OUTPUT);     
  pinMode(inj3, OUTPUT);     
  pinMode(inj4, OUTPUT);
  // attach action when interrupt gets actived:
  pinMode(cyl1, INPUT);
  attachInterrupt(1, inject1, RISING);
  pinMode(cyl2, INPUT);
  attachInterrupt(2, inject2, RISING);
  pinMode(cyl3, INPUT);
  attachInterrupt(3, inject3, RISING);
  pinMode(cyl4, INPUT);
  attachInterrupt(4, inject4, RISING);
}

void loop()
{
  // read the throttle input on analog pin 0:
  ThrottleValue = analogRead(ThrottlePin);
  // see if we are trying to have fun
  if (ThrottleValue > 5)
    {
    // injection delay uS/180*170 to make sure all juice is injected 10 degree before TDP.
    InjectionDelay = TimeFrame/18*17;
    // recalculate throttle value to wanted microseconds:
    ThrottleDuration = ThrottleValue/ThrottleCalib;
    // check the interrupts:
    digitalWrite(cyl1, state);
    digitalWrite(cyl2, state);
    digitalWrite(cyl3, state);
    digitalWrite(cyl4, state);
    }
  // it seems we are idling
  else
    {
    // on idle we want injecting to stop at TDP not before
    InjectionDelay = TimeFrame;
    // if we are running 900rpm we reduce injection time
    if (TimeFrame > 33333)
      {
      // reduce injection time
      IdleDuration=IdleDuration-5;
      ThrottleDuration = IdleDuration;
      }
    // if we are running 800rpm we inject a bit longer
    else if (TimeFrame < 37500)
      {
      // expand injection time
      IdleDuration=IdleDuration+5;
      ThrottleDuration = IdleDuration;
      }
    // check the interrupts:
    digitalWrite(cyl1, state);
    digitalWrite(cyl2, state);
    digitalWrite(cyl3, state);
    digitalWrite(cyl4, state);
    }
}

void inject1()
{
  // find out how many uS 90 degrees camshaft is
  TimeFrame = (micros() - TimeOld);
  TimeOld = TimeFrame;
  Delay = InjectionDelay-ThrottleDuration;
  // open injector, hold it and close
  digitalWrite(inj1, HIGH);
  delayMicroseconds(ThrottleDuration);
  digitalWrite(inj1, LOW);
}

void inject2()
{
  TimeFrame = (micros() - TimeOld);
  TimeOld = TimeFrame;
  Delay = TimeFrame/18*17-ThrottleDuration;
  digitalWrite(inj2, HIGH);
  delayMicroseconds(ThrottleDuration);
  digitalWrite(inj2, LOW);
}

void inject3()
{
  TimeFrame = (micros() - TimeOld);
  TimeOld = TimeFrame;
  Delay = TimeFrame/18*17-ThrottleDuration;
  digitalWrite(inj3, HIGH);
  delayMicroseconds(ThrottleDuration);
  digitalWrite(inj3, LOW);
}

void inject4()
{
  TimeFrame = (micros() - TimeOld);
  TimeOld = TimeFrame;
  Delay = TimeFrame/18*17-ThrottleDuration;
  digitalWrite(inj4, HIGH);
  delayMicroseconds(ThrottleDuration);
  digitalWrite(inj4, LOW);
}