Lambda Delay TunerStudio Log Parser

Fuel Supply & Ignition Systems

Moderator: Tom Notch

Post Reply
luftvagon
Posts: 239
Joined: Tue May 01, 2012 11:27 am
Location: Little Rock, AR

Lambda Delay TunerStudio Log Parser

Post by luftvagon » Sun Jan 01, 2017 5:24 pm

Got bored, decided to write a "Lambda Delay" estimator using parsing of your TunerStudio logs. The more records, the longer the log, the better.

If anybody has a very long TunerStudio log, and you think your Lambda Delay is correct, please let me take a look at your log file to see if numbers will match close to the script output.

Usage:

Code: Select all


$ l_delay.gawk Downloads/2016-12-27_18.01.04.msl 
F:1656:S:1657:T:1662 Delay: 387ms RPM: 1180 MAP: 64
F:1657:S:1658:T:1662 Delay: 322ms RPM: 1196 MAP: 64
F:1666:S:1667:T:1670 Delay: 200ms RPM: 2128 MAP: 65
F:1680:S:1681:T:1686 Delay: 334ms RPM: 1502 MAP: 65
F:1719:S:1720:T:1724 Delay: 270ms RPM: 2093 MAP: 65
...
Requirements:
  • GNU Awk
Limitations:
  • Single Wide Band Sensor
  • Single Channel Batch Fuel Delivery
Change Log:
  • 00001a

Code: Select all


Split "events" ahead into PW, and AFR. 
Spit out event line # for first,second,and third data point for log reference lookups.
  • 00001

Code: Select all


Initial Release
Last edited by luftvagon on Mon Jan 02, 2017 1:19 pm, edited 8 times in total.
1981 Volkswagen Vanagon Westfalia - air-cooled Type4 1970cc CV (hydraulic lifters, 42x36 valves, stock cam, microSquirt FI)
1993 Ford F-250 XL LWB Extended Cab 7.3L IDI

luftvagon
Posts: 239
Joined: Tue May 01, 2012 11:27 am
Location: Little Rock, AR

Re: Lambda Delay TunerStudio Log Parser

Post by luftvagon » Sun Jan 01, 2017 5:25 pm

Code:

Code: Select all


#!/usr/bin/awk -f 
# awk script to figure out lambda delay based on changes to pw, followed by afr changes logged within tunerstudio mlv logs.
# version 00001a

BEGIN {
# Field Separator; either \t or , for CSV
FS="\t"

# How many PW events ahead to look for deltas
pw_events_ahead=1

# How many AFR events ahead to look for deltas
afr_events_ahead=5

# Reject events with CLT below
clt_reject_below=170

# Delta PW (10%)
delta_pw = 90

# Delta AFR (15%)
delta_afr = 85
}

function cmp_num_idx(i1, v1, i2, v2)
{
# numerical index comparison, ascending order
return (i1 - i2)
}

/Time/ {
q=split($0,a,"\t")
for (v=1;v<=q;v++) {
c[a[v]]=v
}
}

/^[0-9]/ {
q=split($0,a,"\t")
track[NR]["TIME"] = a[c["Time"]]
track[NR]["RPM"] = a[c["RPM"]]
track[NR]["MAP"] = a[c["MAP"]]
track[NR]["AFR"] = a[c["AFR"]]
track[NR]["PW"] = a[c["PW"]]
track[NR]["CLT"] = a[c["CLT"]]
}

