1. ABSTRACT

The main objective of this project is to design and implement an Automotive Systems Monitor (ASM). The ASM allows the driver to access all pertinent information in one central location. This information includes the speed of the vehicle, the mileage, direction, distance traveled, projected distance, and the current time. Our design is modular, which will not only make it easier to locate errors, but also allow flexibility in terms of adding or deleting modules. We are using the Altera Flex 10K chip for our design because it is a reprogrammable FPGA and has enough resources for our implementation.

We have been able to design and implement most of the modules we intended to from the initial project proposal with some changes. Some of our modules had to be adjusted in order to fulfill certain requirements. We weren’t able to implement projected distance and trip odometer due to the problem that our state_mahcine module couldn’t support vectors more than 8 bits long, therefore we excluded these two modules. Otherwise, we had no problems simulating them.

2. IC DESCRIPTION

Modules

Logic Cells

Description

Clock Chip

300

Update and displays the current time.

Push_to_change_state

35

Holds the state select button press for one clock cycle

Direction

3

Displays the current direction of travel for the vehicle.

Trip Odometer

30

Calculate and displays the distance travelled since the last reset.

Mileage

6000

Calculate and display the current mileage of the vehicle.

Projected Distance

4323

Using the MILEAGE and amount of fuel left in the gas tank, the projected distance is calculated and displayed.

Speed

223

Calculate and display the current velocity of the vehicle.

State_mahcine

90

Depending on which state, send the appropriate data to the CHAR_GENERATOR. Also changes the state when a button is pushed.

Char_generator

32

Data passed from STATE_MAHCINE is converted to an ASCII vector which is then passed to WRITE_LCD.

Write_lcd

231431

Writes the ASCII vectors to the LCD.

Altera

400

Connects all the ASM modules together.

 

Pin Name

Pin Type

Signal/Pin Number

FLEX_EXPAN_B Hole Number

state_button

Input

109

15

Minute_button

Input

110

16

Hour_button

Input

111

17

Clkpulse

Input

113

18

Revolution

Input

114

19

Reset

Input

115

20

Litres_ml pulse

Input

116

21

Direct1(2)

Input

117

22

Direct1(1)

Input

118

23

Direct1(0)

Input

119

24

Datalines(7)

Output

139

37

Datalines(6)

Output

138

36

Datalines(5)

Output

137

35

Datalines(4)

Output

136

34

Datalines(3)

Output

134

33

Datalines(2)

Output

133

32

Datalines(1)

Output

132

31

Datalines(0)

Output

131

30

Reg_select

Output

129

29

Lcd_enable

Output

128

28

 

3. OVERVIEW

3.1 INTRODUCTION

This project entails the design of an Automotive Systems Monitor (ASM). This system is able to display various properties of a vehicle such as speed, direction, clock, mileage, trip odometer, and projected distance. This information will be displayed onto an LCD and be controlled by a state machine that will toggle through each of the modules when a button is pressed. The inputs include the amount of fuel left in the tank, a pulse for each revolution, the direction, and a clock pulse generated from an external 555 timer. From this information each module can calculate their corresponding outputs. The modules can be described as follows:

3.1.1 Clock Chip

The clock module accepts the pulses generated from the 555 timer and depending upon how many pulses are in one second, it increments the minutes and hours accordingly. Two buttons are also used to set the hours and minutes when needed. The hours or minutes will increment with each press of the set hour or set minute buttons.

      1. Trip Odometer
      2. The trip odometer module uses the revolution pulse and the circumference of the wheel (predetermined to be 2 m) to calculate the distance traveled in kilometers.

      3. Mileage
      4. Mileage is calculated by determining the distance traveled for a one millilitre change in the gas tank.

      5. Projected Distance
      6. Projected distance is determined from the amount of fuel left multiplied by the mileage. It is updated every kilometer.

      7. Speed
      8. Speed is in meters per second, and is updated every second. The distance traveled in that second is determined using the revolution pulse and the circumference of the wheel.

      9. Direction
      10. Direction displays which way the vehicle is traveling in one of eight directions. These directions are N, NE, E, SE, S, SW, W, and NW.

      11. State_machine
      12. The state_machine module is composed of a state machine which is changed for each button press. Depending on the state, state_machine will pass the necessary information to Char_generator.

      13. Char_generator
      14. Char_generator converts the integer, passed from state_machine, into a decimal ASCII 8-bit standard logic vectors. The ASCII vectors are passed to write_lcd for display.

      15. Write_lcd
      16. Write_lcd displays the ASCII vectors from char_generator on the LCD.

      17. Altera

