Flex Fuel Control

A1C calibration can be modified and configured to operate all EFI-SD4x ECUs in 4 cylinder, 6 cylinder and 8 cylinder configurations.
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

It can take a 5-10 minute drive and several adjustments to get it settled back down. I have a 38 Gallon rear tank and 17 or so up front so depending on their level it can also be hard to get them balanced when refueling. The point of all of this is to not have to think about it or mess with tuning when switching fuels or tanks.

I will optimize the code as you mentioned once I have settled on the final code. I hate having to recalculate jumps constantly so I will take your advice later on in the development process. All of the input is greatly appreciated.
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

Assuming LAMAVE is scaled the same as LAMBSE1:

Example if LAMAVE is 10% lean or .900 (0x7400)
If 0x7400 < 0x8000
R34 = (0x8000-0x7400) + KAMAFR 'input to UROLAV Function

If KAMAFR was previously 8be5 (14.64:1) the new value would be 97e5 (13.48:1)

0x8000 - 0x7400 = C00
C00 + 8eb5 = 97e5 (38885)
524288/38885 = 13.48

Obviously will need to be flipped if LAMAVE is greater than 0x8000. Any thoughts before testing this?
decipha
Posts: 6297
Joined: 2021 Feb 15, 12:23
Location: Metairie, LA
Vehicle Information: Work Truck
'25 F-150 5L

Re: Flex Fuel Control

Unread post by decipha »

lambse is a byte

0x80 (128) == 1.0 lambda

why even consider a word?
sailorbob
Posts: 28
Joined: 2021 Feb 15, 15:09
Location: UK
Vehicle Information: MR2 turbo / Lotus

Re: Flex Fuel Control

Unread post by sailorbob »

LAMAVE is scaled the same as LAMBSE.

90% of 0x8000 is 0x7333 so your example values need a little adjusting.

LAMBSE is clipped to a maximum of 0x8000 to prevent lean excursions so I would expect LAMAVE to not exceed 0x8000 too.
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

If I run some gasoline without adjusting StoichAFR, lambse during CL will stay above 1.0 while it is pulling fuel. I am assuming 1.1 Lambse will be around 8c (or 8c00 when applying to AFR Word) in which case I believe this code will work to prove the concept. More code is still needed for validation and to avoid making unnecessary updates to KAMAFR. I should be able to test this later on today.

Code: Select all

Sub_a30d:
a30d: ef,2e,b1            call  543e             Sub_543e ();
a310: 32,9f,01            jnb   B2,R9f,a314      if (B2_R9f = 1)  {
a313: f0                  ret                    return; }

a314: a1,00,80,34         ldw   R34,8000         R34 = 8000;
a318: 88,96,34            cmpw  R34,R96          
a31b: d1,0c               jleu  a329             if (R34 > R96)  {
a31d: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a321: 68,96,34            sb2w  R34,R96          R34 -= R96;
a324: 64,32,34            ad2w  R34,R32          R34 += R32;
a327: 20,10               sjmp  a339             goto a339; }

a329: a0,96,32            ldw   R32,R96          R32 = R96;
a32c: 69,00,80,32         sb2w  R32,8000         R32 -= 8000;
a330: 47,ee,96,32,34      ad3w  R34,R32,[Ree+96] R34 = R32 + [716];
a335: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a339: a3,f8,18,36         ldw   R36,[Rf8+18]     R36 = [adf0];
a33d: ef,32,a4            call  4772             Sub_4772 ();
a340: c3,ee,96,3e         stw   R3e,[Ree+96]     [716] = R3e;
a344: f0                  ret                    return;
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

Test worked but kept chasing the 02 switching. Here is an update to resolve. Going to spend some time with the fam now.

Code: Select all

Sub_a30d:
a30d: ef,2e,b1            call  543e             Sub_543e ();
a310: 3a,9f,0c            jb    B2,R9f,a31f      if (B2_R9f = 0)  {
a313: 89,00,77,96         cmpw  R96,7700         
a317: d1,07               jleu  a320             if (R96 <= 7700) goto a320;
a319: 89,00,83,96         cmpw  R96,8300         
a31d: db,11               jc    a330             if (R96 >= 8300) goto a330; }
a31f: f0                  ret                    return; }

a320: a1,00,80,34         ldw   R34,8000         R34 = 8000;
a324: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a328: 68,96,34            sb2w  R34,R96          R34 -= R96;
a32b: 64,32,34            ad2w  R34,R32          R34 += R32;
a32e: 20,10               sjmp  a340             goto a340; }

