"Black Box for a Car" report

131
BLACK BOX A PROJECT REPORT SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD OF DEGREE OF Bachelor of Technology In Electronics and Telecommunication By Ritwik Chinmaya Pandia Roll no- 126072 Under the Guidance of Prof. Pravat Kumar Dash 1

Transcript of "Black Box for a Car" report

Page 1: "Black Box for a Car" report

BLACK BOXA PROJECT REPORT SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD OF DEGREE OF

Bachelor of TechnologyIn

Electronics and TelecommunicationBy

Ritwik Chinmaya PandiaRoll no- 126072

Under the Guidance ofProf. Pravat Kumar Dash

Department of Electronics and Telecommunication EngineeringOrissa Engineering College

Bhubaneswar- 752050

1

Page 2: "Black Box for a Car" report

ORISSA ENGINEERING COLLEGE

BHUBANSWAR

CERTIFICATE

This is to certify that the dissertation work entitled “BLACK BOX” is the

work done by Ritwik Chinmaya Pandia submitted in partial fulfillment of

the requirements for the award of ‘BACHELOR OF TECHNOLOGY’ in

Electronics and Telecommunication Engineering during the session 2015-

2016 at Orissa Engineering College, Bhubaneswar , affiliated to Biju

Patnaik University of Technology, Odisha, an authentic work by them under

my supervision and guidance.

Prof. Pravat KumarDash Dept. of Electronics and

Telecommunication Engg.

Prof. Sunil Kumar BisoiH.O.DDept. of Electronics andTelecommunication Engg. EXTERNAL EXAMINER

2

Page 3: "Black Box for a Car" report

Acknowledgement

I would like to express my gratitude to my thesis guide Prof. Pravat Kumar Dash for his guidance, advice and constant support throughout my thesis work. I would like to thank him for being my advisor here at Orissa Engineering College, Bhubaneswar.

I would like to thank all faculty members and staff of the department of Electronics and Telecommunication Engineering, O.E.C. Bhubaneswar for their generous help in various way for the completion of this thesis.

I would like to thank all my friends and especially my classmates for all the thoughtful and mind stimulating discussions I had, which prompted me to think beyond the obvious. I have enjoyed their companionship so much during my stay at OEC, Bhubaneswar.

I especially indebted to my parent for their love, sacrifice and support. They were my first teachers after I come to this world and have set great examples for me about how to live, study and work.

Ritwik Chinmaya Pandia Roll no- 126072

3

Page 4: "Black Box for a Car" report

DECLARATION

I, the undersigned, declare that the project entitled “BLACK BOX” being

submitted in partial fulfillment for the award of Bachelor of Technology Degree in

Electronics and Communication Engineering, affiliated to Biju Patnaik

University of Technology, is the work carried out by me.

Ritwik Chinmaya Pandia Roll no- 126072

4

Page 5: "Black Box for a Car" report

CONTENTS PAGE NO.

1. ABSTRACT 08

2. INTRODUCTION TO EMBEDDED SYSTEMS 12

3. BLOCK DIAGRAM OF PROJECT 12

4. HARDWARE REQUIREMENTS

4.1 TRANSFORMERS 14

4.2 VOLTAGE REGULATOR (LM7805) 16

4.3 RECTIFIER 18

4.4 FILTER 18

4.5 MICROCONTROLLER 20

4.6 GSM MODEM 34

4.7 RELAY 55

4.8 L293D 58

4.9 1N4007 60

4.10 LED 65

4.11 RESISTOR 66

4.12 LCD 68

4.15 CAPACITOR 73

5. SOFTWARE REQUIREMENTS 75

6. HARDWARE TESTING

6.1 CONTINUITY TEST 94

5

Page 6: "Black Box for a Car" report

6.2 POWER ON TEST 95

7. RESULTS 96

8. CONCLUSION 97

9. BIBLIOGRAPHY

6

Page 7: "Black Box for a Car" report

LIST OF FIGURES PAGE NO.

2(a) EMBEDDED DESIGN CALLS 09

2(b) EMBEDDED DESIGN CYCLE 10

3 BLOCK DIAGRAM OF THE PROJECT 12

4.1 A TYPICAL TRANSFORMER 14

4.2(a) BLOCK DIAGRAM OF VOLTAGE REGULATOR 17

4.2(b) RATING OF VOLTAGE REGULATOR 17

4.5(a) BLOCK DIAGRAM OF ATMEGA16 28

4.5(b) PIN DIAGRAM OF ATMEGA16 29

4.5(c) OSCILLATOR CONNECTIONS 33

4.5(d) EXTERNAL CLOCK DRIVE CONFIG. 33

4.6(a) L293D PIN DIAGRAM 59

4.6(b) BLOCK DIAGRAM OF L293D 63

4.6(c) DC MOTOR 64

5. SCHEMATIC DIAGRAM

6. LAYOUT DIAGRAM

7

Page 8: "Black Box for a Car" report

1. ABSTRACT

Objective:

They are used in the vehicles to monitor the Final moment of impact during the accident.

This project is developed to record information such as vehicle speed ,location of the vehicle at the time of accident. Determining speed & location information using GPS technology and to be displayed on the LCD.

We can use this system for emergency accident alert also. When the car crashes the system send the accident alert and the current position of the vehicle to a preprogrammed mobile number via GSM modem.

8

Page 9: "Black Box for a Car" report

2. INTRODUCTION TO EMBEDDED SYSTEMS

What is Embedded system?An Embedded System is a combination of computer hardware and software, and perhaps

additional mechanical or other parts, designed to perform a specific function. An embedded

system is a microcontroller-based, software driven, reliable, real-time control system,

autonomous, or human or network interactive, operating on diverse physical variables and in

diverse environments and sold into a competitive and cost conscious market.

An embedded system is not a computer system that is used primarily for processing, not a

software system on PC or UNIX, not a traditional business or scientific application. High-end

embedded & lower end embedded systems. High-end embedded system - Generally 32, 64 Bit

Controllers used with OS. Examples Personal Digital Assistant and Mobile phones etc .Lower

end embedded systems - Generally 8,16 Bit Controllers used with an minimal operating systems

and hardware layout designed for the specific purpose. Examples Small controllers and devices

in our everyday life like Washing Machine, Microwave Ovens, where they are embedded in.

SYSTEM DESIGN CALLS:

Figure 2(a): design cycles

9

EmbeddedSystems

ComputerArchitecture

SoftwareEngineering

Data Communication

ControlEngineering

Electric motorsand actuators

Sensors andmeasurements

AnalogElectronic design

DigitalElectronic design Integrated circuit

design

Embedded system design calls on many disciplines

Operating Systems

BuildDownload

DebugTools

Page 10: "Black Box for a Car" report

EMBEDDED SYSTEM DESIGN CYCLE

Figure.2(b):“V Diagram”

Characteristics of Embedded System• An embedded system is any computer system hidden inside a product other than a

computer.

• They will encounter a number of difficulties when writing embedded system software in

addition to those we encounter when we write applications

– Throughput – Our system may need to handle a lot of data in a short period of

time.

– Response–Our system may need to react to events quickly

– Testability–Setting up equipment to test embedded software can be difficult

– Debugability–Without a screen or a keyboard, finding out what the software is

doing wrong (other than not working) is a troublesome problem

– Reliability – embedded systems must be able to handle any situation without

human intervention

– Memory space – Memory is limited on embedded systems, and you must make

the software and the data fit into whatever memory exists

10

System

Testing

System

Definition

Targeting

Rapid Prototyp

ing

Hardware-in-

the-Loop Testin

g

Page 11: "Black Box for a Car" report

– Program installation – you will need special tools to get your software into

embedded systems

– Power consumption – Portable systems must run on battery power, and the

software in these systems must conserve power

– Processor hogs – computing that requires large amounts of CPU time can

complicate the response problem

– Cost – Reducing the cost of the hardware is a concern in many embedded system

projects; software often operates on hardware that is barely adequate for the job.

• Embedded systems have a microprocessor/ microcontroller and a memory. Some have a

serial port or a network connection. They usually do not have keyboards, screens or disk

drives.

APPLICATIONS1) Military and aerospace embedded software applications

2) Communicat ion Appl icat ions

3) Indust r ia l automat ion and process control sof tware

4) Mastering the complexity of applications.

5) Reduction of product design time.

6) Real time processing of ever increasing amounts of data.

7) Intelligent, autonomous sensors.

CLASSIFICATION Real Time Systems.

RTS is one which has to respond to events within a specified deadline.

A right answer after the dead line is a wrong answer.

RTS CLASSIFICATION Hard Real Time Systems

Soft Real Time System

11

Page 12: "Black Box for a Car" report

HARD REAL TIME SYSTEM "Hard" real-time systems have very narrow response time.

Example: Nuclear power system, Cardiac pacemaker.

SOFT REAL TIME SYSTEM "Soft" real-time systems have reduced constrains on "lateness" but still must operate very

quickly and repeatable.

Example: Railway reservation system – takes a few extra seconds the data remains valid.

3. PROJECT BLOCK DIAGRAM

FIG 3: BLOCK DIAGRAM

4. HARDWARE REQUIREMENTS12

Page 13: "Black Box for a Car" report

HARDWARE COMPONENTS:

1. TRANSFORMER (230 – 12 V AC)

2. VOLTAGE REGULATOR (LM 7805)

3. RECTIFIER

4. FILTER

5. MICROCONTROLLER

6. GSM MODULE

7. PUSH BUTTON

8. PIEZO SENSOR

9. 1N4007

10. LED

11. LCD

12. RESISTOR

13. CAPACITOR

14. GPS

15. MOTOR DRIVER

16. DC MOTOR

