Fuel Consumption Using OBD-II and Support Vector Machine Model

)is paper presents a method to estimate gasoline fuel consumption using the onboard vehicle information system OBD-II (Onboard Diagnoses-II). Multiple vehicles were used on a test route so that their consumption can be compared.)e relationships between fuel consumption and both of the engine speed are measured in RPM (revolutions per minute), and the throttle position sensor (TPS).)e relationships are expressed as polynomial equations.)emethod which is composed of an SVM (support vector machine) classifier combined with Lagrange interpolation, is used to define the relationship between the two engine parameters and the overall fuel consumption. )e relationship model is plotted using a surface fitting tool. In the experimental section, the proposedmethod is tested using the vehicles on a major highway between two cities in Jordan.)e proposedmodel gets its sample data from the engine’s RPM, TPS, and fuel consumption.)emethod successfully has given precise fuel consumption with square root mean difference of 2.43, and the figures are compared with the values calculated by the conventional method.


Introduction
Over the past few years, automotive manufactures have been concerned about reducing emissions and the overall utilization of fuel resources that is associated with the transportation industry.
is evolving problem has urged government agencies and decision-makers to set regulations and standards on efficiency and low emissions [1].Moreover, the high costs of oil, together with the rising worries about environmental and atmospheric pollution, has forced automotive manufacturers to the development and marketing of energy efficient vehicles, by adopting strategies such as (i) designing more efficient small displacement engines, (ii) reducing weight and coefficient of drag of the vehicle, (iii) usage of low profile tires to minimize rolling resistance, (iv) adding an electric powertrain along with the conventional fuel engine, etc. [2].Worldwide, governments are imploring for more efficient vehicles; therefore, there have been outstanding advancements in the use of alternative and low emission fuels such as hydrogen combustion cells.For the past decade, the Japanese government has been urging Japan's automotive manufacturers to increase the development work spent on battery-powered electric vehicles (EVs) and hybrid electric vehicles (HEVs).Fuel cell electric vehicles (FCVs) such as hydrogen cells is one more types that is either used to generate power using hydrogen combustion engine which moves the vehicle or indirectly generating electricity to power up an electric motor [3].
Earlier, non-spark-ignition engines (diesel) were known for their weakness in terms of emissions and reliability.However, only very recently, modern technologies have significantly improved such engines.In general, diesel engines get better fuel mileage when compared with gasoline engines.Despite that, this work studies gasoline powered vehicles because they produce less harmful emissions and because the overall trend nowadays is moving towards gasoline and hybrid/electric vehicles.is paper brings to discussion fuel consumption in real-time using instantaneous vehicle parameters and tries to estimate such consumption using an SVM. is work does not necessarily suggest the best driving style nor how to save fuel, but it attempts to model fuel consumption on a specific terrain for three vehicles, each of which has different engine displacements using machine learning prediction.While evaluating the vehicles, it is also worth comparing them in terms of fuel efficiency as an attempt to answer the question that "would the type of the vehicle help improving gas mileage over a specific terrain?"In other words, "would a vehicle with a bigger displacement engine be more efficient than vehicles with relatively smaller engines when driven in the same conditions?" is paper presents an overview of the related work and contribution in Section 2. A discussion of the OBD-II system is presented in Section 3, followed by a brief description of the PIDs found in the OBD-II connector.Section 4 shows the experiment details and discusses fuel economy for the test vehicles.Section 5.1 gives an overview of the proposed method.Section 5.2 presents the results of prediction equations and fuel consumption validation for the vehicles, followed by the conclusion in Section 6.