END {
PROCINFO["sorted_in"] = "cmp_num_idx"
for (first_data_point in track) {
if (track[first_data_point]["CLT"] >= clt_reject_below) {
for (second_data_point = first_data_point; second_data_point <= first_data_point+pw_events_ahead; second_data_point++) {
if ((track[second_data_point]["PW"] > delta_pw/100) && (track[first_data_point]["PW"] > 100/delta_pw) ) {
deltapw = track[first_data_point]["PW"]/track[second_data_point]["PW"]
} else {
deltapw = 1
}
if ((deltapw < delta_pw/100) || (deltapw > 100/delta_pw)) {
for (third_data_point = second_data_point; third_data_point <= second_data_point+afr_events_ahead; third_data_point++) {
if ((track[second_data_point]["AFR"] > 0.1) && (track[third_data_point]["AFR"] > 0.1) ) {
deltaafr = track[third_data_point]["AFR"]/track[second_data_point]["AFR"]
} else {
deltaafr = 1
}
if ((deltaafr < delta_afr/100) || (deltaafr > 100/delta_afr)) {
if ((track[third_data_point]["TIME"]-track[second_data_point]["TIME"] < 1 ) && (track[second_data_point]["RPM"] > 0)) {
printf "F:%d:S:%d:T:%d Delay: %dms\tRPM: %d\tMAP: %d\n", first_data_point, second_data_point, third_data_point, (track[third_data_point]["TIME"]-track[second_data_point]["TIME"])*1000 , track[second_data_point]["RPM"] , track[second_data_point]["MAP"]
}
break
}
}
break
}
}
}
}
}
Alternative:

Find 0 PW, and seek for "freeair" AFR; display delta between the two events.

Code: Select all


#!/usr/bin/awk -f 
# awk script to figure out lambda delay based on changes to pw, followed by afr changes logged within tunerstudio mlv logs.

BEGIN {
# Field Separator; either \t or , for CSV
FS="\t"

# Maximum events to seek ahead
events_ahead = 15

# Controller Freeair AFR
freeair_afr = 22.3

# Controller Power-on AFR
poweron_afr = 7.5

# Reject events with CLT below
clt_reject_below=120
}

function cmp_num_idx(i1, v1, i2, v2)
{
# numerical index comparison, ascending order
return (i1 - i2)
}

/Time/ {
q=split($0,a,"\t")
for (v=1;v<=q;v++) {
c[a[v]]=v
}
}

/^[0-9]/ {
q=split($0,a,"\t")
track[NR]["TIME"] = a[c["Time"]]
track[NR]["RPM"] = a[c["RPM"]]
track[NR]["MAP"] = a[c["MAP"]]
track[NR]["AFR"] = a[c["AFR"]]
track[NR]["PW"] = a[c["PW"]]
track[NR]["CLT"] = a[c["CLT"]]
}

END {
PROCINFO["sorted_in"] = "cmp_num_idx"
for (first_data_point in track) {
if ((track[first_data_point]["CLT"] >= clt_reject_below) && (track[first_data_point]["AFR"] > poweron_afr)) {
if (track[first_data_point]["PW"] < 1) {
found = 0
for (second_data_point = first_data_point+1; second_data_point <= first_data_point+events_ahead; second_data_point++) {
if ((track[second_data_point]["AFR"] == freeair_afr) && (track[first_data_point]["AFR"] < freeair_afr) && (track[first_data_point]["AFR"] > poweron_afr)) {
if (found == 0) {
printf "Event: %d-%d \tDelta: %dms \tPW: %3.2f \tMAP: %d \tRPM: %d \tAFR: %3.1f \t| \tPW: %3.2f \tMAP: %d \tRPM: %d \tAFR: %3.1f \n" , first_data_point, second_data_point, 1000*(track[second_data_point]["TIME"]-track[first_data_point]["TIME"]) , track[first_data_point]["PW"], track[first_data_point]["MAP"], track[first_data_point]["RPM"], track[first_data_point]["AFR"], track[second_data_point]["PW"], track[second_data_point]["MAP"], track[second_data_point]["RPM"], track[second_data_point]["AFR"]
found = 1
}
}
}
}
}
}
}
Last edited by luftvagon on Mon Jan 02, 2017 5:01 pm, edited 12 times in total.
1981 Volkswagen Vanagon Westfalia - air-cooled Type4 1970cc CV (hydraulic lifters, 42x36 valves, stock cam, microSquirt FI)
1993 Ford F-250 XL LWB Extended Cab 7.3L IDI

User avatar
MarioVelotta
Posts: 3741
Joined: Wed Mar 12, 2003 3:01 am
Location: Monroe, Wa.
Contact:

Re: Lambda Delay TunerStudio Log Parser

Post by MarioVelotta » Sun Jan 01, 2017 8:36 pm