17. LCD

18. RELAY

13

Page 14: "Black Box for a Car" report

4.1 TRANSFORMER

Transformers convert AC electricity from one voltage to another with a little loss of power.

Step-up transformers increase voltage, step-down transformers reduce voltage. Most power

supplies use a step-down transformer to reduce the dangerously high voltage to a safer low

voltage.

FIG 4.1: A TYPICAL TRANSFORMER

The input coil is called the primary and the output coil is called the secondary. There is

no electrical connection between the two coils; instead they are linked by an alternating magnetic

field created in the soft-iron core of the transformer. The two lines in the middle of the circuit

symbol represent the core. Transformers waste very little power so the power out is (almost)

equal to the power in. Note that as voltage is stepped down and current is stepped up.

The ratio of the number of turns on each coil, called the turn’s ratio, determines the ratio

of the voltages. A step-down transformer has a large number of turns on its primary (input) coil

which is connected to the high voltage mains supply, and a small number of turns on its

secondary (output) coil to give a low output voltage.

TURNS RATIO = (Vp / Vs) = ( Np / Ns )

Where,

Vp = primary (input) voltage.

Vs = secondary (output) voltage

Np = number of turns on primary coil

Ns = number of turns on secondary coil

Ip = primary (input) current

Is = secondary (output) current.

14

Page 15: "Black Box for a Car" report

Ideal power equation

The ideal transformer as a circuit element.

If the secondary coil is attached to a load that allows current to flow, electrical power is

transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is perfectly

efficient; all the incoming energy is transformed from the primary circuit to the magnetic field

and into the secondary circuit. If this condition is met, the incoming electric power must equal

the outgoing power:

Giving the ideal transformer equation

Transformers normally have high efficiency, so this formula is a reasonable approximation.

If the voltage is increased, then the current is decreased by the same factor. The

impedance in one circuit is transformed by the square of the turns ratio.

15

Page 16: "Black Box for a Car" report

For example, if an impedance Zs is attached across the terminals of the secondary coil, it

appears to the primary circuit to have an impedance of (Np/Ns)2Zs. This relationship is reciprocal,

so that the impedance Zp of the primary circuit appears to the secondary to be (Ns/Np)2Zp.

4.2 VOLTAGE REGULATOR 7805Features

• Output Current up to 1A.

• Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V.

• Thermal Overload Protection.

• Short Circuit Protection.

• Output Transistor Safe Operating Area Protection.

Description

The LM78XX/LM78XXA series of three-terminal positive regulators are available in the

TO-220/D-PAK package and with several fixed output voltages, making them useful in a Wide

range of applications. Each type employs internal current limiting, thermal shutdown and safe

operating area protection, making it essentially indestructible. If adequate heat sinking is

provided, they can deliver over 1A output Current. Although designed primarily as fixed voltage

regulators, these devices can be used with external components to obtain adjustable voltages and

currents.16

Page 17: "Black Box for a Car" report

Internal Block Diagram

FIG

4.2(a): BLOCK DIAGRAM OF VOLTAGE REGULATOR

Absolute Maximum Ratings

TABLE 4.2(b): RATINGS OF THE VOLTAGE REGULATOR

17

Page 18: "Black Box for a Car" report

4.3 RECTIFIER

A rectifier is an electrical device that converts alternating current (AC), which

periodically reverses direction, to direct current (DC), current that flows in only one direction, a

process known as rectification. Rectifiers have many uses including as components of power

supplies and as detectors of radio signals. Rectifiers may be made of solid state diodes, vacuum

tube diodes, mercury arc valves, and other components. The output from the transformer is fed to

the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave

rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full

wave rectification. In positive half cycle only two diodes( 1 set of parallel diodes) will conduct,

in negative half cycle remaining two diodes will conduct and they will conduct only in forward

bias only.

18

Page 19: "Black Box for a Car" report

4.4 FILTER

Capacitive filter is used in this project. It removes the ripples from the output of rectifier

and smoothens the D.C. Output received from this filter is constant until the mains voltage and

load is maintained constant. However, if either of the two is varied, D.C. voltage received at this

point changes. Therefore a regulator is applied at the output stage.

The simple capacitor filter is the most basic type of power supply filter. The use of this

filter is very limited. It is sometimes used on extremely high-voltage, low-current power supplies

for cathode-ray and similar electron tubes that require very little load current from the supply.

This filter is also used in circuits where the power-supply ripple frequency is not critical and can

be relatively high. Below figure can show how the capacitor changes and discharges.

19

Page 20: "Black Box for a Car" report

4.5 MICROCONTROLLER ATMEGA16

Features

• High-performance, Low-power AVR® 8-bit Microcontroller

• Advanced RISC Architecture

– 131 Powerful Instructions – Most Single-clock Cycle Execution

– 32 x 8 General Purpose Working Registers

– Fully Static Operation

– Up to 16 MIPS Throughput at 16 MHz

– On-chip 2-cycle Multiplier

20

Page 21: "Black Box for a Car" report

• Nonvolatile Program and Data Memories

– 16K Bytes of In-System Self-Programmable Flash

Endurance: 10,000 Write/Erase Cycles

– Optional Boot Code Section with Independent Lock Bits

In-System Programming by On-chip Boot Program

True Read-While-Write Operation

– 512 Bytes EEPROM

Endurance: 100,000 Write/Erase Cycles

– 1K Byte Internal SRAM

– Programming Lock for Software Security

• JTAG (IEEE std. 1149.1 Compliant) Interface

– Boundary-scan Capabilities According to the JTAG Standard

– Extensive On-chip Debug Support

– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface

• Peripheral Features

– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes

– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture

Mode

– Real Time Counter with Separate Oscillator

– Four PWM Channels

– 8-channel, 10-bit ADC

8 Single-ended Channels

7 Differential Channels in TQFP Package Only

2 Differential Channels with Programmable Gain at 1x, 10x, or 200x

– Byte-oriented Two-wire Serial Interface

– Programmable Serial USART

– Master/Slave SPI Serial Interface

– Programmable Watchdog Timer with Separate On-chip Oscillator

– On-chip Analog Comparator

• Special Microcontroller Features

21

Page 22: "Black Box for a Car" report

– Power-on Reset and Programmable Brown-out Detection

– Internal Calibrated RC Oscillator

– External and Internal Interrupt Sources

– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby and

Extended Standby

• I/O and Packages

– 32 Programmable I/O Lines

– 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF

• Operating Voltages

– 2.7 - 5.5V for ATmega16L

– 4.5 - 5.5V for ATmega16

• Speed Grades

– 0 - 8 MHz for ATmega16L

– 0 - 16 MHz for ATmega16

• Power Consumption @ 1 MHz, 3V, and 25°C for ATmega16L

– Active: 1.1 mA

– Idle Mode: 0.35 mA

– Power-down Mode: < 1 μA

ATmega16Introduction

A microcontroller often serves as the “brain” of a mechatronic system. Like a mini, self

contained computer, it can be programmed to interact with both the hardware of the system and

the user. Even the most basic microcontroller can perform simple math operations, control digital

outputs, and monitor digital inputs. As the computer industry has evolved, so has the technology

associated with microcontrollers. Newer microcontrollers are much faster, have more memory,

and have a host of input and output features that dwarf the ability of earlier models. Most modern

22

Page 23: "Black Box for a Car" report

controllers have analog-to-digital converters, high-speed timers and counters, interrupt

capabilities, outputs that can be pulse-width modulated, serial communication ports, etc.

The high-performance, low-power Atmel 8-bit AVR RISC-based microcontroller combines

16KB of programmable flash memory, 1KB SRAM, 512B EEPROM, an 8-channel 10-bit A/D

converter, and a JTAG interface for on-chip debugging. The device supports throughput of 16

MIPS at 16 MHz and operates between 4.5-5.5 volts.

By executing instructions in a single clock cycle, the device achieves throughputs

approaching 1 MIPS per MHz, balancing power consumption and processing speed.

Key Parameters

Parameter Value

Flash (Kbytes): 16 Kbytes

Pin Count: 44

Max. Operating Frequency: 16 MHz

CPU: 8-bit AVR

No of Touch Channels: 16

Hardware QTouch Acquisition: No

Max I/O Pins: 32

Ext Interrupts: 3

USB Speed: No

23

Page 24: "Black Box for a Car" report

USB Interface: No

Ordering Codes

24

Page 25: "Black Box for a Car" report

Pin Diagram:

25

Page 26: "Black Box for a Car" report

Pin Description:

26

Page 27: "Black Box for a Car" report

27

Page 28: "Black Box for a Car" report

28

Page 29: "Black Box for a Car" report

BLOCK DIAGRAM

29

Page 30: "Black Box for a Car" report

Pin Configurations of ATMEGA 16

FIG 4.5(b): PIN DIAGRAM OF ATMEGA16

30

Page 31: "Black Box for a Car" report

I/O PortsAll AVR ports have true Read-Modify-Write functionality when used as general digital

I/O ports. This means that the direction of one port pin can be changed without unintentionally

changing the direction of any other pin with the SBI and CBI instructions. The same applies

when changing drive value (if configured as output) or enabling/disabling of pull-up resistors (if

configured as input). Each output buffer has symmetrical drive characteristics with both high

sink and source capability. The pin driver is strong enough to drive LED displays directly. All

port pins have individually selectable pull-up resistors with a supply-voltage invariant resistance.

All I/O pins have protection diodes to both VCC and Ground as indicated in.

Analog To Digital Converter

The ATmega16 features a 10-bit successive approximation ADC. The ADC is connected to an 8-

channel Analog Multiplexer which allows 8 single-ended voltage inputs constructed from the

