View Single Post
Old 10-09-2008, 09:12 PM   #1 (permalink)
TELVM
EcoModding Lurker
 
Join Date: Sep 2008
Location: Spain
Posts: 55

'El Misil' - '91 Opel Calibra 2.0i
Last 3: 29.02 mpg (US)
Thanks: 0
Thanked 0 Times in 0 Posts
How to get instant fuel consumption from Megasquirt

This works for MS1-Extra/MSnS-E, combat proven. Most probably will also work for MS2. No vehicle speed input is required .


Data we must know beforehand:

- 5th gear ratio
- Differential ratio
- Tractive wheel perimeter in centimeters
- Injector flow in cc


For instance in a Miata NA 1.6 the data are:

- 0.814
- 4.300
- 181.4583917 cm
- 205 cc


Then input the data into this formula:

RPM = ((((100*100000)/60)/wheel perimeter)*(5th gear ratio*differential ratio))

For the Miata:

RPM = ((((100*100000)/60)/181.4583917)*(0.814*4.300)) = 3215 (this will be the magic number)


Now open with notepad the msns-extra.ini file, the path is C:\Program files\MegaSquirt\your-project-car-name\msns-extra.ini . Then choose your way ...





OPTION ONE: FOR LITRES/100KM DISPLAY

Look for this paragraph towards the end of the file:


Code:
;****************************************************************************
;  CHANGE THESE TO SUIT YOUR CAR TO GET MPG, MPH, ETC. THIS WILL ONLY WORK WITH A SUITABLE
;  VEHICLE SPEED SENSOR CONNECTED TO MSnS-EXTRA CODE.

   Speed = { 70 }    ; Change this to your actual speed @ 2.5V from VSS circuit
   fuelCC = { 2168 } ; Enter the total flow for all your injectors here in cc/Min

;****************************************************************************
   squirtmul = { divider1 < 2 ? 2 : divider1 < 3 ? 1 : divider1 < 5 ? 0.5 : divider1 < 9 ? 0.25 : divider1 < 17 ? 0.125 : 1 }
   squirts   = { alternate1 > 0 ? rpm100 / 0.6 * squirtmul : rpm100 * 2 * squirtmul / 0.6                                  } ; How many squirts per Sec
   OpenWidth = { injOpen1 * 0.1 }                                            ; Pulse width for injector opening time
   CCpHr     = { pulseWidth < 1 ? 1 : (fuelCC/60) * ((pulseWidth - OpenWidth)/1000) * squirts * 3600                                      } ; cc / hr
   mphTemp   = { fuelADC < 1 ? 0 : (fuelADC * Speed) /127.5               }  ; MPH
   mph       = { mphTemp < 1 ? 0 : mphTemp                                }  ; Ensure we get 0 mph
   USgph     = {  CCpHr / 3785                                            }  ; US Gallons / Hr
   USmpg     = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / USgph              }  ; US Miles / Gallon
   gph       = {  CCpHr / 4546                                            }  ; Real Gallons / Hr
   mpg       = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / gph                }  ; Real Miles / Gallon

;*****************************************************************************

In 'fuelCC' we must enter the injector flow, times number of injectors (if simultaneous injection). Or injector flow, times number of injectors, divided by 2 (if batch injection). For this particular Miata it is (205*4)/2 = 410 :

Code:
;****************************************************************************
;  CHANGE THESE TO SUIT YOUR CAR TO GET MPG, MPH, ETC. THIS WILL ONLY WORK WITH A SUITABLE
;  VEHICLE SPEED SENSOR CONNECTED TO MSnS-EXTRA CODE.

   Speed = { 70 }    ; Change this to your actual speed @ 2.5V from VSS circuit
   fuelCC = { 410 } ; Enter the total flow for all your injectors here in cc/Min

