Tag Archives: plot

Log Graphs 1


Car: 2009 Impreza 2.0 Turbo Diesel, 110 kW / 148 hp / 150 PS, European domestic market, Euro 4 spec.

Important: Newer Boxer Diesel generations (Euro 5/6) may show different behaviour!

ECU firmware: patched ROM for unlimited logging, otherwise stock.
Protocol: SSM2 via CAN
More than 120 items had been logged, plenty of RAM variables (*) plus standard SSM2 items at roughly 170 ms interval.


I prepared two graph images plotting some interesting parameters, click picture for full resolution:

Image 1/2


Image 2/2


Additional details

… at specific time positions:

#1: State before active regeneration

Time @ ~ 33 ½ min
Cruise Control: active
Vehicle Speed*: 110 km/h
Engine Speed: 2300 rpm
Gear: 5
Coolant Temperature: 93 °C
Injections: 2 (pre + main)
Soot Accumulation Ratio: 64 %
DPF Pressure Difference: ~ 5 kPa
Exhaust Gas Temperature (EGT) Catalyst Inlet: 345 °C
EGT DPF Inlet: 370 °C
Intake Air Amount: 430 mg/cyl
Mass Air Flow: 33.8 g/s
Manifold Absolute Pressure (MAP)*: 126 kPa
Inlet Air Temperature: 25 °C
Manifold Air Temperature: 48 °C
Fuel Temperature: 58 °C
Throttle Opening Angle: 79 deg
EGR Valve Opening Angle: 38 deg
Final Oil Dilution Rate*: -1.9 mg/s (evaporation)
Oil Dilution Amount: 282.0 g (4.6 %)

#2: Soot 65%, preparing for DPF regeneration

@ 33 ¾ min
Soot Accumulation Ratio* reaches 65%, this triggers active regeneration preparations. Note: I am referring to the actual RAM value, diagnostic parameter may indicate 65% earlier due to rounding.
Apparently ECU now does 3 injections (pre + main + after) when power demand is high enough, no post injections yet

#3: Active Regen ON

@ 34:04; = 20 seconds after #2, DPF Regeneration Switch turns ON
EGR valve closes instantly, 0 deg
Manifold Air Temperature dropping
Boost Control opens VGT immediately, from 52 to 25%
Manifold Absolute Pressure* dropping
pilot-injection kicks in, 2 injections (pilot C + main)
post-injections begin to fade in but not active yet

#4: Post-Injections

@ 33 seconds after #2, post-injections A + B become operational (injection amount > 0)
oil dilution rising
EGTs climbing
Manifold Absolute Pressure*: 75 kPa (~ 25 below ambient), varying, stays below ambient most of the time during regen at low power demand
EGT Catalyst Inlet: 340 °C
EGT DPF Inlet: 320 °C
injections: 4 (pilot C + main + post A + post B)

#5: Coasting Fuel Cut-Off During Regen

Example @ 35:12
EGR valve opens instantaneously, 70 deg; EGR behaves rather digitally during regen – either fully closed (0 deg, for max EGT) or max opened (70 deg, less fresh air)
Throttle Opening Angle: rising up to 31 deg
injections: 0
Fuel Consumption*: 0 mm³/s
oil dilution going down slowly due to estimated evaporation
EGT Catalyst Inlet: decreases fast, EGT at DPF inlet (> 600 °C) follows with a delay
Engine Speed: gear change from 5th to 6th to reduce engine braking effect

#6: Idling with Active Regen ON

@ 45:30
Engine Speed: 800 rpm
Post A Injection Amount*: 0
Post B Injection Amount*: ~ 8 mm³/st
Apparently while idling the ECU prefers the 2nd post-injection (“B”), otherwise during driving it’s rather mixed
Final Oil Dilution Rate: ~ 20 mg/s (medium)
Boost Control: 25 % (VGT fully open)
Manifold Absolute Pressure*: 74 kPa
Throttle Opening Angle: 5.5 deg
EGR Valve Opening Angle: 0 deg
Intake Air Amount: 370 mg/cyl
Mass Air Flow: 9.8 g/s

#7: DPF Regeneration OFF

@ 46:15, decision is based on elapsed time from #2, achieved soot level does not matter (!)
DPF Regeneration SW had been ON for 12.2 minutes
all post-injections off
Oil Dilution Amount*: 299.6 g (4.9 %) = + 0.3 % during regeneration
EGR back to normal operation
Boost Control: 65 % instantly (max speed, spooling up turbo)
MAP rising
EGT Catalyst Inlet: 270 °C
EGT DPF Inlet: 490 °C