pins of Port A. The single-ended voltage inputs refer to 0V (GND). The device also supports 16

differential voltage input combinations.

31

Page 32: "Black Box for a Car" report

Two of the differential inputs (ADC1, ADC0 and ADC3, ADC2) are equipped with a

programmable gain stage, providing amplification steps of 0 dB (1x), 20 dB (10x), or 46 dB

(200x) on the differential input voltage before the A/D conversion. Seven differential analog

input channels share a common negative terminal (ADC1), while any other ADC input can be

selected as the positive input terminal. If 1x or 10x gain is used, 8-bit resolution can be expected.

If 200x gain is used, 7-bit resolution can be expected. The ADC contains a Sample and Hold

circuit which ensures that the input voltage to the

ADC is held at a constant level during conversion. A block diagram of the ADC is shown

in Figure 98. The ADC has a separate analog supply voltage pin, AVCC. AVCC must not differ

more than ±0.3 V from VCC. See the paragraph “ADC Noise Canceler” on page 213 on how to

connect this pin. Internal reference voltages of nominally 2.56V or AVCC are provided On-chip.

The voltage reference may be externally decoupled at the AREF pin by a capacitor for better

noise performance.

The ADC converts an analog input voltage to a 10-bit digital value through successive

approximation. The minimum value represents GND and the maximum value represents the

voltage on the AREF pin minus 1 LSB. Optionally, AVCC or an internal 2.56V reference

voltage may be connected to the AREF pin by writing to the REFSn bits in the ADMUX

Register. The internal voltage reference may thus be decoupled by an external capacitor at the

AREF pin to improve noise immunity. The analog input channel and differential gain are

selected by writing to the MUX bits in ADMUX. Any of the ADC input pins, as well as GND

and a fixed bandgap voltage reference, can be selected as single ended inputs to the ADC. A

selection of ADC input pins can be selected as positive and negative inputs to the differential

gain amplifier. If differential channels are selected, the differential gain stage amplifies the

voltage difference between the selected input channel pair by the selected gain factor. This

amplified value then becomes the analog input to the ADC. If single ended channels are used, the

gain amplifier is bypassed altogether.

The ADC is enabled by setting the ADC Enable bit, ADEN in ADCSRA. Voltage

reference and input channel selections will not go into effect until ADEN is set. The ADC does

not consume power when ADEN is cleared, so it is recommended to switch off the ADC before

entering power saving sleep modes.

32

Page 33: "Black Box for a Car" report

The ADC generates a 10-bit result which is presented in the ADC Data Registers, ADCH

and ADCL. By default, the result is presented right adjusted, but can optionally be presented left

adjusted by setting the ADLAR bit in ADMUX. If the result is left adjusted and no more than 8-

bit precision is required, it is sufficient to read ADCH. Otherwise, ADCL must be read first, then

ADCH, to ensure that the content of the Data Registers belongs to the same conversion. Once

ADCL is read, ADC access to Data Registers is blocked. This means that if ADCL has been

read, and a conversion completes before ADCH is read, neither register is updated and the result

from the conversion is lost. When ADCH is read, ADC access to the ADCH and ADCL

Registers is re-enabled. The ADC has its own interrupt which can be triggered when a

conversion completes. When ADC access to the Data Registers is prohibited between reading of

ADCH and ADCL, the interrupt will trigger even if the result is lost.

XTAL1:

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2:

Output from the inverting oscillator amplifier.

Oscillator Characteristics:

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier

which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz

crystal or ceramic resonator may be used. To drive the device from an external clock source,

XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 6.2. There are no

requirements on the duty cycle of the external clock signal, since the input to the internal

clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high

and low time specifications must be observed.

33

Page 34: "Black Box for a Car" report

FIG 4.5(b): Oscillator Connections

FIG 4.5(d): External Clock Drive Configuration

Idle Mode

In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The

mode is invoked by software. The content of the on-chip RAM and all the special functions

registers remain unchanged during this mode. The idle mode can be terminated by any enabled

interrupt or by a hardware reset.

34

Page 35: "Black Box for a Car" report

Power down Mode

In the power down mode the oscillator is stopped, and the instruction that invokes power

down is the last instruction executed. The on-chip RAM and Special Function Registers retain

their values until the power down mode is terminated. The only exit from power down is a

hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset

should not be activated before VCC is restored to its normal operating level and must be held

active long enough to allow the oscillator to restart and stabilize.

GSM MODEMGSM/GPRS module is used to establish communication between a computer and a

GSM-GPRS system. Global System for Mobile communication (GSM) is an architecture

used for mobile communication in most of the countries. Global Packet Radio Service (GPRS)

is an extension of GSM that enables higher data transmission rate. GSM/GPRS module consists

of a GSM/GPRS modem assembled together with power supply circuit and communication

interfaces (like RS-232, USB, etc) for computer. The MODEM is the soul of such modules.

35

Page 36: "Black Box for a Car" report

Wireless MODEMs

Wireless MODEMs are the MODEM devices that generate, transmit or decode data from

a cellular network, for establishing communication between the cellular network and the

computer. These are manufactured for specific cellular network (GSM/UMTS/CDMA) or

specific cellular data standard (GSM/UMTS/GPRS/EDGE/HSDPA) or technology (GPS/SIM).

Wireless MODEMs like other MODEM devices use serial communication to interface with and

need Hayes compatible AT commands for communication with the computer (any

microprocessor or microcontroller system).

GSM/GPRS MODEM

GSM/GPRS MODEM is a class of wireless MODEM devices that are designed for

communication of a computer with the GSM and GPRS network. It requires a SIM (Subscriber

Identity Module) card just like mobile phones to activate communication with the network. Also

they have IMEI (International Mobile Equipment Identity) number similar to mobile phones for

their identification. A GSM/GPRS MODEM can perform the following operations:

1. Receive, send or delete SMS messages in a SIM.

2. Read, add, search phonebook entries of the SIM.

3. Make, Receive, or reject a voice call.

36

Page 37: "Black Box for a Car" report

The MODEM needs AT commands, for interacting with processor or controller, which

are communicated through serial communication. These commands are sent by the

controller/processor. The MODEM sends back a result after it receives a command. Different AT

commands supported by the MODEM can be sent by the processor/controller/computer to

interact with the GSM and GPRS cellular network.

GSM/GPRS Module

A GSM/GPRS module assembles a GSM/GPRS modem with standard communication

interfaces like RS-232 (Serial Port), USB etc., so that it can be easily interfaced with a computer

or a microprocessor / microcontroller based system. The power supply circuit is also built in the

module that can be activated by using a suitable adaptor.

AT Commands

AT commands are used to control MODEMs. AT is the abbreviation for Attention. These

commands come from Hayes commands that were used by the Hayes smart modems. The Hayes

commands started with AT to indicate the attention from the MODEM. The dial up and wireless

MODEMs (devices that involve machine to machine communication) need AT commands to

interact with a computer. These include the Hayes command set as a subset, along with other

extended AT commands.

AT commands with a GSM/GPRS MODEM or mobile phone can be used to access following

information and services:

1. Information and configuration pertaining to mobile device or MODEM and SIM card.

2. SMS services.

3. MMS services.

4. Fax services.

5. Data and Voice link over mobile network.

The Hayes subset commands are called the basic commands and the commands specific to a

GSM network are called extended AT commands.

37

Page 38: "Black Box for a Car" report

Command, Information response and Result Codes:

The AT commands are sent by the computer to the MODEM/ mobile phone. The MODEM sends

back an Information Response i.e. the information requested by or pertaining to the action

initiated by the AT command. This is followed by a Result Code. The result code tells about the

successful execution of that command.

There are also unsolicited Result Codes that are returned automatically by the MODEM to notify

the occurrence of an event. For example the reception of a SMS will force MODEM to return an

unsolicited result code.

38

Page 39: "Black Box for a Car" report

AT commands' syntax

Case Sensitivity -

The AT commands are generally used in uppercase letters. However some MODEMs and

mobile phones allow both uppercase and small case letters.

Single Command -

The AT commands include a prefix AT which indicates the beginning of the command to

MODEM; and a carriage return which indicates the end of the command.

Using a Single AT Command

However string ‘AT’ itself is not the part of the command. For example in ATD, D is the

command name not ATD.

The extended AT commands have a ‘+’ in the command name.

For example: AT+CGMI<Carriage return>

Command Line -

Multiple AT commands can be sent to MODEM in a single command line. The commands in a

line are separated by a semi-colon (;).

39

Page 40: "Black Box for a Car" report

For example: AT+CGMI; +CBS<Carriage return>

String in Command Line -

Strings in a command line are enclosed in double quotes.

For example: AT+CGML=”ALL”<Carriage return>

Information Response and Result Code –

The Information Response and Result Codes, returned by the MODEM, have a carriage

return and line feed in the beginning as well as at the end.

Information Response and Result Code

For example:

<Carriage return><Line feed>OK<Carriage return><Line feed>

<Carriage return><Line feed>ERROR<Carriage return><Line feed>

<Carriage return><Line feed>+CBC: 0, 60<Carriage return><Line feed> etc.

40

Page 41: "Black Box for a Car" report

Sequence of Execution –

In the command line, the command appearing first is executed first. The execution then follows for second appeared command and so on. The execution of commands in a command line takes place in sequential manner.

If an error occurs in the execution of a command, an error result code is returned by the MODEM and the execution of the command line is terminated irrespective of presence of other commands next in the command line.

Types of commands:

There are four types of AT commands:

1) Test commands

2) Read commands

3) Set commands

4) Execution commands

Different Result CodesRESULT CODE DESCRIPTION

OK Successful Execution of a command

ERROR Execution of a command failed

