From 439a936d87b96fe7eac909c662b7a869b71ecebc Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Tue, 5 Feb 2013 22:31:17 +1100 Subject: [PATCH] Added some testing code and fixed some minor issues (req_fuel must be float) --- kartduino.ino | 18 +++++++++++++++--- testing.h | 25 +++++++++++++------------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/kartduino.ino b/kartduino.ino index b2cc8c32..ceef5aa4 100644 --- a/kartduino.ino +++ b/kartduino.ino @@ -23,7 +23,7 @@ Need to calculate the req_fuel figure here, preferably in pre-processor macro #include "table.h" #include "testing.h" -int req_fuel = ((engineCapacity / engineInjectorSize) / engineCylinders / engineStoich) * 100; // This doesn't seem quite correct, but I can't find why. It will be close enough to start an engine +float req_fuel = ((engineCapacity / engineInjectorSize) / engineCylinders / engineStoich) * 100; // This doesn't seem quite correct, but I can't find why. It will be close enough to start an engine @@ -69,7 +69,7 @@ void setup() { req_fuel = req_fuel / engineSquirtsPerCycle; //The req_fuel calculation above gives the total required fuel (At VE 100%) in the full cycle. If we're doing more than 1 squirt per cycle then we need to split the amount accordingly. (Note that in a non-sequential 4-stroke setup you cannot have less than 2 squirts as you cannot determine the stroke to make the single squirt on) - + Serial.begin(9600); @@ -90,7 +90,7 @@ void loop() } //Get the current MAP value - int MAP = 1; //Placeholder + int MAP = 50; //Placeholder //Perform lookup into fuel map for RPM vs MAP value int VE = getTableValue(fuelTable, rpm, MAP); @@ -102,13 +102,25 @@ void loop() } else { getSync(); } + + Serial.print("Time"); + Serial.println(micros()); + Serial.println(toothLastToothTime); + Serial.println(toothLastMinusOneToothTime); + Serial.println(rpm); + delay(100); } //The get Sync function attempts to wait void getSync() { + //The are some placeholder values so we can get a fake RPM + toothLastMinusOneToothTime = micros(); + delay(1); //A 1000us delay should make for about a 5000rpm test speed with a 12 tooth wheel(60000000us / (1000us * triggerTeeth) + toothLastToothTime = micros(); + hasSync = true; } diff --git a/testing.h b/testing.h index bbe96ff2..147148d3 100644 --- a/testing.h +++ b/testing.h @@ -4,19 +4,20 @@ This file has a few functions that are helpful for testing such as creating dumm /* Aim is to create an 8x8 table that looks like the below: - VE -_____________________________________________ -|100| | | | | | | | 90 | -| 88| -| 75| -| 63| -| 50| -| 38| -| 25| 17 | 21 | -| 13| 15 | 20 | -| | 500|1500|2000|2500|3000|4000|5000|6000| RPM + MAP +______________________________________________ +|100|| 78 | 88 | 92 | 95 | 97 |101 |107 |110 | +| 88|| 58 | +| 75|| 45 | +| 63|| 35 | +| 50|| 28 | 30 +| 38|| 22 | 23 | +| 25|| 17 | 21 | +| 13|| 15 | 20 | 25 | +| || 500|1500|2000|2500|3000|4000|5000|6000| RPM -This is a fairly standard 8x8 VE vs RPM 2D map +This is a fairly realistic 8x8 VE vs RPM 2D map +Here is a run through of how the interpolation would flow: Pass in: x = 1000 y = 20