;****************************************************************************
   squirtmul = { divider1 < 2 ? 2 : divider1 < 3 ? 1 : divider1 < 5 ? 0.5 : divider1 < 9 ? 0.25 : divider1 < 17 ? 0.125 : 1 }
   squirts   = { alternate1 > 0 ? rpm100 / 0.6 * squirtmul : rpm100 * 2 * squirtmul / 0.6                                  } ; How many squirts per Sec
   OpenWidth = { injOpen1 * 0.1 }                                            ; Pulse width for injector opening time
   CCpHr     = { pulseWidth < 1 ? 1 : (fuelCC/60) * ((pulseWidth - OpenWidth)/1000) * squirts * 3600                                      } ; cc / hr
   mphTemp   = { fuelADC < 1 ? 0 : (fuelADC * Speed) /127.5               }  ; MPH
   mph       = { mphTemp < 1 ? 0 : mphTemp                                }  ; Ensure we get 0 mph
   USgph     = {  CCpHr / 3785                                            }  ; US Gallons / Hr
   USmpg     = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / USgph              }  ; US Miles / Gallon
   gph       = {  CCpHr / 4546                                            }  ; Real Gallons / Hr
   mpg       = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / gph                }  ; Real Miles / Gallon

;*****************************************************************************

Now we add an user defined variable with its formula:

Code:
;****************************************************************************
;  CHANGE THESE TO SUIT YOUR CAR TO GET MPG, MPH, ETC. THIS WILL ONLY WORK WITH A SUITABLE
;  VEHICLE SPEED SENSOR CONNECTED TO MSnS-EXTRA CODE.

   Speed = { 70 }    ; Change this to your actual speed @ 2.5V from VSS circuit
   fuelCC = { 410 } ; Enter the total flow for all your injectors here in cc/Min

;****************************************************************************
   squirtmul = { divider1 < 2 ? 2 : divider1 < 3 ? 1 : divider1 < 5 ? 0.5 : divider1 < 9 ? 0.25 : divider1 < 17 ? 0.125 : 1 }
   squirts   = { alternate1 > 0 ? rpm100 / 0.6 * squirtmul : rpm100 * 2 * squirtmul / 0.6                                  } ; How many squirts per Sec
   OpenWidth = { injOpen1 * 0.1 }                                            ; Pulse width for injector opening time
   CCpHr     = { pulseWidth < 1 ? 1 : (fuelCC/60) * ((pulseWidth - OpenWidth)/1000) * squirts * 3600                                      } ; cc / hr
   mphTemp   = { fuelADC < 1 ? 0 : (fuelADC * Speed) /127.5               }  ; MPH
   mph       = { mphTemp < 1 ? 0 : mphTemp                                }  ; Ensure we get 0 mph
   USgph     = {  CCpHr / 3785                                            }  ; US Gallons / Hr
   USmpg     = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / USgph              }  ; US Miles / Gallon
   gph       = {  CCpHr / 4546                                            }  ; Real Gallons / Hr
   mpg       = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / gph                }  ; Real Miles / Gallon

   L100in5th = {  (CCpHr/1000)*(3215/RpmHiRes)                            }  ; Litres/100 in 5th gear

;*****************************************************************************

Now we look for the paragraph ' [GaugeConfigurations] ' :

Code:
[GaugeConfigurations]

...
...

; Extra Stuff

...
...

 mpgGauge          = mpg,               "MPG",                    "MPG",    0, 100, -1, -1, 100, 100, 1
 YGForceGauge      = YForce,            "Y G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 XGForceGauge      = XForce,            "X G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 MAFGauge          = MAFVolts,         "Volts",                  "V",      0, 5, 0, 0, 5, 5, 2
 bcDCGauge         = bcDC,             "Boost Control DC",       "%",      0, 100, -1, -1 999, 999, 0, 0
 idleDCGauge       = idleDC,           "Idle DC",                "%",      0, 100, -1, -1 999, 999, 0, 0
 RealDutyGauge1    = dutyCy1Real,       "Fuel Delivery 1",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1
 RealDutyGauge2    = dutyCy2Real,       "Fuel Delivery 2",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1 

;-------------------------------------------------------------------------------

And we add this line at the end of the paragraph:

Code:
[GaugeConfigurations]

...
...

; Extra Stuff