The altera module instantiates all of the modules described above.

4. DESIGN DETAILS

4.1 Design Specifications and Problems

Over the course of this project we have encountered many obstacles that required special attention. One of the major setbacks to our design was the conversion of our VHDL code from Design Architect to Altera Maxplus II tools. Initially, we began to code and simulate using Design Architect and thought everything was running perfectly. When we tried to switch over to Altera, we ran into many compilation errors and simulation problems. For some of our modules we had to modify a majority of the code to make it function. Mathematical calculations proved to be the biggest problem, for example, Altera didn’t support division unless it was divided by a power of 2. We solved this problem by creating a divider module in order to display integers to ASCII text.

      1. Clock Chip
      2. Clock was one of the major components to our system. We decided to utilize an external 555 timer for our timing. The 555 timer will be operated in the astable mode or as a free running oscillator that will send pulses to our clock module. Depending on this frequency, we can determine the number of pulses in one second and increment the time accordingly to display the hours and minutes. The 555 timer is reliable and easy to implement which made it an easy choice. When reset is pushed, the clock is set to 1:00. The user may also set the time by using two external buttons to increment the hours and minutes. We ran into a problem with the buttons where for some reason we were getting warnings stating these were unnecessary. A separate module was used to detect a button push and hold the corresponding signal high for one clock period.

      3. Trip Odometer
      4. Trip odometer required the revolution pulse and the wheel circumference to calculate the distance the vehicle has gone. Pressing the reset button sets the value to zero. This was easily implemented since we arbitrarily set the circumference to 2 meters so when this distance equals 1000, we know one kilometer has elapsed so we increment the trip odometer. No specific problems were encountered in this module.

      5. Mileage
      6. Originally, our specification for mileage required the use of trip odometer and the amount of fuel. We wanted to have the design such that when one kilometer has elapsed the module will be updated. This is where we encountered our problem of dividing by a number other than a power of two. To solve this problem we kept track of the distance traveled for every change in millilitre of remaining fuel.

      7. Projected Distance
      8. Projected distance used the most logic cells because of the multiplication. Projected distance needed to convert a 18 bit vector, specifying the number of litres of fuel, to an integer. When the integer was determined, it was multiplied by the mileage provided by the mileage module.

      9. Speed
      10. Our initial design called speed to calculated the velocity of the vehicle in kilometers per hour. Due to the fact that divide or multiply by numbers other than powers of 2 was not supported by Altera, we decided to display the velocity in meters per second. This turned out to be an easy calculation, with the revolution pulse going high for every two meters, (The circumference of the wheel) and the seconds pulse that was provided by the clock module.

      11. Direction
      12. Direction displays which way the vehicle is traveling in one of eight directions. These directions are N, NE, E, SE, S, SW, W, and NW. Originally, we had thought to implement an actual physical digital compass. This would have involved getting a compass to provide a pulse for each change in heading, and implementing a state machine to figure out this heading. Due to time constraints, we could not get this feature working. The display module now just takes in the three-bit directional vector directly.

      13. State_machine
      14. The state_machine module is composed of a state machine which is changed for each button press. This module interfaces with the speed, direction, mileage, and clockchip modules to obtain the data values that are sent to the character generator module. The state button press is handled by a separate module called, push_to_change_state. This module sets the change_state signal high for one clock pulse when it detects a state button press.

      15. Char_generator
      16. We needed a char_generator module to calculate the actual ASCII codes that are to be sent to the LCD. The four states of our system are: clock, direction, mileage, and speed. This module, according to these four states and the data being sent from the state_machine module, generates the proper ASCII codes.

        A problem encountered with this module was to convert an 8-bit vector, which represented an integer, into four 8-bit ASCII codes specifying each digit of the integer. Division by a number other than a power of 2 is not supported by Altera, therefore, we created a division algorithm modelled after binary long division. Because we needed to divide this 8-bit vector four times we would have needed to implement this algorithm four times. We discovered that these four loops could be run in parallel, and therefore came up with an algorithm that uses a single loop, run 8 times, that calculates all four digits. The ASCII codes of the number digits were generated by simply adding "00110000" to the bit vectors calculated in the previously described algorithm.

      17. Write_lcd
      18. This module was designed after the LCD example in the student app notes. Using the ASCII codes generated in the previous module, this module sends these ASCII bit vectors to the actual LCD, one at a time, every 2 ms. It also has the responsibility to send intialization and instrucions codes to the LCD.

      19. Altera

