DFI and ECM Discuss all aspects of DFI (Digital Fuel Injection), ECMs (Electronic Control Module), scanners, and diagnostic equipment. Fine tune your Third Gen computer system for top performance.

Q about $8D bpw calculation

Thread Tools
 
Search this Thread
 
Old Nov 13, 2003 | 10:57 AM
  #1  
Doctor J's Avatar
Thread Starter
Member
 
Joined: Jun 2001
Posts: 146
Likes: 0
From: Greenwich, CT
Q about $8D bpw calculation

RBob, may I ask a Q about the $8D mask? I haven't seen this in the archives anywhere.

Somebody on another board was wondering how the bpw calc is done in 8D,
and once I started looking at it, I realized I can't folllow the code with any degree of certainty.
Could you please help interpret how the ECM is calculating engine air/fuel flow?

The code below is from the ANHT hack on the ECMGuy site, about 55% of the way
down through the text. If my formatting works, the code is on the left & my confusion
notes on the right. Looking at the code:

It looks like it takes the ideal gas law for the grams of air in 1 cyl, and then
corrects it for VE (=L006F?); then calc's an air RATE for that RPM;
then corrects it to a flow for 4 cyl/crank rev ( 4 DRP = 1 crank rev?).

Then a term 'EGR0' appears that I don't understand - is that part of the
assembly code? I didn't see it anywhere else.

Then it seems to multiply X 2, to give an air rate for 8 cyl???? This number
then seems to be forgotten(=L006B?).

After that it seems to take the calc'd air per cyl (L006F?) and multiply it by
the 'commanded AFR' (I imagine that should be 1/AFR) to get a fuel weight.
Somehow it converts the fuel weight into a PW from the sec/gram rating of
ONE inj, but how that math is done is confounding me - since again they
are using 1 DRP. One DRP is one quarter of a crank rev, is it not?

Seems like that bpw would result in 2X as much fuel as you need, if you
are firing the inj's once per crank rev.

Anyway, thanks in advance for any light you can shed on the code.
This is done for my own curiosity - I am not in the chip business,
this is just a hobby .

DrJ


Code:
*************************************************** 
* CALCULATE SPEED DENSITY 
* 
* ANHT, TYPE $8D ECM 
*************************************************** 
;----------------------------- 
; GMS of AIR per CYLINDER 
; (CALC VE) 
;----------------------------- 
LDX L006D ; GET INV MAT                                                      OK, I know what Inv MAT is
LDD L0079 ; MAP FOR SP/DENS CALC                                              OK, I know what MAP is
SUBD L0069 ; PARTIAL PRESS DUE TO EGR                                         Let's ignore EGR for now
; SUB OFF EGR PART PRESSURE 
BCC LCC40 ; IF NO UNDERFLOW 
; ... else 
CLRA ; LIMIT, (MAP-EGR) = 0 
CLRB 
; 
; VE CALC = ((MAP - EGR part press) * CYL VOL)/((MAT + 233) * 128))      This looks like ideal gas law=1 cyl
; 
LCC40: JSR LE424 ; 16 * 16 )RET W MIDDLE 2 BYTES IN D)                  16X16 = multiply 2 16 bit terms?
PSHB 
PSHA 
TSX ; Point to VE CAL ON STACK 
LDAA L0067 ; FILTERED V.E, (TRACKING)                                      =get current VE from memory
JSR LE33F ; 8 x 16 MULT,                                                     8X16  bit multiplication?
STD L006F ; GRAMS AIR/CYL                                                  =grams or air in 1 cyl X VE
PULX ; CLR STX 
;---------------------- 
; CALC AIR FLOW USING                                                OK, above we calc'd corrected grams
; IDEAL GAS LAW                                                          air in 1 cyl; so now what's EGR0?
;--------------------- 
LDX L00B3 ; CURRENT MNR LOOP DRP PERIOD                              =get DRP time from memory
IDIV ; X = (((EGR0 * INV MAT) * VE * 1/DRP PER                       =grams air/time for 1/4 crank rev?
;                                                            does that give air RATE for 4 cyl??
; REMAINDER TO STX 
;
PSHB 
PSHA 
PSHX 
; 
; GET INTEGER PORTION 
; 
PULA 
PULB 
ASLD ; Mult * 2, FOR SCALE                                                   =X2 gives a rate for 8 cyl??? 
STD L0064 ; SAVE INTG PART OF AIR FLOW 
; 
; REMAINDER FROM STX 
; 
PULA ; 
PULB ; 
LDX L00B3 ; CURRENT MNR LOOP DRP PERIOD 
FDIV ; FRACT = REMAINDER 
PSHX ; 16 bit FRACT TO STX 
PULA 
PULB 
ASLD ; SCALE & ROUND FRACT 
STAA L0066 ; SAVE FRACT PART OF AIR FLOW 
BCC LCC6B ; BR IF NO FRACT OVERFLOW 
; ... else 
LDX L0064 ; GET INTEG AIR FLOW 
INX ; INCR FRO FRACT 
STX L0064 ; AIR FLOW 
LCC6B: TAB ; FRACT TO B Reg 
LDAA L0065 ; GET LO BYTE ON INTEG 
BRCLR L0064,#$FF,LCC75 ; BR TO SPD DENS CALC IF 
; AIR FLOW LT 256 G/SEC 
; ... else 
LDD #$FFFF ; LIMIT TO 255.996 Gms\                                   =max flow for 8 cyl = 256 g/sec?
LCC75: STD L006B ; SAVE LIMITED AIR FLOW FM IDEAL GAS LAW                where does L006B get used?
;---------------------------- 
; SPEED DENS BPW CALCULATION 
;---------------------------- 
LDD L006F ; GRAMS AIR/CYL                                                =grams/ 1 cyl corrected for VE
LDX L00F1 ; FINAL TOTAL AF VAL                                              =commanded AFR
JSR LE424 ; 16 * 16 )RET W MIDDLE 2 BYTES IN D)                         ????  
LDX $841C ; SEC/GRAM PROD OF INJ FLOW Rate,                             =inj PW in sec/gram????
; (0.359 SEC/GRAM, 2.86 g/Sec) 
JSR LE3EE ; 16 x 16 (RET W/UPPER 2 BYTES IN D) 
ROLB ; MULT X 2                                                      why X2 ??  Inj's fire 1 time in 4 DRP?
ROLA                                                                       seems like it should be /2 ???
STD L00E2 ; Base Pulse width 
;-------------------------------------------------- 
;-------------------------------------------------- 
; DO BLM CORRECTION                                                              Worry about the BLMs later..
;
Reply
Old Nov 13, 2003 | 02:29 PM
  #2  
