Throttle Change Enrichment/Enleanment

FlashPro questions & answers specific to the 2006-2009 (US, UK, Asia) S2000
Post Reply
shind3
Posts: 109
Joined: Mon Jun 30, 2014 8:02 am
Location: Pittsburgh, PA

Throttle Change Enrichment/Enleanment

Post by shind3 »

Hello, I am a customer of FlashPro circa 2014. I also have reverse engineered a BMW MS41 ECU to define most relevant tables as well as written custom firmware to add functionality such as native WidebandO2 integration, FlexFuel, BoostControl, Speed Density, etc. If you have any further questions about it or my qualifications please visit : https://sites.google.com/site/openms41/ ... e---ms41-3

I have been able read my stock S2000 ECU using Honda Tuning Suite CANBUS Edition (after unmarrying FlashPro) and analyze some of the logic.

Anyway, my reason for this post is to shed light on how Throttle Change Enrichment/Enleanment is done on these Honda S2000 ECUs. It seems Hondata gives us two tables to adjust but I believe their explanation is flawed. Also, I know there are several more tables that define the Wall-Wetting phenomenon that are not yet defined. Well, here is some of the decompiled ASM as per Ghidra version 10.2.2 in addition to my personal renaming of variables and commenting on the code.

I believe that the TipInFuel_ECT table actually is a Decaying table while the other one actually Adds to the Fuel pulse. This is in contradiction of the help notes posted on the Hondata website regarding "Throttle Tip In Fuel" which says both tables are Adders.
https://www.hondata.com/help/flashpro/i ... meters.htm

I was hoping someone at Hondata could look over my review of the commented decomplied source code and see if it agrees with your assessment.

Anyway, my end goal is to improve Honda Tuning specifically for my car and by association everyone by coming to a better understanding of how the stock logic works.

Code: Select all

void TipInFuel_FUN_00050f3c(void)

{
  short wVar2;
  int extraout_r0;
  uint Z;
  int TipInFuel;
  bool TipInEnrich;
  word wVar1;
  short sVar2;
  TipInFuel *TIF;
  
  TIF = &TipInFuel_ffff2f20;
  TipInFuel = (int)?_TipInFuel_LastApplied_SHORT_ffff2576;
  if (TipInFuel < 0x8000) {
    if ((-0x7fff < TipInFuel) && (Ready_BOOL_ffff292a)) {
                    /* if (-7fff < xffff2576 < 8000) and (xffff292a == true) then normal decay */
      Z = 2DTableLookup(&2D_TipInFuel?Decay_ECT_0000a61c,(int)?_ECT_SHORT_ffff24ac);
      TIF->Z_TipInFuel?Decay_ECT = (word)Z;
      TipInFuel = (uint)TIF->TipInFuel - (Z & 0xffff);
      if ((int)&TipInFuel_Min_BYTE_00007fff < TipInFuel) goto LAB_000510ac;
    }
    TipInFuel = -0x8000;
  }
  else {
                    /* (x8000h <= xffff2576) */
    if ((int)TipInFuel_New_SHORT_ffff2baa < (int)TipInFuel_Last_SHORT_ffff2bdc) {
                    /* decay */
      TipInFuel = Math_Limit_-8000to7fff_FUN_00008f28
                            (TipInFuel -
                             ((int)TipInFuel_Last_SHORT_ffff2bdc - (int)TipInFuel_New_SHORT_ffff2b aa
                             ));
      TIF->TipInFuel_Applied = (short)TipInFuel;
      sVar2 = (short)TipInFuel;
    }
    else {
                    /* no decay */
      TipInFuel_ffff2f20.TipInFuel_Applied = ?_TipInFuel_LastApplied_SHORT_ffff2576;
      sVar2 = ?_TipInFuel_LastApplied_SHORT_ffff2576;
    }
                    /* 
                        */
    if (TipInFuel_New_SHORT_ffff2baa == 0) {
      TipInFuel = Math_Limit_-8000to7fff_FUN_00008f28((int)sVar2 << 15);
      wVar2 = (short)TipInFuel;
      wVar1 = wVar2;
    }
    else {
      Math_FUN_000a0e2c();
      TipInFuel = Math_Limit_-8000to7fff_FUN_00008f28(extraout_r0);
      wVar1 = (word)TipInFuel;
    }
                    /* 
                        */
    TIF->TipInFuel_AppliedFinal = wVar1;
    if ((TIF->TipInStatus != false) ||
       ((SHORT_ffff2bda < (short)5501 && (SHORT_ffff2bde <= TipInFuel_New_SHORT_ffff2baa)))) {
      Z = 2DTableLookup(&2D_TipInFuel_Throttle_0000a628,(int)(short)wVar1);
      TIF->Z_TipInFuel?Adder_Throttle = (word)Z;
      if ((uint)TIF->TipInFuel < (Z & 0xffff)) {
        TIF->TipInFuel = (word)Z;
      }
      TipInEnrich = true;
      goto LAB_000510b0;
    }
    Z = 2DTableLookup(&2D_TipInFuel?Decay_ECT_0000a61c,(int)?_ECT_SHORT_ffff24ac);
    TIF->Z_TipInFuel?Decay_ECT = (word)Z;
    TipInFuel = (uint)TIF->TipInFuel - (Z & 0xffff);
    if (TipInFuel < (int)&Min_TipInFuelEnrich_WORD_00008000) {
      TipInFuel = -0x8000;
    }
  }
LAB_000510ac:
  TIF->TipInFuel = (word)TipInFuel;
  TipInEnrich = false;
LAB_000510b0:
  TIF->TipInStatus = TipInEnrich;
  return;
}

