Pages: [1] 2
Author Topic: Converting A2L to ECU  (Read 20299 times)
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« on: October 22, 2013, 08:21:34 PM »

Has anyone created an A2L to ECU converter for measurements?

I'm 3/4 of the way through creating a Perl script which does exactly this but there are a couple of values that are giving me issues.  I think I have most of the columns sorted expect for the offset column (B) which is giving me some issues.  Does anyone know how the formula for calculating the offset based on the A2L description?

As an example, tv2

A2L def:
/begin MEASUREMENT

    atv2
    "aktueller Lernkennfeld-Integratorwert der Regelung hinter Kat Bank2"
    SBYTE
    t100msxs_sb_q0p01
    1
    100
    -1.28
    1.27

   
    FORMAT "%5.3"
   
    ECU_ADDRESS 0x3829FC
    /begin IF_DATA ASAP1B_ADDRESS  KP_BLOB 0x3829FC /end IF_DATA
    /begin IF_DATA ETK  KP_BLOB 0x3829FC 0x1 0x1 /end IF_DATA
/end MEASUREMENT

/begin MEASUREMENT


ME7info .ECU output
atv2            , {}                                , 0x3829FC,  1,  0x0000, {s}       , 1, 0,         0.01,      0, {aktueller Lernkennfeld-Integratorwert der Regelung hinter Kat Bank 2}

Current version of Perl Script
atv2             , {}                    , 0x3829FC,  1,  0x0000, {s}       ,1, 0,          0.01, 1.28, {aktueller Lernkennfeld-Integratorwert der Regelung hinter Kat Bank2}

When I have a couple of little calcs figured out I will be making this available if anyone wants it
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #1 on: October 22, 2013, 08:35:19 PM »

Very interesting. i am also interested in the a2l format, but for different reasons: i'd like to make an xdf to a2l converter so i can import xdfs into winols and create .kps.
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
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #2 on: October 22, 2013, 08:56:34 PM »

Yeah that would also be interesting.

I'm trying to do this so I can import A2L defined variables into IDA, which I can pretty much do now.  But the second part is to have every A2L measurement definition in ECU format for logging without having to manually create the entries (worst case change the address from the A2L bin address to my 558B-002 address)

Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #3 on: October 22, 2013, 09:06:13 PM »

Has anyone created an A2L to ECU converter for measurements?

I'm 3/4 of the way through creating a Perl script which does exactly this but there are a couple of values that are giving me issues.  I think I have most of the columns sorted expect for the offset column (B) which is giving me some issues.  Does anyone know how the formula for calculating the offset based on the A2L description?

As an example, tv2

A2L def:
/begin MEASUREMENT

    atv2
    "aktueller Lernkennfeld-Integratorwert der Regelung hinter Kat Bank2"
    SBYTE
    t100msxs_sb_q0p01
    1
    100
    -1.28
    1.27

    
    FORMAT "%5.3"
    
    ECU_ADDRESS 0x3829FC
    /begin IF_DATA ASAP1B_ADDRESS  KP_BLOB 0x3829FC /end IF_DATA
    /begin IF_DATA ETK  KP_BLOB 0x3829FC 0x1 0x1 /end IF_DATA
/end MEASUREMENT

/begin MEASUREMENT


ME7info .ECU output
atv2            , {}                                , 0x3829FC,  1,  0x0000, {s}       , 1, 0,         0.01,      0, {aktueller Lernkennfeld-Integratorwert der Regelung hinter Kat Bank 2}

Current version of Perl Script
atv2             , {}                    , 0x3829FC,  1,  0x0000, {s}       ,1, 0,          0.01, 1.28, {aktueller Lernkennfeld-Integratorwert der Regelung hinter Kat Bank2}

When I have a couple of little calcs figured out I will be making this available if anyone wants it


atv2 offset appears to be zero...
-1.28 1.28 are NOT offsets in a2l, they are possible min/max values ... i.e. atv2 is a single signed byte that ranges from -128 (0x80) to 127 (0x7f), and scale is .01...

