Pages: [1] 2
Author Topic: Add a new AFR variable in KWP1281 protocol. DONE  (Read 12880 times)
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« on: December 29, 2014, 03:41:30 PM »

 ive got cluster fis control, he`s ability to display vcds measurement groups. and here`s an idea - declare new variables to show current AFR (simply calc with lamsoni and lambsg)
i know how to add its to vcds but idk how to make it from scratch and has no idea where to start from
« Last Edit: April 22, 2015, 05:02:55 PM by fukenbroken » Logged
byzan a4
Full Member
***

Karma: +0/-1
Offline Offline

Posts: 73


« Reply #1 on: January 02, 2015, 04:11:45 AM »

Interested in this.  I have v1 fis box.  Can this be done on that too
Logged
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #2 on: January 02, 2015, 06:46:11 AM »

im making my first steps with asm Smiley
all seems ok
to add new variable in vcds group we need to know # of variable (page 1555 FR - 1 nmot, 2 rl, etc) but i cant find where variables are getting their #
Logged
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #3 on: January 02, 2015, 08:37:53 PM »

holy sh
i did it!
can log 0x385EE0 for now  Smiley which is copy of lamsoni_w
oh its very hard for me
still dont know how to multiply its by 14.7 (bricked ECU with MUL-s tryouts Sad) and where is variable physical #`s stored to saw that variable in vcds

Code:
pussy_afr	EQU	5EE0h ;385EE0h
lamsoni_w EQU 1B46h
ub EQU 099Dh

sub_mainfunc:

exts #38h, #1
mov r4, lamsoni_w
exts #38h, #1
mov pussy_afr, r4
jmpr cc_UC, loc_end

loc_end:
movb rl4, ub
rets


;*****************************************************
procseg004 endp
seg004 ends

end;
« Last Edit: January 02, 2015, 08:44:11 PM by fukenbroken » Logged
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #4 on: January 03, 2015, 09:27:29 PM »

ok ive recovered bricked ECU (btw nefmoto, mpps and galleto doesnt help me in boot mode, only chiploader with dumb kkl cable helps)
and multiply my new variable by 14 but dont know how to multiply it by 14.7 Smiley))
offcourse i can simply use any other factor with untouched value but still dont know where those factors are stored in ecu
any help will be appreciated
im totally noob in asm  Smiley
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #5 on: January 03, 2015, 11:02:38 PM »

and multiply my new variable by 14 but dont know how to multiply it by 14.7 Smiley))

You can use cheap fixed point integer math:

x * 15 - (x*30/100) or (x*15/50) or .. etc.. down to (x*3/10) depending on how much overhead you have in your variable.

which will get you close.
Logged

ME7.1 tuning guide
ECUx Plot
ME7Sum checksum
Trim heatmap tool

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your ex
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #6 on: January 04, 2015, 09:24:18 PM »

Thanks nyet ive made it!
here is mine alot of noob code for desired and actual AFR variables. ive using this formula for calculation

((x/2)*15)-((x/2)*3/10)

Now im planning to find some 2 unused second O2 sensor (already turned off) variables which is already existed in FR and have their physical adress to add them into vcds group and use them to show AFR.
then i log them and make a same fake variables to replace them in ecu routines.

Am i right?

Code:
actual_afr	EQU	5EE0h ;385EE0h
desired_afr EQU 5EE2h ;385EE2h
testmem1 EQU 5EA2h
testmem2 EQU 5EA4h
testmem3 EQU 5EA6h
lamsoni_w EQU 1B46h ;actual
lamsbg_w EQU 1FBEh ;desired
ub EQU 099Dh


;actual part
sub_mainfunc:

exts #38h, #1 ; divide lamsoni_w by 2 and then multiply by 15
mov mdl, lamsoni_w
mov r15, #2
div r15
mov r4, mdl
mov r15, #0Fh
mul r4, r15
mov r14, mdl

exts #38h, #1 ; divide lamsoni_w by 2 and multiply lamsoni_w by 0.3 (mul 10, div 3)
mov mdl, lamsoni_w
mov r15, #2
div r15
mov r4, mdl
mov r15, #03h
mul r4, r15
mov r15, #0Ah
div r15
mov r15, mdl