Literature Review and Contribution
Meanwhile, until alternate power vehicles are mass-produced, efficient utilization of fuel is the current concern [4].Taking this into consideration, economical driving (or ecodrive) is one of the effective methods that can be very useful.As it is mentioned earlier, economical driving can be defined as a driving style that does not put unnecessary load on the engine.Although most modern vehicles are equipped with onboard economy-mode feature, many driving manners can be of great influence to minimize fuel consumption while driving.Researchers who expertise in vehicular engineering have had special interest in developing methods for fuel emissions over a driving cycle.Alessandrini et al. [5], for example, were interested in creating a new method that gives more precise description of the relationship between fuel consumption and the road network or specific users.Ericsson [6] explains that fuel can be saved by avoiding sudden changes in acceleration and high-speed driving definitely consumes more fuel.Instead, driving styles should include upshifting to a higher speed at the right time, avoiding speeds that exceed 100 km/h, anticipating traffic flow, accelerating and decelerating smoothly with minimal usage of brakes, and keeping the vehicle in good mechanical condition.Meseguer et al. [7] suggest maintaining lessfrequent tendency for deceleration followed by acceleration, minimizing the use of low gears, and trying to get to highest available gears as soon as possible, while avoiding continuous gear changes.Different mobile eco-driving applications have been introduced to help improve fuel economy [8][9][10].Alternatively, fuel consumption is greatly affected by the nature of the route on which the vehicle is commuting on the daily basis.
From computer science perspective, this work tries to develop a new method to calculate real-time fuel consumption based on two OBD parameters and to validate the results against the conventional method which is restricted to MAF (mass air flow) and vehicle speeds readings only.e previous paragraph summarizes research topics on fuel consumption in general; however, it is also important to include what actual parameters and methods that have been introduced by different authors who investigated fuel consumption in vehicles.
ere have been several state-of-the-art papers that propose a set of parameters that can be used to calculate fuel consumption.One of the main categories is identifying such variables.Xaio et al. [11] presented a formula to compute fuel consumption rate (FCR) function by analyzing data figures of various factors and then provided examples to show the different results without considering TPS as a factor affecting fuel consumption.Other authors like Syahputra [12] and Langari and Won [13] increased the number of parameters and introduced neuro-fuzzy methods in order to improve the obtained results.Beside these researches that deal with variables to estimate fuel consumption, the current state-of-the-art models offer an estimation of fuel consumption based on typical urban driving behavior.Moreover, Most of these models present simplified mathematical equations [12,14].Others introduced approaches to compute fuel and emission rates are based on average link speeds [15,16].
e second category is the approaches that use machine learning.Chen et al. [17] were interested in analyzing the driving behavior using machine learning classifier.ey used the classical AdaBoost algorithm along with information from the ECU to determine whether or not the driving behavior is a fuel-saver.Wong et al. [18] also used a machine learning classifier but only to predict air-fuel mixture optimum for best fuel economy.Different tools are designed to collect data in real-time from the OBD-II.In conjunction with an exhaust analyzer, Ortenzi and Costagliola [19] have created consumption and emission models developed for vehicles with gasoline engines.It is also worth mentioning that several mobile applications combined with dedicated devices are available, that can read and monitor multiple values such as fuel consumption and engine parameters using OBD-II.Apart from such devices, some programs work by measuring the instantaneous consumption using different approaches such as neural networks [20], while the others focuses on the setting standards for emissions such as Copert III [21].
e consensus point in most of the previous proposals is that they involve MAF readings in their techniques.Just relying on such values have the disadvantage in cases when gas pedal movement has an influence on the air-fuel ratio, but it remains stable around the fixed value when the accelerator is being slightly depressed, but it changes with harsh accelerating behavior In some circumstances, MAF remains unchanged when throttle position rotates in small angles and sometimes stays still despite that engine load is changing in bigger amounts that do necessarily match the changes in throttle position.One more difference is that most of the researches towards vehicular technology focus on analyzing variable data from ECU to creating software programs/mobile applications that informs the driver whether his driving style is economical. is work, however, does not create a program but it tries to propose new method to fuel consumption based on a combination of training data set.

2
Journal of Robotics