so technically 1.28 (should be 1.27) is wrong but hey, thats just nitpicking.

i dont think there is a way to encode offset in a2l, but i could be wrong.
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
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #4 on: October 22, 2013, 09:28:48 PM »

I think I getting there, it has to do with the Coeffs in the Compu Method.  If you look at the compu method name most are actually defined with factor and offset in the title!

t100msxs_sb_q0p01
Offset 0
Factor 0.01
(atv2)

temp_ub_q0p75_o48
Offset 48
Factor 0.75
(tmotlin)
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #5 on: October 22, 2013, 09:31:42 PM »

OH duh. there you go

youll just have to make a compu look up table in perl and deref it.

should be cake.
any chance you can post the perl on github or something?
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
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #6 on: October 22, 2013, 09:47:24 PM »

I will def make it available one way or another but the calc is not that easy as the title is only approx, to get it correct it needs to be calculated from the Coeffs themselves, will try and have it done by tomorrow. Will keep posting on progress
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #7 on: October 22, 2013, 09:50:51 PM »

easy enough to make a hash table with the factor/offset in it.
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
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #8 on: October 22, 2013, 10:03:29 PM »

Yeah the actual Perl side is not the issue it's the figuring out how the Coeffs work together to give the Factor and Offset.

In the ASAP2 defs the formula is f(x)=(axx+bx+c)/(dxx+ex+f), this does not work for all cases using the ECU from ME7Info as a guide.

I'm slowly getting there
Logged
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #9 on: October 22, 2013, 10:17:39 PM »

At this point looks like it might be

factor - f/b
offset - c/b

That matches 10 CompuMethods that use RAT_FUNC, more to test to make sure
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #10 on: October 22, 2013, 10:25:48 PM »

Yeah the actual Perl side is not the issue it's the figuring out how the Coeffs work together to give the Factor and Offset.

In the ASAP2 defs the formula is f(x)=(axx+bx+c)/(dxx+ex+f), this does not work for all cases using the ECU from ME7Info as a guide.

I'm slowly getting there

assuming a, d, and e are always zero (linear transfer function), shoudlnt it be f(x) = (b/f)x + c/f, so facctor is b/f and offset is c/f?
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
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #11 on: October 27, 2013, 04:45:20 AM »

Ok, I'm 90% of the way there but there are a few entries that are not matching the ECU file from MEInfo.

As an example:  A2L then .ECU
frkte_w   0.0001667    frkte_w   0.0001111

Now the interesting thing is when I check my XDF for the krkte factor it is 0.0001667.  I would have thought it should be same as frkte,  as they both use the same CompuMethod:rkti11_sy, so factor should be the same right?

Could the .ECU output be wrong for these measurements?  Or am I thinking about this wrong?
Logged
Milka
Full Member
***

Karma: +3/-0
Offline Offline

Posts: 129


« Reply #12 on: October 27, 2013, 04:49:19 AM »

assuming a, d, and e are always zero (linear transfer function), shoudlnt it be f(x) = (b/f)x + c/f, so facctor is b/f and offset is c/f?

Yeah agree, but unfortunately they are not always 0
Logged
gremlin
Hero Member
*****

Karma: +196/-9
Offline Offline

Posts: 653


« Reply #13 on: October 28, 2013, 05:30:35 AM »

As an example:  A2L then .ECU
frkte_w   0.0001667    frkte_w   0.0001111

Now the interesting thing is when I check my XDF for the krkte factor it is 0.0001667.  I would have thought it should be same as frkte,  as they both use the same CompuMethod:rkti11_sy, so factor should be the same right?

frkte factor depends on processor ticks and will different if MCU use different clock frequency.
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #14 on: October 28, 2013, 05:36:22 AM »

Yeah agree, but unfortunately they are not always 0

if any are non zero you cannot represent the transfer function via factor + offset.

if a, b and d are zero, but e is not, then the transfer function is a linear inverse.
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
Pages: [1] 2
  Print  
 
Jump to:  

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