...
...

 mpgGauge          = mpg,               "MPG",                    "MPG",    0, 100, -1, -1, 100, 100, 1
 YGForceGauge      = YForce,            "Y G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 XGForceGauge      = XForce,            "X G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 MAFGauge          = MAFVolts,         "Volts",                  "V",      0, 5, 0, 0, 5, 5, 2
 bcDCGauge         = bcDC,             "Boost Control DC",       "%",      0, 100, -1, -1 999, 999, 0, 0
 idleDCGauge       = idleDC,           "Idle DC",                "%",      0, 100, -1, -1 999, 999, 0, 0
 RealDutyGauge1    = dutyCy1Real,       "Fuel Delivery 1",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1
 RealDutyGauge2    = dutyCy2Real,       "Fuel Delivery 2",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1 

 L100in5thGauge    = L100in5th,         "F.Cons. in 5th",        "l./100", 0, 30, 0, 0, 10, 20, 1

;-------------------------------------------------------------------------------

Lastly we look for the ' [FrontPage] ' paragraph:

Code:
[FrontPage]

#if NARROW_BAND_EGO
   egoLEDs         = 0.0, 1.0, 0.5 ; NB settings.
#else
   ; If you reverse these range values as you see below, then the LED
   ; bar will work as you expect, high on the right, low on the left.
   egoLEDs         = 4.0, 1.0, 2.5 ; WB settings.
#endif

   ; Gauges are numbered left to right, top to bottom.
   ;
   ;    1  2  3  4
   ;    5  6  7  8

;Gauge Setup 0

    gauge1 = RpmHiResGauge
    gauge2 = cltGauge
    gauge3 = pulseWidth1Gauge
    gauge4 = dutyCycle1Gauge
    gauge5 = mapGauge
    gauge6 = matGauge
    gauge7 = afrGauge
    gauge8 = advanceGauge

And do this change:

Code:
[FrontPage]

#if NARROW_BAND_EGO
   egoLEDs         = 0.0, 1.0, 0.5 ; NB settings.
#else
   ; If you reverse these range values as you see below, then the LED
   ; bar will work as you expect, high on the right, low on the left.
   egoLEDs         = 4.0, 1.0, 2.5 ; WB settings.
#endif

   ; Gauges are numbered left to right, top to bottom.
   ;
   ;    1  2  3  4
   ;    5  6  7  8

;Gauge Setup 0

    gauge1 = RpmHiResGauge
    gauge2 = cltGauge
    gauge3 = pulseWidth1Gauge
;    gauge4 = dutyCycle1Gauge
    gauge4 = L100in5thGauge
    gauge5 = mapGauge
    gauge6 = matGauge
    gauge7 = afrGauge
    gauge8 = advanceGauge

Job done. Save the msns-extra.ini file. Next time you open Megatune you'll see a new virtual gauge showing instant fuel consumption in litres/100 km, something like this (increase brightness if necessary):



It will only be valid for the 5th gear, but it's precise and free.





OPTION TWO: FOR USMPG DISPLAY

Look for this paragraph towards the end of the file:


Code:
;****************************************************************************
;  CHANGE THESE TO SUIT YOUR CAR TO GET MPG, MPH, ETC. THIS WILL ONLY WORK WITH A SUITABLE
;  VEHICLE SPEED SENSOR CONNECTED TO MSnS-EXTRA CODE.

   Speed = { 70 }    ; Change this to your actual speed @ 2.5V from VSS circuit
   fuelCC = { 2168 } ; Enter the total flow for all your injectors here in cc/Min

;****************************************************************************
   squirtmul = { divider1 < 2 ? 2 : divider1 < 3 ? 1 : divider1 < 5 ? 0.5 : divider1 < 9 ? 0.25 : divider1 < 17 ? 0.125 : 1 }
   squirts   = { alternate1 > 0 ? rpm100 / 0.6 * squirtmul : rpm100 * 2 * squirtmul / 0.6                                  } ; How many squirts per Sec
   OpenWidth = { injOpen1 * 0.1 }                                            ; Pulse width for injector opening time
   CCpHr     = { pulseWidth < 1 ? 1 : (fuelCC/60) * ((pulseWidth - OpenWidth)/1000) * squirts * 3600                                      } ; cc / hr
   mphTemp   = { fuelADC < 1 ? 0 : (fuelADC * Speed) /127.5               }  ; MPH
   mph       = { mphTemp < 1 ? 0 : mphTemp                                }  ; Ensure we get 0 mph
   USgph     = {  CCpHr / 3785                                            }  ; US Gallons / Hr
   USmpg     = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / USgph              }  ; US Miles / Gallon
   gph       = {  CCpHr / 4546                                            }  ; Real Gallons / Hr
   mpg       = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / gph                }  ; Real Miles / Gallon

