From 0fd819fe3b34a368c4623cc80c4b7d61d0c7d6c3 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 6 Feb 2013 10:43:17 +1100 Subject: [PATCH] Change the pulsewidth calc to us rather than ms --- kartduino.ino | 6 ++++++ utils.h | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/kartduino.ino b/kartduino.ino index 97af50a3..f43ee57d 100644 --- a/kartduino.ino +++ b/kartduino.ino @@ -103,6 +103,12 @@ void loop() //Serial.println(VE); Serial.print("VE: "); Serial.println(VE); + + Serial.print("Injector pulsewidth: "); + Serial.println(pulseWidth); + //Serial.println(req_fuel * (float)(VE/100.0) * (float)(MAP/100.0) * (float)(100/100.0) + engineInjectorDeadTime); + //Serial.println( (float)(req_fuel * (float)(VE/100)) ); + //Serial.println( (float)(VE/100.0)); } else diff --git a/utils.h b/utils.h index 47843b92..c673afcc 100644 --- a/utils.h +++ b/utils.h @@ -15,16 +15,16 @@ int AIRDEN(int MAP, int temp) } /* -This functino retuns a pulsewidth time (in tenths of a ms) given the following: +This functino retuns a pulsewidth time (in us) given the following: REQ_FUEL VE: Lookup from the main MAP vs RPM fuel table MAP: In KPa, read from the sensor GammaE: Sum of Enrichment factors (Cold start, acceleration). This is a multiplication factor (Eg to add 10%, this should be 110) injOpen: Injector open time. The time the injector take to open in tenths of a ms */ -int PW(int REQ_FUEL, int VE, int MAP, int GammaE, int injOpen) +int PW(float REQ_FUEL, int VE, int MAP, int GammaE, float injOpen) { - return REQ_FUEL * (VE/100) * (MAP/100) * (GammaE/100) + injOpen; + return (REQ_FUEL * (float)(VE/100.0) * (float)(MAP/100.0) * (float)(GammaE/100.0) + injOpen) * 1000; } /* Determine the Gamma Enrichment number. Forumla borrowed from MS2 manual... may be skipped/simplified for arduino!