luftvagon wrote:If anybody has a very long TunerStudio log, and you think your Lambda Delay is correct, please let me take a look at your log file to see if our numbers match. I'll be posting the script in the 2nd thread, after I do some more testing.
Hey Luftvagon, way to go! Can you teach me how to code? :)

How would our numbers match? Each install is going to be different due to countless differences from engine to engine. I've got some long logs with data from the 6 02 sensors I have in my exhaust right now :roll: :mrgreen: The Major 4 are just off the heads about 4", the 5th is just before the collector on a type 1 sidewinder type exhaust and the 6th is about 4" further but after the collector. This was actually to test the internal lambda controller in my new ECU's against the LC2 that was in the 5th position.
The Dub Shop
Mario@thedubshop.net
2276 Turbo - 92 Octane
11.537 @ 115.74mph - 15psi
1600dp - 18sec @ 0psi :lol:
Facebook-Tech-Store

luftvagon
Posts: 239
Joined: Tue May 01, 2012 11:27 am
Location: Little Rock, AR

Re: Lambda Delay TunerStudio Log Parser

Post by luftvagon » Sun Jan 01, 2017 9:17 pm

Hey Mario,

The number(s) to compare would be your lambda delay (probably calculated using a different method/guessing/or default) versus what the your log produces. I don't have any of my own logs to try it on, so I will go for a long drive on Tuesday. Currently, I was testing this on someone else's 5 MB log file, and it got some good data points.

Here is what the program/parser does:
- I take each event in the log that has CLT>130F (adjustable) (event1)
- For each event, I look for subsequent events that have PW delta __ % (configurable) (event2)
- and then, I follow event2 subsequent AFR delta __%. (event3)
- If event3-event2 AFR delta % is met, spit out event3-event2 time delta, followed by event2's RPM, and event2 MAP.

In theory, this sounds "close" to the magic numbers we need. One could go further to average this, because there would be many data points.
1981 Volkswagen Vanagon Westfalia - air-cooled Type4 1970cc CV (hydraulic lifters, 42x36 valves, stock cam, microSquirt FI)
1993 Ford F-250 XL LWB Extended Cab 7.3L IDI

luftvagon
Posts: 239
Joined: Tue May 01, 2012 11:27 am
Location: Little Rock, AR

Re: Lambda Delay TunerStudio Log Parser

Post by luftvagon » Mon Jan 02, 2017 1:48 pm

I wrote another version that will only look for PW = 0, and then look for subsequent AFR DROP -- it may be more helpful:

Code: Select all


$ l_delay_3.gawk Downloads/2016*.msl | more
Event: 1812-1813 Delta: 62ms PW: 0.00 MAP: 17 RPM: 2156 AFR: 16.3 | PW: 0.00 MAP: 17 RPM: 2149 AFR: 22.3
Event: 2153-2154 Delta: 78ms PW: 0.00 MAP: 17 RPM: 2054 AFR: 21.4 | PW: 0.00 MAP: 18 RPM: 2023 AFR: 22.3
Event: 2542-2543 Delta: 93ms PW: 0.00 MAP: 18 RPM: 1937 AFR: 20.0 | PW: 0.00 MAP: 18 RPM: 1950 AFR: 22.3
Event: 2629-2631 Delta: 125ms PW: 0.00 MAP: 22 RPM: 1499 AFR: 22.3 | PW: 0.00 MAP: 25 RPM: 1451 AFR: 8.4
Event: 2630-2631 Delta: 61ms PW: 0.00 MAP: 23 RPM: 1488 AFR: 22.3 | PW: 0.00 MAP: 25 RPM: 1451 AFR: 8.4
Event: 2631-2632 Delta: 78ms PW: 0.00 MAP: 25 RPM: 1451 AFR: 8.4 | PW: 1.58 MAP: 28 RPM: 1470 AFR: 7.5
Event: 3601-3602 Delta: 62ms PW: 0.00 MAP: 17 RPM: 2163 AFR: 21.4 | PW: 0.00 MAP: 18 RPM: 2154 AFR: 22.3
Event: 10211-10212 Delta: 62ms PW: 0.00 MAP: 15 RPM: 2557 AFR: 22.2 | PW: 0.00 MAP: 15 RPM: 2565 AFR: 22.3
Event: 11536-11537 Delta: 62ms PW: 0.00 MAP: 18 RPM: 1887 AFR: 22.0 | PW: 0.00 MAP: 19 RPM: 1880 AFR: 22.3
1981 Volkswagen Vanagon Westfalia - air-cooled Type4 1970cc CV (hydraulic lifters, 42x36 valves, stock cam, microSquirt FI)
1993 Ford F-250 XL LWB Extended Cab 7.3L IDI