+CMS ERROR Message service failure, is returned with an error code

Unsolicited Result Codes

+CDS Notify receipt of SMS status report of a new message to computer

+CDSI Notify receipt of SMS status report of a new message and its location

in memory to computer

+CMT Notify forwarding of a new SMS to computer

+CMTI Notify receipt of SMS status report of a new message and its location

in memory to computer

41

Page 42: "Black Box for a Car" report

Overview

To connect most GSM modules to microcontrollers a serial connection is utilized, the problem with this

can be if you are using a microcontroller that running at a higher voltage than the GSM module the

serial logic levels will be off.

Every module has specifications for its serial port and they have to be followed in order

to have a working communications system (the below specifications are from a GE863 Telit

model):

42

Page 43: "Black Box for a Car" report

Each input and output is described with a Min and Max level, what this means is between

the two specifications is where the input state will trigger or the output voltage will range

between. So as you can see the GSM will read a logic low between 0-.5V and will output a logic

high between 2.2-3V. So our microcontroller needs to have these same voltage levels to talk with

the GSM.

Logic levels are very important and can determine the quality of serial communication

you have to take into account the HIGH logic level as well as the low logic level to get a good

connection. The GSM modules usually have a Logic Level of 2.8v CMOS compatible, because

they are designed to run off a single cell Lithium battery. So if you are running your

microcontroller at another voltage than ~3V you will need to change the logic levels. Below are a

few ways you can hook up your boards to a GSM.

How to connectInterfacing MODEM/Mobile phone with Windows platform

The Windows (XP and lower versions) comes with an application called HyperTerminal

for data communication through serial port of the computer. The interfacing of the GSM/GPRS

module with the serial port of the computer involves following steps:

1) Connect RS-232 port of GSM module with the serial port of the computer. Insert a SIM card in

the module.

2) Open HyperTerminal from Start -> All Programs -> Accessories -> Communications ->

HyperTerminal.

3) Enter a name for the connection and press OK.

4) Now select the communication port (COM) at which GSM module is connected.

5) Create a new connection set on HyperTerminal. Set parameters, like baud rate as 9600,

handshaking mode as none, parity bit as none, stop bit as 1 and data bit as 8.

The below examples show you how to connect microcontrollers running at different

voltages to a GSM module (or any serial device)

43

Page 44: "Black Box for a Car" report

~3V devices

If the microcontroller you are using is running at 2.8-~3.3V, you can probably get away without

using a level conversion circuit, just check to see that the range of your microcontroller matches

with the GSMs,

ATMEGA644P LEVELS

44

Page 45: "Black Box for a Car" report

GE863 LEVELS

As you can see if you run the ATMEGA644P at 3.0V:

On the Microcontroller:

*The input Low level (VIL) is rated -> -.5 to .3(Vcc)

and the

*The input High level (VIH) is rated -> .6(VCC) to (.5 + VCC)

so if VCC = 3V

*we get -.5 - .9V for the range of the Low voltage Input.

and

*we get 1.8V - 3.5V for the Input High range.

On the Telit:

*The Output Low level (VOL) is 0 - 3.5V

and *The Output High level (VOH) is 2.2 - 3.0V

We then compare the Microcontrollers input to the Telits output levels,

Microcontroller TELIT -.5 - .9 (VIL) -> (VOH) is 0 - 3.5V 1.8V - 3.5V (VIH) -> (VOL) is 2.2 - 3.0V Then do the same thing for the output of the microcontroller to the input of the Telit. And find that they will trigger just fine.

So to hook the device up in this case you would just connect the RX and TX together and make sure they share a common ground.

45

Page 46: "Black Box for a Car" report

>3.3V or <2.8V devices

These devices need a Logic conversion circuit in order to operate. The voltages on the

microcontroller need to be shifted up or down accordingly to match the telits range and visa

versa. This can be done in a couple ways:

Logic Level conversion

There are many ways you can do logic conversion most involve using a comparator of some sort

but you can also use transistor arrays or a zener diode to accomplish the feat.

As you can see there is a Arduino mega(blue running @ 5V) and a GSM(red running @

3.6V) the third board is the logic conversion board(yellow). The circuit is made up of a LM311N

comparator chip and a zener diode with a couple resistors thrown in the mix.

46

Page 47: "Black Box for a Car" report

Comparator

The comparator works by comparing two voltages on two inputs and biasing the output high or low according to which input is higher. So the way it is used in this circuit is to rise up the voltage of the GSM output (Telit RXD normal TX) to the input level of the Arduino mega. The way we accomplish this is to use a voltage divider on one of the inputs which floats the voltage near the max voltage the LOW logic level will output from the GSM. This level is compared to the output of the GSM serial line (Telit RXD normal TX), if the voltage on that line is LOWER than the voltage on the voltage divider the output will be pulled Low (to GND) and the microcontroller will read a LOW logic level. If the voltage out (Telit RXD normal TX) is larger than the dividers level the output is released and the 10K pull up resistor brings the output high, registering a HIGH on the microcontroller.

47

Page 48: "Black Box for a Car" report

To figure out what voltage level the voltage divider needs to be at and what resistors to use, we

employ the ever-ready ohms law (Voltage = current*resistance or V=I*R):

48

Page 49: "Black Box for a Car" report

So once again we check the Telits documentation to find the LOW LEVEL threshold:

and see it is .35V this is a good place to set your threshold, but since I only had a certain set of

resistors with me that day I set it at about half that and it works just fine. This is to show that as

long as you know what you are shooting for in a pinch there is some wiggle room (and that

everyone runs out of parts).

So to figure out how to get a .35 voltage out of the divider and into pin 3 on the comparator we

need to figure out the voltage drop:

So we take 5v and need a drop of 4.65 volts to hit the .35V mark.

To find this we use ohms law and take the total resistance value 480K ohms and divide the

original voltage by 480k ohms to get the current (I)

5/480K = .0000104166 amps (I)

Then we can find the voltage drop by saying (I)*(top resistance = 470k)

(.0000104166 amps)(470k) = 4.8958020000 V

and so 5V - 4.8958020000V = .1041980000 V

which is < half of the specked .35 but in a pinch it works ok, The one thing you don't want to do

is just tie the line to ground, in my experience outputs never reliably hit a clean GND and your

communications will probably not work.

49

Page 50: "Black Box for a Car" report

zener

The zener diode is the other half of this circuit and cuts down the 5V output from the

microcontroller to the 2.8 volt level the GSM needs. You can see the circuit is trivial all you need

is a resistor and a zener diode to make it work. The drawbacks of the circuit are at higher baud

rates it cad start having inductance problems that mimick RC circuits which will throw off your

communications.

You can see the circuit in the bottom part of the drawing, what a zener diode does is allow

current to flow to ground once a certain threshold is reached and therefore “clamping” the

voltage at that set level. You need to put a resistor in series with the zener from preventing a

large in-rush of current from destroying the zener.

PRE-BUILT boards/systems

There are also boards that have the microcontroller and the GSM built into one package for you

so you just have to turn it on or solder up a couple connections.

50

Page 51: "Black Box for a Car" report

The circuit we used on this board utilizes the TC7W125 duel bus buffer with a pull up resistor as

shown here:

51

Page 52: "Black Box for a Car" report

The second board is a small board with a built in logic level circuit on board. With this device

you can just make four connections to a microcontroller running 1.8-12v and you are ready to go.

Connections:

The connections you need to make are,

microcontroller GSM(Telit board)

RX -> RXD

TX -> TXD

VCC -> microVcc

GND -> GND

52

Page 53: "Black Box for a Car" report

GSM (Global System for Mobile communication) is a digital mobile telephone system that is

widely used in Europe and other parts of the world. GSM uses a variation of Time Division

Multiple Access (TDMA) and is the most widely used of the three digital wireless telephone

technologies (TDMA, GSM, and CDMA). GSM digitizes and compresses data, then sends it

down a channel with two other streams of user data, each in its own time slot. It operates at

either the 900 MHz or 1,800 MHz frequency band.

GSM characteristics

Multiple Access Method TDMA/FDM

Duplex Method FDD

Number of Channels 124 (8 users per channel)

Channel Spacing 200kHz

Modulation GMSK (0.3 Gaussian Filter)

Channel Bit Rate 270.833Kb

53

Page 54: "Black Box for a Car" report

54

Page 55: "Black Box for a Car" report

GPS SYSTEM

• GPS modem is a device which receives signals from satellite and provides information

about latitude, longitude, altitude, time etc.

• The GPS modem has an antenna which receives the satellite signals and transfers them to

the modem. The modem in turn converts the data into useful information and sends the

output in serial RS232 logic level format longitude, altitude, time etc.

• The information about latitude, longitude etc is sent continuously and accompanied by an

identifier string.

PIEZO SENSOR

• Piezoelectric sensors have proven to be versatile tools for the measurement of various

processes.

• The sensors are either directly mounted into additional holes into the cylinder head or the

spark/glow plug is equipped with a built in miniature piezoelectric sensor.

• Unlike strain gages that can measure static forces, piezoelectric force sensors are mostly

used for dynamic- force measurements such as oscillation, impact, or highspeed

compression or tension.

55

Page 56: "Black Box for a Car" report

• When a force is applied to the impact cap, the quartz elements generate an output voltage

which can be routed directly to a charge amplifier or converted to a low-impedance signal

within the sensor.

The use of the direct sensor output demands that any connector, cable, and charge

amplifier input must maintain a high insulation resistance on the order of >10≠″ Ω.

4.7 RELAYA relay is an electrically operated switch. Many relays use an electromagnet to operate a

switching mechanism mechanically, but other operating principles are also used. Relays are used

