UBC Undergraduate Research

Fuel efficiency meter prototype : “Mileage Master” Porter, Devan; Zheng, Sandra Apr 4, 2011

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
52966-Porter_Devan_et_al_APSC_459_2011.pdf [ 1.1MB ]
Metadata
JSON: 52966-1.0074464.json
JSON-LD: 52966-1.0074464-ld.json
RDF/XML (Pretty): 52966-1.0074464-rdf.xml
RDF/JSON: 52966-1.0074464-rdf.json
Turtle: 52966-1.0074464-turtle.txt
N-Triples: 52966-1.0074464-rdf-ntriples.txt
Original Record: 52966-1.0074464-source.json
Full Text
52966-1.0074464-fulltext.txt
Citation
52966-1.0074464.ris

Full Text

Fuel Efficiency Meter Prototype “Mileage Master” Devan Porter Sandra Zheng  Project Sponsor: Dr. Cyril Leung  Group Number 1108  Applied Science 459 Engineering Physics The University of British Columbia 2011 April 4  Executive Summary The intent of designing a fuel efficiency meter was mainly to provide end users with a tool to monitor their instantaneous mileage while driving. This has the capability of allowing users to develop their driving skills to reduce fuel costs and improve the overall sustainability of the environment. A number of other features have been integrated into the instrument as the project progressed, including trip mileage, fuel flow, digital speed, and best efficiency speed. A prototype was built as a team effort between January and March 2011. The design and implementation of the prototype involved integrating a flow sensor with appropriate flow capacity, assembling a suitable user interface, and programming a menu using an Arduino environment to accommodate the different features in an efficient manner. The resulting prototype is comprised of a compact enclosure with three push buttons for “select,” “next,” and “back,” and a fuel flow sensor that can be inserted into the fuel line of most vehicles. The next step in this project would be to assess it for small-scale production and market it over the internet. It is then recommended to look into further testing procedures to have a certain degree of quality assurance before proposing the product to distributors. A number of obstacles and regulations may be involved should the project eventually enter this stage.  ii  Table of Contents Executive Summary ...................................................................................................................................................................... ii 1 Background and Motivation.................................................................................................................................................. 1 1.1  Obtaining Vehicle Fuel Consumption .............................................................................................................. 1  1.2  Existing Designs ........................................................................................................................................................ 1  1.2.1  MPGuino Project ....................................................................................................................................... 2  1.2.2  ScanGauge II ............................................................................................................................................... 2  1.3 2  Alternative Strategies............................................................................................................................................. 3  Discussion .............................................................................................................................................................................. 4 2.1  Project Objectives .................................................................................................................................................... 4  2.2  Technical Background ........................................................................................................................................... 4  2.2.1  Arduino & EEPROM ...................................................................................................................................... 4  2.2.2  Fuel Consumption ......................................................................................................................................... 5  2.3  Theory: Fluid Mechanics ....................................................................................................................................... 6  2.4  Final Design ................................................................................................................................................................ 8  2.4.1  User Interface .................................................................................................................................................. 8  2.4.2  Flow Sensor...................................................................................................................................................... 8  2.4.3  GPS Speed Signal............................................................................................................................................ 9  2.4.4  Casing ................................................................................................................................................................. 9  2.4.5  Schematics and Installation Diagram .................................................................................................10  2.5  Alternative Designs ...............................................................................................................................................11  2.5.1  Ultrasonic Low Flow Meter.....................................................................................................................11  2.5.2  Marine Flow Meter .....................................................................................................................................11  2.5.3  Paddlewheel Flow Indicator...................................................................................................................11  2.6  Experimental Setup and Testing .....................................................................................................................12  2.7  Results.........................................................................................................................................................................12  2.8  Discussion of Results ............................................................................................................................................13  3  Conclusions..........................................................................................................................................................................14  4  Project Deliverables .........................................................................................................................................................15  5  Recommendations ............................................................................................................................................................16 5.1  6  Continuation of Work ...........................................................................................................................................16  References ............................................................................................................................................................................17  Appendix A: Circuit Schematic Diagram............................................................................................................................18 Appendix B: Fluid Flow System Curve ...............................................................................................................................19 Appendix C: Complete Arduino Code..................................................................................................................................20  iii  List of Figures Figure 1. MPGuino display interface. .................................................................................................................................... 2 Figure 2. ScanGauge II interface.............................................................................................................................................. 3 Figure 3. Arduino Uno and Mini Arduino Pro ................................................................................................................... 5 Figure 4. Schematic of flow sensor placement in the fuel line .................................................................................. 5 Figure 5. Casing diagram with applicable parameters ................................................................................................. 7 Figure 6. Differential pressure gauge setup (0.5 psi operating pressure transducer). .................................. 9 Figure 7. Final prototype enclosure holding flow sensor ............................................................................................ 9 Figure 8. Fuel efficiency meter plastic enclosure ..........................................................................................................10 Figure 9. Vehicle diagram with the fuel efficiency meter’s components ............................................................10 Figure 10. ThermalTake Liquid Flow Meter CL-W0080 with square wave signal from QRD ...................12 Figure 11. Experimental setup in Project Lab.................................................................................................................12  iv  List of Tables Table 1. Approximate fuel flows in gallons per minute (GPM) ................................................................................. 6 Table 2. Approximate fuel flows in millilitres per minute (mL/min) .................................................................... 6 Table 3. Flow rates obtained for various fuel sensor options..................................................................................13 Table 4. Financial summary of major components ......................................................................................................15  v  1 Background and Motivation This project is sponsored by Dr. Cyril Leung, Associate Dean of Research in the Electrical and Computer Engineering Department at UBC.  In a society where vehicle transportation is vital to our lifestyles, fuel can be an expensive commodity for some. The average household living in an urban area will own at least one vehicle, although typically drivers are not aware they are capable of reducing fuel consumption. One solution would be to produce a fuel economy meter that can be retrofitted onto existing vehicles.  A typical driver may be interested in determining the most efficient use of fuel, whether driving on the highway or in the city. For more advanced drivers and hypermilers who know their vehicle well, it would be advantageous to know whether fuel efficiency changes with a certain vehicle modification they may have chosen to carry out.  1.1  Obtaining Vehicle Fuel Consumption  The instantaneous fuel consumption of a vehicle can be calculated from two pieces of information – the vehicle speed and the fuel flow.  Most vehicles manufactured since the late 1980s are equipped with an engine control unit (ECU) which is essentially a vehicle computer that can provide information such as the amount of fuel injected, injection timing, and ignition timing [1]. These vehicles may already have built-in fuel flow sensors, which would make it a significantly simpler task to calculate instantaneous mileage compared to vehicles that do not have ECUs.  Vehicles manufactured earlier than the late 1980s relied on pneumatic and mechanical sensors as well as actuators to perform the same tasks as an ECU. Without an ECU, one method of obtaining the fuel flow would be to place a flow sensor directly in the fuel line. This method has been discussed via online forums but not yet implemented.  1.2  Existing Designs  As with many technologies, there are existing fuel efficiency meter designs that have been successfully implemented. MPGuino and ScanGauge II are two products similar to this project, but with different capabilities and features as well as implementation methods.  1|Page  1.2.1 MPGuino Project Project Name:  OpenGauge MPGuino Project  Platform:  ATmega168 microcontroller compatible with Arduino  Features:  Live display of instantaneous gas mileage in imperial and metric units  Price:  USD $55  Distribution:  Available online only  Vehicles:  Computerized fuel injection  Connections:  OBD-II (On Board Diagnostics II) connections – CAN network, power, ground  Websites:  http://ecomodder.com/wiki/index.php/MPGuino http://opengauge.org/mpguino/  Figure 1. MPGuino display interface.  The MPGuino was developed by a group of American vehicle enthusiasts with open source code available online. It is only compatible with vehicles that are equipped with ECUs. The end user is required to modify coding and complete an extensive calibration procedure before the product can be used [2]. The fuel meter project at hand is meant to target a different market, with the knowledge that not all users are comfortable with coding and not all vehicles have an ECU. The aim is also to provide a simple, streamlined calibration procedure (or none at all) to minimize the technical obstacles the end user could face. 1.2.2 ScanGauge II Project Name:  ScanGauge II  Features:  Average speed, driving distance, fuel used/left, distance to empty, fuel economy, engine speed, various temperatures, throttle position, ignition timing, troubleshooting vehicle problems, memory storage (total of 30 different features with varying levels of significance)  Price:  USD $170  Distribution:  Autozone, Camping Zone, online  Vehicles:  1996 and newer  Connections:  OBD-II (On Board Diagnostics II) connections – CAN network, power, ground  Websites:  http://www.ScanGauge.com  2|Page  Figure 2. ScanGauge II interface.  ScanGauge is a relatively robust product that is successfully mass marketed and produced. The main difference between ScanGauge and this project is that ScanGauge requires an OBD-II connection (to the ECU) which is generally only available on vehicles 1996 and newer [3], while the current objective for this project is to develop a fuel economy meter for all vehicles. The additional features on ScanGauge may be somewhat excessive for the average driver and the minor features may distract the user from the more important ones. The overall compact design of this product is attractive and easy to use, which is also reflected in the price along with its numerous features.  1.3  Alternative Strategies  The main component (and the most difficult one to obtain) was the fuel flow sensor. This was particularly challenging since typical flow sensors were for much larger applications. A sensor that would be suitable on a 1/4” or 3/8” diameter line with a flow of 30 mL/min to 300 mL/min was not a popular product from manufacturers. A number of low flow fuel sensors were considered before settling on a pressure transducer. These include an ultrasonic flow meter, marine flow meter, and paddlewheel flow indicator; descriptions are included in the “Alternative Designs” section.  3|Page  2  Discussion  The following discussion sections will provide a comprehensive account of the aims, theory, design, and testing procedures for this project. Extensive details, such as algorithms, are provided as appendices rather than in the body of the discussion.  2.1  Project Objectives  The objectives of this project are to: •  deliver a fuel efficiency meter than can be retrofitted on almost all vehicles, regardless of whether or not the vehicle has an ECU, runs on gasoline or diesel, fuel injected or carbureted  •  supply an instrument that has a minimal installation process and does not require excessive calibration or advanced electronics skills, if any at all  Since most of the existing fuel meter designs make use of the ECU specifically, they do not work on older vehicles. The prototype design is meant to be compatible with many other vehicles, including motorcycles, boats, and recreational vehicles.  2.2  Technical Background  A few notes regarding the software and vehicle fuel consumption are established in the following section. 2.2.1 Arduino & EEPROM The fuel efficiency meter is programmed with the C language in Arduino, an open source electronics platform commonly used for prototyping. The Arduino Uno was the primary microcontroller board used to do the coding and debugging. It contains 14 digital input/output pins, 6 analog inputs, a crystal oscillator operating at 16 MHz, a USB connection, a power jack, an ICSP header, and a reset switch [4]. After the program is condensed to an efficient form, if small enough, it could then be transferred to a Mini Arduino Pro. The Arduino can simply be connected to a computer for coding and powered up via the same USB cable. The relative sizes of the Arduino Uno and Mini are shown in Figure 3. In order to retain memory without drawing power from the vehicle battery, the electrically erasable programmable read-only memory (EEPROM) built into the Arduino is utilized. Implementation simply involves writing data to a function in the code [5].  4|Page  Figure 3. Arduino Uno and Mini Arduino Pro  2.2.2 Fuel Consumption The fuel flow signal is acquired (without the need for an ECU) by intercepting the flow directly downstream of the fuel filter in a vehicle, as shown in Figure 4.  Figure 4. Schematic of flow sensor placement in the fuel line  A vehicle’s fuel flow is an essential piece of information for calculating fuel economy. The fuel sensor provides an output signal in voltage to the Arduino, which is calibrated and programmed to calculate fuel efficiency.  The efficiency and speed determine the approximate range of fuel flow. Flow is related to the speed that a vehicle is travelling as well as the overall efficiency of the vehicle. The basic calculation is: ݂݈‫݈ܽ݃( ݓ݋‬/݉݅݊) =  ‫݅݉[ ݀݁݁݌ݏ‬⁄ℎ‫]ݎ‬ [ℎ‫]ݎ‬ ∗ ݂݂݁݅ܿ݅݁݊ܿ‫ ݅݉[ ݕ‬⁄݈݃ܽ ] 60 [݉݅݊]  This roughly establishes the range of the fuel flow but does not take into consideration the effects of coasting and idling. Possible fuel flows are displayed in Table 1 and Table 2.  5|Page  Fuel Efficiency (MPG) 5 10 15 20 25 30 35 40 45 50 55 60  Speed (MPH) 5 0.017 0.008 0.006 0.004 0.003 0.003 0.002 0.002 0.002 0.002 0.002 0.001  10 0.033 0.017 0.011 0.008 0.007 0.006 0.005 0.004 0.004 0.003 0.003 0.003  15 0.05 0.025 0.017 0.013 0.01 0.008 0.007 0.006 0.006 0.005 0.005 0.004  20 0.067 0.033 0.022 0.017 0.013 0.011 0.01 0.008 0.007 0.007 0.006 0.006  25 0.083 0.042 0.028 0.021 0.017 0.014 0.012 0.01 0.009 0.008 0.008 0.007  30 0.1 0.05 0.033 0.025 0.02 0.017 0.014 0.013 0.011 0.01 0.009 0.008  35 0.117 0.058 0.039 0.029 0.023 0.019 0.017 0.015 0.013 0.012 0.011 0.01  40 0.133 0.067 0.044 0.033 0.027 0.022 0.019 0.017 0.015 0.013 0.012 0.011  45 0.15 0.075 0.05 0.038 0.03 0.025 0.021 0.019 0.017 0.015 0.014 0.013  50 0.167 0.083 0.056 0.042 0.033 0.028 0.024 0.021 0.019 0.017 0.015 0.014  55 0.183 0.092 0.061 0.046 0.037 0.031 0.026 0.023 0.02 0.018 0.017 0.015  60 0.2 0.1 0.067 0.05 0.04 0.033 0.029 0.025 0.022 0.02 0.018 0.017  65 0.217 0.108 0.072 0.054 0.043 0.036 0.031 0.027 0.024 0.022 0.02 0.018  70 0.233 0.117 0.078 0.058 0.047 0.039 0.033 0.029 0.026 0.023 0.021 0.019  75 0.25 0.125 0.083 0.063 0.05 0.042 0.036 0.031 0.028 0.025 0.023 0.021  80 0.267 0.133 0.089 0.067 0.053 0.044 0.038 0.033 0.03 0.027 0.024 0.022  85 0.283 0.142 0.094 0.071 0.057 0.047 0.04 0.035 0.031 0.028 0.026 0.024  90 0.3 0.15 0.1 0.075 0.06 0.05 0.043 0.038 0.033 0.03 0.027 0.025  Table 1. Approximate fuel flows in gallons per minute (GPM)  Fuel Efficiency (MPG) 5 10 15 20 25 30 35 40 45 50 55 60  Speed (MPH) 5 63.08 31.54 21.03 15.77 12.62 10.51 9.012 7.885 7.009 6.308 5.735 5.257  10 126.2 63.08 42.06 31.54 25.23 21.03 18.02 15.77 14.02 12.62 11.47 10.51  15 189.3 94.63 63.08 47.31 37.85 31.54 27.04 23.66 21.03 18.93 17.2 15.77  20 252.3 126.2 84.11 63.08 50.47 42.06 36.05 31.54 28.04 25.23 22.94 21.03  25 315.4 157.7 105.1 78.85 63.08 52.57 45.06 39.43 35.05 31.54 28.67 26.28  30 378.5 189.3 126.2 94.63 75.7 63.08 54.07 47.31 42.06 37.85 34.41 31.54  35 441.6 220.8 147.2 110.4 88.32 73.6 63.08 55.2 49.06 44.16 40.14 36.8  40 504.7 252.3 168.2 126.2 100.9 84.11 72.1 63.08 56.07 50.47 45.88 42.06  45 567.8 283.9 189.3 141.9 113.6 94.63 81.11 70.97 63.08 56.78 51.61 47.31  50 630.8 315.4 210.3 157.7 126.2 105.1 90.12 78.85 70.09 63.08 57.35 52.57  55 693.9 347 231.3 173.5 138.8 115.7 99.13 86.74 77.1 69.39 63.08 57.83  60 757 378.5 252.3 189.3 151.4 126.2 108.1 94.63 84.11 75.7 68.82 63.08  65 820.1 410 273.4 205 164 136.7 117.2 102.5 91.12 82.01 74.55 68.34  70 883.2 441.6 294.4 220.8 176.6 147.2 126.2 110.4 98.13 88.32 80.29 73.6  75 946.3 473.1 315.4 236.6 189.3 157.7 135.2 118.3 105.1 94.63 86.02 78.85  80 1009 504.7 336.4 252.3 201.9 168.2 144.2 126.2 112.1 100.9 91.76 84.11  85 1072 536.2 357.5 268.1 214.5 178.7 153.2 134.1 119.2 107.2 97.49 89.37  90 1136 567.8 378.5 283.9 227.1 189.3 162.2 141.9 126.2 113.6 103.2 94.63  Table 2. Approximate fuel flows in millilitres per minute (mL/min)  After consultation with others and online research, it was determined that typical vehicle operating limits approximately yield the data circled in green. The purpose of establishing these limits is to use it as a basis for selecting or designing the flow sensor. If a vehicle does operate outside the given range, then the fuel meter will simply display that it is out of range.  2.3  Theory: Fluid Mechanics  The major piece of the fuel efficiency meter lies in the method chosen to obtain fuel flow. After many trials of different options, the selected method was to use a pressure differential transducer to measure the pressure drop across an orifice. The Freescale Semiconductor pressure transducer used in the final prototype has a max pressure drop rating of ±1.0 psi; therefore, a cylindrical in-line casing needed to be machined with suitable dimensions for the given fluid service and flow rate.  Using Figure 5 as a reference for parameters, Bernoulli's equation gives: ௉భ ఘ௚  + ‫ݖ‬ଵ +  ௏భమ ଶ௚  + ℎ௣௨௠௣ =  ௉మ ఘ௚  + ‫ݖ‬ଶ +  ௏మమ ଶ௚  + ℎ௟௢௦௦ + ℎ௧௨௥௕௜௡௘  Equation (1)  6|Page  Figure 5. Casing diagram with applicable parameters  In the case of fuel line with a pressure differential casing and orifice added as fitting, the surviving terms of (1) are: ௉భ ି௉మ ఘ௚  =  ∆௉ ఘ௚  = ℎ௟௢௦௦  The total hloss is a sum of major and minor losses:  ℎ݈‫݂(ߑ = ݏݏ݋‬  ܸ2 ‫ܸ ܮ‬2 ) + ߑ(‫) ܮܭ‬ 2݃ ‫ ܦ‬2݃  However, since the L/D is small enough in this case and the friction factor (f) is a small number, the major losses can be neglected. Major losses tend to dominate minor losses when the system of interest is a long pipeline. The effective expression is as follows: ܸ2  ℎ݈‫ ܮܭ( ߑ = ݏݏ݋‬2݃) The minor loss coefficients (KL) in this case are applicable at the entrance and exit points of the smaller diameter orifice, which is shown with diameter “d” in Figure 5. Sharp entrance: ‫ܭ‬௅ = 0.5 Sharp exit:  ‫ܭ‬௅ = 1 −  ௗ2 ஽మ  For a ΔP of 1.0 psi, the applicable flow rates were modeled in a spreadsheet to determine the approximate diameter “d” required required. Appendix B contains the applicable system curve.  7|Page  2.4  Final Design  Several fundament elements were successfully implemented on the fuel meter prototype. The following sections will provide detailed accounts of the various aspects of this project.  2.4.1 User Interface The user interface is an important consideration of a potential market product. Several individuals from a variety of age groups and technical backgrounds were consulted on their preferred interface. The general consensus was that the fuel efficiency meter is designed with a menu style that allows the end user to quickly switch between options. Menu structure is as follows: Instantaneous Mileage Fuel Flow Trip Mileage Best Efficiency Speed Digital Speed Settings Select Units - L/100 KM - MPG - KM/L Reset Trip  The user navigates through the menu using three push buttons: “next,” “select,” and “back.”  2.4.2 Flow Sensor The flow sensor is to be installed in the fuel line. It involves a pressure transducer, several barb adapters, and an aluminum housing with an orifice (diameter 2mm) drilled laterally through in the direction of fuel flow to facilitate a pressure drop. The schematic image is shown in Figure 5 from the previous section, and the actual component in Figure 6.  8|Page  Figure 6. Differential pressure gauge setup (0.5 psi operating pressure transducer).  The Honeywell 0.5 psi pressure transducer first used was capable of reading flows as low as 35 mL/min and up to 500 mL/min, which are acceptable boundary flow rates for the application. However, a second pressure transducer made by Freescale Semiconductor, which is rated at a maximum of 1.0 psi was later used instead. It was actually slightly more cost effective and was rated for a lower range more suitable for the fuel meter. Its setup is very close to that of Figure 6. The final enclosure for the flow sensor circuit is shown in Figure 7.  Figure 7. Final prototype enclosure holding flow sensor  2.4.3 GPS Speed Signal A reliable speed signal is essential to calculating the fuel efficiency, since Efficiency = Speed/Flow as mentioned earlier. This information was obtained successfully by incorporating the speed from a small GPS unit into the coding for the fuel meter. The unit is labeled in Figure 8 and the associated code is in Appendix C.  2.4.4 Casing A 110 mm x 60 mm x 30 mm plastic casing holds all the components of the instrument, as shown in Figure 8. The enclosed items are a Mini Arduino Pro, the LCD display board with serial encoder, and the GPS unit with antenna. The smaller Arduino is required to due to its compact size.  9|Page  The connection used is a standard 1/8” stereo audio jack, which is easy to connect and not likely to result in tangled wires. Power is obtained from the vehicle’s battery, which is regulated to 5 volts. Mini Arduino Pro  GPS unit with antenna receiver  Serial decoder for LCD display (behind)  Power grid  110mm x 60 mm x 30 mm box Figure 8. Fuel efficiency meter plastic enclosure  2.4.5 Schematics and Installation Diagram The two enclosures for fuel efficiency meter are installed in different areas as displayed in Figure 9. The flow sensor is installed on the fuel line, downstream of the fuel filter. End users have constant access to the user interface enclosure, which will be located on the dashboard. A standard 3 mm audio jack connection links the two enclosures.  Figure 9. Vehicle diagram with the fuel efficiency meter’s components  10 | P a g e  2.5  Alternative Designs  As mentioned in the introduction, several different types of low flow meters were considered, evaluated, and some even tested before the pressure differential method was selected. 2.5.1 Ultrasonic Low Flow Meter Ultrasonic low flow meters are available for purchase and capable of measuring low flows. One good advantage to using this type of sensor is that the fuel line would not need to be cut in order to measure flow; it would simply be attached on the exterior of the line. However, gas and diesel are non-magnetizable fluids and therefore would not be detected at low flows if at all. Ultrasonic flow meters in general cost significantly more than other mechanical sensors, between $1,000 and $2,000. 2.5.2 Marine Flow Meter Another option that was purchased locally and evaluated in detail was the EP60-R marine flow meter. This flow sensor operated based on serial communication in the NMEA 2000 (National Marine Electronics Association) specification. NMEA 2000 is particular to the marine industry and the decoder is not publicly available unless purchased for the relatively high cost product. Even with the decoder at hand, an Arduino environment would not be able to communicate with the device. After a few challenging weeks of attempting to communicate with the EP60-R, this option was abandoned after a different flow indicator arrived. The EP60-R would have been a good choice if no communication problems had occurred as it was reasonably priced and guaranteed to work for fluids such as gas and diesel. 2.5.3 Paddlewheel Flow Indicator A flow indicator meant for liquid cooling systems was the next option available. The purchased product was a ThermalTake® model (shown in Figure 10) which included connection adapters that were similar in size to a fuel line. Modifications were needed to increase the velocity of the fuel flow to get the wheel to spin. A 1mm reducer was added to create a high velocity jet stream that helped spin the paddlewheel. After the adjustments were made, it was experimentally determined that the minimum flow rate for the paddlewheel to turn is 48 mL/min, still shy of the required minimum of 30 mL/min.  11 | P a g e  Figure 10. ThermalTake Liquid Flow Meter CL-W0080 with square wave signal from QRD  2.6  Experimental Setup and Testing  A simple yet effective experimental setup is shown in Figure 11. This apparatus allows the flow rates to be acquired easily – a power supply drives the water pump motor, and a stopwatch and graduated cylinder are used to record the volume per unit of time.  Water pump Graduated cylinder for measuring flow rate  Flow sensor  Figure 11. Experimental setup in Project Lab  2.7  Results  The main results of the technical work performed over the semester include: •  finding a suitable flow meter for a vehicle’s typical flow range  •  designing and soldering a complete set of circuits  •  constructing enclosures for both fuel sensor and user interface  •  implementing code for the user menu  12 | P a g e  Table 3 summarizes the various flow sensors that were tested, some more successful than others. Ten trials were performed for each of the data. No leakage occurred during the trials or during informal testing procedures (to get water pump working, etc.).  REQUIRED EP60-R marine flow sensor, less decoder Paddlewheel  Pressure differential (selected solution)  Lower Flow Limit 30 mL/min -  Upper Flow Limit 300 mL/min -  Price  48 mL/min  1000 mL/min upwards  $20  35 mL/min  510 mL/min  $15  $90  Comments Typical vehicle flow rates Serial communication unsuccessful; calibration aborted Higher than desired flow range; lower end is too high; large pressure drop resulted Closest to desired flow range; relatively small pressure drop, easily replaced  Table 3. Flow rates obtained for various fuel sensor options  2.8  Discussion of Results  Based on the findings in Table 3, the pressure differential is clearly the most suitable solution as it performs closest to the lower flow limit and exceeds the upper limit. Other aspects, such as low cost, ease of replacement (which involves changing a defective pressure transducer without adjusting the in line component) and relatively small pressure drop make it the favourable solution. Component errors are unavoidable and include the following: •  Position accuracy of GPS (±3 metres)  •  Accuracy of pressure transducer (±5%)  In addition, manufacturing flaws also contribute to the test results due to the smoothness of the channels and attachment of the adapters. These effects vary in significance on the overall results and are difficult to measure unless a large sample (~100 units) is tested. Additional tests that could provide applicable data would be to use gasoline or diesel fuel to determine the upper and lower flow limits. Fuel has a higher viscosity, which may introduce unforeseen issues in the flow sensor’s orifice. The material in contact with the fuel would only be brass (adapters) and aluminum (housing), both of which should not cause a problem.  13 | P a g e  3  Conclusions  A prototype fuel efficiency meter was constructed and assembled successfully over the course of four months. Two compact enclosures now exist – one to hold the flow sensor circuit in the engine area, and the other to implement the user interface on the vehicle dashboard. These enclosures are connected with a long wire which can be mounted strategically throughout the front of the vehicle.  The in line flow sensor demonstrated no leakage for over 30 trials with only barb adapters holding it in place. This statistic is held in confidence as informal testing (which comprises more than half the testing time) did not yield any leakage either. In addition, the flow ranges of a typical vehicle (30 to 300 mL/min) are accommodated by the prototype flow sensor (35 to 510 mL/min) with the exception of a few mL/min at the lower limit.  The fuel efficiency meter does not require an engine control unit to operate, a feature that has not been previously implemented.  14 | P a g e  4  Project Deliverables  A list of project deliverables is as follows: •  Flow sensor with circuit in enclosure and adapters for fuel line  •  User interface enclosure, including GPS and Arduino Mini which implements the code for calculating fuel efficiency  •  Circuit schematic is included as Appendix A  •  Implementation code is included as Appendix C  •  Installation instructions  Deviations from the proposal stage include SolidWorks drawings, installation instructions, and test data using gasoline or diesel. As casings were simply measured and manufactured using available materials in the Project Lab and Hennings Machine Shop, SolidWorks design work was excessive and unnecessary. This may be backfilled in the future if this prototype is to be reproduced. Brief installation instructions are available from Section 2.4.5 – detailed installation instructions are meant to be included as a final step after the prototype is installed and tested on an actual vehicle.  Table 4 offers a financial summary of the various purchases involved in this project. Green highlighted items are incorporated in the final prototype. Fittings and small electrical components are not included as the relative cost is insignificant. It should be noted that many of the components are significantly less expensive when purchased in bulk for mass production. # 1 2 3 4 5 6 7 8 9 10  Description Marine flow meter Arduino Uno board Arduino Mini Pro LCD display LCD serial commun. Paddlewheel Parallax GPS Antenna Pressure transducer* Enclosures PROTOTYPE COST TOTAL PROJECT COST  Qty 1 1 1 1 1 1 1 1 2 2  Vendor(s) Steveston Marine Available in lab Sparkfun Sparkfun Robotshop Ebay Robotshop Digikey Digikey Available in lab  Cost $90 $33 $33 $15 $15 $20 $35 $20 $50 $10  Purchased by: Students Available in lab Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab Available in lab  Funded by: Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab Project Lab  $133 $321  *Note that only one of the two purchased pressure transducers was used in the final prototype. Table 4. Financial summary of major components  15 | P a g e  5  Recommendations  The current working prototype sufficiently carries out calculations for fuel efficiency and displays the instantaneous mileage, trip mileage, digital speed, and fuel flow, as well as configures the user settings. If the other suggested feature (“best efficiency speed”) is to be implemented, further testing and coding will be required. However, these additional features do not hinder the overall objective of the project, so the unit is fully functional without it. The final testing procedures were not carried out during the four months allocated to the course, and some work will need to be continued to complete the quality assurance. Suggestions for continuation of work include laboratory testing using fuel, and eventually installation on a running vehicle.  5.1  Continuation of Work  Laboratory testing would involve setting up an apparatus similar to the existing one, except using a container of gas or diesel instead of water. A fuel pump may need to be used in lieu of the water pump; the cost is approximately $15 to $20. Strict safety precautions must be taken, as the fluids are flammable.  Installation and testing on a running vehicle would be the last step in the testing process. The data recorded during this procedure, however, would only be a general verification procedure based on common knowledge of driving habits. A series of maneuvers could be conducted, such as: rapid acceleration gradual acceleration rapid braking gradual braking driving at constant 50 km/h driving at constant 70 km/h driving at constant 100 km/h  These steps are part of the quality assurance plan and will be time consuming. This may lead to a future APSC 459 or APSC 479 project since it is suitable for another four-month semester of work. Detailed installation instructions and implementing code for the “best efficiency speed” feature may be included as well for the next project.  16 | P a g e  6  References  [1] Nice, Karim. “How Car Computers Work.” From HowStuffWorks [Retrieved March 13, 2011] http://auto.howstuffworks.com/under-the-hood/trends-innovations/car-computer1.htm [2] OpenGauge Project. “MPGuino Calibration instructions.” From Ecomodder [Retrieved January 27, 2011] http://ecomodder.com/wiki/index.php/Mpguino_calibration [3] Linear Logic. “ScanGauge II.” From ScanGauge [Retrieved January 28, 2011] http://www.scangauge.com/ [4] “Arduino Board Uno.” From Arduino official reference site [Retrieved April 4, 2011] http://arduino.cc/en/Main/arduinoBoardUno [5] “EEPROM Library.” From Arduino official reference site [Retrieved April 4, 2011] http://www.arduino.cc/en/Reference/EEPROM  17 | P a g e  Appendix A: Circuit Schematic Diagram Volt_reg_5V_2A_1 LM109H 1 2  U1 1 2 3 4 5 6 7 8  R1 R3 10kΩ 10kΩ  SparkFun_LCD_Screen  3  ParallaxGPS  16 15 14 13 12 11 10 9  D7 D6 D5 D4 D3 D2 D1 D0  COMMON  E RS RW  R2 10kΩ  U3  VREG  VCC CV GND  V1 12 V  LINE VOLTAGE  atmega168 Buttons  R5 Pot  Volt_reg_5V_2A_2 LM109H V2 12 V  LINE VOLTAGE  VREG  COMMON  10kΩ 55% Key=A  U4 V+ VIN+  U2 1 2  Output signal to Arduino  10kΩ V0  RG-  R4 47kΩ  C1 10µF  REF  V02 SEN 3  PressureTransducer_1psi  VINV-  V01  RG1  INA163UA Instrumentational amp comparing transducer voltage to 2.6 volts  18 | P a g e  Appendix B: Fluid Flow System Curve  Pressure Drop vs. Flow Rate 0.4000 0.3500  Pressure Drop (psi)  0.3000 0.2500 0.2000 0.1500 0.1000 0.0500 0.0000 0  50  100  150  200  250  300  350  400  Flow Rate (mL/min)  19 | P a g e  Appendix C: Complete Arduino Code //Mileage Master fuel efficiency meter menu #include <NewSoftSerial.h> #include <EEPROM.h> #include "EEPROM_anything.h" #include <string.h> #include <ctype.h> //--pins-#define LCD_TX_PIN 2 //#define GPS_RX_PIN 6 #define SELECT_BUTTON 3 #define NEXT_BUTTON 4 #define BACK_BUTTON 5 #define FUEL_INPUT 0  //SparkFun LCD screen out //GPS serial in //digital in (user) //digital in (user) //digital in (user) //analog in  //--constants-#define LOOP_TIME 30000 #define FLOW_COUNTS 500 #define WRITE_THRES 1000000 #define L100_CONV 235.21 //mpg->L/100km conversion #define KML_CONV 0.4251 // mpg ->km/L conversion #define KM_MPH_CONV 0.62137 //km->mpg conversion #define KNOTS_KM_CONV 1.852 //knots to km/h conversion #define KNOTS_MPH_CONV 1.1508 //knots to mph conversion  //--variables-double inst_mileage;//, fuel_flow; int index = 1; int write_count = 0; boolean select, next; NewSoftSerial LCD(12, LCD_TX_PIN); struct config_trip { double mileage_total; double BES; int mileage_count; int display_units; int menu_selection; int setting_selection; } configuration; struct gps_values { double latitude; double longitude; double knots; double spd; char state; } GPS; void setup() { backlightOn(); pinMode(LCD_TX_PIN,OUTPUT); LCD.begin(9600); Serial.begin(4800); clearLCD(); EEPROM_readAnything(0, configuration); }  void loop(){ if(digitalRead(SELECT_BUTTON) && digitalRead(BACK_BUTTON)){configuration.menu_selection=0; configuration.setting_selection=0;} //Write reset defaults into EEPROM  select = false; index = 1;  20 | P a g e  while(configuration.menu_selection == 0){ if(select==false){while(digitalRead(SELECT_BUTTON)==LOW){} select=true;}  clearLCD(); selectLineOne(); LCD.print("Main menu:  ");  switch(index){ case 1: selectLineTwo(); LCD.print("Inst. Mileage ->"); if(next==false){while(digitalRead(NEXT_BUTTON)==LOW){} next=true;} for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 1; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 2; next = false; break;} } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 1; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 2; next = false; break;} } break; case 2: selectLineTwo(); LCD.print("Trip Mileage ->"); if(next==false){while(digitalRead(NEXT_BUTTON)==LOW){} next=true;} for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 2; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 3; next = false; break;} } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 2; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 3; next = false; break;} } break; case 3: selectLineTwo(); LCD.print("Fuel flow ->"); if(next==false){while(digitalRead(NEXT_BUTTON)==LOW){} next=true;} for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 3; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 4; next = false; break;} } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 3; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 4; next = false; break;} } break; case 4: selectLineTwo(); LCD.print("Best eff speed->"); if(next==false){while(digitalRead(NEXT_BUTTON)==LOW){} next=true;} for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 4; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 5; next = false; break;} } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 4; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 5; next = false; break;} } break; case 5: selectLineTwo(); LCD.print("Digital speed ->");  21 | P a g e  if(next==false){while(digitalRead(NEXT_BUTTON)==LOW){} next=true;} for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 5; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 6; next = false; break;} } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 5; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 6; next = false; break;} } break; case 6: selectLineTwo(); LCD.print("Settings ->"); if(next==false){while(digitalRead(NEXT_BUTTON)==LOW){} next=true;} for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 6; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 1; next = false; break;} } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.menu_selection = 6; break;} if(digitalRead(NEXT_BUTTON)==LOW){ index = 1; next = false; break;} } break; } } switch(configuration.menu_selection){ case 1: Instantaneous_Mileage(); break; case 2: Trip_Mileage(); break; case 3: Display_Fuel_Flow(); break; case 4: Best_Efficiency_Speed(); break; case 5: Display_Speed(); break; case 6: Settings(); break; } } // End of Main Loop  //~~~~~~~~~~~~GENERAL LCD FUNCTIONS~~~~~~~~~~~~~~ void selectLineOne(){ //puts the cursor at line 0 char 0. LCD.print(0xFE, BYTE); //command flag LCD.print(128, BYTE); //position } void selectLineTwo(){ //puts the cursor at line 0 char 0. LCD.print(0xFE, BYTE); //command flag LCD.print(192, BYTE); //position } void selectTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0 if (position<16){ LCD.print(0xFE, BYTE); //command flag LCD.print((position+128), BYTE); //position }else if (position<32){LCD.print(0xFE, BYTE); //command flag LCD.print((position+48+128), BYTE); //position } else { selectTo(0); } } void clearLCD(){ LCD.print(0xFE, BYTE); LCD.print(0x01, BYTE);  //command flag //clear command.  22 | P a g e  } void backlightOn(){ //turns on the backlight LCD.print(0x7C, BYTE); //command flag for backlight stuff LCD.print(157, BYTE); //light level. } void backlightOff(){ //turns off the backlight LCD.print(0x7C, BYTE); //command flag for backlight stuff LCD.print(128, BYTE); //light level for off. } void serCommand(){ //a general function to call the command flag for issuing all other commands LCD.print(0xFE, BYTE); }  void Instantaneous_Mileage(void){ clearLCD(); selectLineOne(); LCD.print("Inst. mileage:  ");  while(configuration.menu_selection ==1){ Get_Data(); if(GPS.state=='V'){ clearLCD(); selectLineOne(); LCD.print("GPS out of range"); } else if(GPS.state=='A'){ clearLCD(); selectLineOne(); if(GPS.spd==0.00){ LCD.print("GPS warming up"); }  else{ clearLCD(); selectLineOne(); LCD.print("Inst. mileage:  ");  selectLineTwo(); if(configuration.display_units==3){ LCD.print(inst_mileage); LCD.print(" MPG"); } else if(configuration.display_units==2){ LCD.print(inst_mileage); LCD.print(" km/L"); } else if(configuration.display_units==1){ LCD.print(constrain(1/inst_mileage*100,0,100)); LCD.print(" L/100km"); } } }  for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection=0; } }  } }  void Trip_Mileage(void){ clearLCD(); selectLineOne(); LCD.print("Trip mileage:  ");  while(configuration.menu_selection ==2){  23 | P a g e  //Don't need to check if GPS is working since the "Trip Mileage" is averaged over a long time, waiting to see if the GPS is working won't change the result. selectLineTwo(); LCD.print(" "); selectLineTwo(); if(configuration.display_units==3){ LCD.print(configuration.mileage_total/(double)configuration.mileage_count); selectTo(22); LCD.print(" MPG"); } else if(configuration.display_units==2){ LCD.print((configuration.mileage_total/(double)configuration.mileage_count)*KML_CONV); selectTo(22); LCD.print(" km/L"); } else if(configuration.display_units==1){ LCD.print(constrain(L100_CONV/(configuration.mileage_total/(double)configuration.mileage_count),0,100) ); selectTo(22); LCD.print(" L/100km"); }  Get_Data();  for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection=0; } } } }  void Display_Fuel_Flow(void){  while(configuration.menu_selection ==3){  clearLCD(); selectLineOne(); LCD.print("Fuel Flow: selectLineTwo();  ");  LCD.print(" "); selectLineTwo(); if(configuration.display_units==1 || configuration.display_units==2){ LCD.print(Read_Fuel_Flow()); // selectTo(22); LCD.print(" LPH"); } else if(configuration.display_units==3){ LCD.print(Read_Fuel_Flow()); // selectTo(22); LCD.print(" GPH"); } Get_Data();  for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection=0; } } } }  24 | P a g e  void Best_Efficiency_Speed (void){ while(configuration.menu_selection ==4){  //algorithm to find best mileage to tell the user the speed they should be driving at Get_Data();  for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection=0;} } } } void Display_Speed(void){ clearLCD(); selectLineOne(); LCD.print("Speed:  ");  while(configuration.menu_selection ==5){  Get_Data();  if(GPS.state=='V'){ clearLCD(); selectLineOne(); LCD.print("GPS out of range"); } else if(GPS.state=='A'){ clearLCD(); selectLineOne(); if(GPS.spd==0.00){ LCD.print("GPS warming up"); } else{ LCD.print("Speed:  ");  if(configuration.display_units==3){ selectTo(22); LCD.print(" mph"); } else if(configuration.display_units==1 || configuration.display_units==2){ selectTo(22); LCD.print(" km/h"); }  //  //  LCD.print(GPS.spd); } }  for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection=0; } } } }  void Settings (void){ while(configuration.menu_selection ==6){  select = false; index = 1; while(configuration.setting_selection==0 && configuration.menu_selection ==6){ if(select==false){ while(digitalRead(SELECT_BUTTON)==LOW){ } select=true;  25 | P a g e  }  clearLCD(); selectLineOne(); LCD.print("Settings:  ");  switch(index){ case 1: selectLineTwo(); LCD.print("Select units ->"); if(next==false){ while(digitalRead(NEXT_BUTTON)==LOW){ } next=true; } for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.setting_selection = 1; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 2; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection = 0; break; } } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.setting_selection = 1; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 2; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection = 0; break; } } break; case 2: selectLineTwo(); LCD.print("Reset trip ->"); if(next==false){ while(digitalRead(NEXT_BUTTON)==LOW){ } next=true; } for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.setting_selection = 3; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 1; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection = 0; break; } } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.setting_selection = 3; break; }  26 | P a g e  if(digitalRead(NEXT_BUTTON)==LOW){ index = 1; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection = 0; break; } } break; } }  //#######SELECT UNITS####### select = false; index = 1; while(configuration.setting_selection==1 && configuration.menu_selection ==6){ if(select==false){ while(digitalRead(SELECT_BUTTON)==LOW){ } select=true; }  clearLCD(); selectLineOne(); LCD.print("Select units:  ");  switch(index){ case 1: selectLineTwo(); LCD.print("L/100 km ->"); if(next==false){ while(digitalRead(NEXT_BUTTON)==LOW){ } next=true; } for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.display_units = 1; configuration.setting_selection = 2; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 2; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.setting_selection = 0; break; } } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.display_units = 1; configuration.setting_selection = 2; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 2; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.setting_selection = 0; break; } } break; case 2:  27 | P a g e  selectLineTwo(); LCD.print("km/L ->"); if(next==false){ while(digitalRead(NEXT_BUTTON)==LOW){ } next=true; } for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.display_units = 2; configuration.setting_selection = 2; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 3; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.setting_selection = 0; break; } } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.display_units = 2; configuration.setting_selection = 2; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 3; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.setting_selection = 0; break; } } break; case 3: selectLineTwo(); LCD.print("MPG ->"); if(next==false){ while(digitalRead(NEXT_BUTTON)==LOW){ } next=true; } for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.display_units = 3; configuration.setting_selection = 2; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 1; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.setting_selection = 0; break; } } selectLineTwo(); LCD.print(" ->"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ configuration.display_units = 3; configuration.setting_selection = 2; break; } if(digitalRead(NEXT_BUTTON)==LOW){ index = 1; next = false; break; } if(digitalRead(BACK_BUTTON)==LOW){  28 | P a g e  configuration.setting_selection = 0; break; } } break; } } while(configuration.setting_selection==2 && configuration.menu_selection ==6){ selectLineTwo(); LCD.print("Done"); }  //#######END SELECT UNITS#######  //#######ADD NEW TRIP######## select = false; while(configuration.setting_selection==3 && configuration.menu_selection==6){ if(select==false){ while(digitalRead(SELECT_BUTTON)==LOW){ } select=true; } clearLCD(); selectLineOne(); LCD.print("Are you sure? Select=Yes Back=No"); for(int i = 0; i<LOOP_TIME; i++){ if(digitalRead(SELECT_BUTTON)==LOW){ clearLCD(); selectLineOne(); LCD.print("Are you sure?"); selectLineTwo(); LCD.print("RESET"); configuration.mileage_total=0; configuration.mileage_count=0; configuration.setting_selection=0; delay(2000); break; } if(digitalRead(BACK_BUTTON)==LOW){ configuration.setting_selection = 0; break; } } }  //#######END ADD NEW TRIP#######  EEPROM_writeAnything(0, configuration); } } #include <WProgram.h>  template <class T> int EEPROM_writeAnything(int ee, const T& value) { const byte* p = (const byte*)(const void*)&value; int i; for (i = 0; i < sizeof(value); i++) { EEPROM.write(ee++, *p++); } return i; } template <class T> int EEPROM_readAnything(int ee, T& value) { byte* p = (byte*)(void*)&value; int i; for (i = 0; i < sizeof(value); i++) { *p++ = EEPROM.read(ee++); } return i; }  29 | P a g e  //this function gets the speed, fuel flow, instataneous mileage, and trip mileage. void Get_Data(void){ Read_GPS(); double flow_temp = Read_Fuel_Flow(); if(flow_temp>0){ inst_mileage = GPS.spd/flow_temp; selected  //IN TERMS OF MPH/GPH or KMPH/LPH depending on what units are  if(configuration.display_units==3){ configuration.mileage_total += inst_mileage; //mileage_total always in MPG; need to convert when printing } else if(configuration.display_units==1 || configuration.display_units==2){ configuration.mileage_total += inst_mileage/KML_CONV; //change into MPG to standardize it in case user switches units half way through a trip, etc. } } else if(GPS.spd<1){ inst_mileage=0; }  // 1>km/h or 1>mph ... in case the gps fluctuates around  configuration.mileage_count++; write_count++; if(write_count>WRITE_THRES){ EEPROM_writeAnything(0, configuration); write_count = 0; } }  // Read_Fuel_flow takes in nothing and returns the fuel flow in either LPH or GPH, depending on what units the user has selected double Read_Fuel_Flow(void){ double fuel_flow, flow_bits = 0; for(int i=0;i<FLOW_COUNTS;i++){ flow_bits += analogRead(FUEL_INPUT); } flow_bits/=FLOW_COUNTS;  //from calibration file if((0<flow_bits) && (flow_bits<=3.00)){ fuel_flow = 0; } else if((3.0<flow_bits) && (flow_bits<=3.4)){ fuel_flow = -2.0210024*flow_bits*flow_bits + 14.0833854*flow_bits - 24.0611343; } else if((3.4<flow_bits) && (flow_bits<=20)){ fuel_flow = -0.0005426*flow_bits*flow_bits + 0.0251076*flow_bits + 0.3804944; } else if((20<flow_bits) && (flow_bits<=520)){ fuel_flow = -0.0000039*flow_bits*flow_bits + 0.0059436*flow_bits + 0.5817425; } else if((520<flow_bits) && (flow_bits<=829)){ fuel_flow = -0.0000101*flow_bits*flow_bits + 0.0161246*flow_bits - 3.0312707; } else { fuel_flow=-1;  //error - past flow range (>500mL/min)  } //return flow_bits; //just calibrating the flow sensor. delete this after and remove the /**/ below  if(configuration.display_units==1 || configuration.display_units==2){ return fuel_flow*3.785;} //return in LPH else if(configuration.display_units==3){  30 | P a g e  return fuel_flow;}  //return in GPH  } void Read_GPS(void){  int byteGPS=-1; char linea[200];// = ""; char comandoGPR[7] = "$GPRMC"; int cont=0; int bien=0; int conta=0; int indices[13]; boolean data_obtained=false; double knots1,longitude1,latitude1; //testing purposes while(data_obtained==false && configuration.menu_selection != 0){ byteGPS=Serial.read();  // Read a byte of the serial port  if(digitalRead(BACK_BUTTON)==LOW){ configuration.menu_selection=0;} if (byteGPS == -1) { delay(100); } else { linea[conta]=byteGPS; conta++; if (byteGPS==13){  // See if the port is empty yet  // If there is serial port data, it is put in the buffer  // If the received byte is = to 13, end of transmission  cont=0; bien=0; for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR if (linea[i]==comandoGPR[i-1]){ bien++; } } if(bien==6){ // If yes, continue and process the data for (int i=0;i<200;i++){ if (linea[i]==','){ // check for the position of the "," separator indices[cont]=i; cont++; } if (linea[i]=='*'){ // ... and the "*" indices[12]=i; cont++; } } GPS.state=linea[indices[1]+1]; char temp_latitude[(indices[2+1]-indices[2]-1)]; for(int j=indices[2], x=0;j<(indices[2+1]-1);j++,x++){ temp_latitude[x]=linea[j+1]; } GPS.latitude = atof(temp_latitude);  char temp_longitude[(indices[4+1]-indices[4]-1)]; for(int j=indices[4], x=0;j<(indices[4+1]-1);j++,x++){ temp_longitude[x]=linea[j+1]; } GPS.longitude= atof(temp_longitude); char temp_knots[(indices[6+1]-indices[6]-1)]; for(int j=indices[6], x=0;j<(indices[6+1]-1);j++,x++){ temp_knots[x]=linea[j+1]; } GPS.knots = atof(temp_knots);  if(configuration.display_units==1 || configuration.display_units==2){ GPS.spd=GPS.knots*KNOTS_KM_CONV; } else if(configuration.display_units==3){ GPS.spd=GPS.knots*KNOTS_MPH_CONV; }  31 | P a g e  data_obtained=true;  } else{ data_obtained=true; } conta=0; for (int i=0;i<200;i++){ linea[i]=' '; }  // Reset the buffer //  } } } }  32 | P a g e  

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.52966.1-0074464/manifest

Comment

Related Items