Code:
// for ls1 / D580 coils
#define DWELL_TGT 6.1 // dwell target in milliseconds - edit to your liking
#define CRANK_DWELL_TGT 3.6 // dwell target for cranking / startup
#define ACCEL_COMP 0.6 // for accell comp table
const uint8_t PROGMEM dwellTable[VOLT_DIVS][RPM_DIVS] = {
{ 1, 2, 3, 4, 5, 5, 6, 7, 14, 31, 41, 51, 62, 71, 82, 92, 102, 113, 123, 133, 144, 155, 163, 173, 185, 198, 207, 230, 250, 255, 255, 255, 255, 255 }, << last cell should be 346.9
{ 1, 2, 2, 3, 4, 5, 5, 6, 12, 27, 37, 46, 55, 64, 73, 83, 92, 101, 110, 119, 129, 138, 146, 155, 165, 177, 185, 205, 224, 238, 255, 255, 255, 255 },
{ 1, 1, 2, 3, 3, 4, 5, 5, 11, 25, 34, 42, 51, 59, 67, 76, 84, 93, 101, 109, 119, 127, 135, 143, 152, 163, 171, 189, 206, 219, 241, 255, 255, 255 },
{ 1, 1, 2, 2, 3, 4, 4, 5, 10, 23, 31, 39, 47, 55, 63, 71, 78, 87, 94, 102, 110, 118, 125, 133, 141, 151, 159, 176, 191, 203, 224, 241, 250, 255 }, << last cell should be 265.3
{ 1, 1, 2, 2, 3, 3, 4, 4, 9, 22, 29, 37, 44, 51, 59, 66, 73, 81, 88, 95, 103, 111, 117, 124, 133, 142, 149, 165, 179, 191, 210, 226, 235, 254 },
{ 1, 1, 2, 2, 3, 3, 4, 4, 8, 21, 28, 36, 43, 50, 57, 64, 71, 79, 86, 92, 100, 107, 113, 120, 128, 137, 144, 159, 174, 184, 203, 219, 227, 246 },
{ 1, 1, 1, 2, 2, 3, 3, 4, 7, 20, 27, 34, 41, 47, 54, 61, 67, 75, 81, 88, 95, 102, 108, 114, 122, 130, 137, 151, 165, 175, 193, 207, 215, 233 },
{ 1, 1, 1, 2, 2, 3, 3, 3, 7, 19, 26, 33, 39, 45, 52, 59, 65, 72, 78, 84, 92, 98, 104, 110, 117, 126, 132, 146, 159, 169, 186, 200, 208, 225 },
{ 1, 1, 1, 2, 2, 2, 3, 3, 6, 19, 25, 31, 38, 44, 50, 57, 63, 69, 75, 81, 88, 95, 100, 106, 113, 121, 127, 141, 153, 163, 179, 193, 200, 217 },
{ 1, 1, 1, 2, 2, 2, 3, 3, 6, 18, 25, 31, 37, 43, 49, 55, 61, 68, 74, 80, 86, 93, 98, 104, 111, 119, 124, 138, 150, 159, 176, 189, 196, 213 }
};
I was starting to think this wasn't worth doing correctly because these are some fairly dumb operating ranges (< 10.49 volts, > 5600 rpm), but making the dwell table a 16 bit uint only uses another ~300 bytes of flash but I've also found a few things I can optimize and a few routines that can be eliminated so it will only cost a hundred bytes or so.
Bookmarks