where it is necessary to control a circuit by a low-power signal (with complete electrical isolation

between control and controlled circuits), or where several circuits must be controlled by one

signal.

56

Page 57: "Black Box for a Car" report

A relay is an electrically operated switch. Current flowing through the coil of the relay

creates a magnetic field which attracts a lever and changes the switch contacts. The coil current

can be on or off so relays have two switch positions and most have double throw (changeover)

switch contacts as shown in the diagram.

Fig 4.8 Relay showing coil and switch contacts

Relays allow one circuit to switch a second circuit which can be completely separate

from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC

mains circuit. There is no electrical connection inside the relay between the two circuits; the link

is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it

can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips)

cannot provide this current and a transistor is usually used to amplify the small IC current to the

larger value required for the relay coil. The maximum output current for the popular 555 timer

IC is 200mA so these devices can supply relay coils directly without amplification.

Relays are usually SPDT or DPDT but they can have many more sets of switch contacts,

for example relays with 4 sets of changeover contacts are readily available. For further

information about switch contacts and the terms used to describe them please see the page on

switches.

57

Page 58: "Black Box for a Car" report

Most relays are designed for PCB mounting but you can solder wires directly to the pins

providing you take care to avoid melting the plastic case of the relay.

The supplier's catalogue should show you the relay's connections. The coil will be

obvious and it may be connected either way round. Relay coils produce brief high voltage

'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To

prevent damage you must connect a protection diode across the relay coil.

The figure shows a relay with its coil and switch contacts. You can see a lever on the left

being attracted by magnetism when the coil is switched on. This lever moves the switch contacts.

There is one set of contacts (SPDT) in the foreground and another behind them, making

the relay DPDT.

The relay's switch connections are usually labelled COM, NC and NO:

COM = Common, always connect to this; it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

58

Page 59: "Black Box for a Car" report

Applications of relays

Relays are used to and for:

Control a high-voltage circuit with a low-voltage signal, as in some types of modems or

audio amplifiers.

Control a high-current circuit with a low-current signal, as in the starter solenoid of an

automobile.

Detect and isolate faults on transmission and distribution lines by opening and closing

circuit breakers.

Time delay functions. Relays can be modified to delay opening or delay closing a set of

contacts. A very short (a fraction of a second) delay would use a copper disk between the

armature and moving blade assembly. Current flowing in the disk maintains magnetic

field for a short time, lengthening release time. For a slightly longer (up to a minute)

delay, a dashpot is used. A dashpot is a piston filled with fluid that is allowed to escape

slowly. The time period can be varied by increasing or decreasing the flow rate. For longer

time periods, a mechanical clockwork timer is installed.

4.8 MOTOR DRIVER (L293D)

Features:

Wide supply-voltage range: 4.5V to 36V

Separate input- logic supply

Internal ESD protection

Thermal shutdown

High-Noise-Immunity input

Functional Replacements for SGS L293 and SGS L293D

Output current 1A per channel (600 mA for L293D)

Peak output current 2 A per channel (1.2 A for L293D)

Output clamp diodes for Inductive Transient Suppression(L293D)

59

Page 60: "Black Box for a Car" report

DESCRIPTION:

L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as

current amplifiers since they take a low-current control signal and provide a higher-current

signal. This higher current signal is used to drive the motors.

L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation,

two DC motors can be driven simultaneously, both in forward and reverse direction. The motor

operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic

00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and

anticlockwise directions, respectively.

Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start

operating. When an enable input is high, the associated driver gets enabled. As a result, the

outputs become active and work in phase with their inputs. Similarly, when the enable input is

low, that driver is disabled, and their outputs are off and in the high-impedance state.

 

BLOCK DIAGRAM OF L293D

60

Page 61: "Black Box for a Car" report

4.9 1N4007

Diodes are used to convert AC into DC these are used as half wave rectifier or full wave

rectifier. Three points must he kept in mind while using any type of diode.

1. Maximum forward current capacity

2. Maximum reverse voltage capacity

3. Maximum forward voltage capacity

Fig: 1N4007 diodesThe number and voltage capacity of some of the important diodes available in the market

are as follows:

Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and IN4007 have

maximum reverse bias voltage capacity of 50V and maximum forward current capacity of 1

Amp.

Diode of same capacities can be used in place of one another. Besides this diode of more

capacity can be used in place of diode of low capacity but diode of low capacity cannot be used

in place of diode of high capacity. For example, in place of IN4002; IN4001 or IN4007 can be

used but IN4001 or IN4002 cannot be used in place of IN4007.The diode BY125made by

company BEL is equivalent of diode from IN4001 to IN4003. BY 126 is equivalent to diodes

IN4004 to 4006 and BY 127 is equivalent to diode IN4007.

61

Page 62: "Black Box for a Car" report

Fig:PN Junction diode

PN JUNCTION OPERATION

Now that you are familiar with P- and N-type materials, how these materials are joined

together to form a diode, and the function of the diode, let us continue our discussion with the

operation of the PN junction. But before we can understand how the PN junction works, we must

first consider current flow in the materials that make up the junction and what happens initially

within the junction when these two materials are joined together.

Current Flow in the N-Type Material

Conduction in the N-type semiconductor, or crystal, is similar to conduction in a copper

wire. That is, with voltage applied across the material, electrons will move through the crystal

just as current would flow in a copper wire. This is shown in figure 1-15. The positive potential

of the battery will attract the free electrons in the crystal. These electrons will leave the crystal

and flow into the positive terminal of the battery. As an electron leaves the crystal, an electron

from the negative terminal of the battery will enter the crystal, thus completing the current path.

Therefore, the majority current carriers in the N-type material (electrons) are repelled by the negative

side of the battery and move through the crystal toward the positive side of the battery.

62

Page 63: "Black Box for a Car" report

Current Flow in the P-Type Material

Current flow through the P-type material is illustrated. Conduction in the P material is by

positive holes, instead of negative electrons. A hole moves from the positive terminal of the P

material to the negative terminal. Electrons from the external circuit enter the negative terminal

of the material and fill holes in the vicinity of this terminal. At the positive terminal, electrons

are removed from the covalent bonds, thus creating new holes. This process continues as the

steady stream of holes (hole current) moves toward the negative terminal

DC motor A DC motor is a mechanically commutated electric motor powered from direct current

(DC). The stator is stationary in space by definition and therefore its current. The current in the

rotor is switched by the commutator to also be stationary in space. This is how the relative angle

between the stator and rotor magnetic flux is maintained near 90 degrees, which generates the

maximum torque.

DC motors have a rotating armature winding (winding in which a voltage is induced) but

non-rotating armature magnetic field and a static field winding (winding that produce the main

magnetic flux) or permanent magnet. Different connections of the field and armature winding

provide different inherent speed/torque regulation characteristics. The speed of a DC motor can

be controlled by changing the voltage applied to the armature or by changing the field current.

The introduction of variable resistance in the armature circuit or field circuit allowed speed

control. Modern DC motors are often controlled by power electronics systems called DC drives.

The introduction of DC motors to run machinery eliminated the need for local steam or

internal combustion engines, and line shaft drive systems. DC motors can operate directly from

rechargeable batteries, providing the motive power for the first electric vehicles. Today DC

motors are still found in applications as small as toys and disk drives, or in large sizes to operate

steel rolling mills and paper machines.

63

Page 64: "Black Box for a Car" report

Brush

The brushed DC electric motor generates torque directly from DC power supplied to the

motor by using internal commutation, stationary magnets (permanent or electromagnets), and

rotating electrical magnets.

Like all electric motors or generators, torque is produced by the principle of Lorentz

force, which states that any current-carrying conductor placed within an external magnetic field

experiences a torque or force known as Lorentz force. Advantages of a brushed DC motor

include low initial cost, high reliability, and simple control of motor speed. Disadvantages are

high maintenance and low life-span for high intensity uses. Maintenance involves regularly

replacing the brushes and springs which carry the electric current, as well as cleaning or

replacing the commutator. These components are necessary for transferring electrical power

from outside the motor to the spinning wire windings of the rotor inside the motor.Brushes are

made of conductors.

Brushless

Typical brushless DC motors use a rotating permanent magnet in the rotor, and stationary

electrical current/coil magnets on the motor housing for the rotor, but the symmetrical opposite is also

possible. A motor controller converts DC to AC.

64

Page 65: "Black Box for a Car" report

This design is simpler than that of brushed motors because it eliminates the complication of

transferring power from outside the motor to the spinning rotor. Advantages of brushless motors include

long life span, little or no maintenance, and high efficiency. Disadvantages include high initial cost, and

more complicated motor speed controllers. Some such brushless motors are sometimes referred to as

"synchronous motors" although they have no external power supply to be synchronized with, as would be

the case with normal AC synchronous motors.

Connection types

Series connection

A series DC motor connects the armature and field windings in series with a common D.C. power

source. The motor speed varies as a non-linear function of load torque and armature current; current is

common to both the stator and rotor yielding (current) squared behavior. A series motor has very high

starting torque and is commonly used for starting high inertia loads, such as trains, elevators or hoists.

This speed/torque characteristic is useful in applications such as dragline excavators, where the digging

tool moves rapidly when unloaded but slowly when carrying a heavy load.

Shunt connection

A shunt DC motor connects the armature and field windings in parallel or shunt with a

common D.C. power source. This type of motor has good speed regulation even as the load

varies, but does not have the starting torque of a series DC motor.It is typically used for

industrial, adjustable speed applications, such as machine tools, winding/unwinding machines

and tensioners.

65

Page 66: "Black Box for a Car" report

Compound connection

A compound DC motor connects the armature and fields windings in a shunt and a series

