Well, guys. I've been holding off on the update for a couple reasons. Mainly, I wanted to make a couple more updates, and I wanted a tailored post to this audience, but now I'm square in the middle of the next quarter, and it's looking less and less like I'll be able to devote the time again to this for a while. So, I just wanted to follow up with the executive summary I wrote. This isn't going away. I'm going to continue to work on this project, as well as my tunes in both foxes as the opportunity presents itself. In the end, the project went very well and resulted in an A for the group, even though I did almost all of the work, lol. That's ok, my partners don't have the same enthusiasm for this that I do, and they've helped me significantly in other classes. Without further adieu:
PYTHON PERFORMANCE TUNING
COMPUTATIONAL METHODS
20 MARCH 2018
INTRODUCTION:
Tuning is perhaps the most challenging aspect in modifying a high-performance street car. Tuning is the process of altering controllable variables to achieve the correct mixture of air and fuel throughout the operating range of an engine. Dozens of uncontrolled variables complicate the tuning process to the point that even the vast majority of do-it-yourself hobbyists who take pride in building their own car must still take it to a professional for this step.
Normally, tuning is a trial-and-error process whereby a tuner starts by inputting a best guess at the controllable variables and parameters, conducts a trial during which the tuner revises inputs based on singular observations, and eventually stops based on their best judgment and impression of how the engine feels. This is the process even in high-end, world class performance shops where customers typically pay around $1,000 each time they require tuning services.
OBJECTIVE:
Our objective in this Computational Methods exercise was to automate the tuning process in Python. Our goal was to take output directly from the computer of a high-performance engine with an existing sub-optimal tune and adjust its tuning tables to bring actual fuel injected to within 5% of desired values under normal operating conditions.
For the purposes of this exercise we defined “normal operating conditions” based on our assessment of how vehicles are typically operated on the street. While individual driving patterns vary, we targeted an engine speed range between 700 and 3,000 revolutions per minute (RPM) and an engine load range of between 15 and 85 kPa. At any given RPM, engine load is the capacity of the engine to produce power, and it is directly correlated with the pressure in the engine’s manifold, which is measured in kilopascals. 100 kilopascals is equivalent to atmospheric pressure.
SUMMARY OF FINDINGS:
Figure 1 depicts the AFR Diff Pct output from data collected in our base and final runs. Green cells indicate an AFR Difference within 5%, yellow cells indicate an AFR Difference of 5-16%, red indicates a difference of 16+%, and black indicates cells where not enough data was collected to accurately determine the AFR difference.
Figure 1:
In the data collected from the base tune, the percentage difference between the desired and the actual air-fuel mixtures varied widely. The automated tune corrections after two iterations produced a significant improvement. Whereas the base run produced only 4 cells that fell within our goal, the final iteration resulted in 21 green cells. 7 more remained within 7% of the desired air-fuel mixture, and only 2 cells remained outside of 15% of desired.
During our base run, our initial observations did not gather enough data on many of the cells, because our group had no way to determine how long the engine operated in each cell. Even though approximately 5.5 minutes of observations were collected in each sample, python output allowed us to better target cells after the base run. During both subsequent iterations, enough data was collected on almost every cell. However, the 15 kPa load range proved difficult to target, because it required 0 throttle input and a high rate of deceleration to generate the necessary conditions. Also, the engine idles at approximately 55 kPa, which made targeting 700-900 RPM at 30 kPa also challenging. This is still useful information, because it indicates that the lowest load range should be increased.
METHODOLOGY:
In each iteration, we exported the tuning table from the engine’s computer into a text file in XML format. We imported that into python using the xml.etree.ElementTree package. This provided the RPM, load ranges, and the values that controlled the amount of fuel to be injected in each load-RPM cell.
We collected roughly 5.5 minutes of logs while driving on roads in and around Monterey. The logs provide all available sensor readings 50 times per second for up to 30 seconds per log, which were output into csv files. Next, we imported and parsed the data into a Python Pandas data frame. After binning the data by RPM and load appropriate to the cells in the tuning table, we filtered out the cells that did not contain at least total 150 observations, an amount equivalent to spending at least 3 seconds in each cell. In Pandas, we calculated the AFR diff pct values for each cell, calculated the new recommended fuel table values, and exported them into a new tune file in XML format. Finally, we imported the new tune into the engine’s computer.
After the base tune data was collected, we ran two iterations to test our code and produced the results summarized in Figure 1.
CONCLUSION AND FUTURE WORK:
The automated tuning process has many significant advantages over the standard tuning method. Primarily, the standard method depends on single observations, whereas using the automated process the tuner can specify the amount of time required in each cell before adjustments are recommended. The automated process also helps in data collection, because with a quick run of our code, the tuner can see how many observations still need to be collected in each cell. Due to these advantages, the final tune resulted in the smoothest driving experience in this vehicle to date.
In the future, we will incorporate data filters that will provide a powerful tool to the tuner to understand the impact of the many uncontrollable variables that simultaneously affect the tune in previously unpredictable ways. Standard tuning using single observations make these uncontrollable variables infeasible to account for on an individual basis. Additionally, we will generate more analysis of the data using more sophisticated statistical techniques. Finally, we are currently working with the engine computer manufacturer and hope to gain access to the computer’s API to work towards automated in real time while driving.