OBD-II Standard
e onboard diagnostic (OBD) standard was developed in the United States basically to help detecting engine malfunctions.e primary objective of having such system is to detect any increase of the harmful gas emissions that exceed some acceptable limits.e system works by continuously monitoring various sensors dedicated to send electrical signals as a feedback to the vehicle's main ECU.Such sensors monitor the engine management functions; more specifically, these sensors are responsible to detect air/fuel volume so the ECU can precisely determine the accurate mixture in real-time.Other sensors also contribute to air/fuel mixture such as oxygen sensor and MAF sensor.An OBD scanner is used to communicate with the vehicles' ECU.
e OBD scanner is a tool to diagnose problems on the vehicles' electrical and emission systems.When a failure is detected, the ECU stores faulty code in memory so that it can be read by the scanner.
e first OBD standard, known as OBD-I, was designed to monitor relatively fewer parameters when compared with OBD-II.When fuel-injection systems have emerged in the automotive industry, OBD-I was mainly focused on detecting faulty errors in the engines' ignition, emission, and injection systems.e diagnosing technique then was basic, and OBD-I did not set a standard for acceptable emission level for vehicles.erefore, the situation of running too rich or too lean, which increases fuel consumption, would not be detected.Ignition systems back then were not as sophisticated and advanced as we have today.Many other nonengine electrical error codes were not included in the standard.Failures were just expressed as a visual warning to the driver, and the error is stored in the ECU's memory.e second generation of OBD, known as OBD-II, has set standards for more components such as the plug and the connector used for diagnostic, the diagnostic trouble codes (DTCs), and the signaling protocols on the controller area network (CAN) bus.Additionally, the detailed list of DTCs (diagnostic trouble codes) is also defined in the standard.OBD-II standard also defined parameters that can be monitored and assigned a code (Identification ID) to each parameter (PID).Several subsystem interaction modes are also set by the OBD-II standard to offer a straight-forward interaction with the vehicle's systems, such as the heating and ventilation systems, transmission system, and engine/chassis system, thus, allowing for more accurate diagnosis depending on functionality.Well-known automobile manufacturers such as Daimler Mercedes and BMW have introduced additional interaction modes that are specific to their vehicles, thus offering a full control of the vehicle's functionality.e European regulations equivalent to the OBD-II standard, known as EOBD, set a standard for fault codes which consists of five characters: a letter, followed by four numbers.EOBD and OBD-II have the same connectors and interfaces.Figure 1 shows an example of both male and female OBD-II connectors.In this particular scan device, the female connector is a part of a CDP AutoCom OBD-II [22] device that offers a connection between the vehicle's internal bus and a personal computer using a Bluetooth connection.
A Schematic description of OBD-II female connector PINS is shown in Table 1 [23].
Table 2 shows a list of some OBD-II PIDs defined by SAE J1979 standard that can be used in the experiment.e description for each PID is given, along with information on the number of bytes and the units of each PID [24].