combination to give it characteristics of both a shunt and a series DC motor.This motor is used

when both a high starting torque and good speed regulation is needed. The motor can be

connected in two arrangements: cumulatively or differentially. Cumulative compound motors

connect the series field to aid the shunt field, which provides higher starting torque but less speed

regulation. Differential compound DC motors have good speed regulation and are typically

operated at constant speed.

4.10 LED

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator

lamps in many devices, and are increasingly used for lighting. When a light-emitting diode is

forward biased (switched on), electrons are able to recombine with holes within the device,

releasing energy in the form of photons. This effect is called electroluminescence and the color

of the light (corresponding to the energy of the photon) is determined by the energy gap of the

semiconductor. An LED is often small in area (less than 1 mm2), and integrated optical

components may be used to shape its radiation pattern. LEDs present many advantages over

incandescent light sources including lower energy consumption, longer lifetime, improved

robustness, smaller size, faster switching, and greater durability and reliability.

Types of LED’S

66

Page 67: "Black Box for a Car" report

Light-emitting diodes are used in applications as diverse as replacements for aviation

lighting, automotive lighting as well as in traffic signals. The compact size, the possibility of

narrow bandwidth, switching speed, and extreme reliability of LEDs has allowed new text and

video displays and sensors to be developed, while their high switching rates are also useful in

advanced communications technology.

Electronic Symbol:

4.11 RESISTORS

A resistor is a two-terminal electronic component designed to oppose an electric

current by producing a voltage drop between its terminals in proportion to the current, that is, in

accordance with Ohm's law:

V = IR

Resistors are used as part of electrical networks and electronic circuits. They are

extremely commonplace in most electronic equipment. Practical resistors can be made of various

compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as

nickel/chrome).

The primary characteristics of resistors are their resistance and the power they can

dissipate. Other characteristics include temperature coefficient, noise, and inductance. Less well-

known is critical resistance, the value below which power dissipation limits the maximum

permitted current flow, and above which the limit is applied voltage. Critical resistance depends

upon the materials constituting the resistor as well as its physical dimensions; it's determined by

design.

Resistors can be integrated into hybrid and printed circuits, as well as integrated

circuits. Size, and position of leads (or terminals) are relevant to equipment designers; resistors

must be physically large enough not to overheat when dissipating their power.

67

Page 68: "Black Box for a Car" report

A resistor is a two-terminal passive electronic component which implements electrical

resistance as a circuit element. When a voltage V is applied across the terminals of a resistor, a

current I will flow through the resistor in direct proportion to that voltage. The reciprocal of the

constant of proportionality is known as the resistance R, since, with a given voltage V, a larger

value of R further "resists" the flow of current I as given by Ohm's law:

Resistors are common elements of electrical networks and electronic circuits and are

ubiquitous in most electronic equipment. Practical resistors can be made of various compounds

and films, as well as resistance wire (wire made of a high-resistivity alloy, such as nickel-

chrome). Resistors are also implemented within integrated circuits, particularly analog devices,

and can also be integrated into hybrid and printed circuits.

The electrical functionality of a resistor is specified by its resistance: common

commercial resistors are manufactured over a range of more than 9 orders of magnitude. When

specifying that resistance in an electronic design, the required precision of the resistance may

require attention to the manufacturing tolerance of the chosen resistor, according to its specific

application. The temperature coefficient of the resistance may also be of concern in some

precision applications. Practical resistors are also specified as having a maximum power rating

which must exceed the anticipated power dissipation of that resistor in a particular circuit: this is

mainly of concern in power electronics applications. 68

Page 69: "Black Box for a Car" report

Resistors with higher power ratings are physically larger and may require heat sinking. In

a high voltage circuit, attention must sometimes be paid to the rated maximum working voltage

of the resistor.

The series inductance of a practical resistor causes its behavior to depart from ohms law;

this specification can be important in some high-frequency applications for smaller values of

resistance. In a low-noise amplifier or pre-amp the noise characteristics of a resistor may be an

issue. The unwanted inductance, excess noise, and temperature coefficient are mainly dependent

on the technology used in manufacturing the resistor. They are not normally specified

individually for a particular family of resistors manufactured using a particular technology. A

family of discrete resistors is also characterized according to its form factor, that is, the size of

the device and position of its leads (or terminals) which is relevant in the practical manufacturing

of circuits using them.

Units

The ohm (symbol: Ω) is the SI unit of electrical resistance, named after Georg Simon

Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified and manufactured

over a very large range of values, the derived units of milliohm (1 mΩ = 10−3 Ω), kilohm (1 kΩ =

103 Ω), and megohm (1 MΩ = 106 Ω) are also in common usage.

The reciprocal of resistance R is called conductance G = 1/R and is measured in Siemens

(SI unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal of an ohm: S = Ω − 1.

Although the concept of conductance is often used in circuit analysis, practical resistors are

always specified in terms of their resistance (ohms) rather than conductance.

4.12 LIQUID CRYSTAL DISPLAY (LCD)

Description:

This is the example for the Parallel Port. This example doesn't use the Bi-directional

feature found on newer ports, thus it should work with most, if not all Parallel Ports.

69

Page 70: "Black Box for a Car" report

It however doesn't show the use of the Status Port as an input for a 16 Character x 2 Line

LCD Module to the Parallel Port. These LCD Modules are very common these days, and are

quite simple to work with, as all the logic required running them is on board.

Pros:

Very compact and light

Low power consumption

No geometric distortion

Little or no flicker depending on backlight technology

Not affected by screen burn-in

No high voltage or other hazards present during repair/service

Can be made in almost any size or shape

No theoretical resolution limit

LCD Background:

Frequently, an 8051 program must interact with the outside world using input and output

devices that communicate directly with a human being. One of the most common devices

attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051

are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per

line by 2 lines, respectively.

Fortunately , a very popular standard exists which allows us to communicate with the

vast majority of LCDs regardless of their manufacturer. The standard is referred to as

HD44780U, which refers to the controller chip which receives data from an external source (in

this case, the 8051) and communicates directly with the LCD.

FIG 4.10: LCD

70

Page 71: "Black Box for a Car" report

44780 LCD BACKGROUND

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data

bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus.

If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4

lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3

control lines plus the 8 lines for the data bus).

The three control lines are referred to as EN, RS, and RW.

The EN line is called "Enable." This control line is used to tell the LCD that you are

sending it data. To send data to the LCD, your program should make sure this line is low (0) and

then set the other two control lines and/or put data on the data bus. When the other lines are

completely ready, bring EN high (1) and wait for the minimum amount of time required by the

LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

71

Page 72: "Black Box for a Car" report

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a

command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1),

the data being sent is text data which should be displayed on the screen. For example, to display

the letter "T" on the screen you would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the information on

the data bus is being written to the LCD. When RW is high (1), the program is effectively

querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All

others are write commands--so RW will almost always be low .Finally, the data bus consists of 4

or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data

bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

4.13 CAPACITORS

A capacitor or condenser is a passive electronic component consisting of a pair of

conductors separated by a dielectric. When a voltage potential difference exists between the

conductors, an electric field is present in the dielectric. This field stores energy and produces a

mechanical force between the plates. The effect is greatest between wide, flat, parallel, narrowly

separated conductors.

An ideal capacitor is characterized by a single constant value, capacitance, which is

measured in farads. This is the ratio of the electric charge on each conductor to the potential

difference between them. In practice, the dielectric between the plates passes a small amount of

leakage current. The conductors and leads introduce an equivalent series resistance and the

dielectric has an electric field strength limit resulting in a breakdown voltage.

The properties of capacitors in a circuit may determine the resonant frequency and

quality factor of a resonant circuit, power dissipation and operating frequency in a digital logic

circuit, energy capacity in a high-power system, and many other important aspects.

72

Page 73: "Black Box for a Car" report

A capacitor (formerly known as condenser) is a device for storing electric charge. The

forms of practical capacitors vary widely, but all contain at least two conductors separated by a

non-conductor. Capacitors used as parts of electrical systems, for example, consist of metal foils

separated by a layer of insulating film.

Capacitors are widely used in electronic circuits for blocking direct current while

allowing alternating current to pass, in filter networks, for smoothing the output of power

supplies, in the resonant circuits that tune radios to particular frequencies and for many other

purposes.

A capacitor is a passive electronic component consisting of a pair of conductors separated

by a dielectric (insulator). When there is a potential difference (voltage) across the conductors, a

static electric field develops in the dielectric that stores energy and produces a mechanical force

between the conductors. An ideal capacitor is characterized by a single constant value,

capacitance, measured in farads. This is the ratio of the electric charge on each conductor to the

potential difference between them.

The capacitance is greatest when there is a narrow separation between large areas of

conductor, hence capacitor conductors are often called "plates", referring to an early means of 73

Page 74: "Black Box for a Car" report

construction. In practice the dielectric between the plates passes a small amount of leakage

current and also has an electric field strength limit, resulting in a breakdown voltage, while the

conductors and leads introduce an undesired inductance and resistance.

Theory of operation

Capacitance

Charge separation in a parallel-plate capacitor causes an internal electric field. A

dielectric (orange) reduces the field and increases the capacitance.

A simple demonstration of a parallel-plate capacitor

A capacitor consists of two conductors separated by a non-conductive region. The non-

conductive region is called the dielectric or sometimes the dielectric medium. In simpler terms,

the dielectric is just an electrical insulator.

Examples of dielectric mediums are glass, air, paper, vacuum, and even a semiconductor

depletion region chemically identical to the conductors. A capacitor is assumed to be self-

74

Page 75: "Black Box for a Car" report

contained and isolated, with no net electric charge and no influence from any external electric

field.