User avatar
Piledriver
Moderator
Posts: 21715
Joined: Sat Feb 16, 2002 3:01 am
Location: Van Alstyne, Texas

Re: Lambda Delay TunerStudio Log Parser

Post by Piledriver » Mon Jan 02, 2017 3:49 pm

Nice work!

I'll give it a try later this week, waiting on some brake bits.
I, for one, regularly embrace our new robot overlords, as I am the guy fixing the robots...

User avatar
MarioVelotta
Posts: 3741
Joined: Wed Mar 12, 2003 3:01 am
Location: Monroe, Wa.
Contact:

Re: Lambda Delay TunerStudio Log Parser

Post by MarioVelotta » Mon Jan 02, 2017 4:27 pm

When it looks for 0.00 PW, are you then looking for the Lambda Feedback to reach freeair or just change from current?
The Dub Shop
Mario@thedubshop.net
2276 Turbo - 92 Octane
11.537 @ 115.74mph - 15psi
1600dp - 18sec @ 0psi :lol:
Facebook-Tech-Store

luftvagon
Posts: 239
Joined: Tue May 01, 2012 11:27 am
Location: Little Rock, AR

Re: Lambda Delay TunerStudio Log Parser

Post by luftvagon » Mon Jan 02, 2017 4:46 pm

Mario, I can make it either or configurable.. What would be freeair? 22.3? Guess that value would be controller specific.

awk code posted above.
1981 Volkswagen Vanagon Westfalia - air-cooled Type4 1970cc CV (hydraulic lifters, 42x36 valves, stock cam, microSquirt FI)
1993 Ford F-250 XL LWB Extended Cab 7.3L IDI

User avatar
MarioVelotta
Posts: 3741
Joined: Wed Mar 12, 2003 3:01 am
Location: Monroe, Wa.
Contact:

Re: Lambda Delay TunerStudio Log Parser

Post by MarioVelotta » Tue Jan 03, 2017 11:01 pm

Anyway I can run this on a PC without linux?
The Dub Shop
Mario@thedubshop.net
2276 Turbo - 92 Octane
11.537 @ 115.74mph - 15psi
1600dp - 18sec @ 0psi :lol:
Facebook-Tech-Store

User avatar
Piledriver
Moderator
Posts: 21715
Joined: Sat Feb 16, 2002 3:01 am
Location: Van Alstyne, Texas

Re: Lambda Delay TunerStudio Log Parser

Post by Piledriver » Wed Jan 04, 2017 2:12 am

MarioVelotta wrote:Anyway I can run this on a PC without linux?
More work than you would probably like.
Installing the gnu tools compiled for windows has always been iffy, if available at all.

That's why MS is working on a compatibility layer and has ported bash to WinX...
bash makes powershell seem like command.com...

Boot from a USB stick of DVD, recent Knoppix DVD has all of the tools you need, and you can "install" more packages w/o installing to you HDD. You can even install TS etc. Works fine, even with just a "persistent" Live install to USB.

You can even install fully to a large USB stick or drive, works fine, although Knoppix isn't really intended to be a real distro.
Mint 18/kde or Mageia 5.1 are probably better choices, and can also be installed to USB.
(Mageia 6 will be out RSN)
I, for one, regularly embrace our new robot overlords, as I am the guy fixing the robots...

luftvagon
Posts: 239
Joined: Tue May 01, 2012 11:27 am
Location: Little Rock, AR

Re: Lambda Delay TunerStudio Log Parser

Post by luftvagon » Thu Jan 05, 2017 8:45 am

1981 Volkswagen Vanagon Westfalia - air-cooled Type4 1970cc CV (hydraulic lifters, 42x36 valves, stock cam, microSquirt FI)
1993 Ford F-250 XL LWB Extended Cab 7.3L IDI

Post Reply