RBob's Avatar
Moderator
iTrader: (1)
 
Joined: Mar 2002
Posts: 18,432
Likes: 233
From: Chasing Electrons
Car: check
Engine: check
Transmission: check
I've found that when it comes to GM code some things are almost impossible (or at least tedious) to follow to the exact value. A simulator would be helpful, or a calulator and lots of paper

Math scaling is the foremost in this area. There is all kinds of scaling going on. The AFR is an inverse term: ARG = 6553.6/AFR_RATIO.
Then the injector flow is scaled: ARG = ((SEC/GRAM * 256) * 5). It isn't even in gms/sec or #'s/hr, it is in seconds to flow 1 gram of fuel times 256 times 5.
The cylinder volume is used to scale the MAT term before it is used in this routine.

L86DD: FDB 159 ; CYL VOL & UNIT CONV, (0.7125 LITRE/CYL)
; (CAL = L/CYL * 223.157)

The three multiply routines are scaling the result before it is returned.

The 8 x 16 routine (an 8 bit value times a 16 bit value) returns a value that is the result divided by 256:

JSR LE33F ; 8 x 16 MULT, AB = (A * *X) / 256

One of the 16 x 16 routine returns a value that is the result multiplied by 256:

JSR LE424 ; 16 x 16 MULT, AB = (AB * X) * 256 (RET W MIDDLE 2 BYTES IN D)

Another 16 x 16 routine returns a value that is the result multiplied by 65536:

JSR LE3EE ; 16 x 16 MULT, AB = (AB * X) * 65536 (RET W/UPPER 2 BYTES IN D)

An example of how this multiply/scaling is used is where the airflow is multiplied by the VE:

Code:
    TSX          ; Point to VE CAL ON STACK (really the airflow here!)
    LDAA   L0067 ; FILTERED V.E, (TRACKING)                         =get current VE from memory
    JSR    LE33F ; 8 x 16 MULT, AB = (A * *X) / 256
    STD    L006F ; GRAMS AIR/CYL                                     =grams or air in 1 cyl X VE
The VE is a percentage of what amount out of 100% will actually flow into the cylinder. The math routine will do exactly that. It will multiply the airflow by the VE value and then divide by 256. This will reduce the airflow by the VE%.

The 'EGR0' looks to be used just to show that the EGR flow has been subtracted out of the air flow. It's inert so it doesn't count. The way the comment is written may also be a mistake.

The L00B6 airflow term is used in the closed loop fueling for integral & proportional gains/delays.

Yes, one DRP is the time it takes to move 90 degrees of crank rotation. It is the number of clock ticks between each DRP. The ticks run at 65,536 a second, or 15.26 usec/tick.

There is a comment in the hac about the injector flow rate that is interesting:

Single Fire #/h = 20317.6/cal val

Using this the 22#/hr injectors are seen as 44#/hr injectors. That may be the scaling factor you are looking for.

RBob.
Reply
Old Nov 13, 2003 | 02:47 PM
  #3  
Doctor J's Avatar
Thread Starter
Member
 
Joined: Jun 2001
Posts: 146
Likes: 0
From: Greenwich, CT
RBob,

Many thanks for your time.

I hadn't figured out what the 'JSR' was for - apparently it
calls a 'xxx.SRC' routine?

That helps a lot. I'll go back to picking at it.

BTW, I noticed that 'single fire' comment too - somewhere
early in the text was a line to the effect 'single fire'
was invoked when the bpw got below ~1 ms.

Thanks again.
DrJ
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Elephantismo
Electronics
14
Feb 13, 2019 12:51 AM
PurelyPMD
Camaros for Sale
27
May 5, 2016 04:57 PM
Rousseau92maro
Exhaust
9
Feb 1, 2016 05:12 PM
fasteddi
Power Adders
30
Sep 2, 2015 10:29 AM
Armored91Camaro
DIY PROM
3
Aug 12, 2015 09:41 AM




All times are GMT -5. The time now is 05:26 PM.