advice needed for arduino as diesel injection brain...

PaulS:

long previousMillis = 0;     // will store last time injection time was updated

Time variables are unsigned long. You don't normally need to accommodate time running backwards. At least not in our universe.

I don't understand.
In bash to would mean "if $currentTime minus $previousTime is larger then Interval (throttle position) stop injecting"???

It means, without the $, exactly the same thing in C.

I new that but I wanted to know what cyclegadgets reason was with that...

PaulS:

  if(posPin == 0) // of camshaft position is 0 degrees then fire cylinder 1

if(posPin == 256) // of camshaft position is 90 degrees then fire cylinder 3
  if(posPin == 512) // of camshaft position is 180 degrees then fire cylinder 4
  if(posPin == 768) // of camshaft position is 270 degrees then fire cylinder 2



I don't know what kind of analog device you are reading, but depending on exact values from an ADC with a resolution of +/- 1 is not a good idea. Your injectors are going to not fire when they are supposed to, a lot.

When to fire the injector. with respect to cam position, is typically a function of load, engine RPM, and a host of other sensor readings. I fear that you are oversimplifying a very complex process.

I have know clue how to read a rotary encoder so I presumed that it would give me an output from 0-1023 like a potentiometer would. (the documentation of the automotive encoder also was talking about 1024 steps)
You are writing that the injectors will gonna skip firing with that resolution, is that due to the duration of a single encoder step compared to the time the loop lasts?
If so a loop won't work with my timing disc either since at 9K rpm the pulse from that is about 1microsecond. (that is why I tried to use interrupts in my first code)

A combustion engine isn't a very complex process at all, current automotive products make it complex due to drivability, environmental issues and so on.
In tractor pulling we need an engine that runs at idle and at full throttle, we don't shift but open throttle and hold on.
We have a 2.0l diesel engine making 400HP at 8000rpm with a boost pressure of 5bar, when hoocked on we rev up to 4000rpm (3bar of boost) and release the clutch.
This is our conventional injected machine:
https://picasaweb.google.com/lh/photo/4USFns0LHkMvU5lqaYSGmdMTjNZETYmyPJy0liipFm0?feat=directlink
And this is our common-rail, no uC used, ne555, HEF4044 and HEF4081.
https://picasaweb.google.com/lh/photo/do7wdb7tZnFQsgpcPFTMmNMTjNZETYmyPJy0liipFm0?feat=directlink

Throttle controls the injection time, the fuel pressure (800-2500bar) and timing advance (-10 at idle and -35 at full throttle) so the only thing the uC has to do is read an input and opens an output for a throttle defined amount of time. (ok, 4 times in a cycle)

If I understand correctly;
rotation encoder isn't a good idea.
using a loop either.
So back to my first thought with using 4 interrupts and a distributor for giving injection pulses?