PDA

View Full Version : $4D table mangling



steveo
08-07-2014, 05:02 AM
just a thread so i can get some help in trying to play with table lookups in $4d, or at least so you can all watch me fail miserably

first time trying to mess with table lookups, so chances of me doing the obvious and failing miserably are high.

my goal is, want both tables to be re-ranged from 20kpa to 100kpa. i do a LOT of decel and very light crusing, and spend a ton of time 20-40kpa, so i want more fine grained control in that range, and there is NO way to force an LO3 above 100kpa.

i'd like to increase VE resolution too, but maybe that's next, since there's very little free space to shove stuff around with only a 4k bin.

relavent code;



;~~~~~~~~~~~~~~~~
;-Main %VE table
;~~~~~~~~~~~~~~~~
;
LD278 FCB 0 ;row offset
FCB 16 ;Col offset
FCB 8 ;# of cols

; RPM/1k .4 .8 1.2 1.6 2.0 2.4 2.8 3.2 ;kPa
;
FCB 50, 49, 54, 57, 60, 62, 63, 65 ; 30
FCB 51, 52, 55, 63, 69, 76, 86, 90 ; 40
FCB 53, 54, 61, 65, 79, 88, 99, 103 ; 50
FCB 55, 59, 75, 82, 86, 94, 101, 108 ; 60
FCB 65, 71, 88, 91, 93, 99, 110, 116 ; 70
FCB 95, 107, 112, 108, 103, 103, 111, 120 ; 80
FCB 98, 106, 121, 121, 119, 119, 122, 127 ; 90
FCB 99, 107, 121, 125, 124, 125, 125, 129 ;100
FCB 99, 106, 120, 127, 126, 124, 126, 130 ;110

;~~~~~~~~~~~~~~~~
;main %VE lookup
;~~~~~~~~~~~~~~~~
;
LD596 LDAB L001B ;RPM/25
BPL LD59C ;bra if <3200
;
LDAB #$0080 ;3200 rpm
;
LD59C LDX #LD278 ;%VE table
JSR LFB99 ;Do 3D lookup
ADDA L00AC ;add %VE in
BCC LD5A8 ;Bra if overflow
;
LDAA #$00FF ;clr overflow
;
LD5A8 STAA L00AC ;Store it, %VE

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;>
;>3D lookup routine
;>
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
LFB99 SUBA $0000,X ;Subtract row offset from A
BCC LFB9E ;Bra if > offset
;
CLRA ;Clr A
;
LFB9E SUBB $0001,X ;Subtract column offset from B
;
BCC LFBA3 ;Bra if > offset
;
CLRB ;Clr B
;
LFBA3 STAB L004B ;tmp storage
LDAB #$0010 ;
MUL ;Calc column offset
PSHB ;Push the leftovers to the stack
;
LDAB $0002,X ;Load in # of cols. into B
PSHB ;Push that to the stack too
MUL ;Offset in A x # cols.
ABX ;Add in offset to X
;
INX ;Addr +1
INX ; "
INX ; "
PSHX ;Addr of column ----> stack
LDAA L004B ;Load row offset into A
BSR LFB7B ;Go do 2D lookup
;
STAA L004A ;tmp storage
LDAA L004B ;load row offset into B
PULX ;Get column address off the stack
PULB ;Get # of columns from stack
ABX ;Add # of columns to X, go over one row
BSR LFB7B ;2D lookup, get value next to it
TAB ;Value ----> B
LDAA L004A ;Get that value back into A
BRA LFB83 ;Go interpolate it and return

jim_in_dorris
08-07-2014, 05:15 AM
Steveo, I have never played with $4d, but I do understand assembly language programming really well, so maybe I can help out. Changing the table itself isn't too difficult, but what values are you going to want for the 20 kpa row? And as far as increasing resolution, do you mean making the table bigger? In a 4k bin that might be a problem. You also will have to make sure to check boundary values at the high and low end of the table to ensure you don't exceed them in the call.

steveo
08-07-2014, 05:17 AM
oh this too, most important part ..



