Quote:
Originally Posted by Pawtuckett
So, would it be possible for me to modify the code my MPGuino is using? I know you're currently working on modifying the original MPGuino code, but I'm not that great of a programmer. At least, I'm not familiar with Arduino, that is.
|
Everyone's got to start somewhere. Both rationality checks should be able to be squeezed into the existing 0.86 code without too much fuss, though they'll be effectively hardcoded in. That means that, in order to change the thresholds, changes would have to be made to the modified 0.86 code itself. (My code has an EEPROM parameter associated with each rationality check).
The below code is pasted for reference. Only the boldfaced stuff has to be added into the 0.86 code.
Code:
pFunc eventFuncs[] = { enableVSS, enableLButton, enableMButton, enableRButton, injTimeOutCheck };
#define eventFuncSize (sizeof(eventFuncs)/sizeof(pFunc))
//define the event IDs
#define enableVSSID 0
#define enableLButtonID 1
#define enableMButtonID 2
#define enableRButtonID 3
#define injTimeOutCheckID 4
volatile boolean injFlop = 0;
void injTimeOutCheck() {
injFlop = 0;
}
Now, this other stuff will have to replace the existing processInjOpen/processInjClosed functions, in their entirety.
Code:
// The value of 240000ul used below for the low engine speed rationality check assumes the following:
// The engine uses sequential port injection (that is, one injection event every other crank revolution)
// 400 RPM engine speed
// 80% injector duty cycle at the given engine speed
// MPGuino running on 16 MHz clocked hardware
// Use a value of 300000ul for a 20 MHz chip
void processInjOpen(void) {
injHiStart = microSeconds();
injFlop = 1;
addEvent(injTimeOutCheckID, 500); // use 625 on a 20 MHz system
}
void processInjClosed(void) {
unsigned long t = microSeconds();
unsigned long x = elapsedMicroseconds(injHiStart, t);
if ((x > injectorSettleTime) && (x < 240000ul) && (injFlop != 0)) {
x -= injectorSettleTime;
tmpTrip.injHius += x;
tmpTrip.injPulses++;
if (tmpInstInjStart != nil) {
if (x > 0) tmpInstInjTot += x;
tmpInstInjCount++;
} else {
tmpInstInjStart = t;
}
tmpInstInjEnd = t;
}
injFlop = 0;
}