;*****************************************************************************

In 'fuelCC' we must enter the injector flow, times number of injectors (if simultaneous injection). Or injector flow, times number of injectors, divided by 2 (if batch injection). For this Miata it is (205*4)/2 = 410 :

Code:
;****************************************************************************
;  CHANGE THESE TO SUIT YOUR CAR TO GET MPG, MPH, ETC. THIS WILL ONLY WORK WITH A SUITABLE
;  VEHICLE SPEED SENSOR CONNECTED TO MSnS-EXTRA CODE.

   Speed = { 70 }    ; Change this to your actual speed @ 2.5V from VSS circuit
   fuelCC = { 410 } ; Enter the total flow for all your injectors here in cc/Min

;****************************************************************************
   squirtmul = { divider1 < 2 ? 2 : divider1 < 3 ? 1 : divider1 < 5 ? 0.5 : divider1 < 9 ? 0.25 : divider1 < 17 ? 0.125 : 1 }
   squirts   = { alternate1 > 0 ? rpm100 / 0.6 * squirtmul : rpm100 * 2 * squirtmul / 0.6                                  } ; How many squirts per Sec
   OpenWidth = { injOpen1 * 0.1 }                                            ; Pulse width for injector opening time
   CCpHr     = { pulseWidth < 1 ? 1 : (fuelCC/60) * ((pulseWidth - OpenWidth)/1000) * squirts * 3600                                      } ; cc / hr
   mphTemp   = { fuelADC < 1 ? 0 : (fuelADC * Speed) /127.5               }  ; MPH
   mph       = { mphTemp < 1 ? 0 : mphTemp                                }  ; Ensure we get 0 mph
   USgph     = {  CCpHr / 3785                                            }  ; US Gallons / Hr
   USmpg     = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / USgph              }  ; US Miles / Gallon
   gph       = {  CCpHr / 4546                                            }  ; Real Gallons / Hr
   mpg       = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / gph                }  ; Real Miles / Gallon

;*****************************************************************************

Now we add an user defined variable with its formula:

Code:
;****************************************************************************
;  CHANGE THESE TO SUIT YOUR CAR TO GET MPG, MPH, ETC. THIS WILL ONLY WORK WITH A SUITABLE
;  VEHICLE SPEED SENSOR CONNECTED TO MSnS-EXTRA CODE.

   Speed = { 70 }    ; Change this to your actual speed @ 2.5V from VSS circuit
   fuelCC = { 410 } ; Enter the total flow for all your injectors here in cc/Min

;****************************************************************************
   squirtmul = { divider1 < 2 ? 2 : divider1 < 3 ? 1 : divider1 < 5 ? 0.5 : divider1 < 9 ? 0.25 : divider1 < 17 ? 0.125 : 1 }
   squirts   = { alternate1 > 0 ? rpm100 / 0.6 * squirtmul : rpm100 * 2 * squirtmul / 0.6                                  } ; How many squirts per Sec
   OpenWidth = { injOpen1 * 0.1 }                                            ; Pulse width for injector opening time
   CCpHr     = { pulseWidth < 1 ? 1 : (fuelCC/60) * ((pulseWidth - OpenWidth)/1000) * squirts * 3600                                      } ; cc / hr
   mphTemp   = { fuelADC < 1 ? 0 : (fuelADC * Speed) /127.5               }  ; MPH
   mph       = { mphTemp < 1 ? 0 : mphTemp                                }  ; Ensure we get 0 mph
   USgph     = {  CCpHr / 3785                                            }  ; US Gallons / Hr
   USmpg     = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / USgph              }  ; US Miles / Gallon
   gph       = {  CCpHr / 4546                                            }  ; Real Gallons / Hr
   mpg       = { fuelADC < 1 ? 0 : mph < 1 ? 0 : mph / gph                }  ; Real Miles / Gallon

   USMPG5th  = {  235.2/((CCpHr/1000)*(3215/RpmHiRes))                    }  ; USMPG in 5th gear

;*****************************************************************************

Now we look for the paragraph ' [GaugeConfigurations] ' :

