1
CHAPTER 1
INTRODUCTION
There is one death every four minutes due to a road accident in
India.16 children die on Indian roads daily. One serious road accident in the
country occurs every minute and 16 die on Indian roads every hour. Tamil
Nadu is the state with the maximum number of road crash injuries. This project
“ADAPTIVE ZONE PREDICTION SYSTEM” aims to reduce this statistics by
providing a safe environment for pedestrians especially in major zones such as
schools, hospitals and highways. The project consists of two units: The wireless
location informer and the vehicle unit. The former unit is present within the
zone whereas the latter unit is present inside the vehicle. These two units
communicate using RF communication. Here, the speed of the vehicle is
controlled in school zones, the horn intensity level is controlled in hospital
zones and the headlight is controlled in highway zones. We employ the use of
PIC16F887 microcontroller, RF Transmitter and Receiver modules and
individual control units for each zone.
2
CHAPTER 2
PROJECT OVERVIEW
2.1 BLOCK DIAGRAM
Fig 2.1.1 Block Diagram of Wireless Location Informer
3
Fig 2.1.2 Block Diagram of Vehicle Unit
2.2 WORKING
Each zone consists of a transmitter unit. The data regarding that zone
(school zone, hospital zone or highway zone) is encoded using HT12E encoder
and transmitted through a 433MHz RF Transmitter.
The data is received by the 433MHz RF Receiver present in the vehicle
unit and is decoded using a HT12D decoder. The decoded data is passed
through a buffer and then sent to the PIC16F887 microcontroller. The controller
then processes these inputs and sends control inputs to the corresponding
circuits. On entering the school zone, the speed of the vehicle is controlled. In
hospital zone the horn intensity level of the vehicle is controlled and in highway
zone the headlight intensity of the vehicle is controlled. The LCD display
present on the dashboard of the vehicle displays the details of the zone.
4
CHAPTER 3
POWER SUPPLY
3.1 INTRODUCTION
A power supply is a device that supplies electrical energy to one or more
electric loads. The term is most commonly applied to devices that convert one
form of electrical energy to another.
A regulated power supply is one that controls the output voltage or
current to a specific value, the controlled value is held nearly constant despite
variations in either load current or the voltage supplied by the power supplies
energy source.
Every power supply obtains the energy it supplies to its load, as well as
any energy it consumes while performing that task, from an energy source.
A power supply may be implemented as a discrete, stand-alone device or
as an integral device that is hardwired to its load. In the latter case, for example
low voltage DC power supplies are commonly integrated with their loads in
devices such as computers and household electronics.
Fig 3.1.1 Block Diagram of Power Supply
5
3.2 WORKING PRINCIPLE
The ac voltage, typically 220V rms, is connected to a transformer, which
steps that ac voltage down to the level of the desired dc output. A diode rectifier
then provides a full-wave rectified voltage that is initially filtered by a simple
capacitor filter to produce a dc voltage. This resulting dc voltage usually has
some ripple or ac voltage variation.
A regulator circuit removes the ripples and also remains the same dc
value even if the input dc voltage varies, or the load connected to the output dc
voltage changes. This voltage regulation is usually obtained using one of the
popular voltage regulator IC units.
6
CHAPTER 4
TRANSMITTER
4.1 INTRODUCTION
A transmitter or radio transmitter is an electronic device which, with the
aid of an antenna, produces radio waves. The transmitter itself generates a radio
frequency alternating current, which is applied to the antenna. When excited by
this alternating current, the antenna radiates radio waves. In addition to their use
in broadcasting, transmitters are necessary component parts of many electronic
devices that communicate by radio, such as cell phones, wireless computer
networks, Bluetooth enabled devices, garage door openers, two-way radios in
aircraft, ships, spacecraft, radar sets and navigational beacons. The term
transmitter is usually limited to equipment that generates radio waves
for communication purposes, or radiolocation, such as radar and navigational
transmitters. Generators of radio waves for heating or industrial purposes, such
as microwave ovens or diathermy equipment, are not usually called transmitters
even though they often have similar circuits.
The term is popularly used more specifically to refer to a broadcast
transmitter, a transmitter used in broadcasting, as in FM radio
transmitter or television transmitter. This usage typically includes the
transmitter, the antenna, and often the building it is housed in.
The RF module, as the name suggests, operates at Radio Frequency. The
corresponding frequency range varies between 30 kHz & 300 GHz. In this RF
system, the digital data is represented as variations in the amplitude of carrier
wave. This kind of modulation is known as Amplitude Shift Keying (ASK).
7
Radio Frequency transmission is more strong and reliable than Infrared
transmission because of the following reasons:
Radio Frequency signals can travel longer distances than Infrared.
Only line of sight communication is possible through Infrared while
radio frequency signals can be transmitted even when there are
obstacles.
Infrared signals will get interfered by other IR sources but signals on
one frequency band in RF will not interfered by other frequency RF
signals.
4.2 RF TRANSMITTER
An RF transmitter module is a small PCB sub-assembly capable of
transmitting a radio wave and modulating that wave to carry data. Transmitter
modules are usually implemented alongside a micro controller which will
provide data to the module which can be transmitted. RF transmitters are
usually subject to regulatory requirements which dictate the maximum
allowable transmitter power output, harmonics, and band edge requirements.
The transmitter operates at a frequency of 434MHz. An RF transmitter
receives serial data and transmits it wirelessly. The transmission occurs at the
rate of 1Kbps - 10Kbps.The transmitted data is received by an RF receiver
operating at the same frequency as that of the transmitter.
8
Fig 4.2.1 Pin Diagram of RF Transmitter
4.2.1 PIN DESCRIPTION
Pin
No Function Name
1 Ground (0V) Ground
2 Serial data input pin Data
3 Supply voltage; 5V Vcc
4 Antenna output pin ANT
Table 4.2.1 Pin Description
9
4.2.2 ELECTRICAL CHARACTERISTICS
T=25oC, Vcc=3.6V, Frequency=433.92MHZ
Characteristic Min. Typ. Max. Unit
Operating Frequency (200Khz) - 433.92 - MHZ
Data Rate - - 100 Kbps
Peak Input Current, 12 Vdc Supply - 45 - mA
Peak Output Power - 10 - mW
Turn on / Turn Off Time - - 1 µs
Operating Ambient Temperature -20 - +85 oC
Table 4.2.2 Electrical Characteristics
4.3 ENCODER
The HT12E encoder is a CMOS IC built especially for remote control system
applications. It is capable of encoding 8 bits of address (A0-A7) and 4 bits of data
(AD0-AD3) information. Each address/data input can be set to one of the two logic
states, 0 or 1. Grounding the pins is taken as a 0 while a high can be given by giving
+5V or leaving the pins open (no connection). Upon reception of transmit enable
(TE-active low), the programmed address/data are transmitted together with the
header bits via an RF medium.
10
4.3.1 FEATURES
• 2.4-12V Operation
• Low power, high noise immunity CMOS technology
• Low standby current of < 1µA at 5V supply
• Built-in oscillator with only a 5% resister
• Minimal external components
Fig 4.3.1 Circuit Diagram of Encoder
11
4.3.2 PIN DESCRIPTION
Fig 4.3.2 Pin Diagram of HT12E Encoder
VCC: Positive power supply pin.
OSC1 and OSC2: Input and output pin of the oscillator respectively.
TE: Used for enabling the transmission; a low signal in this pin will enable
the transmission of data bits.
A0 – A7: Input address pins used for secured transmission. These pins can be
connected to GND for low signal or left open for high state.
AD0 – AD3: Used for feeding data into the IC. These pins may be connected
to GND for sending LOW since it is an active low pin
OUTPUT: Output pin of the encoder
12
4.3.3 ELECTRICAL CHARACTERISTICS
Ta=250C
Symbol Parameter Test Conditions Min Typ Max Unit
VDD Conditions
VDD Operating
Voltage - - 2.4 5 12 V
ISTB
Standby Current 3V Oscillator
stops
- 0.1 1 µA
12V - 2 4 µA
IDD
Operating Current 3V No load
fOSC= 3kHz
- 40 80 µA
12V - 150 300 µA
IDOUT
Output Drive
Current 5V
VOH=0.9VDD
(Source) -1 -1.6 - mA
VOL=0.1VDD
(Sink) 1 1.6 - mA
VIH “H” Input
Voltage - - 0.8VDD - VDD V
VIL “L” Input Voltage - - 0 - 0.2VDD V
fOSC Oscillator
frequency 5V ROSC=1.1MΩ - 3 - kHz
RTE TE pull high
resistance 5V VTE=0V - 1.5 3 MΩ
Table 4.3.1 Electrical Characteristic of HT12E
13
4.3.4 WORKING OF HT12E IC
Fig 4.3.3 Transmission Timing Diagram of HT12E
HT12E starts working with a low signal on the TE pin. After receiving a
low signal the HT12E starts the transmission of 4 data bits as shown in the
timing diagram above. And the output cycle will repeats based on the status of
the TE pin in the IC. If the TE pin retains the low signal the cycle repeats as
long as the low signal in the TE pin exists. The encoder IC will be in standby
mode if the TE pin is disabled and thus the status of this pin was necessary for
encoding process. The address of these bits can be set through A0 – A7 and the
same scheme should be used in decoders to retrieve the signal bits.
14
4.3.4.1 ENCODER OPERATION FLOW CHART
The encoder operation can be represented by a flowchart as shown in Fig 4.3.4
Fig 4.3.4 Encoder Operation Flow Chart
15
Fig 4.3.5 Circuit Diagram
HT12E Encoder IC will convert the 4 bit parallel data given to pins D0 –
D3 to serial data and will be available at DOUT. This output serial data is given
to ASK RF Transmitter. Address inputs A0 – A7 can be used to provide data
security and can be connected to GND (Logic ZERO) or left open (Logic ONE).
Status of these Address pins should match with status of address pins in the
receiver for the transmission of the data. Data will be transmitted only when the
Transmit Enable pin (TE) is LOW. 1.1MΩ resistor will provide the necessary
external resistance for the operation of the internal oscillator of HT12E.
16
CHAPTER 5
RECEIVER
5.1 INTRODUCTION
In radio communications, a radio receiver is an electronic device that
receives radio waves and converts the information carried by them to a usable
form. It is used with an antenna. The antenna intercepts radio waves
(electromagnetic waves) and converts them to tiny alternating currents which
are applied to the receiver, and the receiver extracts the desired information.
The receiver uses electronic filters to separate the desired radio frequency signal
from all the other signals picked up by the antenna, an electronic amplifier to
increase the power of the signal for further processing, and finally recovers the
desired information through demodulation.
The information produced by the receiver may be in the form of sound
(an audio signal), images (a video signal) or data (a digital signal). A radio
receiver may be a separate piece of electronic equipment, or an electronic
circuit within another device. Devices that contain radio receivers
include television sets, radar equipment, two-way radios, cell phones, wireless
computer networks, GPS navigation devices, satellite dishes, radio
telescopes, Bluetooth enabled devices, garage door openers, and baby monitors.
17
5.2 RF RECEIVER:
An RF receiver module receives the modulated RF signal,
and demodulates it. There are two types of RF receiver modules: super
heterodyne receivers and super-regenerative receivers. Super-regenerative
modules are usually low cost and low power designs using a series of amplifiers
to extract modulated data from a carrier wave. Super-regenerative modules are
generally imprecise as their frequency of operation varies considerably with
temperature and power supply voltage. Super heterodyne receivers have a
performance advantage over super-regenerative; they offer increased accuracy
and stability over a large voltage and temperature range. This stability comes
from a fixed crystal design which in turn leads to a comparatively more
expensive product.
This is a PLL based ASK Hybrid 433Mhz RF receiver module and is
ideal for short-range wireless control applications where quality is a primary
concern. The receiver module requires no external RF components except for
the antenna. The super-regenerative design exhibits exceptional sensitivity at a
very low cost.
Fig 5.2.1 Pin Diagram of RF Receiver
18
5.2.1 PIN DESCRIPTION
Pin
No Function Name
1 Ground (0V) Ground
2 Serial data output pin Data
3 Linear output pin; not connected NC
4 Supply voltage; 5V Vcc
5 Supply voltage; 5V Vcc
6 Ground (0V) Ground
7 Ground (0V) Ground
8 Antenna input pin ANT
Table 5.2.1 Pin Description of RF 433 MHz Receiver
19
5.2.2 ELECTRICAL CHARACTERISTICS
Characteristic Symbol Min. Typ. Max. Unit
Reception Bandwidth BWrx - 1.0 - MHZ
Centre Frequency Fc - 433.92 - MHZ
Sensitivity - - -105
dBm
Operating current Icc - 3.5 4.5 mA
Peak Output Power Po - 10 - mW
Turn on Time Ton - 25 - us
Operating Voltage Vcc 4.5 5.0 5.5 Vdc
Operating Ambient Temperature Top -10 - +60 °C
Max Data Rate - 300 1k 3k Kbit/s
Table 5.2.2 Electrical Characteristic of RF Receiver
5.3 DECODER
HT12D is a decoder integrated circuit that belongs to 212
series of
decoders. This series of decoders are mainly used for remote control system
applications, like burglar alarm, car door controller, security system etc. It is
mainly provided to interface RF and infrared circuits. They are paired with
212
series of encoders.
20
HT12D converts the serial input into parallel outputs. It decodes the serial
addresses and data received by, say, an RF receiver, into parallel data and sends
them to output data pins. The serial input data is compared with the local
addresses three times continuously. The input data code is decoded when no
error or unmatched codes are found. A valid transmission in indicated by a high
signal at VT pin.
HT12D is capable of decoding 12 bits, of which 8 are address bits and 4
are data bits. The data on 4 bit latch type output pins remain unchanged until
new is received.
5.3.1 FEATURES
Operating voltage: 2.4V-12V
Low power and high noise immunity CMOS technology
Low standby current
Capable of decoding 12 bits of information
Binary address setting
Received codes are checked 3 times
Fig 5.3.1 Circuit Diagram of HT12D Decoder
21
5.3.2 PIN DESCRIPTION:
Fig 5.3.2 Pin Diagram of HT12D Decoder
VCC and GND are used to provide power to the IC, Positive and
Negative of the power supply respectively.
Osc1 and Osc2:OSC1 is the oscillator input pin and OSC2 is the
oscillator output pin.
A0 – A7 are the address input pins. These pins can be connected to VSS
or left open.
INPUT is the serial data input pin.
D8 – D11 are the data output pins.
VT stands for Valid Transmission. This output pin will be HIGH when
valid data is available at D8 – D11 data output pins.
22
5.3.3 ELECTRICAL CHARACTERISTICS
Ta=250C
Symbol Parameter Test Conditions Min Typ Max Unit
VDD Conditions
VDD Operating Voltage - - 2.4 5 12 V
ISTB
Standby Current 5V Oscillator
stops
- 0.1 1 µA
12V - 2 4 µA
IDD
Operating Current 5V
No load
fOSC=150kHz - 200 400 µA
IO Data Output
Source Current 5V VOH=4.5V -1 -1.6 - mA
Data Output Sink
Current 5V VOL=0.5V 1 1.6 - mA
IVT VT Output Source
Current 5V
VOH=4.5V -1 -1.6 - mA
VT Output Sink
Current VOL=0.5V 1 1.6 - mA
VIH “H” Input Voltage 5V - 3.5 - 5 V
VIL “L” Input Voltage 5V - 0 - 1 V
fOSC Oscillator
frequency 5V ROSC=51 kΩ - 150 - kHz
Table 5.3.1 Electrical Characteristics of HT12D Decoder
23
5.3.4 WORKING
Fig 5.3.3 Timing Diagram of HT12D Decoder
HT12D decoder will be in standby mode initially i.e., oscillator is
disabled and a HIGH on DIN pin activates the oscillator. Thus the oscillator will
be active when the decoder receives data transmitted by an encoder. The device
starts decoding the input address and data. The decoder matches the received
address three times continuously with the local address given to pin A0 – A7. If
all matches, data bits are decoded and output pins D8 – D11 are activated. This
valid data is indicated by making the pin VT (Valid Transmission) HIGH. This
will continue till the address code becomes incorrect or no signal is received.
24
5.3.4.1 FLOW CHART
Fig 5.3.4 Operational Flow Chart of HT12D Decoder
25
5.3.4.2 CIRCUIT DIAGRAM:
Fig 5.3.5 Circuit Diagram of RF 433 MHz Receiver
ASK RF Receiver receives the data transmitted using ASK RF
Transmitter. HT12D decoder will convert the received serial data to 4 bit
parallel data D0 – D3. The status of these address pins A0-A7 should match
with status of address pin in the HT12E at the transmitter for the transmission of
data. The LED connected to the above circuit glows when valid data
transmission occurs from transmitter to receiver. 51KΩ resistor will provide the
necessary resistance required for the internal oscillator of the HT12D.
26
CHAPTER 6
LCD DISPLAY
6.1 INTRODUCTION
A Liquid Crystal Display (LCD) is an electronically-
modulated optical device shaped into a thin, flat panel made up of any number
of color or monochrome pixels filled with liquid crystals and arrayed in front of
a light source (backlight) or reflector. It is often utilized in battery-powered
electronic devices because it uses very small amounts of electric power. Liquid
crystal cell displays (LCDs) are used in similar applications where LEDs are
used. These applications are to display of numeric and alphanumeric characters
in dot matrix and segmental displays.
A 16x2 LCD means it can display 16 characters per line and there
are two such lines. In this LCD each character is displayed in 5x7 pixel matrix.
This LCD has 2 registers namely command and data. The command register
stores the command instructions given to the LCD. A command is an instruction
given to LCD to do a predefined task like initializing it, clearing its screen,
setting the cursor position, controlling the display, etc. The data register stores
the data to be displayed in the LCD. The data is the ASCII value of the
character to be displayed.
LCD consists of two glass panels, with the liquid crystal materials
sandwiched between them. The inner surface of the glass plates is coated with
transparent electrodes which define in between the electrodes and the crystal,
which makes the liquid crystal molecules to maintain a defined orientation
angle. When a potential is applied across the cell, charge carriers flowing
through the liquid will disrupt the molecular alignment and produce turbulence.
27
When the liquid is not activated, it is transparent. When the liquid is
activated the molecular turbulence causes light to be scattered in all directions
and the cell appears to be bright. Thus the required message is displayed. When
the LCD is in the OFF state, the two polarizers and the liquid crystal rotate the
light rays, such that they come out of the LCD without any orientation, and
hence the LCD appears transparent.
Fig 6.1.1 Pin Description of 16x2 LCD Display
28
6.2 WORKING
When sufficient voltage is applied to the electrodes the liquid crystal
molecules will be aligned in a specific direction. The light rays passing through
the LCD would be rotated by the polarizer, which would result in
activating/highlighting the desired characters. The power supply should be of
+5V, with maximum allowable transients of 10mV. To achieve a better/suitable
contrast for the display, the voltage (VL) at pin 3 should be adjusted properly.
The ground terminal of the power supply must be isolated properly
so that voltage is induced in it. The module should be isolated properly so that
stray voltages are not induced, which could cause a flicking display. LCD is
lightweight with only a few, millimeters thickness since the LCD consumes less
power, they are compatible with low power electronic circuits, and can be
powered for long durations. LCD does not generate light and so light is needed
to read the display. By using backlighting, reading is possible in the dark. LCDs
have long life and a wide operating temperature range. Before LCD is used for
displaying proper initialization should be done.
The pixels are addressed one at a time by row and column
addresses. Each pixel has its own dedicated transistor, all of each column line to
access one pixel. When a row line is activated, all of the column lines are
connected to a row of pixels and the correct voltage is driven onto all of the
column lines. The row line is then deactivated and the next row line is activated.
All of the row lines are activated in sequence during a refresh operation.
29
Fig 6.2.1 Internal Block Diagram of 16x2 LCD Display
30
CHAPTER 7
PIC16F887
7.1 INTRODUCTION
PIC is a family of Harvard architecture microcontrollers made by
Microchip Technology, developed by General Instrument's Microelectronics
Division. The name PIC initially refers to "Peripheral Interface Controller".
PICs are popular with developers due to their low cost, wide availability, large
user base, extensive collection of application notes, availability of low cost or
free development tools, and serial programming (and re-programming with
flash memory) capability.
The microcontroller used in our project is PIC16F887.It is a 40 pin flash-
based, 8-bit CMOS microcontroller with nanoWatt Technology.
It is a high performance RISC CPU with the following specifications:
• Only 35 instructions to learn:
- All single-cycle instructions except branches
• Operating speed:
- DC – 20 MHz oscillator/clock input
- DC – 200 ns instruction cycle
• Interrupt capability
• 8-level deep hardware stack
• Direct, Indirect and Relative Addressing modes
31
7.2 FEATURES OF PIC16F887
7.2.1 SPECIAL MICROCONTROLLER FEATURES
• Precision Internal Oscillator:
- Factory calibrated to ±1%
- Software selectable frequency range of 31 kHz to 8 MHz
- Two-Speed Start-up mode
- Crystal fail detect for critical applications
- Clock mode switching during operation for power savings
• Power-Saving Sleep mode
• Wide operating voltage range (2.0V-5.5V)
• Industrial and Extended Temperature range
• Power-on Reset (POR)
• Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
• Brown-out Reset (BOR) with software control option
• Enhanced low-current Watchdog Timer (WDT) with on-chip oscillator
• Multiplexed Master Clear with pull-up/input pin
• Programmable code protection
• High Endurance Flash/EEPROM cell:
- 100,000 write Flash endurance
- 1,000,000 write EEPROM endurance
32
- Flash/Data EEPROM retention: > 40 years
• Program memory Read/Write during run time
• In-Circuit Debugger (on board)
7.2.2 LOW POWER FEATURES
• Standby Current: - 50 nA @ 2.0V, typical
• Operating Current: - 11 μA @ 32 kHz, 2.0V, typical - 220 μA @ 4 MHz,
2.0V, typical
• Watchdog Timer Current: -1 μA @ 2.0V, typical
7.2.3 PERIPHERAL FEATURES
• 35 I/O pins with individual direction control:
- High current source/sink for direct LED drive
- Interrupt on change pin
- Ultra Low-Power Wake-up (ULPWU)
• Analog Comparator module with:
- Two analog comparators
- Programmable on-chip voltage reference (CVREF) module
- Fixed voltage reference (0.6V)
- Comparator inputs and outputs externally accessible
- External Timer1 Gate (count enable)
• A/D Converter:
- 10-bit resolution and 14 channels
33
• Timer0:
- 8-bit timer/counter with 8-bit programmable prescalar
• Enhanced Timer1:
- 16-bit timer/counter with prescalar
- External Gate Input mode
• Timer2:
- 8-bit timer/counter with 8-bit period register, prescalar and postscalar
• Enhanced Capture, Compare, PWM+ module:
- 16-bit Capture, max. resolution 12.5 ns
- Compare, max. resolution 200 ns
- 10-bit PWM with 1 output channel
- PWM output steering control
•Capture, Compare, PWM module:
- 16-bit Capture, max. resolution 12.5 ns
- 16-bit Compare, max. resolution 200 ns
- 10-bit PWM, max. frequency 20 kHz
• Enhanced USART module
• In-Circuit Serial Programming (ICSP) via two pins
• Master Synchronous Serial Port (MSSP) module supporting 3-wire SPI (all 4
modes) and I2C Master and Slave Modes with I2C address mask
34
7.3 PIN CONNECTIONS
Fig 7.3.1 Pin Diagram of PIC16F887
Pin No. 1 : Vpp (+5V)
Pin No. 2 : Connected to potentiometer (For speed adjustment)
Pin No. 3 - 10 : No connection
Pin No. 11 : Vdd(+5V)
Pin No. 12 : Gnd
Pin No. 13 – 14 : Connected to 4 MHz oscillator
Pin No. 15 : Connected to horn control circuit
Pin No. 16 : Connected to headlight control circuit
35
Pin No. 17 : Connected to speed control circuit
Pin No. 18 : No connection
Pin No. 19 - 22 : D port connected to a decoder module
Pin No. 23 - 30 : No connection
Pin No. 31 : Gnd
Pin No. 32 : Vdd(+5V)
Pin No. 33 - 40 : B Port connected to LCD
7.4 PORT DESCRIPTION
Port A : Pins 2 to 7 , 13, 14
Port B : Pins 33 to 40
Port C : Pins 15 to 18 and 23 to 26
Port D : Pins 19 to 22 and 27 to 30
Port E : Pins 8 to 10
36
7.5 MEMORY ORGANIZATION
7.5.1 PROGRAM MEMORY ORGANIZATION
PIC16F887 has a 13-bit program counter capable of addressing a 8K x14
(0000h-1FFFh) program memory space. Accessing a location above these
boundaries will cause a wraparound within the first 8Kx14 space. The Reset
vector is at 0000h and the interrupt vector is at 0004h.
7.5.2 DATA MEMORY ORGANIZATION
The data memory is partitioned into four banks which contain the General
Purpose Registers (GPR) and the Special Function Registers (SFR). The Special
Function Registers are located in the first 32 locations of each bank. The
General Purpose Registers, implemented as static RAM, are located in the last
96 locations of each Bank. The actual number of General Purpose Resisters
(GPR) implemented in each Bank depends on the device. All other RAM is
unimplemented and returns ‘0’ when read. RP<1:0> of the STATUS register are
the bank select bits:
RP1 RP0
0 0 → Bank 0 is selected
0 1 → Bank 1 is selected
1 0 → Bank 2 is selected
1 1 → Bank 3 is selected
7.5.2.1 GENERAL PURPOSE REGISTER
The register file is organized as 368 x 8 in the PIC16F886/PIC16F887.
Each register is accessed, either directly or indirectly, through the File Select
Register (FSR).
37
7.5.2.2 SPECIAL FUNCTION REGISTERS
The Special Function Registers are used by the CPU and peripheral functions
for controlling the desired operation of the device. These registers are static
RAM. The special registers can be classified into two sets as
1. Core
2. Peripheral.
7.6 MPLAB IDE
7.6.1 INTRODUCTION
Integrated Development Environment (IDE) is an application that has
multiple functions for software development. MPLAB IDE is an executable
program that integrates a complier, an assembler, a project manager, an editor, a
debugger, simulator and an assortment of other tools within one windows
application. A user developing an application should be able to write code,
compile, debug and test the application without leaving the MPLAB IDE
desktop.
7.6.2 FEATURES
MPLAB IDE is a Windows Operating System (OS) based Integrated
Development Environment for the PIC MCU families. The MPLAB IDE
provides the ability to:
Create and edit source code using the built-in editor.
Assemble, compile and link source code.
38
Debug the executable logic by watching program flow with the
built-in simulator or in real time with in-circuit emulators or in-
circuit debuggers.
Make timing measurements with the simulator or emulator.
View variables in Watch windows.
Program firmware into devices with device programmers.
7.6.3 DESIGN CYCLE
The design cycle for developing an embedded controller application is:
1) Do the high level design – From the features and performance desired,
decide which PIC device you need, then design the associated hardware
circuitry.
2) Knowing which peripherals and pins control your hardware, write the
software. Use either assembly language, which is directly translatable into
machine code, or using a compiler that allows a more natural language for
creating programs. With these Language Tools you can write and edit code that
is more or less understandable, with constructs that help you organize your
code.
3) Compile or assemble the software using a Language Tool to convert your
code into machine code for the PIC device.
4) Test your code. Usually a complex program does not work exactly the way
you might have imagined, and “bugs” need to be removed from your design to
get it to act properly.
5) “Burn” your code into a microcontroller and verify that it executes correctly
in your finished application.
39
7.7 EMBEDDED C
7.7.1 INTRODUCTION
Embedded C is a set of language extensions for the IC programming
language by the C standards committee to address common issues that exist
between C extensions for different embedded systems. Historically, embedded
C programming requires nonstandard extensions to the C language in order to
support exotic features such as fixed-point arithmetic, multiple distinct memory
banks and basic I/O operations. In 2008, the C standards Committee extended
the C language to address these issues by providing a common standard for all
implementations to adhere to. It includes a number of features not available in
normal C such as fixed-point arithmetic, names address spaces and basic I/O
hardware addressing.
Embedded C uses most of the syntax and semantics of standard C. e.g.,
main() function , variable definition, data type declaration, conditional
statements(if, else, case), loops( while, for), functions, arrays and strings,
structures and union, bit operations, macros, etc.
7.7.2 ADVANTAGES
It is small and simpler to learn, understand, program and debug.
Compared to assembly language, C code written is more reliable and
scalable, more portable between different platforms.
C compliers are available for almost all embedded devices.
Unlike assembly language, C has advantage of process or independence
and is not specific to any particular microprocessor/microcontroller or
any system. This makes it convenient for a user to develop programs that
can run on most of the systems.
40
As C combines functionality of assembly language and features of high
level languages, C is treated as a 'middle-level computer language' or
'high level assembly language'.
It is fairly efficient.
It supports access to I/O and provides ease of management for large
embedded projects.
41
CHAPTER 8
CONTROL UNITS
8.1 SPEED CONTROL
When the vehicle enters the school zone, the speed of the vehicle should
be adjusted so as to avoid accidents. This function is implemented using the
speed control module.
An RF transmitter present in the school zone sends the digital data
allocated for that zone (in this case, school zone corresponds to the data 1110)
in the form of serial data using a HT12E encoder explained in chapter-4. By RF
transmission, the RF receiver collects the data and decodes the serial data back
to parallel data which is sent to the PIC16F887 microcontroller for processing.
The PIC microcontroller is programmed in embedded C using MPLAB IDE
software.
Here, the speed is manually altered using a potentiometer. According to
the signal from this POT, the PIC is programmed to generate a Pulse Width
Modulated (PWM) signal with the voltage reduced to its preset threshold value
when the vehicle unit enters the school zone. This PWM signal is given to a DC
motor through a driver circuit as shown in Fig.8.1.1
42
Fig.8.1.1 Circuit Diagram of Speed Control Unit
The circuit consists of a Darlington transistor pair to adjust the gain to the
required level and the speed change is shown using a DC motor. Thus, when the
vehicle unit is present in the school zone, its speed cannot be increased beyond
a preset value.
43
8.2HORN CONTROL
When the vehicle enters the hospital zone, the horn intensity of the
vehicle is to be adjusted. This function is implemented using the horn control
module.
An RF transmitter present in the hospital zone sends the digital data
allocated for that zone (in this case, hospital zone corresponds to the data 1101)
in the form of serial data using a HT12E encoder explained in chapter-4. By RF
transmission, the RF receiver collects the data and decodes the serial data back
to parallel data which is sent to the PIC16F887 microcontroller for processing.
The PIC microcontroller is programmed in embedded C using MPLAB IDE
software.
Here, the horn is manually switched using a push button switch.
According to the signal from this switch, the PIC is programmed to generate an
analog signal with the voltage reduced to its preset threshold value when the
vehicle unit enters the hospital zone and thereby reducing the intensity of the
horn through a driver circuit as shown in Fig.8.2.1
Fig 8.2.1 Circuit Diagram of Horn control Unit
44
It consists of a Darlington transistor pair to adjust the gain levels and a
relay, which acts a switch between high (+12V) and low (+5V) levels. Here, a
buzzer is used to play the role of a horn of the vehicle.
8.2.1 RELAY
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.
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.
Fig 8.2.2 Relay
Relays are usually SPDT or DPDT but they can have many more sets of
switch contacts. The relay's switch connections are labeled COM, NC and NO:
COM = Common, always connected 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.
45
Fig 8.2.3 Pin Description of Relay
8.2.2 HORN (Buzzer)
A buzzer or beeper is a signaling device, usually electronic, typically
used in automobiles, household appliances such as a microwave oven, or game
shows.
Fig 8.2.4 Buzzer
It uses a ceramic-based piezoelectric sounder which makes a high-pitched
tone in the form of a continuous or intermittent buzzing or beeping sound.
Usually these are hooked up to "driver" circuits which vary the pitch of the
sound or pulse the sound on and off.
46
8.3 HEADLIGHT CONTROL
While driving the vehicle in the highway with high beam headlights can
increase the driver’s visibility, it can prove to be a blinding hazard for other
drivers. Thus, it is essential to control the vehicle’s headlight.
An RF transmitter present in the highway sends the digital data allocated
for that zone (in this case, highway zone corresponds to the data 1011) in the
form of serial data using a HT12E encoder explained in chapter-4. By RF
transmission, the RF receiver collects the data and decodes the serial data back
to parallel data which is sent to the PIC16F887 microcontroller for processing.
The PIC microcontroller is programmed in embedded C using MPLAB IDE
software.
Here, the headlight is manually altered using a SPDT switch. According
to the signal from this switch, the PIC is programmed to generate a Pulse Width
Modulated (PWM) signal with the voltage reduced to its preset threshold value
when the vehicle unit enters the highway. This PWM signal is given to the
vehicle’s headlights through a driver circuit as shown in Fig.8.3.1. This is used
to provide automatic switching between high and low beam headlights.
Fig 8.3.1 Circuit Diagram of Headlight Control Unit
47
The circuit consists of a Darlington transistor pair to adjust the gain to the
required level. Here, a bulb or a flashlight maybe used in place of the vehicle
headlights. Thus, the automatic headlight control can perform a great deal in
reducing the manual efforts and fatigue of drivers in dipping the headlight while
driving through the highway and thus provide safe driving without blinding the
other drivers.
48
CHAPTER 9
CONCLUSION
In this project, we have demonstrated a possible method that can be
implemented in order to reduce the accidents in the country. Also it reduces the
discomfort experienced by the people in hospitals due to continuous honking.
This method controls the head light intensity which is a major cause of
accidents in highways. The automatic head light intensity control can perform a
great deal in reducing the manual efforts and fatigue of drivers in dipping the
head light while driving through the highway and thus provides a safe driving
without blinding the other drivers. This project can be implemented in heavily
populated areas. The receiver has to be fitted in each vehicle which will reduce
the risk of collisions and its penalties. When implemented using antennas, it can
cover a wider range. This project can be implemented in automobiles using
cruise control systems.
49
REFERENCES
[1] Ankita Mishra, Harshala Bakshi, Jyoti Solanki, Pranav Paranjpe, Priyanka
Saxena (2012), ‘Design of RF based speed control system for vehicles’,
International Journal of Advanced Research in Computer and Communication
Engineering, Vol. 1, Issue 8.
[2] Abdul Rahim Makandar, Deepa B Chavan, Faizal Hakeem Khan, Syed
Azimuddin Inamdar (2014), ‘Automatic Vehicle Speed Reduction System using
RF technology’, International Journal of Engineering Research and
Applications, Vol. 4, Issue 4, pp. 13-16.
[3] Atul Kumar Dewangan, Nibbedita Chakraborty, Sashi Shukla, Vinod Yadu
(2012), ‘PWM Based Automatic Closed Loop Speed Control of DC Motor’,
International Journal of Engineering Trends and Technology, Volume3, Issue 2.
[4] Larry O'Cull, Richard H. Barnett, Sarah Alison Cox, “Embedded C
Programming and the Microchip PIC”, Volume 1.
[5] Mark Siegesmund, “Embedded C Programming: Techniques and
Applications of C and PIC MCUS”.
[6] Danny Causey, Muhammad Ali Mazidi and Rolin D. Mckinlay, “Pic
Microcontrollers and Embedded Systems”.
[7] Milan Verle, “Pic Microcontrollers-Programming in C”
[8] Han Way Huang and Leo Chartrand, “PIC Microcontroller: An Introduction
to Software & Hardware Interfacing”.