The Experiment
Many commercial OBD-II scanners are available in the market.Some are equipped with Bluetooth connection which allows the scanner to communicate wirelessly with corresponding software installed on a PC or a mobile application.As mentioned in Section 3, CDP Autocom scan tool is one of the available OBD-II scanners.CDP Autocom is manufactured by Delphi, a Swedish automotive technologies and solutions.e Autocom scanner supports all OBD-II compliant vehicles; however, it is not compatible with the diagnostic software written for the ELM327-based interfaces.
e ELM327 is an interface installed on an adapter designed to act as a bridge between OBD-II port and the standard RS-232 interface.
ree test vehicles are put into test, 2017 Ford Fusion, 2016 Toyota Camry LX, and 2006 Mercedes-Benz e280.All of these vehicles are midsized sedans, and their engines are naturally aspirated which means that they are not turboboosted.In this experiment, we tried to avoid turbo engines.Turbo engines tend to consume more fuel because of the consequent result of turbo lag.It is also interesting to mention that almost all passenger cars used in Jordan run on gasoline.Table 3 shows some of their characteristics which directly affect the overall gas consumption such as weight, overall size, and their engine's displacements.Each engine's horsepower is also a key factor in this context.All three vehicles have automatic transmission and run on gasoline.
e driving route connects Sweileh-Amman and Ramtha, and it is about 66 kilometers long.One of the main characteristics of this road is its steep nature; therefore, vehicles would struggle to go uphill on such freeway.Figure 2 shows the intended route.
Typically, modern gasoline injection systems use two oxygen (lambda) sensors, one mounted right after the engine's manifold and the other one is fitted on the exhaust pipe just before the catalytic convertor.Both sensors send feedback data to the vehicle's ECU in order to estimate the air to fuel ratio. is ratio is predetermined chemically at ideal value of 14.7 grams of air to every gram of gasoline [25].
e MAF is the amount of air sucked by the engine in grams per second.erefore, if MAF value is known, the amount of fuel can be calculated by converting the MAF value to gallons per hour and then calculate miles per gallon.eoretically, fuel consumption f can be calculated using the following equation: where vs is the vehicle speed in km/hour, MAF is the mass air flow in g/s, α � 7.718 is a constant to convert the value of f to US MPG (miles per gallons), and β is a constant to Journal of Robotics convert MPG to liters per 100 km.However, vehicle speed and MAF readings cannot be sufficient for precise estimation; fuel consumption is also affected by the throttle angle.Rotation of the throttle is responsible for determining the amount of fuel flow to the combustion chamber.For that reason, this work tries to estimate fuel consumption based on additional variables such as TPS.e three vehicles are put to test on the route shown above.Discussion below brings up the real-time figures of engine and vehicle speed in a 40-minute duration.
Using equation ( 1), the instantaneous fuel consumption is calculated using the vehicle speed and MAF readings.Figure 3 shows the vehicle speed and MAF taken for the Ford Fusion in real amount of fuel parameters and vehicle speed as calculated in equation ( 1).Fuel consumption figure has been used as a reference to be compared with the estimation models of TPS (throttle position sensor) and RPM figures as being discussed later in this work.Table 4 shows the overall fuel consumption of the three vehicles as opposed to fuel consumption rates provided with the manufacturer's datasheet.
e manufacturer claimed consumption values are taken in relatively optimal conditions such as the vehicle should be driven on flat roads rather than curvy steep hills, the vehicle rides using reasonably thinner tires as opposed to the less efficient but sporty wider tires, and finally only premium gasoline grade must be used.By looking at Table 4, the actual fuel consumption numbers suggest that, in some commute conditions, it is feasible to use vehicles with big displacement   engines.e 3-liter engine in the case of the Mercedes is slightly more feasible than the 2.0-liter one in the Ford Fusion.

Modeling Fuel Consumption
Besides showing a comparison of fuel consumption for the tested vehicles, another objective is to model fuel consumption in terms of TPS and RPM readings.One of the typical methods is to use machine learning techniques.Sometimes when sketching relationships between two variables, the relations between variables can be visually observed; however, such relations may not be easy to model neither easy to find the given equation.SVM is one classifier that is used to generate either a linear on a nonlinear mapping function for a given dataset called training set.Given a set of training, each set is assigned to one category called class of data.SVM tries to separate these category classes evenly using equal and maximum margin called hyperplane.e initial form of SVM is a binary classification which classifies data into two categories.To implement multiclass classification, multiple binary classifiers can be used to integrate one or more categories.Figure 4 illustrates the SVM learning process for this particular system.e set of data that has to be modeled in order to let the system learn the driving behavior are throttle position and vehicle speed.A total of 160 samples (x and y values) were collected from the vehicles.Table 5 shows a sample of the collected data from OBD-II.
e SVM algorithm should be given a training dataset of points.In this case, the X-axis is TPS and RPM. e Y-axis is fuel consumption.e algorithm generates a line that indicates the class (group) to which the point belongs.Let us suppose x → i is a real vector of size n.e SVM finds the maximum margin line called "hyperplane" that divides the group of points almost evenly.Hyperplane is defined so that the distance between the hyperplane and the nearest point from either group is maximized [27].
5.1.Lagrange Interpolation.Lagrange interpolation polynomial is used to generate polynomial functions for numerical analysis and curve fitting.
e interpolating polynomial of the least degree is preferred as long as the tradeoff between the oscillation and accuracy is minimized as the fitting curve is exhibited between the data points.Lagrange polynomial is applied separately for TPS and RPM (X-coordinates) with respect to time, thus Y-values will be predicted when the training data follows a particular pattern.For Y-coordinate P x (t), the following expression (2) is used: where In the above formula, f x (t k ) represents x-coordinate of the location at time t k .So, the interpolation is performed for x-coordinate against the independent variable t. e sample dataset shown in Table 5 is fed to the above equation.
e training set has n points represented as (x 1 , y 1 ), . . ., (x n , y n ); let us suppose that y are the fuel consumption values.Multiple vectors x → i specify the best fitting by determining different classes of data.Lagrange finds the best points which form a line that divides the collection of x → i vectors based on values of y i ′ s out of the collection.e resulted model shows a fitted curve that lies evenly between the hyperplane and the nearest x → i vectors.Hence, the hyperplane is expressed as a set of points x → which satisfy the following equation: where w → is the hyperplane and b is a constant.In our case, the data are gathered using observations rather than mathematically described relationships and hence they are considered to be empirical models.Based on these observations, the following section brings up the evaluation of the predicted models.