shind3
Posts: 109
Joined: Mon Jun 30, 2014 8:02 am
Location: Pittsburgh, PA

Re: Throttle Change Enrichment/Enleanment

Post by shind3 »

Also, another point of contention for anyone not versed in reading source code, understand that these tables affect both TipIn and TipOut. Therefore, the naming convention used by Hondata is inherently misleading. These tables affect both positive and negative Throttle Change. So just calling them Tip-In is wrong.
shind3
Posts: 109
Joined: Mon Jun 30, 2014 8:02 am
Location: Pittsburgh, PA

Re: Throttle Change Enrichment/Enleanment

Post by shind3 »

And here is the same function relabeled to accommodate both Enrichment/Enleanment. See if you guys agree/disagree.

Code: Select all

void dTPS_FUN_00050f3c(void)

{
  short wVar2;
  int extraout_r0;
  uint Z;
  int dTPS_Applied;
  bool dTPS_Enrichment/Enleanment;
  word wVar1;
  short sVar2;
  TransientTps *struct_dTPS;
  
  struct_dTPS = &dTPS_ffff2f20;
  dTPS_Applied = (int)?_dTPS_LastApplied_SHORT_ffff2576;
  if (dTPS_Applied < 0x8000) {
    if ((-0x7fff < dTPS_Applied) && (Ready_BOOL_ffff292a)) {
                    /* if (-7fff < xffff2576 < 8000) and (xffff292a == true) then normal decay */
      Z = 2DTableLookup(&2D_TipInFuel?Decay_ECT_0000a61c,(int)?_ECT_SHORT_ffff24ac);
      struct_dTPS->Z_TipInFuel?Decay_ECT = (word)Z;
      dTPS_Applied = (uint)struct_dTPS->dTPS_IPW - (Z & 0xffff);
      if ((int)&TipInFuel_Min_BYTE_00007fff < dTPS_Applied) goto LAB_000510ac;
    }
    dTPS_Applied = -0x8000;
  }
  else {
                    /* (x8000h <= xffff2576) */
    if ((int)TipInFuel_New_SHORT_ffff2baa < (int)TipInFuel_Last_SHORT_ffff2bdc) {
                    /* decay */
      dTPS_Applied = Math_Limit_-8000to7fff_FUN_00008f28
                               (dTPS_Applied -
                                ((int)TipInFuel_Last_SHORT_ffff2bdc -
                                (int)TipInFuel_New_SHORT_ffff2baa));
      struct_dTPS->TipInFuel_Applied = (short)dTPS_Applied;
      sVar2 = (short)dTPS_Applied;
    }
    else {
                    /* no decay */
      dTPS_ffff2f20.TipInFuel_Applied = ?_dTPS_LastApplied_SHORT_ffff2576;
      sVar2 = ?_dTPS_LastApplied_SHORT_ffff2576;
    }
                    /* 
                        */
    if (TipInFuel_New_SHORT_ffff2baa == 0) {
      dTPS_Applied = Math_Limit_-8000to7fff_FUN_00008f28((int)sVar2 << 15);
      wVar2 = (short)dTPS_Applied;
      wVar1 = wVar2;
    }
    else {
      Math_FUN_000a0e2c();
      dTPS_Applied = Math_Limit_-8000to7fff_FUN_00008f28(extraout_r0);
      wVar1 = (word)dTPS_Applied;
    }
                    /* 
                        */
    struct_dTPS->TipInFuel_AppliedFinal = wVar1;
    if ((struct_dTPS->Status != false) ||
       ((SHORT_ffff2bda < (short)5501 && (SHORT_ffff2bde <= TipInFuel_New_SHORT_ffff2baa)))) {
      Z = 2DTableLookup(&2D_TipInFuel_Throttle_0000a628,(int)(short)wVar1);
      struct_dTPS->Z_TipInFuel?Adder_Throttle = (word)Z;
      if ((uint)struct_dTPS->dTPS_IPW < (Z & 0xffff)) {
        struct_dTPS->dTPS_IPW = (word)Z;
      }
      dTPS_Enrichment/Enleanment = true;
      goto LAB_000510b0;
    }
    Z = 2DTableLookup(&2D_TipInFuel?Decay_ECT_0000a61c,(int)?_ECT_SHORT_ffff24ac);
    struct_dTPS->Z_TipInFuel?Decay_ECT = (word)Z;
    dTPS_Applied = (uint)struct_dTPS->dTPS_IPW - (Z & 0xffff);
    if (dTPS_Applied < (int)&Min_TipInFuelEnrich_WORD_00008000) {
      dTPS_Applied = -0x8000;
    }
  }
LAB_000510ac:
  struct_dTPS->dTPS_IPW = (word)dTPS_Applied;
  dTPS_Enrichment/Enleanment = false;
LAB_000510b0:
  struct_dTPS->Status = dTPS_Enrichment/Enleanment;
  return;
}

Post Reply