Yet another color map for EcuFlash

Perhaps another color map for EcuFlash might be interesting? I wrote a little SageMath python script to generate a ScoobyRom-like color map file.

EcuFlash using ScoobyRom color map

EcuFlash using ScoobyRom color map

Note: Although generated color map matches ScoobyRom’s precisely, EcuFlash applies colors based on “min” and “max” specified in XML definitions.

Excerpt from EcuFlash definition file: 32BITDIESELBASE.xml

<scaling name="ChargeAirPressure" units="kPa" toexpr="x" frexpr="x" format="%.0f" min="0" max="255" inc="1" storagetype="uint8" endian="big"/>

Whereas ScoobyRom scales colors ranging from a map’s actually used mininum and maximum. For example, if you would change min="0" to min="100" in above scaling definition, low value colors would appear bluish like in ScoobyRom, effectively making map graphics cover more/most of available color range.


1) Download file scoobyrom-map.odt

2) Rename downloaded file to ScoobyRom.map, since normal file extension is not allowed on wordpress.com.

3) Move file into EcuFlash’s color maps folder, i.e.

C:\Program Files (x86)\OpenECU\EcuFlash\colormaps\

4) Launch or restart EcuFlash.

5) Via EcuFlash menu: File → Options → Appearance → Default Color Map
Select “ScoobyRom.map”
(Btw., default color map directory can also be defined in Options)

Color Map File Format

Color map format is plain text ASCII file, usually 256 lines as in this case, specifying RGB values which will be applied to maps, from low to high:

153 153 255
153 154 255
153 156 255
152 157 255
255 110 103
255 107 102
255 105 102
255 102 102

Fuel Level


On Euro 4/5 diesel models fuel level is being measured by BIU and sent onto CAN-bus as sensor resistance value in ohms (Ω). The ECU parses this and does some processing. First it calculates artificial fuel level voltage using standard voltage divider formula. Voltage value is being damped because the source info fluctuates a lot with fluid moving. Then the damped result is being used for LUT (Lookup table).

Euro 6: fuel level is being digitized by combination meter.

Tables (2D Maps)

So far all Euro 4 diesel ROMs contain this table:

Fuel Tank Level, 2D table, Euro 4, CID: JZ2F441A, ScoobyRom screenshot

Fuel Tank Level, 2D table, Euro 4, CID: JZ2F441A, ScoobyRom screenshot

From Euro 5 ROMs, slightly different:

ScoobyRom screenshot portion, viewing 2D table, Euro 5 diesel ROM CID JZ4A211B

Fuel Tank Level, 2D table, Euro 5, CID: JZ4A211B, ScoobyRom screenshot


Did some work using GNU Octave – import table data (ScoobyRom export as CSV), applying formulas, plot (gnuplot backend) – all on GNU/Linux of course. Btw, Octave comes with built-in interpolation functions.

“The Octave language is quite similar to Matlab so that most programs are easily portable.”
Example Octave formula:

function retval = FuelLevelVoltage (R1, R2, Vin)
         retval = Vin * R2 / (R1 + R2)

For above voltage divider, where:

  • Vin: Battery Voltage (assumed const in this case)
  • R1: const series resistor
  • R2: variable fuel level resistance (two sensors in series)
  • Vout: fuel level voltage (artificial ECU value in this case)

This way I eliminated ECU’s artificial fuel level voltage, creating direct relationship between resistance [ohm] (CAN value) and volume [litre].

Results: volume [litre] vs. resistance [ohm]

Euro 4

Fuel Level vs. Resistance (Euro 4)

Euro 5

(to do…)

Diagnostic Trouble Codes

DTCs are triggered when (artificial) fuel level voltage is outside range. As usual it’s not that simple, many conditions may affect this, too – battery voltage, CAN state etc.

  • P0462 Fuel Level Sensor Circuit (Low Input)
  • P0463 Fuel Level Sensor Circuit (High Input)

gnuplot Power Graph

Created gnuplot script file which plots 2.0D 110 kW power graphs out of two CSV files (torque & power). For CSV data origin see post Power graphs and Calculations. gnuplot experience might come handy from time to time…

Script + data files in here: gnuplotPowerGraph1.zip