sub r14, r15 ; 15-0.3 * 2 (if lamsoni_w = 1.0)
mov r15, #2
mul r14, r15
mov r4, mdl
exts #38h, #1
mov actual_afr, r4

; jmpr cc_UC, loc_end
; rets

; desired part

exts #38h, #1 ; divide lamsbg_w by 2 and then multiply by 15
mov mdl, lamsbg_w
mov r15, #2
div r15
mov r4, mdl
mov r15, #0Fh
mul r4, r15
mov r14, mdl

exts #38h, #1 ; divide lamsbg_w by 2 and multiply lamsbg_w by 0.3 (mul 10, div 3)
mov mdl, lamsbg_w
mov r15, #2
div r15
mov r4, mdl
mov r15, #03h
mul r4, r15
mov r15, #0Ah
div r15
mov r15, mdl

sub r14, r15 ; 15-0.3 * 2 (if lamsbg_w = 1.0)
mov r15, #2
mul r14, r15
mov r4, mdl
exts #38h, #1
mov desired_afr, r4

jmpr cc_UC, loc_end



;*****END loc*****

loc_end:
movb rl4, ub
rets
Logged
aef
Hero Member
*****

Karma: +69/-46
Offline Offline

Posts: 1600


« Reply #7 on: January 05, 2015, 03:50:07 AM »

i know how to add its to vcds

It is descibed here: http://nefariousmotorsports.com/forum/index.php?topic=2349.0title=
but I am not sure if i understood your last sentences.


Logged
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #8 on: January 05, 2015, 05:50:36 AM »

It is descibed here: http://nefariousmotorsports.com/forum/index.php?topic=2349.0title=
but I am not sure if i understood your last sentences.



im sorry my english isnt good Sad i will try to explain

i know how to add existing variables to vcds because they have some kind of offset (1 nmot, 2 rl etc at page 1555 FR) but idk how to add a new variable which have not.
i spend all night searching where stock variables getting this offset with no luck

so im planning to take an unused second o2 sensor variables (that already have their offsets and can be added into vcds, i didnt searching right ones yet so lets imagine that they are called lam20 and lam21) and use them to show AFR in vcds.
but they also gettings values from stock routine and im not sure that this new value will not affect to some other ecu stuff even if second o2 turned off, so i want to create dummy variables with fixed values (like a stock lam20 and lam21 with unplugged o2) and completely replace everywhere in ecu lam20 & lam21 to my dummy20 and dummy21 adresses. thats my masterplan!
« Last Edit: January 05, 2015, 05:52:40 AM by fukenbroken » Logged
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #9 on: January 05, 2015, 05:31:35 PM »

nope
nop
nop
seems that somewhere stored a table with a factor, value limits, offset etc like in .ECU file and linked to memory adress not variable. im completely moved all instances of lamelsh_w to another memory adress and now its factor, offset etc are changed
my 14.7 working good at default lamelsh_w adress but in VCDS its limited to 1.99

nothing i can do now Sad
« Last Edit: January 05, 2015, 05:39:16 PM by fukenbroken » Logged
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #10 on: April 22, 2015, 03:24:57 PM »

ok now i know how it works
here is the source code for 032HN_0001

working good on a bench
will posting file tomorow after the road test Smiley



Code:
lamsbg_w  	EQU 09F78h ;38 desired afr 381ECAh = 9F78h
lamsoni_w EQU 09B2Eh ;38 current afr

act_afr EQU 04FF4h ;38
des_afr EQU 04FF6h ;38



;***************************************************************************************
; starts at 0xB3A00
; ************* ******** ********

;***current AFR

mov r4, lamsoni_w ; call from 0x835BA
cmp r4, #1FFFh
jmpr CC_ULE, loc_next
mov r4, #1FFFh

loc_next:
mov mdl, r4
mov r5, #10h
div r5
mov r5, mdl
mov r4, #93h
mul r5, r4
mov r5, mdl
shr r5, #8
exts #38h, #1
mov act_afr, r5

movb rl6, rl5
mov r8, #08h
movb rl7, #01h
rets