Code:
[GaugeConfigurations]

...
...

; Extra Stuff

...
...

 mpgGauge          = mpg,               "MPG",                    "MPG",    0, 100, -1, -1, 100, 100, 1
 YGForceGauge      = YForce,            "Y G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 XGForceGauge      = XForce,            "X G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 MAFGauge          = MAFVolts,         "Volts",                  "V",      0, 5, 0, 0, 5, 5, 2
 bcDCGauge         = bcDC,             "Boost Control DC",       "%",      0, 100, -1, -1 999, 999, 0, 0
 idleDCGauge       = idleDC,           "Idle DC",                "%",      0, 100, -1, -1 999, 999, 0, 0
 RealDutyGauge1    = dutyCy1Real,       "Fuel Delivery 1",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1
 RealDutyGauge2    = dutyCy2Real,       "Fuel Delivery 2",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1 

;-------------------------------------------------------------------------------

And we add this line at the end of the paragraph:

Code:
[GaugeConfigurations]

...
...

; Extra Stuff

...
...

 mpgGauge          = mpg,               "MPG",                    "MPG",    0, 100, -1, -1, 100, 100, 1
 YGForceGauge      = YForce,            "Y G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 XGForceGauge      = XForce,            "X G-Force",              "G",      -3, 3, 0, 0, 2, 3, 3
 MAFGauge          = MAFVolts,         "Volts",                  "V",      0, 5, 0, 0, 5, 5, 2
 bcDCGauge         = bcDC,             "Boost Control DC",       "%",      0, 100, -1, -1 999, 999, 0, 0
 idleDCGauge       = idleDC,           "Idle DC",                "%",      0, 100, -1, -1 999, 999, 0, 0
 RealDutyGauge1    = dutyCy1Real,       "Fuel Delivery 1",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1
 RealDutyGauge2    = dutyCy2Real,       "Fuel Delivery 2",       "Flow",       0,   75,     -1,    -1,   75,   75, 1, 1 

 USMPG5thGauge     = USMPG5th,          "USMPG in 5th",          "USMPG", 0, 30, 0, 0, 10, 20, 1

;-------------------------------------------------------------------------------

Lastly we look for the ' [FrontPage] ' paragraph:

Code:
[FrontPage]

#if NARROW_BAND_EGO
   egoLEDs         = 0.0, 1.0, 0.5 ; NB settings.
#else
   ; If you reverse these range values as you see below, then the LED
   ; bar will work as you expect, high on the right, low on the left.
   egoLEDs         = 4.0, 1.0, 2.5 ; WB settings.
#endif

   ; Gauges are numbered left to right, top to bottom.
   ;
   ;    1  2  3  4
   ;    5  6  7  8

;Gauge Setup 0

    gauge1 = RpmHiResGauge
    gauge2 = cltGauge
    gauge3 = pulseWidth1Gauge
    gauge4 = dutyCycle1Gauge
    gauge5 = mapGauge
    gauge6 = matGauge
    gauge7 = afrGauge
    gauge8 = advanceGauge

And do this change:

Code:
[FrontPage]

#if NARROW_BAND_EGO
   egoLEDs         = 0.0, 1.0, 0.5 ; NB settings.
#else
   ; If you reverse these range values as you see below, then the LED
   ; bar will work as you expect, high on the right, low on the left.
   egoLEDs         = 4.0, 1.0, 2.5 ; WB settings.
#endif

   ; Gauges are numbered left to right, top to bottom.
   ;
   ;    1  2  3  4
   ;    5  6  7  8

;Gauge Setup 0

    gauge1 = RpmHiResGauge
    gauge2 = cltGauge
    gauge3 = pulseWidth1Gauge
;    gauge4 = dutyCycle1Gauge
    gauge4 = USMPG5thGauge
    gauge5 = mapGauge
    gauge6 = matGauge
    gauge7 = afrGauge
    gauge8 = advanceGauge

Jod done. Save the msns-extra.ini file. Next time you open Megatune you'll see a new virtual gauge showing instant fuel consumption in USMPG, something like this (increase brightness if necessary):



It will only be valid for the 5th gear, but it's precise and free.

__________________

Last edited by TELVM; 10-09-2008 at 09:19 PM..
  Reply With Quote