Introduction: Fuel Efficiency Detector
By: Danica Fujiwara and William McGrouther
Cars are the main mode of transportation in the world today. Specifically, in California, we are surrounded by streets, highways, and toll roads that thousands of cars drive on daily. However, cars use gas and california uses the most gasoline than any other state in the U.S., approximately 4,500 gallons per day. For our CPE 133 Final project, we decided to create system in which it could track the speed of a car and tell whether it exceeds the most efficient speed for the best gas mileage or fuel economy. This project would help drivers become aware of their fuel economy which in turn would hopefully help them save money, use less gas, and create less pollution in the air.
Step 1: Materials
Materials needed for this project:
- Basys 3 FPGA
- Arduino Uno
- Adafruit BNO055 Absolute Orientation Sensor
- Male to Male Wires
Step 2: Understanding the Design
Finite State Diagram
This project has two different states within the finite state diagram shown above. The light can either be on(represented by ‘1’) or off(represented by ‘0’). The state changes depending on the input of the tracking speed(ts) and the constant optimal speed.
Black Box Diagram
Also above there is a Black Box diagram of the Fuel Efficiency module that contains the schematic of the Speed Comparator and the Seven Segment Display that are further discussed below. This VHDL code receives an 8-bit input from the measurements of the accelerometer that is connected to the arduino.
Step 3: Coding VHDL
For this project, there are three VHDL files that construct our design, Fuel_Efficency_FinalProject module, Speed_Comparator module, and the sseg_dec module where Speed_Comparator and the sseg_dec are at the lower level to make up the Fuel Efficiency module.
The Speed comparator Module
This module takes in an 8-bit speed in miles per hour and compares it to the optimal speed for the least amount of gas consumption. The average optimal speed for a car’s best gas mileage is around 55 mph and under. However, this can vary from car to car which can be customized within the module. The line 45 of code that can be changed for personal optimization is show below
if (tracking > "00110111") then
Where “00110111” (55 in binary) can be changed to any 8-bit number for your personal car’s ideal speed for least amount of fuel consumption.
If the speed is over the optimal number the light will turn on notifying that the car is not using maximum fuel efficiency.
The Seven Segment DisplayModule
This module takes in an 8-bit speed in miles per hour and displays the speed on the seven segment display. This would allow the user to know how fast they are going to know whether he or she needs to slow down. This module was given to us within our class and was written by Bryan mealy that contains the components bin2bcdconv which converts the binary 8-bit input to BCD form that is easier to decode and clk_div so that the display can visually show a number with 3 digits by changing the anode output at a high clock frequency . This code accepts an 8- bit number converts the number into a readable display on the basys 3 board.
The Fuel Efficiency module
This is the main file that uses the modules above as components. Its inputs are the clock, and the tracking speed. The clock is built within the basys 3 board and the tracking speed is given by the arduino’s output which is connected to The Analog signal pmod port (XADC). Each bit of the 8-bit tracking speed is map to the ports shown within the wiring section in step4. Other Basys 3 constraints can be found within Basys_3_Master.xdc.
Step 4: Coding Arduino
This project uses one main arduino file that requires the use of several libraries, some of which are already in your arduino program and others have to be downloaded either from this instructable or the Adafruit website(link below).
link to Adafruit BNO055 page : https://learn.adafruit.com/adafruit-bno055-absolu...
Adafruit has developed 2 libraries for use of the BNO055, and give examples of how to use them. In this project we will be using the .getVector function to have the arduino output the accelerometer's data.
This project also utilizes some libraries already installed in the arduino program, like the math library.
This file uses the accelerometer data from the .getVector function and uses mathematical equations to turn it into a speed in miles per hour, that is then outputted in 8 bits of data to the Basys 3(see the "Wiring the Hardware" section for more information).
Step 5: Wiring the Hardware
The Arduino should be wired to the breadboard like they are in the pictures above.
Basys 3 Wiring
The outputs of the arduino are mapped to the inputs of the Basys 3 through the Analog signal pmod JXADC ports. Each bit of the 8-bit tracking speed can be connected to one of the pins shown in the picture above. The least significant bit(digital pin 7) gets connected to ts(7) and the most significant bit(digital pin 0) gets connected to ts(0).