Evaluating Resulted Polynomials.
e above SVM learning algorithm is performed to fit the sample data into a mathematical expression.First, in order to compare the values predicted by the Lagrange polynomial, it is important to obtain the estimated RPM, TPS, and fuel consumption values.Figure 5 demonstrates the fitting curve that reflects the relationship between the estimated fuel consumption and RPM gathered during a particular duration in the test route.
Fuel consumption is measured in liters in multiples of 10 − 4 /second.e RPM and fuel consumption regression functions can be expressed by a quadratic model as shown in the following equation: where a � 1.16885 * e − 7 , b � − 7.05648 * e − 5 , and c � 0.558.One of the major factors that also affect fuel consumption is how much the gas pedal is being depressed.e gas pedal is electronically connected the throttle lid which is responsible for the air mass/flow (MAF).MAF value is linearly correlated with TPS. e fuel consumption relationship with the TPS model is expressed by a linear polynomial as shown in the following equation: where a � 0.2425 and b � 0.0692.
Using surface fitting function in Matlab, Figure 6 shows the relationship between fuel consumption with TPS and RPM.
Equation ( 2) is used to calculate fuel consumption values for the training set using the same test route.It is worth mentioning that maintaining a fixed ratio between vehicle speed and engine speed is the key factor that minimizes fuel consumption.Figure 7 shows the predicted values and a comparison between the proposed SVM prediction model using RPM and the estimated fuel consumption values calculated using equation (1).In the figure, it is seen that the proposed SVM successfully predicted fuel consumption with minor errors.Journal of Robotics RMSE is used to measure the differences in our method and the conventional data model.ese differences can be calculated for each element or for the whole model.As the figure shows, it is obvious that there are some errors that can be numerically analyzed using RMSE as shown in the following equation: After applying this method, the final RMSE value is 2.4364.

Conclusion
A computer-based analysis of the onboard vehicle's parameters has been exploited to demonstrate an estimation of fuel consumption based on readings from the engine's RPM and TPS rather than relying on the conventional MAF readings.e conventional method is based on measuring air volume regardless of the throttle position.An SVM modeling technique has been applied to derive values that reflect the behavior of vehicle's consumption with respect to TPS and RPM.
e SVM modeling is combined with a Lagrange interpolation polynomial and linear functions to predict fuel consumption values.
e predicted model is compared with the data taken from the onboard OBD-II.
Practically, fuel consumption is affected by the engine's displacement, RPM, and TPS. e experiment has shown the extension by which the engine's displacement actually influences fuel consumption.e results have shown that, on specific roads, it is more feasible to use automobiles equipped with bigger engines than that of smaller displacements.We plan to take advantage of the OBD-II parameter monitoring interface to provide a more comprehensive analysis of the ECU data and consequently give a better perception of driving behavior and fuel economy.A more sophisticated scan tool that is specific to a particular car make would give a set of new parameters to be elaborated.is would determine the nongeneric parameters which can be used in the future work other than TPS and engine RPM.Having this in mind, modeling a combination of new PID's against the fuel being consumed is one inspiration that can be accomplished in the future.Another future work is to design a software that can be connected to the ECU which can analyze all the malfunctions or errors/ DTC's that affect fuel consumption.

8
Journal of Robotics

Table 2 :
Some PID codes and their meaning.

Table 4 :
Obtained fuel consumption vs. claimed fuel consumption.

Table 5 :
Training data: vehicle RPM and TPS.