The conductors thus hold equal and opposite charges on their facing surfaces, and the

dielectric develops an electric field. In SI units, a capacitance of one farad means that one

coulomb of charge on each conductor causes a voltage of one volt across the device.

The capacitor is a reasonably general model for electric fields within electric circuits. An

ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge

±Q on each conductor to the voltage V between them:

Sometimes charge build-up affects the capacitor mechanically, causing its capacitance to

vary. In this case, capacitance is defined in terms of incremental changes:

Energy storage

Work must be done by an external influence to "move" charge between the conductors in

a capacitor. When the external influence is removed the charge separation persists in the electric

field and energy is stored to be released when the charge is allowed to return to its equilibrium

position. The work done in establishing the electric field, and hence the amount of energy stored,

is given by:

Current-voltage relation

The current i(t) through any component in an electric circuit is defined as the rate of flow

of a charge q(t) passing through it, but actual charges, electrons, cannot pass through the

dielectric layer of a capacitor, rather an electron accumulates on the negative plate for each one

that leaves the positive plate, resulting in an electron depletion and consequent positive charge

on one electrode that is equal and opposite to the accumulated negative charge on the other.

Thus the charge on the electrodes is equal to the integral of the current as well as

proportional to the voltage as discussed above. As with any antiderivative, a constant of 75

Page 76: "Black Box for a Car" report

integration is added to represent the initial voltage v (t0). This is the integral form of the capacitor

equation,

.

Taking the derivative of this, and multiplying by C, yields the derivative form,

.

The dual of the capacitor is the inductor, which stores energy in the magnetic field rather

than the electric field. Its current-voltage relation is obtained by exchanging current and voltage

in the capacitor equations and replacing C with the inductance L.

4. SOFTWARE REQUIREMENTS

GETTING STARTED WITH EMBEDDED SYSTEM AND AVR STUDIO

WHAT IS AN EMBEDDED SYSTEM?

An embedded computer is frequently a computer that is implemented for a particular

purpose. In contrast, an average PC computer usually serves a number of purposes: checking

email, surfing the internet, listening to music, word processing, etc... However, embedded

systems usually only have a single task, or a very small number of related tasks that they are

programmed to perform. Every home has several examples of embedded computers. Any

appliance that has a digital clock, for instance, has a small embedded microcontroller that

performs no other task than to display the clock. Modern cars have embedded computers

onboard that control such things as ignition timing and anti-lock brakes using input from a

number of different sensors.

In general, an Embedded System:

76

Page 77: "Black Box for a Car" report

Is a system built to perform its duty, completely or partially independent of human

intervention.

Is specially designed to perform a few tasks in the most efficient way.

Interacts with physical elements in our environment, viz. controlling and driving a motor,

sensing temperature, etc.

An embedded system can be defined as a control system or computer system designed to

perform a specific task. Examples:

Pen drives (for controlling the communication between P.C. and Flash Chip and also the small

LED!)

Hard disks( again for the same purpose)

Mouse(Reads and Interprets the Sensors and send final result to P.C.),Keyboards

Printers: Ever opened a printer for installing ink cartridge? Then you must have seen the printed

head. There are motors to control the print head and the paper movement. Your P.C. is not

directly connected to them but there is built in MCU of printer to control all these. Your P.C. just

sends the data (pixels) through the communication line (USB or parallel).But the MCU used here

is fairly fast and has lots of RAM.

Automobiles

Calculators, Electronic wending machines, Electronic weighing scales, Phones(digital with LCD

and phonebook)

Cell phones

WHAT IS A MICROCONTROLLER

A microcontroller is an integrated chip that is often part of an embedded system. The

microcontroller includes a CPU, RAM, ROM, I/O ports, and timers like a standard computer, but

because they are designed to execute only a single specific task to control a single system, they

are much smaller and simplified so that they can include all the functions required on a single

chip. In a microcontroller all that you have to do is to make proper connections of the pins and

then feed a computer program into it.

77

Page 78: "Black Box for a Car" report

After that your microcontroller responds in accordance with the program that has been

fed into it. In a microcontroller program you receive the inputs from a set of input pins that you

specify and then process the input and produce your output on a set of output pins in form digital

signal. However in order to connect the pins, you need to know the pin diagram of the MCU you

are using. The pin diagram of Atmega 16/32 has been given below:

78

Page 79: "Black Box for a Car" report

SIMPLE MCU BASED SYSTEM

A simplest MCU system may look like below

The program it is executing is like this (In C language).The MCU contains a flash

memory where it stores its program (it is like a hard disk to it). The flash memory can be easily

erased and a new program can burned. This makes them very flexible. MCUs can be

programmed few thousand times before they die.

A SMALL NOTE ABOUT “DELAY”

‘C’ has inbuilt libraries which contain many pre-built functions. One such function is

“Delay”, which introduces a time delay at a particular step. To invoke it in your program, you

need to add the following line at the beginning of your code:

#include <delay.h>;

Thereafter, it can be used in the program by adding the following line:

delay_ms(X);

Where X is the time delay you wish to introduce at that particular step in milliseconds.

79

Page 80: "Black Box for a Car" report

A SAMPLE PROGRAM #include <delay.h>;

void main()

{

SetPortDirection();

while(1)

{

PORTA=0b00000001;

delay_ms(500);

PORTA=0b00000000;

delay_ms(500);

}

}

PORTS

A MCU has some ports. Ports are PINs on the MCU that can be turned on and off by program.

On means 5V and off means 0V or GND .This behavior is for OUTPUT mode. They can also be

put in INPUT mode. In INPUT mode they can read what is the signal level on them (only on and

off).If voltage is more than a threshold voltage (usually half the supply) it is reported as ON(1)

otherwise OFF(0).This is how MCU control everything .Majority of the PINs of a MCU are

PORT so you can hookup lots of gizmos to it !!!They are named

PORTA ,PORTB ,PORTC ,PORTD etc .They are of one byte which means 8 Bitts all bits of

them are connected to external pins and are available outside the chip. In smaller chips only

some of the eight bits are available. Setting PORTB=0b00000001 will set PORTB's zeroth bit

high that is 5V while remaining PINs will be low (GND).

To write a binary number in c prefix it with 0b ex 0b00001000. It is decimal 8 not 1000!!

80

Page 81: "Black Box for a Car" report

What the above program does:

STEP 1 SetPortDirection(); This Function Makes the PORTB as OUTPUT. Its implementation detail is

not shown.

STEP 2 PORTB=0b00000001; makes the 0th bit high, switching off the L.E.D. because other end of

LED is connected to VCC (i.e. Supply voltage 5V). Note that the 0 in 0b is a “zero”, not an “oh”.

STEP 3 delay_ms(500); Halts the MCU for 0.5 Sec

STEP 4 PORTB=0b00000000; Switches on the LED

STEP 5 delay_ms(500); STEP 2 to 5 are within an infinite while loop so it runs till MCU is powered.

The program is compiled, and burned into the chip and power is turned on and woillaaaa that LED is

blinking once every second. Although the given program doesn't do something very important and can be

done without a MCU and in a cheap manner, but it introduce you to microcontroller programming .Doing

this with MCU has some advantages also. You can change the way LED blinks by simply writing a new

program without touching the hardware part. You can also connect 8 LEDs to all 8 PINs of the PORTB,

write a nice program them to light them in various pattern and you have a deluxe decorating lights!!!

Which you can't make easily without MCU. So you have seen that major functioning of a MCU project is

made in software and hardware part is simple and small. So you have learned the basics of MCUs and

their use.

BASIC DIGITAL I/O

Digital IO is the most fundamental of connecting a MCU to the external world. The interfacing is done

through PORT. A PORT is a point where data internal to the MCU chip comes out. They are present in

form of PINS of the IC. Most of the Pins (32 out of 40) are dedicated to this function and other pins are

used for Power supply, clock sources etc. Once introduced to the concept of Ports the next task is to learn

how to use these Ports to get Input from a port and to Output to a Port. IO is usually done by controlling

the values of certain registers associated with these PORTs.

81

Page 82: "Black Box for a Car" report

A register is a variable (usually 8 bit) whose value can be changed and read from within your

program just like you do for any other variable. Therefore IO is done in a very simple fashion simply by

altering or reading the values of certain variables. There are 32 pins available for IO (8 pins per Port) and

each pin can be set to either take input (voltage high or low) or to output a digital value (0 or 1). In order

to control which pin should do input and which should do output, there is a register called DDR (Data

Direction Register), whose value tells the microprocessor which is to be set to input and which to output.

For example , to set Pin no 0, 2, 3, 7 of Port A to input and other pins of PORT A to output, the command

would be:

DDRA=0b01110010;

Here DDRA means the DDR register of PORT A. 0b means that we are entering the number in

binary. The sequence of 0s and 1s indicate which pin is to be input and which is to output. A 0 means

input and 1 means output. We could equivalently write: DDRA=114; (decimal equivalent of 01001110).

Next comes how to read/write data from/to these pins. For this task there are two registers, PORT and

PIN. PIN (Port Input) is the register that reads the input from the pin. For example in order to read the

value of pin number 3 of port A into a variable x, the command would be: x=PINA.3; or equivalently

x=PINA&0b00001000;.where the ‘&’ is binary AND. x would be 0 if PINA.3 is set to low otherwise it

would be a non zero value. You can only read from a PIN register, you cannot write into it. PORT is the

register that is used to output values. For example to output 1 on pin no 5 of Port D, you would say

PORTD.5=1; or PORTD=PORTD|0b00100000 after setting pin 5 of port D to output. Here Boolean

algebra is used and the reader is supposed to be familiar with such concepts of ANDing and ORing bits.