The altera module instantiates all of the modules described above. No problems were encountered during the implementation of this module.

 

 

 

  1. DESIGN VERIFICATION
  2. Correct operation and simulation is verified in this section of the report. We tried to simulate all possibilities for each module and cases where values had to ‘wrap’ back to zero when reached its maximum value. Waveforms are provided in the Appendix.

  3. IC TEST MEASUREMENTS
  4.  

     

     

  5. HARDWARE IMPLEMENTATION

7.1 555 Timer

The 555 timer contains the circuitry necessary to realize monostable and astable multivibrators having precise characteristics. The 555 timer is used to generate our system clock pulse. We determined the clock frequency to be 1 kHz.

In the design of any kind of system the need frequently arises for signals having prescribed standard waveforms, which in our case was a system clock pulse. The 555 timer can be configured to operate in a monostable mode in which it functions as a 'one-shot' pulse of predefined length or it can operate in the astable mode where it basically operates as a free running oscillator. The functional diagram of the 555 timer is as shown below:

 

 

 

The circuit consists of two comparators, an SR flip-flop, and a transistor that operates as a switch. One power supply is used for operation, which is typically 5 V. A resistive voltage divider is also employed, and consisting three equal valued resistors is connected across Vcc and established the reference voltages for the two comparators. These are Vth = 2/3 Vcc for comparator 1 and Vtl = 1/3 Vcc for comparator 2.

In the astable mode, two external resistors and one capacitor is used. The diagram is as shown below:

Assuming initially that C is discharged and the flip-flop is set, we have Vo high and transistor Q1 off. The capacitor will charge up through the series combination of RA and RB, and the voltage across it, Vc, will rise exponentially toward Vcc. As Vc crosses the level equal to Vtl, the output of comparator 2 goes low. At this point nothing occurs until Vc reaches and begins to exceed the threshold of comparator 1, Vth. At this instant, the output of comparator 1 goes high and resets the flip-flop, and Vo goes low, Q' goes high, and transistor Q1 is turned on. The capacitor C begins to discharge through RB and the collector of Q1. The voltage Vc decreases exponentially with a time constant of RBC toward 0 V. When Vc reaches the threshold of comparator 2 Vtl, the output of comparator 2, goes high and sets the flip-flop. The output Vo then goes high, and Q' low, turning off Q1. Capacitor C begins to charge through the series equivalent of RA and RB, and its voltage rises exponentially toward Vcc with time constant (RA + RB)C. This rise continues until Vc reaches Vth, at which time the output of comparator 1 goes high, resetting the flip-flop, and the cycle continues. The charge time T1 is given by:

T1 = 0.69(RA + RB)C (1)

and the discharge time is given by:

T2 = 0.69 RBC (2)

The total period can therefore be expressed using equations (1) and (2):

T = 0.69 (RA+2RB)C (3)

The duty cycle can also be evaluated as:

D = (RA + RB)/(RA + 2RB) (4)

In our application, we wanted a 1 ms period and close to a 50% duty cycle. Therefore, substituting these values into equations (3) and (4) to arrive at RA = 5.6 kW , RB = 138 kW , and C = 10 nF for close to a 50% duty cycle.