a330: a0,96,32            ldw   R32,R96          R32 = R96;
a333: 69,00,80,32         sb2w  R32,8000         R32 -= 8000;
a337: 47,ee,96,32,34      ad3w  R34,R32,[Ree+96] R34 = R32 + [716];
a33c: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a340: a3,f8,18,36         ldw   R36,[Rf8+18]     R36 = [adf0];
a344: ef,2b,a4            call  4772             Sub_4772 ();
a347: c3,ee,96,3e         stw   R3e,[Ree+96]     [716] = R3e;
a34b: f0                  ret                    return;
sailorbob
Posts: 28
Joined: 2021 Feb 15, 15:09
Location: UK
Vehicle Information: MR2 turbo / Lotus

Re: Flex Fuel Control

Unread post by sailorbob »

That's why I thought LAMAVE might be a better value to use.
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

Implemented LAMAVE and the code is working. Thinking of just creating a counter that only updates KAMAFR every 500 passes or so. A timer is probably more CPU efficient, but I am not sure how to implement. Not a lot about timers in the docs.

LAMAVE = [3ca]

Code: Select all

Sub_a30d:
a30d: ef,2e,b1            call  543e             Sub_543e ();
a310: 3a,9f,10            jb    B2,R9f,a323      if (B2_R9f = 0)  {
a313: a3,e8,4a,32         ldw   R32,[Re8+4a]     R32 = [3ca];
a317: 89,00,77,32         cmpw  R32,7700         
a31b: d1,07               jleu  a324             if (R32 <= 7700) goto a324;
a31d: 89,00,83,32         cmpw  R32,8300         
a321: d9,12               jgtu  a335             if (R32 > 8300) goto a335; }
a323: f0                  ret                    return; }

a324: a1,00,80,34         ldw   R34,8000         R34 = 8000;
a328: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a32c: 6b,e8,4a,34         sb2w  R34,[Re8+4a]     R34 -= [3ca];
a330: 64,32,34            ad2w  R34,R32          R34 += R32;
a333: 20,0d               sjmp  a342             goto a342; }

a335: 69,00,80,32         sb2w  R32,8000         R32 -= 8000;
a339: 47,ee,96,32,34      ad3w  R34,R32,[Ree+96] R34 = R32 + [716];
a33e: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a342: a3,f8,18,36         ldw   R36,[Rf8+18]     R36 = [adf0];
a346: ef,29,a4            call  4772             Sub_4772 ();
a349: c3,ee,96,3e         stw   R3e,[Ree+96]     [716] = R3e;
a34d: f0                  ret                    return;
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

After several bugs and iterations, this code worked out beautifully. Still under development but I am posting the XDF and ADX in case anyone is interested. The ADX includes payloads for KAMAFR and KAMLAMAVE(my implmentation of rolling average of lambse1)

Any recommendation on minimum temp for KAMAFR updates? I want it to occur before the main adaptive routine runs as to not mess up those trims. I am thinking like 160-170 deg f.

Code: Select all

Sub_a30d:
a30d: ef,2e,b1            call  543e             Sub_543e ();
a310: 3a,9f,31            jb    B2,R9f,a344      if (B2_R9f = 0)  {
a313: a0,96,32            ldw   R32,R96          R32 = R96;
a316: a3,ee,9a,34         ldw   R34,[Ree+9a]     R34 = [71a];
a31a: a3,f8,18,36         ldw   R36,[Rf8+18]     R36 = [adf0];
a31e: ef,4f,a4            call  4770             Sub_4770 ();
a321: c3,ee,9a,3e         stw   R3e,[Ree+9a]     [71a] = R3e;
a325: a3,ee,9c,32         ldw   R32,[Ree+9c]     R32 = [71c];
a329: 07,32               incw  R32              R32++;
a32b: c3,ee,9c,32         stw   R32,[Ree+9c]     [71c] = R32;
a32f: 89,80,00,32         cmpw  R32,80           
a333: d1,1d               jleu  a352             if (R32 <= 80) return;
a335: 89,00,7d,3e         cmpw  R3e,7d00         
a339: d1,18               jleu  a353             if (R3e <= 7d00) goto a353;
a33b: a1,00,81,34         ldw   R34,8100         R34 = 8100;
a33f: 88,3e,34            cmpw  R34,R3e          
a342: d1,19               jleu  a35d             if (R34 <= R3e) goto a35d; }
a344: 01,32               clrw  R32              R32 = 0;
a346: c3,ee,9c,32         stw   R32,[Ree+9c]     [71c] = R32;
a34a: a1,00,80,34         ldw   R34,8000         R34 = 8000;
a34e: c3,ee,9a,34         stw   R34,[Ree+9a]     [71a] = R34; }
a352: f0                  ret                    return; }