By the way, thanks go to http://www.pariaonecu.com for file hosting support.

Tested on Linux, script file displays graph on screen, also creates SVG vector graphics file.
View SVG result (best, good web browser needed): PowerGraph(Subaru).svg

Raster screenshot in case you cannot view SVG:

Assuming gnuplot is installed. To run script type:
gnuplot -p 'PowerGraph(Subaru).gpl'

# gnuplot script
# Linux: gnuplot -p "thisscriptfilename"
# -p  --persist		to keep graph window

# set custom variables
fileTorque = "Torque(Subaru).csv"
filePower = "Power(Subaru).csv"
color1 = "blue"
color2 = "brown"
plotFile = "PowerGraph(Subaru).svg"

# debug: show variable content
#print fileTorque

# necessary for CSV data, input file contains comma-separated values fields
set datafile separator ","

###### terminal settings
set termoption enhanced
set term wxt font "sans,14"

###### title, labels
set title "Boxer Diesel 2.0 110 kW Power Graphs (digitized official Subaru data)"

set xlabel "Engine Speed [1/min]"
set xrange [800 : 4700]	# optional

set ylabel "Torque [Nm]" textcolor rgb color1
set y2label "Power [kW]" textcolor rgb color2

###### define linestyles
# 1: Torque curve
set style line 1 linetype 1 linecolor rgb color1 linewidth 3
# 2: Power curve
set style line 2 linetype 1 linecolor rgb color2 linewidth 3
# 10: grid lines
set style line 10 linetype 1 linecolor rgb "gray"

###### grid lines (independent settings for x, y, y2 are not possible?)
#set grid xtics ytics y2tics linestyle 10
set grid xtics ytics linestyle 10

###### axis tics & labels
# nomirror: don't display tic marks on other side/axis
# x axis tics+grid: increment = 200 1/min
set xtics 200
set ytics nomirror textcolor linestyle 1
set y2tics nomirror textcolor linestyle 2

set autoscale y
set autoscale y2

###### legend
# set key default
# set key bottom center box

###### plot
plot fileTorque title "Torque" with lines linestyle 1, filePower title "Power" with lines linestyle 2 axes x1y2

# quit script immediatly for debugging

pause -1 "Hit return to create SVG file"

###### SVG output (commands sent via standard input from app)
# could also do PDF, LaTeX, PNG etc.
## remember current terminal
set terminal push

# page size affects page layout, relative font size etc. - defaults may not look nice
#set terminal svg size 1200,800 dynamic enhanced font "sans,16"
set terminal svg size 1600,1000 dynamic enhanced

# plot into file, using own variable set at beginning
set output plotFile

## switch back to previous terminal
set terminal pop

Power Graphs and Calculations v2

Updated 2011-01-16: corrected data, added details

Official graphs

These are official Boxer Diesel power graphs from Subaru press info, dated 2008:

Digitizing with Inkscape, zoomed in, bitmap layer in background:

Saved as SVG (Inkscape’s default format) coordinates are plain readable. Some conversion had to be done – SVG origin is top left, scaling, relative coordinates etc.

Digitized torque data

Engine Speed [1/min],Torque [Nm]

Function plot, linear interpolation:

Digitized power data

Engine Speed [1/min],Power [W]

Since power can be calculated from torque and angular velocity, this can be used to check the official power curve. Looks like someone put “lipstick” on the last part of the curve…

Drive force

After applying some math (torque curve, vehicle speed vs. RPM, gear ratios)…

View above graph as SVG (best quality).

Theoretical shift points

Calculated intersection points (drive force equality solutions), slightly rounded:

v [km/h] Gear1 RPM1 [1/min] Gear2 RPM2 [1/min]
75 2 4340 3 2630
116 3 4070 4 3010
151 4 3920 5 3170
181 5 3800 6 3340

Engine Speed vs. Vehicle Speed

View/download above graph as SVG (best quality).
Unfortunately SVG graphics cannot be inlined directly in here.

X-axis is actual vehicle speed as reported from a GPS device or logging using OBD-II protocol. Speedometer shows 6-8% higher e.g. 107 km/h instead of actual 100 km/h.
By the way, tachometer indication seems accurate, this one is driven by square-wave signal generated by the ECU.

Might also apply to other models (same final drive ratio, wheel size)! For gearbox information (gear ratios) see this page: Transmission – 6MT