To summarize, IO is done through PORTS and each PORT is associated with 3 registers for IO.

82

Page 83: "Black Box for a Car" report

A SAMPLE PROGRAM

Suppose that you have a LED and a switch. Now you want that when you press the switch the LED is

switched OFF, otherwise it is ON. Also suppose that you have made proper connection of the mcu, that is

provided power connections (GND on the GND terminals-11 & 31, and Vcc on 10 and 30 and also on

RESET . Then your next task is to connect the output of your switch to appropriate pin, say connect it to

Pin 0 of Port C, and connect LED to, say Pin 2 of Port C. Then the Programme to do the above mentioned

task will be:

#include <delay.h>; DDRC=0b00000100 //it is a good practice to set unused pins to input. While (1) { If(PINC.0==1) { PORTC.2=0; delay_ms(100); } else { PORTC.2=1; delay_ms(100); } }

WinAVR

There are several ways that you can write, compile, and download a program to the

ATmega16 microcontroller. There are many different text editors, compilers, and utilities

available for many different languages (C, BASIC, assembly language, etc.). Some of these are

free of charge, and some require a licensing fee to use them. In this class, we will use a freeware

package of software tools named WinAVR (pronounced, “whenever”). WinAVR has been

installed on the computers in the Mechatronics Laboratory, but you are strongly encouraged to

download it and install it on your own computer, so you can work with your microcontroller

outside of the lab. WinAVR consists of a suite of executable, open source software development

tools for the Atmel AVR series of RISC microprocessors hosted on the Windows platform.

83

Page 84: "Black Box for a Car" report

It includes the GNU GCC compiler for C and C++, which is sometimes referred to as

avr-gcc. Traditionally, the microcontroller in embedded systems was programmed directly using

assembly language. Assembly language uses only the basic instruction set for a particular

microcontroller. While this can produce fast, efficient code, it is limited in that every processor

type has its own instruction set. Therefore it is not a practical language to learn unless you are

doing a project that is dedicated to a specific microcontroller or has a real need for precise timing

and/or memory use. The C language, on the other hand, is commonly used in industry and can be

applied over many different platforms.

By learning this one language, you will be able to program almost any microcontroller,

provided that you have a compiler that can translate C code into assembly language for your

controller. The Gnu-C compiler is an open-source, freeware, C compiler that forms the basis for

compilers that generate code for many different microcontrollers and various operating systems,

such as Windows and UNIX.

GETTING STARTED WITH CODEVISIONAVR

CodeVisionAVR (CVAVR) is the C-program language compiler that shall be used to program

the MCU. CVAVR is a highly versatile software which offers “High Performance ANSI C Compiler,

Integrated Development Environment, Automatic Program Generator and In-System Programmer for the

Atmel AVR family of microcontrollers.” After installing and setting up CVAVR, a typical screen with a

program open looks like this:

84

Page 85: "Black Box for a Car" report

CREATING A NEW PROJECT:

Open up CodeVisionAVR on your PC.

Click on the “New Project” icon to create a new project.

85

Page 86: "Black Box for a Car" report

When the “Create New File” dialog box pops up, click “Project” then “OK.”

86

Page 87: "Black Box for a Car" report

A dialog box titled “Confirm” will pop up asking if you would like to use

“CodeWizardAVR.” This is a helpful tool which will help you automatically generate the proper

code depending on your MCU. Select “Yes”. The following window will open:

Select the appropriate Microcontroller and its appropriate frequency.

Now, click on the Ports tab to determine how the I/O ports are to be initialized for the target

system:

87

Page 88: "Black Box for a Car" report

The default setting is to have the ports for all the target systems to be inputs.

You can also change other settings in this window such as Timers, etc. These topics shall be

covered in the following tutorials.

By selecting the File -> Generate, Save and Exit option, the CodeWizard will generate a skelet

on C program with the appropriate Port initializations. Many Save File prompts shall open –

these are the project files generated by the wizard. Save them with appropriate names.

Now, type your code in the source code window.

Once you’re done with the creation of the source code, you can “make” the project by

clicking on the “Assemble” button.

88

Page 89: "Black Box for a Car" report

A dialog box appears. Make sure that the message says “No errors,” otherwise, go back

to your code and fix the errors.

If there are no errors in the compilation, it is time to program the chip.

PROGRAMMING THE MCU USING AVR STUDIO

Now that the program is ready, it is time to put it on the chip. This is accomplished by a

software known as AVR Studio:

Start AVR Studio. It will immediately ask you to start a new project. Click on Cancel.

In AVR Studio, select menu Tools | Program AVR | Connect.

89

Page 90: "Black Box for a Car" report

In the ‘Select AVR Programmer’ dialog box, choose ‘STK500 or AVRISP’ as the

platform and ‘Auto’ as Port. Then click button Connect.

Depending on the version of your AVR Studio, a message about firmware may appear.

For now, this message can be discarded by clicking button Cancel. In the ‘STK500’ dialog box

that appears, select the generated hex file as ‘Input Hex File’. Then, click the button Program to

download the HEX file to the AVR chip.

90

Page 91: "Black Box for a Car" report

The program will now run on the microcontroller.

3. Software Used For Programming Microcontroller Win AVR2008(For writing code) AVR Studio(For Simulation) AVR Dude(To Burn the program)

91

Page 92: "Black Box for a Car" report

GETTING STARTED:-

First you should require a compiler which converts your program into the hex code of the

avr microcontroller. If you use C for programming Avr then you can use WinAVR. CodeVision

AVR,ImageCraft AVR , BASCOM AVR for programming in BASIC, AVRStuidio for

programming in assembly. But here I am talking about C programming. I use WinaVR2008

for all these programms compilation. Same code is valid for AVRGCC in Linux. Second

requirement is a programmer which transfers the . Hex code(machine code for AVR) into the

chip. That is a programmer which burns the chip. I use USB programmer for that.

92

Page 93: "Black Box for a Car" report

LET'S START:

Let us start with the microcontroller interfacing with a simple code using ‘C’. Here we will make

to turn continuous on & off of LEDs.

THE CODE IS:-

#include<avr/io.h>

void main()

{

DDRA=0x00;

DDRC=0xFF;

while(1)

{

if(PINA==0x01)

{

PORTC=0x0a;

}

else if(PINA==0x02)

{

PORTC=0x06;

}

93

Page 94: "Black Box for a Car" report

else if(PINA==0x04)

{

PORTC=0x09;

}

else if(PINA==0x08)

{

PORTC=0x05;

}

else

PORTC=0x00;

}

}

94

Page 95: "Black Box for a Car" report

10.HARDWARE TESTING

10.1 CONTINUITY TEST:

In electronics, a continuity test is the checking of an electric circuit to see if current flows

(that it is in fact a complete circuit). A continuity test is performed by placing a small voltage

(wired in series with an LED or noise-producing component such as a piezoelectric speaker)

across the chosen path. If electron flow is inhibited by broken conductors, damaged components,

or excessive resistance, the circuit is "open".

Devices that can be used to perform continuity tests include multi meters which measure

current and specialized continuity testers which are cheaper, more basic devices, generally with a

simple light bulb that lights up when current flows.

An important application is the continuity test of a bundle of wires so as to find the two ends

belonging to a particular one of these wires; there will be a negligible resistance between the

"right" ends, and only between the "right" ends.

This test is the performed just after the hardware soldering and configuration has been

completed. This test aims at finding any electrical open paths in the circuit after the soldering.

Many a times, the electrical continuity in the circuit is lost due to improper soldering, wrong and

rough handling of the PCB, improper usage of the soldering iron, component failures and

presence of bugs in the circuit diagram. We use a multi meter to perform this test. We keep the

multi meter in buzzer mode and connect the ground terminal of the multi meter to the ground.

We connect both the terminals across the path that needs to be checked. If there is continuation

then you will hear the beep sound.

10.2 POWER ON TEST:

95

Page 96: "Black Box for a Car" report

This test is performed to check whether the voltage at different terminals is according to

the requirement or not. We take a multi meter and put it in voltage mode. Remember that this test

is performed without microcontroller. Firstly, we check the output of the transformer, whether

we get the required 12 v AC voltage.

Then we apply this voltage to the power supply circuit. Note that we do this test without

microcontroller because if there is any excessive voltage, this may lead to damaging the

controller. We check for the input to the voltage regulator i.e., are we getting an input of 12v and

an output of 5v. This 5v output is given to the microcontrollers’ 40 th pin. Hence we check for the

voltage level at 40th pin. Similarly, we check for the other terminals for the required voltage. In

this way we can assure that the voltage at all the terminals is as per the requirement.

11. RESULTS96

Page 97: "Black Box for a Car" report

We have successfully send the alert to the programmed mobile number. When the piezoelectric sensor (here acting as the accident vibration sensor) sends the signal to the microcontroller, the motor driver drives motor for some time, an alert by buzzer at the place of accident, the accident alert on the LCD and finally the microcontroller sends the message to the GSM modem to send that to the preprogrammed GSM mobile number.

12. CONCLUSION

97

Page 98: "Black Box for a Car" report

Here we are using only the accident detector part of the

BLACKBOX

We can save the vehicle data by connecting a memory in it

Here for project purpose we are using the piezoelectric sensor but

in practical situation there should be a strong detector.

We can use this project on practical basis

By putting the value of longitude and altitude on a smart phone we

can get the accurate place of accident

Also we can use a software to directly view the place in mobile

From the GPS system we can monitor the velocity but here we are

not using that part

BIBLIOGRAPHY

98

Page 99: "Black Box for a Car" report

www.atmel.com

www.beyondlogic.org

www.wikipedia.org

www.howstuffworks.com

www.alldatasheets.com etc.

99