a353: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a357: 65,ff,00,32         ad2w  R32,ff           R32 += ff;
a35b: 20,08               sjmp  a365             goto a365; }

a35d: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a361: 69,ff,00,32         sb2w  R32,ff           R32 -= ff;
a365: c3,ee,96,32         stw   R32,[Ree+96]     [716] = R32;
a369: 01,32               clrw  R32              R32 = 0;
a36b: c3,ee,9c,32         stw   R32,[Ree+9c]     [71c] = R32;
a36f: f0                  ret                    return;
Attachments
A1C_240502_FlexFuel.xdf
(425.56 KiB) Downloaded 131 times
DECIPHA_FlexFuelA1C.adx
(444.88 KiB) Downloaded 127 times
efloth
Posts: 399
Joined: 2021 Feb 15, 22:12
Location: Sacramento CA
Vehicle Information: 1991 F150 4.9L J1X 80lb Injectors E85
1995 F150 5.8L MOB1

Re: Flex Fuel Control

Unread post by efloth »

haven't tested this yet but includes ECT,RPM and TP ranges. Also increased update frequency.

Code: Select all

Sub_a30d:
a30d: ef,2e,b1            call  543e             Sub_543e ();
a310: 99,55,b6            cmpb  Rb6,55           
a313: de,46               jlt   a35b             if (Rb6 >= 55)  {
a315: 89,00,20,b2         cmpw  Rb2,2000         
a319: de,40               jlt   a35b             if (Rb2 >= 2000)  {
a31b: 89,70,17,b4         cmpw  Rb4,1770         
a31f: de,3a               jlt   a35b             if (Rb4 >= 1770)  {
a321: 89,10,27,b4         cmpw  Rb4,2710         
a325: d6,34               jge   a35b             if (Rb4 < 2710)  {
a327: 3a,9f,31            jb    B2,R9f,a35b      if (B2_R9f = 0)  {
a32a: a0,96,32            ldw   R32,R96          R32 = R96;
a32d: a3,ee,9a,34         ldw   R34,[Ree+9a]     R34 = [71a];
a331: a3,f8,18,36         ldw   R36,[Rf8+18]     R36 = [adf0];
a335: ef,38,a4            call  4770             Sub_4770 ();
a338: c3,ee,9a,3e         stw   R3e,[Ree+9a]     [71a] = R3e;
a33c: a3,ee,9c,32         ldw   R32,[Ree+9c]     R32 = [71c];
a340: 07,32               incw  R32              R32++;
a342: c3,ee,9c,32         stw   R32,[Ree+9c]     [71c] = R32;
a346: 89,40,00,32         cmpw  R32,40           
a34a: d1,1d               jleu  a369             if (R32 <= 40) return;
a34c: 89,00,7d,3e         cmpw  R3e,7d00         
a350: d1,18               jleu  a36a             if (R3e <= 7d00) goto a36a;
a352: a1,00,81,34         ldw   R34,8100         R34 = 8100;
a356: 88,3e,34            cmpw  R34,R3e          
a359: d1,19               jleu  a374             if (R34 <= R3e) goto a374; } } } } }
a35b: 01,32               clrw  R32              R32 = 0;
a35d: c3,ee,9c,32         stw   R32,[Ree+9c]     [71c] = R32;
a361: a1,00,80,34         ldw   R34,8000         R34 = 8000;
a365: c3,ee,9a,34         stw   R34,[Ree+9a]     [71a] = R34; }
a369: f0                  ret                    return; }

a36a: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a36e: 65,ff,00,32         ad2w  R32,ff           R32 += ff;
a372: 20,08               sjmp  a37c             goto a37c; }

a374: a3,ee,96,32         ldw   R32,[Ree+96]     R32 = [716];
a378: 69,ff,00,32         sb2w  R32,ff           R32 -= ff;
a37c: c3,ee,96,32         stw   R32,[Ree+96]     [716] = R32;
a380: 01,32               clrw  R32              R32 = 0;
a382: c3,ee,9c,32         stw   R32,[Ree+9c]     [71c] = R32;
a386: f0                  ret                    return;
Post Reply