nop
nop


;**** desired AFR

mov r4, lamsbg_w ; call from 0x835D4
cmp r4, #1FFFh
jmpr CC_ULE, loc_nextx
mov r4, #1FFFh

loc_nextx:
mov mdl, r4
mov r5, #10h
div r5
mov r5, mdl
mov r4, #93h
mul r5, r4
mov r5, mdl
shr r5, #8
exts #38h, #1
mov des_afr, r5

movb rl6, rl5
mov r8, #08h
movb rl7, #01h
rets

nop
nop
« Last Edit: April 22, 2015, 03:29:55 PM by fukenbroken » Logged
vwaudiguy
Hero Member
*****

Karma: +53/-37
Offline Offline

Posts: 2024



« Reply #11 on: April 22, 2015, 03:54:14 PM »

I know absolutely nothing about this type of stuff. Where is this code stored you are modifying? Pretty cool project!
Logged

"If you have a chinese turbo, that you are worried is going to blow up when you floor it, then LOL."
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #12 on: April 22, 2015, 04:54:47 PM »

Here is the original code at 0x835BA


 
Code:
                movbs   r4, dwkrz_6    
                 mov     r5, #80h
                 sub     r5, r4
                 mov     r9, r5
                 mov     r8, #22h
                 movb    rl7, #4Bh
                 mov     r6, r9
                 jmpa    cc_UC, loc_8891B6

dwkrz_6 is unused variable in 1.8t (ignition retard cyl 7) and has phys num 94 (FS page 1555)
now here is a kwp1281 formulas table
http://nefariousmotorsports.com/forum/index.php?topic=22.0

r8 - data type / factor
r7 - A
r6 - B

unfortunaly there is no available space for afr math
so i changed it to

Code:
calls 8Bh, #3A00h
nop
nop
nop
nop
nop
nop
jmpa    cc_UC, loc_8891B6

and place a new code at 0xB3A00
and the other part for desired afr using dwkrz_7 with the same way
after that i put 94 and 95 in a vag-com 17 channel (it was dwkrz_6 and dwkrz_7 and now its an actual and desired afr) edit: moved to 35ch - lambda section Smiley
and job`s done Smiley
im also creating a new variables "act_afr" and "des_afr" because im planning to send them via CAN to cluster display
« Last Edit: April 22, 2015, 05:21:16 PM by fukenbroken » Logged
vwaudiguy
Hero Member
*****

Karma: +53/-37
Offline Offline

Posts: 2024



« Reply #13 on: April 25, 2015, 06:04:48 PM »

Another thing over my head, oh well! Grin Great work, and thanks for the explanation though! Time to get familiar with disasembly I guess??
Logged

"If you have a chinese turbo, that you are worried is going to blow up when you floor it, then LOL."
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #14 on: April 26, 2015, 09:03:23 AM »

This is done way too complicated.
In KWP1281 there are certain formulas to be used.

For example if you use formula 8, it is 0.1*a*b.
If you set normvalue a to 1, then your formula becomes 0.1*b, that way you have a range between 0 AFR and 25.5 AFR with a granularity of .1 AFR.

Taking lamsbg_w, the factor to convert to lambda is "0.000244141" and to AFR "0.0035888727"
However, because the formula is 10 times bigger, it means the factor needs to get multiplied another time, by 10.
So getting the factor of 0.035888727.

All you need to do after that is convert this to a factor and a normvalue. Meaning solving the equation X/(2^Y) = 0.035888727, so that the answer is as precise as possible. If you take Y = 16, then you do not even have to shift anything, you can just take MDH, and bounds check it.
With Y=16 , you get 2352.0036. That's precise enough.

Meaning all of your code in case of formula 8 in KWP1281 can be abbreviated as:
MOV R4, lamsbg_w
MOV R5, #9E4
MULU R4, R5

A three liner, after which the result is in MDH. If you want you can bounds check it, but it should not be neccessary.
just MOV R4, MDH and MOV answerbyte, RL4
« Last Edit: April 26, 2015, 09:05:12 AM by prj » Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.029 seconds with 17 queries. (Pretty URLs adds 0.001s, 0q)