So I've got the pressure input on pin2, and modified the code.
It doesn't work well! Instant mpg is zero, current is 999. What have I done wrong? CPU is at 500%...
This is part of the modified code, I've added 2 lines.
--------------------------------------------------------
#define looptime 1000000ul/loopsPerSecond //1/2 second
void loop (void){
if(newRun !=1)
initGuino();//go through the initialization screen
unsigned long lastActivity =microSeconds();
unsigned long tankHold; //state at point of last activity
while(true){
unsigned long loopStart=microSeconds();
int press = analogRead(2) + 1; //press is common rail pressure approx in bars
instant.reset(); //clear instant
cli();
instant.update(tmpTrip); //"copy" of tmpTrip in instant now
tmpTrip.reset(); //reset tmpTrip first so we don't lose too many interrupts
sei();
instant.injHius = press * instant.injHius; //correct injector for pressure variation
|