Final
Upcoming SlideShare
Loading in...5
×
 

Final

on

  • 1,389 views

 

Statistics

Views

Total Views
1,389
Slideshare-icon Views on SlideShare
1,387
Embed Views
2

Actions

Likes
0
Downloads
29
Comments
0

1 Embed 2

http://www.techgig.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Final Final Document Transcript

    • ENGINE SPEED AUTOMATION WITH AUTO CRUISE AND ANTI LOCK BREAKING SYSTEM A PROJECT REPORT Submitted by RAMANUJAM.R (50306106037) SRAVAN KUMAR.B (5006106049) in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING in ELECTRONICS AND COMMUNICATION ENGINEERING ARULMIGU MEENAKSHI AMMAN COLLEGE OF ENGIN KANCHIPURAM ANNA UNIVERSITY: CHENNAI 600 025 APRIL 2010 1
    • ANNA UNIVERSITY: CHENNAI 600 025 BONAFIDE CERTIFICATE Certified that this project report “ENGINE SPEED SIGNATURE SIGNATURE Mr. PARASURAM, M.E, Mr. SHANTI, B.E, HEAD OF THE DEPARTMENT SUPERVISOR ASST.PROFESSOR LECTURER Department of Electronics Department of Electronics and Communication Engineering and Communication Engineering Arulmigu Meenakshi Amman College Arulmigu Meenakshi Amman College Engineering, Engineering, Vadamavandal-604410 Vadamavandal-604410 Kanchipuram Kanchipuram AUTOMATION WITH AUTO CRUISE AND ANTI-LOCK BRAKING SYSTEM” is the bonafide work of “RAMANUJAM.R (50306106037) and SRAVAN KUMAR.B (50306106049)” who carried out the project under my supervision. Submitted for university project held on _______________ at Arulmigu Meenakshi Amman College Vadamavandal,Kanchipuram External Examiner Internal Examiner ABSTRACT 2
    • Our project basically limits the speed of the vehicle automatically. Speed limiting is done by engine speed automation. Fixed Fuel Delivery (Fixed Speed) when lane input is selected by actuating a solenoid which holds the delivery system in a particular value or fixing the value of fuel delivery by operating a PWM Actuator. This technique is called as Auto cruise control. It is capable of precluding detrimental phenomena such as dipping and hunting of the vehicle speed while the control of the vehicle speed is in transition from the manual status to the automatic status. Antilock braking system applies brake in switched manner to avoid skidding and hence reduces the possibility of accident. It actuates on the occurrence of Brake Switch Input. An ECU controlled ABS works in a smarter way because it is based on sensors and a processor which work together to vary braking force based on numerous information from the vehicle systems. ACKNOWLEDGEMENT We express grateful thanks to our Parents and Friends who have supported us throughout our project. 3
    • We are thankful to the management for having given us the time to complete the project and also for the facilities and support given by them in the college. We wish our deepest gratitude to our beloved Principal Mr. MUTHU, M.E., (Ph.D.) for providing necessary facilities to undertake the project. We also express our gratitude to Mr. PARASURAM, M.E., Head of the Department, Mr.SHANTI , M.E., Project Co-ordinator and Internal Guide Electronics and Communication Engineering,Arulmigu Meenakshi Amman College of Engineering, for permitting us to work on this project and for their constant encouragement and guidance that they provided, while doing this project work. We also thank them for their valuable suggestions and immense contribution at predicaments encountered while accomplishing the project. We submit our sincere acknowledgement to Mr.K.PARTHIPAN Head, E & D department of Delphi-TVS for granting permission to carry out this project in this plant. We extend our heartfelt gratitude to Mr. VIJAY NEELAKANDAN.P and Mr.MRITHUNJAY for their valuable guidance, encouragement and timely help rendered during the project and for her remarkable support. TABLE OF CONTENTS 4
    • CHA TITLE PAGE PTER NO. NO. COMPANY PROFILE ABSTRACT ACKNOWLEDGEMENT LIST OF TABLE LIST OF FIGURES LIST OF ABBREVIATIONS 1. INTRODUCTION 2. OVERVIEW OF THE PROJECT 2.1 Engine Speed Automation 2.2 Auto Cruise Module 2.3 Anti-lock Breaking System module 3. BLOCK DIAGRAM AND CIRCUIT DIAGRAM DESCRIPTION 3.1 Overall Block Diagram Description 3.2 Electronic Control Unit 3.3 Interface Circuit Design 4. MICROCONTROLLER DESCRIPTION 4.1 Controller Unit 4.1.1 Features 4.2 Memory Description 4.3 Pin Assignments 4.4 MCU diagram 4.5 Electrical Specifications 4.6 Mechanical Specifications 5. MICROCONTROLLER INTERFACING CIRCUITRY 5.1.Interfacing Ciruitry 5
    • 5.2 Inputs 5.3 Outputs 6. HARDWARE COMPONENTS AND DESCRIPTION 6.1 Design and Fabrication of PCB 6.2 Component placement in PCB 6.3 Hall Effect Sensor 6.4 Actuator 7. SOFTWARE DESCRIPTION 7.1 P & E Cyclone Pro 7.2 Timer Interface A 7.3 Overflow Interrupt Function in Timer A 7.4 PWMMC 7.5 Entire Strategy 8. CONCLUSION 8.1 Conclusion 8.2 Futureistic Advancement APPENDICES REFERENCES LIST OF TABLES NO. TABLE PAGE NO. 4.6 Electrical Specifications 4.7 Mechanical Specifications 6
    • LIST OF FIGURES NO. FIGURE PAGE NO. 2.3.5 Wheel Speed sensor 3.1 Overall Block Diagram 7
    • 3.2.1 Electronic Control Unit 3.2.2 Picture View of ECU 3.3.1 Power Supply Circuit 3.3.2 Engine Speed Circuit 3.3.3 Brake Switch Circuit 3.3.4 Auto Cruise Switch 3.3.5 Gear Select Switch 3.3.6 Load Driving Capability 3.3.7 ABS-PWM circuit 4.1 Pin Configuration 4.5 MCU Block Diagram 4.6 PWM Module Diagram 5.1 Microcontroller Interfacing Circuit 6.1.1 Schematic Diagram 1 6.1.2 Schematic Diagram 2 6.1.3 Schematic Diagram 3 6.2 Snapshot Of PCB 6.3 Hall Effect Sensor 6.4 Actuator 7.1 Cyclone pro 7.2.1 TimerA usage as input capture and producing the Fuel PWM actuator rattling 7.2.2 Timer A Status and control register 7.2.3 Edge and Level Select Bits 8
    • 7.2.4 Priority and Vector address 7.2.5 Overflow Vector Address 7.4.1 CONFIG Register 7.4.2 PWM Control Register PCTL CHAPTER 1 INTRODUCTION Today's vehicles are becoming more and more reliant on electronic components. Different systems of a vehicle that are being developed and produced today are equipped with electronic systems which aid the mechanical parts in performing effectively. Fuel injection systems for cars rely on electronic components to provide the engine with the right amount of 9
    • fuel. Likewise, safety systems also rely heavily on electronic circuits to provide optimum safety to the occupants of a car in the event of a crash Automobile safety may have become an issue almost from the beginning of mechanized road vehicle development. Despite technological advances, about 40,000 people die every year. Although the fatality rates per vehicle registered and per vehicle distance travelled have steadily decreased since the advent of significant vehicle and driver regulation, the raw number of fatalities generally increases as a function of rising population and more vehicles on the road. However, sharp rises in the price of fuel and related driver behavioral changes are reducing highway fatalities. The objective of preventive safety applications is to support the driver, thus changing his/her driving behavior in certain situations. Preventive and active safety systems are often referred to as Advanced Driver Assistance Systems or ADA applications. Two such applications like Auto cruise and Antilock breaking system are implemented in our project. In the automotive industry, safety systems need electronic components. Electronic stability systems rely on electronics to keep the car stable especially while cornering. Suspension systems also depends on electronics as shown by electronically controlled independent suspension systems employed by the latest mass produced vehicles. In our project, we have incorporated speed adaptation using Auto cruise control and also have designed safety driving technique using Antilock breaking system (ABS).The extensive use of electronics in modern vehicles is well known. Electronics and software provide possibilities for 10
    • substantial improvements in functional content, performance and other product properties. Braking systems also depend on electronic components like the anti- lock braking system (ABS). Electronic components are now essential to control a car's movements and to provide entertainment and communication and also to ensure safety. A new, platform-based methodology can revolutionize the way a car is designed. Dealing properly with electronics and software will be a strong competitive advantage in the automotive sector in the near future. Electronics are driving current innovations and are at the same time becoming a larger part of the cost of the vehicle. In order to be successful as an automotive manufacturer, innovations must be introduced in the vehicle without compromising the final price tag. CHAPTER 2 OVERVIEW OF THE PROJECT 2.1 ENGINE SPEED AUTOMATION Definition 11
    • The Engine Control Unit (ECU) controls the fuel injection system, ignition timing, and the idle speed control system. The ECU also interrupts the operation of the air conditioning and EGR systems, and controls power to the fuel pump (through the control relay). The ECU consists of an 8-bit microprocessor, random access memory (RAM), read only memory (ROM), and an input/output interface. Based on information from the input sensors (engine coolant temperature, barometric pressure, air flow, etc.), the ECU determines optimum settings for the output actuators (injection, idle speed, ignition timing, etc.). What is an Engine Control Unit? An Engine Control Unit (ECU) also known as an Engine Control Module (ECM) or Powertrain Control Unit/Module (PCU, PCM) if it controls both an engine and a transmission, is an electronic control unit which controls various aspects of an internal combustion engine's operation. The simplest ECU’s simply control the quantity of fuel injected into each cylinder each engine cycle. The brain of the cruise control system is the electronic control module . The speed of any vehicle is monitored by the vehicle speed sensor that is attached to the output shaft of the transmission. For every rotation of the shaft, the speed sensor gives off a pre-determined number of pulses. These pulses are sent to the ECU as well as the speedometer which displays the speed of the vehicle on the dash. When the cruising speed on a 12
    • vehicle is selected by the driver, the ECU records the frequency of pulses that corresponds with that speed. It is therefore this pulse frequency that the ECU uses as a benchmark when maintaining the car at a constant speed. After the ECM stores the desired pulse frequency in its memory, it con sensor. If the frequency is ever different in value it causes the ECM to do one of two things: •Apply more throttle •Reduce the throttle. CONTROL OF FUEL INJECTION For an engine with fuel injection, an ECU will determine the quantity of fuel to inject based on a number of parameters. If the throttle pedal is pressed further down, this will open the throttle body and allow more air to be pulled into the engine. The ECU will inject more fuel according to how much air is passing into the engine. If the engine has not warmed up yet, more fuel will be injected (causing the engine to run slightly 'rich' until the engine warms up). 2.2AUTO CRUISE MODULE 2.2.1 INTRODUCTION Auto Cruise Control (ACC) is an automotive feature that allows a vehicle's cruise control system to adapt the vehicle's speed to the traffic environment. The purpose of a cruise control system is to accurately 13
    • maintain the driver's desired set speed, without intervention from the driver, by actuating the throttle-accelerator pedal linkage. A modern automotive cruise control is a control loop that takes over control of the throttle, which is normally controlled by the driver with the gas pedal, and holds the vehicle speed at a set value. But cruise control actuates the throttle valve by a cable connected to an actuator, instead of by pressing a pedal. Cruise control systems are designed to turn off immediately with a slight touch of the brake or clutch pedal. Most cruise controls will cut out if you accidentally shift from drive to neutral. Two cables are connected to a pivot that moves the throttle valve. One cable comes from the accelerator pedal, and one from the actuator. When the cruise control is engaged, the actuator moves the cable connected to the pivot, which adjusts the throttle; but it also pulls on the cable that is connected to the gas pedal. This is a basic overview of the cruise control system used in the majority of modern cars. These systems are constantly being developed and further updated by car manufacturers such as Lexus and Mercedes-Benz. An example of a technologically advanced cruise control system is where a laser is used to track the distance between your car and the nearest car directly in front of you. If that distance ever decreases past a certain point, then not only is the vacuum force applied to the throttle mechanism stopped, but the brakes are applied to avoid a collision 2.2.2 DEVELOPMENT OF AUTO CRUISE 14
    • In modern designs, the cruise control may need to be turned on before use in some designs it is always "on" but not always enabled, others have a separate "on/off" switch, while still others just have an "on" switch that must be pressed after the vehicle has been started. Most designs have buttons like Set Resume Accelerate Cancel button. Alternatively, tapping the brake or clutch pedal will disable the system so the driver can change the speed without resistance from the system. The system is operated with controls easily within the driver's reach, usually with two or more buttons on the steering wheel spokes or on the edge of the hub like those on Honda vehicles, on the turn signal stalk like in some General Motors vehicles or on a dedicated stalk like those found in Toyota and Mercedes-Benz vehicles. Early designs used a dial to set speed choice. The driver must bring the car up to speed manually and use a button to set the cruise control to the current speed. The cruise control takes its speed signal from a rotating driveshaft, speedometer cable, and wheel speed sensor or from the engine's RPM. Most systems do not allow the use of the cruise control below a certain speed (normally 35 mph/55 km/h) to discourage use in city driving. The car will maintain that speed by pulling the throttle cable with a solenoid or a vacuum driven servomechanism. All systems must be turned off both explicitly and automatically, when the driver hits the brake or clutch. 15
    • Cruise control often includes a memory feature to resume the set speed after braking and a coast feature to reset the speed lower without braking. When the cruise control is in effect, the throttle can still be used to accelerate the car, but once the accelerator is released the car will then slow down until it reaches the previously set speed. On the latest vehicles fitted with electronic throttle control, cruise control can be easily integrated into the vehicle's engine management system. Modern "adaptive" systems include the ability to automatically reduce speed when the distance to a car in front, or the speed limit, decreases. This is an advantage for those driving in unfamiliar areas. Cruise control has been around for a long time. Over the years they way they control speed has been improved with better electronics. And as a consequence, have become more difficult to troubleshoot. Most car manufacturers have special testers that hook up between the cruise control module and harness to pinpoint a specific problem. Cruise Contol Module:- The cruise control module has to do three things. First it remembers the speed you set. It stores this set speed until you change it or turn off the ignition. Next it takes the speed signal from the vehicle speed sensor and compares it to the set speed. Lastly it sends pulse signals to the actuator. The actuator will move the throttle linkage to bring the vehicle up to the set speed and then modulate vacuum to maintain that speed. 16
    • Actuator: The actuator is what actually moves the throttle linkage. It is most often vacuum operated although some actuators are electrically controlled with small, stepper type motors. The actuator moves the linkage as directed by the cruise control module until the set speed has been achieved. It then maintains this speed by controlling the amount of vacuum. It actually modulates the vacuum as the pulses from the control module direct. There are two actuators used throttle actuator and brake actuator. Brake Switch The cruise control release switch and stop lamp switch are used to disengage the cruise control system. A cruise control release switch and a stop lamp switch, mounted on the brake pedal bracket disengage the system electrically when the brake pedal is pressed. This is accomplished by interrupting the flow of current to the cruise control module. The cruise speed of the vehicle at brake actuation will be stored in the cruise control module memory. 2.2.3 MODULE DESCRIPTION The majority of modern automobiles have several electronic innovations that were designed to improve our driving experience. One of the most popular automotive innovations is the cruise control system, which is used to regulate the speed of the vehicle most often while its driver is taking a long, tiring journey on highways and interstates. 17
    • In simple terms, a driver regulates the speed of a car by stepping on the gas pedal or applying pressure to the brakes. The cruise control system works in a similar way, except that it isn’t able to activate the brakes, just modulate the throttle. 2.3 ANTI LOCK BREAKING SYSTEM MODULE An anti-lock braking system, or ABS is a safety system which prevents the wheels on a motor vehicle from locking up (or ceasing to rotate) while braking. A rotating road wheel allows the driver to maintain steering control under heavy braking by preventing a skid and allowing the wheel to continue interacting tractively with the road surface as directed by driver steering inputs. ABS offers improved vehicle control and decreases stopping distances on dry and especially slippery surfaces. However, on loose surfaces like gravel and snow-on-pavement, it can slightly increase braking distance while still improving vehicle control. Since initial widespread use in production cars, anti-lock braking systems have evolved considerably. Recent versions not only prevent wheel lock under braking, but also electronically control the front-to-rear brake bias. This function, depending on its specific capabilities and implementation,is known as Electronic brake force distribution (EBD), Traction control system, emergency brake assist, or Electronic stability control. 18
    • CHAPTER 3 BLOCK DIAGRAM AND CIRCUIT DIAGRAM DESCRIPTION 3.1 OVERALL BLOCK DIAGRAM DESCRIPTION 19
    • Fig 3.1 overall block diagram DESCRIPTION When the vehicle speed increases, it is sensed by a HALLEFFECT SENSOR, which gives square wave compatible to the FREE SCALE MICROCONTROLLER. The Pulse width will vary based on the speed of the vehicle. This signal width will be captured by the microcontroller. Microcontroller uses a current driving circuitry in its output, from which current passes to the vacuum solenoid valves. Solenoid refers to a loop of wire, often wrapped around a metallic core, which produce magnetic field when an electric current is passed through it. The Solenoid Valves then push the plunger to control the fuel at regular intervals and in turn the vehicle speed gets controlled. ABS is the Antilock Breaking System which uses an actuator to actuate the vacuum solenoid valves. 3.2 ELECTRONIC CONTROL UNIT: 20
    • Fig 3.1 Electronic Control Unit DESCRIPTION: In automotive electronics, electronic control unit (ECU) is a generic term for any embedded system that controls one or more of the electrical 21
    • systems or subsystems in a motor vehicle. Other terms for ECU include electronic control module (ECM), central control module (CCM), control unit, or control module. Taken together, these systems are sometimes referred to as the car's computer. (Technically there is no single computer but multiple ones.) 3.2.2 picture view of ECU In the above schematic, we have included all the input and output circuits which are discussed below. 3.3 INTERFACE CIRCUIT DESIGN •POWER SUPPLY CIRCUIT 22
    • Fig 3.3.1 power supply regulator circuit The voltage from the power supply unit is 12v, which cannot be supplied directly to the microcontroller. So it is converted to 5v.The above circuit support this convertion.It consists of 1N4001 diode in series with regulator IC7805, which regulates the voltage. This IC is also called buck boost IC.1N4007 diode has peak reverse voltage of 1000V, so it suppresses the negative spikes <=1000V. During suppression of spikes, diode acts as an open circuit. The resistors and capacitors are used for signal shaping and for filtering the ripples present in DC output. •POWER SUPPLY UNIT This is basically a battery powered supply. It is not SMPS based power supply. In SMPS, the voltage produced will be noisy because it operates at high frequency. INPUTS 1. Vehicle speed input 23
    • 2. Throttle lever input 3. Brake switch input 4. Engine speed input OUTPUT 1.Fuel control PWM output 2. Warning lamp output 3. ABS PWM output 4.Fault indicator lamp output 3.4INPUT INTERFACING CIRCUITS •ENGINE SPEED INPUT CIRCUIT 24
    • Fig3.3.2 Engine Speed Input Circuit Engine speed can be sensed by Hall Effect sensor or Variable reluctance sensor. Even when vehicle speed is zero, engine continues to be in ideal speed. The sensor produces a pulse, whose frequency and amplitude changes. This varying frequency and amplitude of the signal, which is produced by the sensor, is proportional to the engine speed. The output signal cannot be directly fed into the microcontroller inside the ECU, since the microcontroller needs a proper signal without fluctuation in its amplitude and frequency. Therefore it becomes necessary to provide Isolation electrically (coupling optically or photically). For engine speed calculation we need Zero crossing detector, and so Optocoupler is used.Optocoupler converts the input voltage to optical signal and it is given to the base of the Phototransistor. Output of the transistor 25
    • produces 5V constantly.In the circuit load resistance used is 1kΏ and the 12v supply is given through 47Ώ resistance. •BRAKE SWITCH CIRCUIT This is basically an ON/OFF switch. It senses whether the brake has been pressed. 3.3.3 Brake switch Circuit The resistors and capacitors are used for signal shaping and for filtering the ripples present in DC output. 26
    • AUTO CRUISE SWITCH: 3.3.4 Auto Cruise Switch Cruise control (sometimes known as speed control or auto cruise) is a system that automatically controls the speed of a motor vehicle. The system takes over the throttle of the car to maintain a steady speed as set by the driver. The above circuit consists of resistors and capacitor, which are used for signal shaping and filtering. ADVANTAGES: Its usefulness for long drives across Interstate highways and sparsely populated roads. This usually results in better fuel efficiency. Some drivers use it to avoid unconsciously violating speed limits. A driver who otherwise tends to unconsciously increase speed over the course of a highway journey may avoid a speeding ticket. Such drivers should note, however, that a cruise control may go over its setting on a downhill which is steep enough to accelerate with an idling engine 27
    • GEAR INPUT CIRCUIT: Gear is a rotating machine part having cut teeth, or cogs, which mesh with another toothed part in order to transmit torque. 3.3.5 Gear Select Switch Two or more gears working in tandem are called a transmission and can produce a mechanical advantage through a gear ratio and thus may be considered a simple machine. Geared devices can change the speed, magnitude, and direction of a power source. The most common situation is for a gear to mesh with another gear; however a gear can also mesh a non-rotating toothed part, called a rack, thereby producing translation instead of rotation. The gears in a transmission are analogous to the wheels in a pulley. An advantage of gears is that the teeth of a gear prevent slipping. When two gears of unequal number of teeth are combined a mechanical advantage is produced, with both the rotational speeds and the torques of the two gears differing in a simple relationship. 28
    • OUTPUT INTERFACING CIRCUITS •OUTPUT DRIVES Generally we cannot drive any output directly from the microcontroller, due to less load driving capability of the microcontroller. •LOAD DRIVING CAPABILITY For loads like actuators and solenoids power consumed will be of the order (10-30) watts. In automotive applications, we use a 12V subsystem. This implies that the current drawn by the loads will be of the order of (1-3) A. 3.3.6 load driving capability For the loads like relays, power consumed will be of the order of (4-5) watts. The current drawn by the load will be of 300 to 400mA. 29
    • •OUTPUT DRIVING CIRCUITS The circuit consists of a MOSFET .The signal from the microcontroller is given to the gate of the MOSFET. An inductor is connected to the drain terminal and between drain and the source, a zener diode is connected. 4.3.7 ABS-PWM circuit The waveform of the inductor consists of kick back voltage. In order to suppress the kick back voltage, zener diode is connected between drain and the source which maintains constant voltage across MOSFET and prevents MOSFET from damage. 30
    • CHAPTER 4 MICROCONTROLLER DESCRIPTION 4.1CONTROLLER UNIT MC68HC908MR16 is an 8 bit microcontroller which is used in the ECU unit. The MC68HC908MR16 is a member of the low-cost, high- performance M68HC08 Family of 8-bit microcontroller units (MCUs). All MCUs in the family use the enhanced M68HC08 central processor unit (CPU08) and are available with a variety of modules, memory sizes and types, and package type. 4..1.1 FEATURES Fully upward-compatible object code with M6805, M146805, and M68HC05Families 8-MHz internal bus frequency On-chip FLASH memory with in-circuit programming capabilities of FLASH program memory: MC68HC908MR16 — 16 Kbytes On-chip programming firmware for use with host personal computer 768 bytes of on-chip random-access memory (RAM) 12-bit, 6-channel center-aligned or edge-aligned pulse-width modulator(PWMMC) Serial peripheral interface module (SPI) Serial communications interface module (SCI) 16-bit, 4-channel timer interface module (TIMA) 31
    • 16-bit, 2-channel timer interface module (TIMB) 10-bit, 10-channel analog-to-digital converter (ADC) 4.2 MEMORY DESCRIPTION 4.2.1Monitor ROM The 240 bytes at addresses $FE10–$FEFF are reserved ROM addresses that contain the instructions for the monitor functions 4.2.2Random-Access Memory (RAM) Addresses $0060–$035F are RAM locations. The location of the stack RAM is programmable. The 16-bit stack pointer allows the stack to be anywhere in the 64-Kbyte memory space. Within page zero are 160 bytes of RAM. Because the location of the stack RAM is programmable, all page zero RAM locations can be used for input/output (I/O) control and user data or code. When the stack pointer is moved from its reset location at $00FF, direct addressing mode instructions can access efficiently all page zero RAM locations. Page zero RAM, therefore, provides ideal locations for frequently accessed global variables. Before processing an interrupt, the central processor unit (CPU) uses five bytes of the stack to save the contents of the CPU registers. 4.3 PIN ASSIGNMENTS The above diagram shows the 64-pin QFP pin assignments. QFP refers to quad flat pin arrangement which have a flat square arrangement with 64 pin around, 32
    • Fig.1 PIN CONFIGURATION Power Supply Pins (VDD and VSS) VDD and VSS are the power supply and ground pins. The MCU operates from a single power supply. Fast signal transitions on MCU pins place high, short-duration current demands on the power supply. To prevent noise problems, take special care to provide power supply bypassing at the MCU as shows. 33
    • Place the C1 bypass capacitor as close to the MCU as possible. Use a high-frequency-response ceramic capacitor for C1. C2 is an optional bulk current bypass capacitor for use in applications that require the port pins to source high-current levels. Oscillator Pins (OSC1 and OSC2 The OSC1 and OSC2 pins are the connections for the on-chip oscillator circuits. External Reset Pin (RST) Logic 0 on the RST pin forces the MCU to a known startup state. RST is bidirectional, allowing a reset of the entire system. It is driven low when any internal reset source is asserted. CGM Power Supply Pins (VDDA and VSSAD) VDDA and VSSAD are the power supply pins for the analog portion of the clock generator module (CGM). Decoupling of these pins should be per the digital supply. Analog Power Supply Pins (VDDAD and VSSAD) VDDAD and VSSAD are the power supply pins for the analog-to-digital converter Decoupling of these pins should be per the digital supply. ADC Voltage Decoupling Capacitor Pin (VREFH) VREFH is the power supply for setting the reference voltage. Connect the VREFH pin to the same voltage potential to DDAD. ADC Voltage Reference Low Pin (VREFL) 34
    • VREFL is the lower reference supply for the ADC. Connect the VREFL pin to the same voltage potential as VSSAD. Port A Input/Output (I/O) Pins (PTA7–PTA0) PTA7–PTA0 is general-purpose bidirectional input/output (I/O) port pins. Port B I/O Pins (PTB7/ATD7–PTB0/ATD0) Port B is an 8-bit special function port that shares all eight pins with the Analog-to-digital converter (ADC). Port C I/O Pins (PTC6–PTC2 and PTC1/ATD9–PTC0/ATD8) PTC6–PTC2 is general-purpose bidirectional I/O port pins. PTC1/ATD9–PTC0/ATD8 is special function port pins that are shared with the analog-to-digital converter (ADC). Port D Input-Only Pins (PTD6/IS3–PTD4/IS1 and PTD3/FAULT4– PTD0/FAULT1) PTD6/IS3–PTD4/IS1 are special function input-only port pins that also serve as current sensing pins for the pulse-width modulator module (PWMMC).PTD3/FAULT4–PTD0/FAULT1 is special function port pins that also serve as fault pins for the PWMMC. PWM Pins (PWM6–PWM1) PWM6–PWM1 is dedicated pins used for the outputs of the pulse- width modulator module (PWMMC). These are high-current sink pins. PWM Ground Pin (PWMGND) 35
    • PWMGND is the ground pin for the pulse-width modulator module (PWMMC). This dedicated ground pin is used as the ground for the six high-current PWM pins. Port E I/O Pins (PTE7/TCH3A–PTE3/TCLKA and PTE2/TCH1B– PTE0/TCLKB) Port E is an 8-bit special function port that shares its pins with the two timer interface modules (TIMA and TIMB). Port F I/O Pins (PTF5/TxD–PTF4/RxD and PTF3/MISO– PTF0/SPSCK) Port F is a 6-bit special function port that shares two of its pins with the serial communications interface module (SCI) and four of its pins with the serial peripheral interface module (SPI) 4.4 MCU BLOCK DIAGRAM 36
    • Fig 4.5MCU BLOCK DIAGRAM 4.5 PULSE WIDTH MODULATOR FOR MOTOR CONTROL (PWMMC) 37
    • This section describes the pulse-width modulator for motor control (PWMMC, version A). The PWM module can generate three complementary PWM pairs or six independent PWM signals. These PWM signals can be centre-aligned or edge-aligned. Fig.4.5 PWM MODULE BLOCK DIAGRAM 4.6.1 Features Features of the PWMMC include: • Three complementary PWM pairs or six independent PWM signals • Edge-aligned PWM signals or center-aligned PWM signals • PWM signal polarity control • 20-mA current sink capability on PWM pins 38
    • • Manual PWM output control through software • Programmable fault protection • Complementary mode featuring: – Dead-time insertion 4.6 ELECTRICAL SPECIFICATIONS Maximum ratings are the extreme limits to which the MCU can be exposed without permanently damaging it. Table 4.6: Electrical Specifications 4.7MECHANICAL SPECIFICATIONS 39
    • Table 4.7: Mechanical Specifications 40
    • CHAPTER 5 MICROCONTROLLER INTERFACING CIRCUITRY 5.1 Interfacing Circuitry Fig 5.1.Microcontoller Interfacing Circuit Diagram 41
    • INPUTS 1.Engine Speed Input:- The Input of the Engine speed is given to the 38th pin of the microcontroller. The 38th pin is Timer Interface Module A channel 2. 2.Brake Switch Input The Brake Switch Input is given to the 34th pin of the microcontroller. The 38th pin is Timer Interface Module B channel 1. 3.Auto Cruise Switch Input The Auto Cruise Switch Input is given to the 33 th pin of the microcontroller. The 33th pin is Timer Interface Module B channel 0. OUTPUTS 1.Fuel Output:- Fuel Pwm Actuator Output is taken from the 36 th pin of the microcontroller. The 38th pin is Timer Interface Module A channel 1. 2.ABS pwm:- ABS Pwm Actuator Output is taken from the 36 th pin of the microcontroller. The 38th pin is Pulse Width Modulator Module Channel 2. 42
    • CHAPTER 6 HARDWARE COMPONENTS AND DESCRIPTIONS 6.1 DESIGNS AND FABRICATION OF PRINTED CIRCUIT BOARDS 6.1.1 PCB MANUFACTURING: The manufacturing process consists of printing, etching and plating. The single sided PCBs are usually made using the print and etch method. The double sided plate through – hole (PTH) boards are made by the print plate and etch method. The software used to obtain the schematic layout is ORCAD. 6.1.2 PANELISATION: Here the schematic transformed in to the working positive / negative films. The circuit is repeated conveniently to accommodate economically as many circuits as possible in a panel, which can be operated in every sequence of subsequent steps in the PCB process. This is called Penalization. 6.1.3 DRILLING: Very small holes are drilled with high-speed CNC drilling machines, giving a wall finish with less or no smear or epoxy, required for void free through hole plating. 6.1.4 PLATING: 43
    • The heart of the PCB manufacturing process is plating. The holes drilled in the board are treated both mechanically and chemically before depositing the copper by the electro less copper plating process. 6.1.5 ETCHING: Once a multilayer board is drilled and copper is deposited, the image available in the form of a film is transferred on to the outside by photo printing using a dry film printing process. The boards are then electrolytic plated on to the circuit pattern with copper and tin. The tin-plated deposit serves an etch resist, when copper in the unwanted area is removed by the conveyors spray etching machines with chemical etch ants. 6.1.6 SOLDERMASK: Since a PCB design may call for very close spacing between conductors, a solder mask has to be applied on the both sides of the circuitry to avoid the bridging of conductors. The solder mask ink is applied by the process screening. 6.1.7 HOT AIR LEVELLING: After applying the solder mask, the circuit pads are soldered using the hot air leveling process. The bare body is fluxed and dipped into a molten solder bath. While removing the board from the solder bath, hot air is blown on both sides of the board through air knives in the machines, leaving the board soldered and leveled. This is one of the common finishes given to the boards. 44
    • Fig 6.1.1 Schematic diagram 1 45
    • Fig 6.1.2 Schematic diagram 2 46
    • Fig 6.1.3.Schematic diagram 3 6.2 COMPONENT PLACEMENT One of the most frequent applications of soldering is assembling electronic components to printed circuit boards (PCBs). Another common application is making permanent but reversible connections between copper pipes in plumbing systems. Joints in sheet metal objects such as food cans, roof flashing, rain gutters and automobile radiators have also historically been soldered, and occasionally still are. Jewelry components are assembled and repaired by soldering. Small mechanical parts are often soldered as well. Soldering is also used to join lead came and copper foil in stained glass work. Soldering can also be used as a semi-permanent patch for a leak in a container or cooking vessel. 47
    • Guidelines to consider when soldering is that, since soldering temperatures are so low, a soldered joint has limited service at elevated temperatures. Solders generally do not have much strength, so the process should not be used for load-bearing members. Fig 6.2: Snapshot of PCB 6.4 ACTUATOR An actuator is a mechanical device for moving or controlling a mechanism or system. It takes energy, usually transported by air, electric current, or liquid, and converts that into some kind of motion. 48
    • Put simply, an actuator is something that converts energy into motion. It can also be used to apply a force. An actuator typically is a mechanical device that takes energy, usually created by air, electricity, or liquid, and converts that into some kind of motion. That motion can be anything from blocking to clamping to ejecting. Actuators are typically used in manufacturing or industrial applications and may be used in things like motors, pumps, switches, and valves. Fig6.4: Actuator Perhaps the most common type of actuator is powered by air — the pneumatic cylinder, also known as the air cylinder. Air cylinders are air-tight cylinders, typically made from metal, that use the energy of compressed air to move a piston. Air cylinders are most commonly used in manufacturing and assembly processes. Grippers, which are used in robotics, use actuators driven by compressed air to work much like human fingers. 49
    • Actuators can also be powered by electricity or hydraulics. Much like there are air cylinders, there are also electric cylinders and hydraulic cylinders where the cylinder converts electricity or hydraulics into motion. Hydraulic cylinders are often used in certain types of vehicles. 50
    • CHAPTER 7 SOFTWARE DESCRIPTION 7.1 P&E CYCLONE PRO P&E Microcomputer Systems' Cyclone PRO is an extremely flexible tool designed for in-circuit flash programming, debugging, and testing of Freescale HC08, HCS08, HC12, HC(S)12(X), and RS08 microcontrollers. Now featuring support for Freescale's ColdFire V1. By connecting to a simple BDM or MON08 header on the target, the Cyclone PRO can program, test, or debug internal memory on a Freescale processor or external flash connected to the processor's address/data bus. The processor or memory device can be mounted on the final printed circuit board before programming. The Cyclone PRO may be operated interactively via Windows based programming applications as well as under batch or dll commands from a PC. Once loaded with data by a PC it can be disconnected and operated manually in a completely stand-alone mode via the LCD menu and control buttons. The Cyclone PRO has over 3Mbytes of non-volatile memory, which allows the onboard storage of multiple programming images. When connected to a PC for programming it can communicate via the ethernet, USB, or serial interfaces. 51
    • Fig 7.1 cyclone pro CodeWarrior Development Studio for HC08 Microcontrollers Version 2.0 CodeWarrior for 8- and 16-bit Embedded Systems is a powerful and easy-to- use tool suite designed to increase your software development productivity. Our Integrated Development Environment (IDE) provides unrivaled, intuitive GUI development tools for the 8- and 16-bit family of microcontrollers. Now you can speed your time to market by creating, compiling, linking, assembling, and debugging within a single, integrated development environment. Spend less time navigating between tools and more time generating code, thanks to CodeWarrior’s IDE. 52
    • Plus, you can plug in familiar third-party products such as editors, debuggers, and Rapid Application Development (RAD) graphically oriented and model-based development tools such as the I-Logix Rhapsody in MicroC. The comprehensive, highly visual CodeWarrior Development Studio for Motorola HC08 Microcontrollers enables engineers to build and deploy HC08 systems quickly and easily. This tool suite provides the capabilities required by every engineer in the development cycle… from board bring- up… to firmware development… to final application development. With a common, project-based, development environment reuse becomes a natural by-product as each team builds on the work already completed by the previous team. Whether the application is targeted at consumer white goods, industrial control or automotive body controllers, the CodeWarrior environment provides you everything you need to exploit the capabilities of the HC08 architecture. The award-winning CodeWarrior IDE goes well beyond basic code generation and debugging, streamlining applications design from the moment you open the box. It features an intuitive, state-of-the-art project manager and build system; a highly optimized compiler; a graphical, source- level debugger; integrated profiling capabilities, a cycle-accurate, instruction-set simulator. 7.2 Timer Interface A (TIMA) The TIMA is a 4-channel timer that provides: 53
    • • Timing reference with input capture • Output compare • Pulse-width modulator functions In this Project, we implemented the timer interface A with 2 channels as input capture and one for loading the output to produce the respective Duty cycle for fuel PWM output. 1. Output Fuel PWM in Channel 0 of Timer module A. 2. Input Capture used for capturing Engine Speed Sensor input 3. Input Capture used for capturing Vehicle speed Variable reluctance sensor. Fig.7.2.1TimerA usage as input capture and producing the Fuel PWM actuator rattling Engine speed can be sensed by Hall Effect sensor or Variable reluctance sensor.Whenever vehicle speed is zero engine speed will in ideal speed. Engine speed programming in Timer A channel 2. Timer A channel 2 is started to run with a set pre-scalar frequency. 54
    • Fig 7.2.2.Timer A Status and control register. There are Two Process in input Capture of Engine speed in channel 2 :- 1.Intiallising Settings for Channel as per Engine speed requirements 2.Detecting Edge in the interrupt function of channel 2 in Timer A. 3.Overflow interrupt function for timer A. 1.Intiallising Settings for Channel as per Engine speed requirements As per the datasheet of microcontroller, basic initializations are done. 1.Timer A mode value is set to full value. 2.Enable the Timer A interrupt to make sure it detect the edges. 3. Clearing all the previous counter values and resetting the counter. 4. PS[2:0] — Prescaler Select Bits These read/write bits select either the PTE3/TCLKA pin or one of the seven prescaler outputs as the input to the TIMA counter. Reset clears the PS[2:0] bits. We selected the pre scalar value of the counter to be (011)3. 55
    • Internal Clock Bus frequency is 4 MHz. By using the pre scalar value to be 3. We are using the divide by 8 counters. So, the frequency of this Input capture module is set to be 500 KHz. 5.MS2A — Mode Select Bit A When ELS2B:A ≠ 00, this read/write bit selects either input capture operation or unbuffered output compare/PWM operation. We set this bit to be 0 for capturing Input. 0 = Input capture operation 6. ELS2A — Edge and level Select Bits A ELS2B and ELS2A — Edge/Level Select Bits When channel 2 is an input capture channel, these read/write bits control the Active edge-sensing logic on channel 2. 56
    • fig 7.2.3.Edge and Level select bits. Here in engine speed module, the Input is captured for every falling edge.So, the edge and level select bits are set as (10)binary bits. 2. Detecting Edge in the interrupt function. As per the priority of Timer A Channel 2, the interrupt number is designated in the microcontroller as (11) decimal with the Memory address assigned to be FFE8 and FEE9. 7.2.4 priority and vector adddress In the interrupt routine, CH2F — Channel 3 Flag Bit When channel 3 is an input capture channel, this read/write bit is set when an active edge occurs on the channel 3 pin.Reset clears the CH3F bit. Writing a 1 to CH3F has no effect. 1 = Input capture or output compare on channel 2. 57
    • Algorithm and Routine for detecting falling edges and checking overflow:- Algorithm:- Step 1. If the first edge is false then detected edge is load it into temp 1 and change the status of flag to true. Else go to step 2. Step 2. detected edge is loaded into temp2 and change the status of flag to false. Step 3. Interrupt counter is incremented Step 4. Check for overflow if happens go to step 5 else go to step 6. Step 5 .subtract the overflow temp 1 with the full value(65535). Step 6:- subtract temp2 from temp 1. Routine:- if(first_edge == false) { temp1 =TACH2; first_edge =true; } else { temp2 = TACH2; first edge =false; TASC2_CH2IE =0x00; } 58
    • interrupt_counter++; if (interrupt_counter==2) { if(overflow) { temp1 = 65535-temp1; temp1 += temp2; } else temp1 = temp2-temp1; overflow =0; interrupt_counter =0; } } 7.3.Overflow interrupt function for timer A. As per the priority of Timer A , the interrupt number is designated in the microcontroller as (13) decimal with the Memory address assigned to be FFE4 and FEE5. 7.3 overflow interrupt vector address 59
    • TOF — TIMA Overflow Flag This read/write flag is set when the TIMA counter reaches the modulo value programmed in the TIMA counter modulo registers. A TOF interrupt request cannot be lost due to inadvertent clearing of TOF. Reset clears the TOF bit.Writing a logic 1 to TOF has no effect. Routine:- void interrupt 13 timera_overflow(void) { TASC_TOF; TASC_TOF =0x00; if(first_edge) overflow =1; } 7.4 PWMMC(PWM motor Control): CONFIG=81 7.4.1 CONFIG register 1.EDGE — Edge-Align Enable Bit 60
    • EDGE determines if the motor control PWM will operate in edge-aligned mode. or center-aligned mode. 1 = Edge-aligned mode enabled. 2.LVIPWR — LVI Power Enable Bit LVIPWR enables the LVI module. 1 = LVI module resets enabled. PCTL=128 Fig 7.4.2 PWM Control Register PCTL DISX — Software Disable Bit for Bank X Bit This read/write bit allows the user to disable one or more PWM pins in bank X.The pins that are disabled are determined by the disable mapping write- once register. 1 = Disable PWM pins in bank X. PWMEN — PWM Module Enable Bit This read/write bit enables and disables the PWM generator and the PWM pins. When PWMEN is clear, the PWM generator is disabled and the PWM 61
    • pins are in the high-impedance state (unless OUTCTL = 1).When the PWMEN bit is set, the PWM generator and PWM pins are activated. 1 = PWM generator and PWM pins enabled. FCR=85 Fault pins 1, 3 and 4 are in automatic mode FINT2 — Fault 2 Interrupt Enable Bit This read/write bit allows the CPU interrupt caused by faults on fault pin 2 to be enabled. The fault protection circuitry is independent of this bit and will always be active. If a fault is detected, the PWM pins will still be disabled according to the disable mapping register. 1 = Fault pin 2 will cause CPU interrupts PWM program module:- void PWM_Init(void) { CONFIG = 81; PCTL1 = 128; FCR = 85; PMOD = 4094; PWMOUT = 0; DEADTM = 0; 62
    • PVAL1H = (byte)(0 >> 8); /* Store initial value to the duty-compare register */ PVAL1L = (byte)0; PCTL1 = 0; /* Set up PWM control register 1*/ PCTL2 = 130; /* Set up PWM control register 2*/ DISMAP = 0; /* Set up Disable Mapping Write-Once Register*/ FSR =0; PCTL1_LDOK = 1; PVAL2 =2047; } void PWM_SetDutyPercent(byte duty) { PVAL2 =2047; } void PWM_Enable(void) { PCTL1_PWMEN = 1; 63
    • } void PWM_Disable(void) { PCTL1_PWMEN = 0; } STRATEGY:- The hierarchy of the Implementation is briefly described in this module. The entire strategy is coded in the while(1) loop which is inside the main() function. Step 1:-Check for the Engine Speed updated flag = 1.This means the engine interrupt is acknowledged.The interrupt is diabled for further interruption in the pre running counter. Step 2:-Calculate the Gear ratio. Step 3:-If auto cruise is enabled and break is disabled , then the gear ratio is checked for consistency and the auto cruise is enalbled by loading a constant value in the TBMOD. 64
    • Step 4:-If the gear ratio is changed , then the auto cruise is disabled. Step 6:-Fuel Count is calculated by the formula Step 7:- If the count value exceeds the limit then the TBMOD =0. Step 8:- For the first time of the Engine speed interrupt, the timer is started and the fuel count value is loaded in the TBMOD register. while(1) { if(new_engine_speed_updated == 1) { TASC2_CH2IE =0x01; new_engine_speed_updated =0; } calculate_gear_ratio(); ser = (unsigned char)gear_ratio & 0x0F; if(ser > 9) ser +=0x07; 65
    • ser += 0x30; while(SCS1_SCTE==0); SCDR = ser; if((autocruise_flag==1)&&(brake_switch_flag==0)) { if(load_auto_cruise_count ==1) {load_auto_cruise_count =0); prev_gear_ratio = gear_ratio; TBSC_TSTOP =0; TBMOD=4552; } If(prev_gear_ratio != gear_ratio) autocruise_flag =0; continue; } else{ fuel_count = (engine_period/(unsigned int)gear_ratio); 66
    • if(fuel_count < 3125){ TBSC_TSTOP =1; PTB_PTB6 = 1 ; firstTim =1; continue; } if(firstTim) { firstTim = 0; TBSC_TSTOP =0; TBMOD = fuel_count; } } if(firstTim) { firstTim = 0; TBSC_TSTOP =0; TBMOD = fuel_count; } TBMOD = fuel_count; 67
    • } } } EXECUTION SCREEN:- 68
    • CHAPTER 8 CONCLUSION AND FUTURISTIC ADVANCEMENT 8.1CONCLUSION: The Indian automobile industry is the tenth largest in the world with an annual production of approximately 2 million units. Indian auto industry, promises to become the major automotive industry in the upcoming years and the industry experts are hopeful that it will touch 10 million units mark. Indian automobile industry is involved in design, development, manufacture, marketing, and sale of motor vehicles. There are a number of global automotive giants that are upbeat about the expansion plans and collaboration with domestic companies to produce automobiles in India. Thus in our project, we have successfully designed a working model of Auto Cruise and Anti Lock braking system. 69
    • 8.2 FUTURISTIC ADVANCEMENT: Preventive safety systems offer predictive intelligence and are adapted to individual drivers to reach the highest safety benefits. A range of technologies are used and integrated in safety applications: •Sensing technologies for environment perception (infrared sensing, video and camera image perception, LIDAR / RADAR sensors, gyro sensors sensing vehicle motion and acceleration, inertial sensors such as tachometers and speedometers). Processing the sensor data through mathematical algorithms results in a virtual understanding of the vehicle environment - for example, the path and position of vulnerable road users from other vehicles and road infrastructure. •In-vehicle digital maps and positioning technologies (GPS, GNSS and GALILEO) can be perceived as further sensing systems to accurately identify the vehicle position and interpret the environment to help the prediction of a vehicle’s path, especially a vehicle ahead. 70
    • •Wireless communication technologies can send information from the vehicle to other vehicles or infrastructure, as well as enable high-value safety information to be received to further complement the real-time road information. APPENDICES APPENDIX – I MC68HC908MR16CFU Interrupt priority table:- 71
    • 72
    • 73
    • APPENDIX - II Program Coding for MC68HC908MR16CFU:- #include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */ #define true 1 #define false 0 word prev_fuel_pwm=0; unsigned int prev_flp_ac=0; unsigned int tima_counter =0; float temp; signed int diff,dummy3=0; unsigned int dummy1 =0; unsigned char prev_gear_ratio=0; unsigned int engine_period; unsigned long dummy4; int firstTim = 1; unsigned int x=0; unsigned char engine_overflow=0; unsigned int engine_temp1=0 ,engine_temp2=0; 74
    • unsigned int adc_count,fuel_count; unsigned char engine_interrupt_counter=0,i=0; unsigned char engine_speed_first_edge =false; unsigned char brake_switch_flag=0; unsigned char autocruise_flag=0; unsigned char ser; unsigned char dummy =0; unsigned int temp2=0; unsigned char load_auto_cruise_count =1; unsigned int gear_ratio ; float engine_speed_frequency=0; float fuel_pwm=0.00; void interrupt 11 input_capture(void); void interrupt 13 timera_overflow(void); void interrupt 14 auto_cruise_input_capture(void); void interrupt 15 brake_switch_input_capture(void); void interrupt 16 TIMB_OVERFLOW(void); void calculate_gear_ratio(void); void auto_cruise_init(void); 75
    • void brake_switch_init(void); void engine_speed_init(void); void PWM_Init(void); void PWM_Enable(void); void PWM_Disable(void); void PWM_SetDutyPercent(unsigned char duty_cycle); void sci_init(void); void main(void) { EnableInterrupts; /* enable interrupts */ /* include your code here */ CONFIG=81; auto_cruise_init(); vehicle_speed_init(); brake_switch_init(); PWM_Init(); sci_init(); engine_speed_init(); TBSC_TRST =1; TBSC_TSTOP =1; 76
    • TBSC_TOIE =0x01; TBSC_PS = 0x03; ADCLK = 0x14; DDRE_DDRE4 =0X01; DDRE_DDRE0 =0X01; TASC_TSTOP =0X00; DDRC_DDRC5 =0X01; TBSC_TOIE =0x01; DDRB_DDRB6 =0X01; while(1) { if(new_engine_speed_updated == 1) { TASC2_CH2IE =0x01; new_engine_speed_updated =0; } calculate_gear_ratio(); ser = (unsigned char)gear_ratio & 0x0F; if(ser > 9) ser +=0x07; 77
    • ser += 0x30; while(SCS1_SCTE==0); SCDR = ser; if((autocruise_flag==1)&&(brake_switch_flag==0)) { if(load_auto_cruise_count ==1) {load_auto_cruise_count =0; prev_gear_ratio = gear_ratio; TBSC_TSTOP =0; TBMOD=4552; } If( prev_gear_ratio != gear_ratio) autocruise_flag =0; continue; } else{ fuel_count = (engine_period/(unsigned int)gear_ratio); if(fuel_count < 3125){ TBSC_TSTOP =1; PTB_PTB6 = 1 ; 78
    • firstTim =1; continue; } else PTB_PTB6 = 0 ; if(firstTim) { firstTim = 0; TBSC_TSTOP =0; TBMOD = fuel_count; } } if(firstTim) { firstTim = 0; TBSC_TSTOP =0; TBMOD = fuel_count; } TBMOD = fuel_count; } } 79
    • } /* please make sure that you never leave this function */ void interrupt 11 input_capture(void){ TASC2_CH2F; TASC2_CH2F =0x00; PTE_PTE0 = PTE_PTE0 ^ 0XFF;// toggle if(engine_speed_first_edge == false) { engine_overflow=0; TASC_TOIE =0X01; engine_temp1 =TACH2; engine_speed_first_edge =true; return; } else { engine_temp2 = TACH2; engine_speed_first_edge =false; if(engine_overflow) { engine_temp1 = 65535-engine_temp1; engine_temp1 += engine_temp2; 80
    • engine_overflow =0; TASC_TOIE =0X00; } else engine_period = engine_temp2-engine_temp1; TASC2_CH2IE =0x00; //changed time_being new_engine_speed_updated =1; } } void interrupt 13 timera_overflow(void) { TASC_TOF; TASC_TOF =0x00; engine_overflow =1; TASC_TOIE =0X00; } void interrupt 14 auto_cruise_input_capture(void){ TBSC0_CH0F; TBSC0_CH0F =0x00; dummy = TBCH0; 81
    • autocruise_flag =1; load_auto_cruise_count =1; } void interrupt 15 brake_switch_input_capture(void){ TBSC1_CH1F; TBSC1_CH1F =0x00; dummy = TBCH1; if(brake_switch_flag == 0) { PCTL1_PWMEN = 1; brake_switch_flag =1; autocruise_flag =0; } else { PCTL1_PWMEN = 0; brake_switch_flag =0; } } 82
    • void calculate_gear_ratio(void) { ADSCR=0x28; while(ADSCR_COCO == 0); adc_count = ADR ; if(adc_count <= 300) gear_ratio = 1;//(float)1/4; else if (adc_count <= 600) gear_ratio = 2;//(float)2/4; else if (adc_count <= 900) gear_ratio = 3;//(float)3/4; else if (adc_count <= 1023) gear_ratio = 4;//(float)4/4; } void engine_speed_init(void) { TAMOD =0Xffff; TASC_TOIE =0X00; TASC_TSTOP =1; 83
    • TASC_TRST =1; TASC2_ELS2A =0X00; TASC2_ELS2B =0X00; TASC2_MS2A =0X00; for(i=0;i<100;i++); TASC_PS =0X03; TASC2_CH2IE =0x01; TASC2_MS2B =0X00; TASC2_ELS2B =0X01; TASC2_ELS2A =0x00; for(i=0;i<100;i++); } void brake_switch_init(void) { TBMOD =0Xffff; TBSC_TOIE =0X00; 84
    • TBSC_TSTOP =1; TBSC_TRST =1; TBSC1_ELS1A =0X00; TBSC1_ELS1B =0X00; TBSC1_MS1A =0X00; TBSC0_MS0B =0X00; for(i=0;i<100;i++); TBSC_PS =0X02; TBSC1_CH1IE =0x01; TBSC1_MS1A =0X00; TBSC1_ELS1B =0X01; TBSC1_ELS1A =0x01; for(i=0;i<100;i++); } void auto_cruise_init(void) { TBMOD =0Xffff; 85
    • TBSC_TOIE =0X00; TBSC_TSTOP =1; TBSC_TRST =1; TBSC0_ELS0A =0X00; TBSC0_ELS0B =0X00; TBSC0_MS0A =0X00; for(i=0;i<100;i++); TBSC_PS =0X02; TBSC0_CH0IE =0x01; TBSC0_MS0B =0X00; TBSC0_ELS0B =0X01; TBSC0_ELS0A =0x00; for(i=0;i<100;i++); } void PWM_SetDutyPercent(byte duty) { PVAL2 =2047;//2033;//0x7FF;//1220; } 86
    • void PWM_Enable(void) { PCTL1_PWMEN = 1; } void PWM_Disable(void) { PCTL1_PWMEN = 0; } void interrupt 16 TIMB_OVERFLOW(void) { TBSC_TOF; TBSC_TOF =0X00; PTE_PTE4= PTE_PTE4 ^ 0XFF;// toggle TBSC_TSTOP =1; TBSC_TRST =1; TBSC_PS =0X03; TBSC_TSTOP =0; } void sci_init(void) { 87
    • CONFIG =1; DDRB_DDRB2 = 0X01; PTB_PTB2 = 0X00; SCC1_ENSCI =0x01; SCBR_SCP = 0x03; /*0x00;*/ SCBR_SCR =0x01; /*0x04;*/ SCC2_TE = 0x01; } REFERENCES BOOKS •Muhammad Ali Mazidi and Janice Gillispie Mazidi “The 8051 Microcontroller and Embedded Systems” 88
    • Automotive lubricants reference book” By Roger F. Haycock •“Real-Time Computer Control” by Bennett •Real-time systems: scheduling, analysis, and verification by Albert M. K. Cheng •The C programming Language by Brian W. Kernighan and Dennis M. Ritchie. WEBSITES •www.microcontrollershop.com •www.autocruise.co.in •www.sportscarmonitor.com •www.dieselreports.com •www.geekzone.co •www.ehow.com •www.howstuffworks.com 89
    • 90