You can type here any text you want

I want to save gas - Lean Cruise

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

BJM

Senior Member
Joined
May 25, 2001
Messages
905
I want to try a lean cruise patch for myself in my own chip. Before anyone asks I do not want to buy a chip to do this. I have written most of this but am having trouble figuring out how to set the A/F properly.

Assumptions
1. I will only allow lean cruise when highway spark mode is active (4th gear, TCC locked, LV8<128)
2. I will further constrain it so it won't be active with LV8<40-50 or so, (TBD)
3. I use the highway A/F ratio at $324B and set it to $66 = 16.1:1 as a start for 40<LV8<70.
4. I will add a bit of fuel for 70<LV8<100. ~15.5:1
5. I will add still more for 100<LV8<128. ~15.0:1
6. To prevent screwing up my BLMs I will turn off C/L when using lean mixtures. Kind of like the O/L code built into the car already.

I wrote a patch that intercepted what I thought was the final A/F calculation at $3C3D and jumped to my patch. I did all of the above and jumped back again. For 16:1 I wrote the value $0066 (102 decimal) into location $91,$92 which is what I thought I had to do.

It mostly worked, DS showed highway spark mode enabling and then a couple of frames later it went into O/L but the A/F ratio according to DS was 0.1:1! Obviously screwy, on top of that the injector PW went to 173%!!!, the O2 did not show it going rich but I only let it do it for a second or 2. I let off on the gas and the normal fueling picked up again. If I stepped on the gas it would kick out of highway mode just fine and worked normally. I am somehow modifying the A/F ratio incorrectly.

Have I picked the wrong location to set the A/F ratio? Is my value getting modified further in the code somewhere? I assumed that no matter what A/F ratio was calculated, mine would overwrite it.
 
Highway A/F mode is never used in the chip if you search for 342B, you'll see its never referenced.
 
I put a value there and use it in my patch. I put 16:1 there.
 
Sounds like $91,92 doesn't have the right value (0066) in it.

What method did you use to get the value from 324B and save it into 91,92?


Eric
 
Basically after making sure I was within the constraints listed above I load the value of #$66 into Acc B from $342B, I add a little depending on load (either another #$04 or #$08). I then clear Acc A (I was testing conditions with it). Finally, I save Acc D to $91, which should be $91,$92.

F6 34 2B LDAB $342B
4F CLRA
DD 91 STAD $91

Does that sound right? I think D should be #$0066 or a little bigger and is saved onto $91 and $92.
 
I actually let the normal STD $91 at $3C3D occur and jump out after where the check for external equipment occurs. I'll just post everything here.

This is where I make the JMP out.

3C3D: DD 91 STD $91 Need to store original A/F value as calculated before doing Lean cruise checks. FuelTrim = D
3C3F: 7E 3D 97 JMP $3D97 JMP to Lean Patch
3C42: 01 NOP
3C43: 01 NOP
3C44: 97 00 STAA $00 Store flags again unaltered.
3C46: 96 0B LDAA $0B
3C48: 84 FB ANDA #$FB ; Enable Block Learn /0B04
3C4A: 97 0B STAA $0B

Here is the actual patch I JMP to.

3D97: 96 04 LDAA $04 Highway Mode Flags
3D99: 84 F7 ANDA #$F7 Zero Bit 3 - new Highway Mode O/L bit.
3D9B: 85 10 BITA #$10 Check Bit 4
3D9D: 27 24 BEQ $3DC3 If no highway mode, branch

Here if highway mode active.

3D9F: DE EA LDX $EA $00EA - Timer: Time since run enable (unsigned word max. 65535 [18hrs 12 minutes])
3DA1: 8C 00 1E CMPX #$001E Compare to 30 seconds?
3DA4: 23 1D BLS $3DC3 If run time <= limit (seconds), branch

Need to check if LV8 too low.

3DA6: D6 23 LDAB $23 $0023 - Filtered Load Variable (LV8)
3DA8: C1 32 CMPB #$32 Compare to low LV8 limit.
3DAA: 23 17 BLS $3DC3 If LV8<50, branch to end
3DAC: 17 TBA Move LV8 from B to A. Need to make comparisons using A with A/F in B below. Overwrites flags in A.
3DAD: F6 34 2B LDAB $342B Here if able to load Lean A/F, this is basic ratio for low loads. LV8 from 40-70.
3DB0: 81 46 CMPA #$46 Is load above 70?
3DB2: 25 09 BCS $3DBD If LV8<70, branch.
3DB4: CB 04 ADDB #$04 Here if LV8>70, add fuel. LV8 from 70-100.
3DB6: 81 64 CMPA #$64 Is load above 100?
3DB8: 25 03 BCS $3DBD If LV8<100, branch.
3DBA: CB 04 ADDB #$04 Here if LV8>100, add fuel. LV8 from 100-128.
3DBC: 4F CLRA Need to have A clear as part of D.
3DBD: DD 91 STAD $91 Store A/F in $91-92. A is clear, B is A/F set according to LV8.
3DBF: 96 04 LDAA $04 Need to reload flags.
3DC1: 8A 08 ORA #$08 Set Lean Cruise flag to trigger O/L.
3DC3: 97 04 STAA $04 If no lean cruise, from branches the flags were kept in A with checks made in B and flag for O/L is lowered. If lean cruise is on, Bit 3 is high.

3DC5: 96 00 LDAA $00 Load flags again.
3DC7: 7E 3C 42 JMP $3C42 Return to code.


You will notice I set a new flag to indicate we should be in O/L. I redirect that JMP at $37A3 that lets you into the C/L routine to turn off C/L if that bit is set. That extra little routine goes below the one above. That part seems to work fine, its going in and out of C/L when it should. I am sure this could be smaller but first I just want to get it working. I don't really know why I bother checking for run time but on cold mornings I didn't want it to operate for at least 10 minutes, its only set to 30 seconds right now.
 
3DB2: 25 09 BCS $3DBD If LV8<70, branch.
3DB4: CB 04 ADDB #$04 Here if LV8>70, add fuel. LV8 from 70-100.
3DB6: 81 64 CMPA #$64 Is load above 100?
3DB8: 25 03 BCS $3DBD If LV8<100, branch.
3DBA: CB 04 ADDB #$04 Here if LV8>100, add fuel. LV8 from 100-128.
3DBC: 4F CLRA Need to have A clear as part of D.
3DBD: DD 91 STAD $91 Store A/F in $91-92. A is clear, B is A/F set according to LV8.

On those 2 branches in red, the CLRA is being bypassed, allowing LV8 to remain in A, screwing up the $91 trim. :)
 
That fixed it perfectly. I shortened the 2 branches by one each and it works great. I just got back from a run and the car never felt too lean anywhere. My leanest setting is now 16.1:1. How lean do these cars operate? I don't want to go nuts or anything.

Thanks for all the help.

Gotta love the internet, I am typing this while still in my car hooked up to DS outside my house and am hooked up to my wireless link.
 
Back
Top