;-Check if use Baro/Raw map is flagged, else use SD MAP for %VE lookup
;
LDAA L0024 ;Load SD map
LSRA ;/2
LDAB LD006 ;opt word
BITB #$0008 ;Test b3, do baro fuel corr.
BEQ LD596 ;Bra if ==0
;
;-Do raw map conv. and use for %VE lookup, takes baro press. into account.
;
LDAA L0027 ;Raw map
CMPA L00FE ;Baro pressure
BCS LD58C ;Bra if < baro pressure
;
LDAA #$007F ;127
BRA LD596 ;Bra
;
LD58C LSRA ;Raw Map /2
ADDA #$000E ;15, offset
LDAB L002F ;factor from Baro lookup
MUL ;(MAP val. x factor)
ASLD ;x2
ASLD ;x2
SUBA #$0020 ;-32

steveo
08-07-2014, 05:20 AM
Steveo, I have never played with $4d, but I do understand assembly language programming really well, so maybe I can help out. Changing the table itself isn't too difficult, but what values are you going to want for the 20 kpa row?

basically i just want to shift the entire table -10kpa in range, so instead of being 30kpa-110kpa i get 20kpa-100kpa.

(obviously this is a lookup thing instead of modifying the table itself...)

steveo
08-07-2014, 05:23 AM
there's full disassembly in the $4d sticky if you're interested in helping

jim_in_dorris
08-07-2014, 05:31 AM
I will take a look at it. Again, the only thing you probably need to change is a couple of bytes in the lookups and putting the values you want in the 20kpa row. Do you see 20kpa that often?

steveo
08-07-2014, 05:35 AM
never really looked at it too hard, but it's interesting that there are two SD lookup modes, one with barometric pressure compensation and one without.... and that bit isn't set in ANY factory calibrations...

steveo
08-07-2014, 05:38 AM
Do you see 20kpa that often?

well, yeah. cruising range is ~30kpa and decel is 20kpa. i'd really like to be able to manipulate spark and fuel @20-30kpa a bit more effectively. especially since i never hit 110kpa, so that entire row is useless.... it'd be nice to lose it in favor of better low end tuning.

jim_in_dorris
08-07-2014, 05:50 AM
Does Decel use the VE table or a DFCO table? You need to pay attention to what happens in decel before you go changing the table.

steveo
08-07-2014, 05:57 AM
yes. i do have to pay attention to that. let me have a look at it.

steveo
08-07-2014, 06:02 AM
on an initial glance, it doesn't seem to 'use' the ve table at all; it seems to be straight up coolant temp lookup that's multiplied into BPW. and it's controlled by a status bit set by a threshold.

;BPW = BPWC x AFR x VE x MAP x Cool corr. x BLM corr. x DFCO x decel. x FPV corr.
; +/- INT prop. term

i think the author of this program intended anything below 30kpa to start nearing decel mode, and just run a multiplier to start enleanment

i dont want to have a ve table that runs over decel or anything, but i do think there's quite a bit of territory JUST UNDER 30kpa that i play around in that i could fine tune for driveability.

jim_in_dorris
08-07-2014, 06:45 AM
Well, I will take a look at it and make a guess, but right now I think that it might be doable without too much effort.

steveo
08-07-2014, 06:57 AM
its lookin' that way, if you'd have a look i'd appreciate it, but im going to stare at it too see if i can figure it out.

jim_in_dorris
08-08-2014, 10:27 AM
Steveo, I looked at the code a little tonight, and the only thing I am not sure about is the use of the raw map signal. Other than that, It should be just as simple as changing the table. If the code does what I think, the map/ raw baro merely gives one of the offsets into the table. RPM is the other. I am not 100% sure what the boundary values are for RAW/ baro, and MAP, but so long as the value doesn't resolve outside the table boundaries you should be ok. What you might want to do is to look at the MAP conversion routine and see what values are possible coming out of the a/d converter reading the MAP.

steveo
08-08-2014, 05:51 PM
yeah it does look that easy; doesn't it. i'll try a few approaches tonight and see if it runs. im lucky; i have a nice chunk of unused code there (the barometric compensation branch) that i can use for my own purposes.