+ All Categories
Home > Documents > VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14....

VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14....

Date post: 18-Mar-2018
Category:
Upload: phamtram
View: 217 times
Download: 2 times
Share this document with a friend
54
VEHICLE SWITCHING SYSTEM USING RF TECHNOLOGY UNIVERSITY OF NAIROBI DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING DR. GEORGE KAMUCHA PROJECT NO. 69 27-Apr-15 OWINO MOSES ORIARE F17/36042/2010 DESIGNING AND IMPLEMENTING AN RF BASED VEHICLE SYSTEM TO SWITCH IGNITION OFF, LIGHTS ON/OFF AND TO SHUT/OPEN DOOR LOCK, OF A VEHICLE WITHIN A SHORT DISTANCE.
Transcript
Page 1: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

VEHICLE SWITCHING SYSTEM USING RF TECHNOLOGY

U N I V E R S I T Y O F N A I R O B I

D E P A R T M E N T O F E L E C T R I C A L

A N D I N F O R M A T I O N

E N G I N E E R I N G

D R . G E O R G E K A M U C H A

P R O J E C T N O . 6 9

2 7 - A p r - 1 5

OWINO MOSES ORIARE

F17/36042/2010

DESIGNING AND IMPLEMENTING AN RF BASED VEHICLE

SYSTEM TO SWITCH IGNITION OFF, LIGHTS ON/OFF AND TO

SHUT/OPEN DOOR LOCK, OF A VEHICLE WITHIN A SHORT

DISTANCE.

Page 2: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

i

DECLARATION OF ORIGINALITY NAME OF STUDENT: OWINO MOSES ORIARE

REGISTRATION NUMBER: F17/36042/2010

COLLEGE: Architecture and Engineering

FACULTY: Engineering

DEPARTMENT: Electrical and Information Engineering

COURSE: Bachelor of Science Electrical & Electronic Engineering

TITLE OF THE WORK: A Remote Vehicle Switching System

1) I understand what plagiarism is and I am aware of the university policy in this regard.

2) I declare that this final year project is my original work and has not been submitted elsewhere for

examination, award of degree or publication. Where other people‘s work or my work has been

used, this has properly been acknowledged and referenced in accordance with the University of

Nairobi‘s requirements.

3) I have not sought or used the services of any professional agencies to produce this work.

4) I have not allowed, and shall not allow anyone to copy my work with the intention of passing it

off as his/her own work.

5) I understand that any false claim in respect of this work shall result in disciplinary action, in

accordance with the university anti-plagiarism policy

Signature……………………………………………………………………………………….

Date……………………………………………………….…………………………………….

Page 3: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

ii

DEDICATION This project is dedicated to my family for the untiring love and support they have shown over the

whole period of my education.

Page 4: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

iii

ACKNOWLEDGEMENTS I would like to first acknowledge the Department of Electrical and Electronic Department to

grant me this opportunity to undertake this project.

I‘m very grateful to my supervisor, Dr. Kamucha for the effortless guidance and supervision he

bestowed during the working period of this project. He is truly one in a million.

I would like to thank my family, all my good friends and colleagues of the Class of 2015 for the

continuous encouragement and undying support.

Last but not least, I would like to thank the Almighty God for keeping me safe, sound and

healthy over the whole period of my undergraduate degree course.

Page 5: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

iv

ABSTRACT The project is aimed at designing a wireless remote vehicle system that has the option of

switching the vehicle ignition off, lights on/off, and to shut/open the vehicle door lock within a

short distance. The project incorporates the use of Radio Frequency (RF) technology in

achieving the wireless communication within the short distance.

In the past, drivers have been forced to manually do the above mentioned tasks while still within

the car. This traditional system has been prone to insecurity and inconvenience as drivers at

times tend to forget them and are forced to physically go back to the Car after alighting to secure

the car. Also remotely shutting/opening the vehicle door allows the drivers spend minimum time

beside the car trying to open/shut the door where they are vulnerable to mugging and hi-jacking.

This project therefore offers a solution for all the above problems by allowing all those vehicle

securing tasks be done easily and remotely. The project also simply offer a great deal of

convenience to drivers by allowing all the above tasks be done simply and remotely from a

simple touch of a button.

A microcontroller (ATmega 32), HT12 encoder and decoder and rf module (transmitter and

receiver) has been successfully used in designing a prototype that when integrated with a

vehicles electrical system can easily be used as a switching system.

This is an advanced technology for vehicle automation as it is used to make vehicles smarter

without requiring much switches on the vehicle.

Page 6: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

v

Table of Contents

DECLARATION OF ORIGINALITY .......................................................................................................... i

DEDICATION .............................................................................................................................................. ii

ACKNOWLEDGEMENTS ......................................................................................................................... iii

ABSTRACT ................................................................................................................................................. iv

LIST OF FIGURES ................................................................................................................................. vi

LIST OF TABLES .................................................................................................................................. vii

OBJECTIVE .............................................................................................................................................. viii

CHAPTER 1 INTRODUCTION .................................................................................................................. 1

1.1 JUSTIFICATION ............................................................................................................................... 1

1.2 SCOPE OF WORK ............................................................................................................................. 1

1.3 PROJECT REPORT ORGANISATION ............................................................................................ 1

CHAPTER 2 LITERATURE REVIEW ....................................................................................................... 2

2.1 PRINCIPLES OF RADIO COMMUNICATIONS ............................................................................ 2

2.2 WIRELESS SIGNALING THROUGH RF MODULE ...................................................................... 6

2.3 RF MODULE...................................................................................................................................... 7

2.4 ENCODER (HT12E) .......................................................................................................................... 9

2.5 DECODER (HT12D) ........................................................................................................................ 12

2.6 7805 VOLTAGE REGULATOR...................................................................................................... 16

2.7 ATMEGA 32 MICROCONTROLLER. ........................................................................................... 20

CHAPTER 3 DESIGN AND IMPLEMENTATION ................................................................................. 23

3.1BASIC OPERATION STRUCTURE OF THE SYSTEM ................................................................ 23

3.2 IMPLEMENTATION. ...................................................................................................................... 26

CHAPTER 4 TESTING, RESULTS AND ANALYSIS ............................................................................ 39

4.1 DISCUSSION. .................................................................................................................................. 40

4.2 RECOMMENDATIONS .................................................................................................................. 40

References ................................................................................................................................................... 41

APPENDIX ............................................................................................................................................. 42

i. BILL OF QUANTITIES ................................................................................................................. 42

ii. C LANGUAGE CODE ................................................................................................................... 42

Page 7: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

vi

LIST OF FIGURES 1. Fig 1.1 Radio Waves Characterization

2. Fig 1.2 Wireless Communication System Block Diagram

3. Fig 1.3 Modulator and Demodulator Block Diagram

4. Fig 1.4 Building Blocks

5. Fig 1.5 Block Diagram Transmitter

6. Fig 1.6 Block Diagram Receiver

7. Fig 2.1 Wireless Communication through RF Module

8. Fig 2.2 RF Module Pair Pin Configuration

9. Fig 2.3 HT12 Encoder

10. Fig 2.4 Pin Diagram and Description

11. Fig 2.5 Oscillator of HT12E

12. Fig 2.6 Transmission Timing for HT12E

13. Fig 2.7 Working Flowchart for HT12E

14. Fig 2.8 Typical Application Circuit for HT12E

15. Fig 2.9 HT12 Decoder

16. Fig 2.10 Pin diagram and Description

17. Fig 2.11 Oscillator for HT12D

18. Fig 2.12 HT12 Decoder Timing

19. Fig 2.13 Decoder Working Flow Chart

20. Fig 2.14 Typical Decoder Circuit Diagram

21. Fig 2.15 Connection Diagram of RF Module with Encoder and Decoder

22. Fig 2.16 Voltage Regulator Pin Diagram

23. Fig 2.17 Circuit Connection

24. Fig 2.18 ATmega 32 Pin Configuration

25. Fig 3.1 Block Diagram Transmitter

26. Fig 3.2 Block Diagram Receiver

27. Fig 3.3 Working Flowchart

28. Fig 3.4 USBasp Programmer

29. Fig 3.5 Programmer Pin Configurations

30. Fig 3.6 Transmitter Schematic Diagram

31. Fig 3.7 Receiver Schematic Diagram

32. Fig 3.8 Simple Switch Pull-up Circuit

33. Fig 3.9 Switch Bounce produced on switch press

34. Fig 3.10 Switch Debounce Circuit

35. Fig 3.11 Debouncing circuit in switch Open and Closed States

36. Fig 3.12 Final Transmitter Circuit

37. Fig 3.13 Final Receiver Circuit

38. Fig 3.14 Final Transmitter Circuit

Page 8: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

vii

LIST OF TABLES 1. RF Pin Functions

2. LM7805 Pin Configuration

3. ATmega 32 Key Parameters

4. Components Justification

5. Results.

Page 9: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

viii

OBJECTIVE To design and implement an RF based vehicle system to switch ignition off, lights on/off and to

shut/open door locks of a vehicle within a short distance

SPECIFIC OBJECTIVES

To design and implement a microcontroller based control unit using receiver, transmitter,

encoder, decoder, ATmega 32 microcontroller among other system components.

To develop a computer programme/code using C language for the working of the MCU.

To develop and implement a circuit diagram that will work in a manner so as to meet the

objective of the project.

Page 10: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

1

CHAPTER 1 INTRODUCTION

1.1 JUSTIFICATION A successful design and implementation would see a significant improvement in security

especially for motorists, as they are allowed a fast secure and convenient method of securing

their vehicles by a simple push of a button.

It also enables efficiency in terms of easier switching of the vehicle lights and ignition when they

are not in use preventing unnecessary wastage of resources.

1.2 SCOPE OF WORK This project entails the following:

Understanding microcontroller‘s structure and functionality.

Understanding the ATmega 32 internal components specifically and its working

principle.

Interfacing microcontrollers with input/output devices specifically the load buttons,

encoder/decoder and output LEDs

Developing a microcontroller program or code using C language.

1.3 PROJECT REPORT ORGANISATION

Preface: Contains the Abstract, Objectives, Justification, Scope of Work and Project Report

Organization.

Chapter 1: Introduction to RF Communication, Wireless Communication System and the Basic

Operation Structure of the Project.

Chapter 2: Literature review, Contains basic information about RF Module, Encoder and Decoder,

7805 Voltage Regulator and the microcontroller ATmega 32.

Chapter 3: Design and Implementation.

Design; Contains the basic design layout of the system.

Implementation; Contains;

Pseudo code

Actual Code

Illustration of Simulation Process

Results and Conclusion

The Fabrication Process

Limitation

Testing

Page 11: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

2

CHAPTER 2 LITERATURE REVIEW

2.1 PRINCIPLES OF RADIO COMMUNICATIONS Radio waves belong to the electromagnetic radiation family, which includes x-ray, ultraviolet,

and visible light. Much like the gentle waves that form when a stone is tossed into a still lake,

radio signals radiate outward, or propagate, from a transmitting antenna. However, unlike water

waves, radio waves propagate at the speed of light.

We characterize a radio wave in terms of its amplitude, frequency, and wavelength (Figure 1-1).

Fig 1.1 Radio Waves Characterization

Radio wave amplitude, or strength, can be visualized as its height being the distance between its

peak and its lowest point. Amplitude, which is measured in volts, is usually expressed in terms of

an average value called root-mean-square, or RMS. The frequency of a radio wave is the number

of repetitions or cycles it completes in a given period of time. Frequency is measured in Hertz

(Hz); one Hertz equals one cycle per second. Thousands of Hertz are expressed as kilohertz

(kHz), and millions of Hertz as megahertz (MHz). You would typically see a frequency of

2,345,000 Hertz, for example, written as 2,345 kHz or 2.345 MHz Radio wavelength is the

distance between crests of a wave. The product of wavelength and frequency is a constant that is

equal to the speed of propagation. Thus, as the frequency increases, wavelength decreases, and

vice versa. Radio waves propagate at the speed of light (300 million meters per second). To

determine the wavelength in meters for any frequency, divide 300 by the frequency in

Page 12: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

3

megahertz. So, the wavelength of a 10 MHz wave is 30 meters, determined by dividing 300 by

10.

Radio frequencies are regulated according to transmission type: emergency, broadcast, voice,

Morse code, facsimile, and data. Frequency allocations are governed by international treaty and

national licensing authorities. The allocation of a frequency is just the beginning of radio

communications. By itself, a radio wave conveys no information. It‘s simply a rhythmic stream

of continuous waves (CW). When we modulate radio waves to carry information, we refer to

them as carriers. To convey information, a carrier must be varied so that its properties — its

amplitude, frequency, or phase (the measurement of a complete wave cycle) — are changed, or

modulated, by the information signal. (1)

SUMMARY

Radio signals propagate from a transmitting antenna as waves through space at the speed of light.

Radio frequency is expressed in terms of hertz (cycles per second), kilohertz (thousands of

Hertz), or megahertz (millions of Hertz). Frequency determines the length of a radio wave; lower

frequencies have longer wavelengths and higher frequencies have shorter wavelengths. Long-

range radio communications take place in the high-frequency (HF) range of 1.6 to 30 MHz

Different portions of this band are allocated to specific radio services under international

agreement. Modulation is the process whereby the phase, amplitude, or frequency of a carrier

signal is modified to convey intelligence. HF radio waves can propagate as sky waves, which are

refracted from the earth‘s ionosphere, permitting communications over long distances. (1)

Fig 1.2 Wireless Communication System Block Diagram

Page 13: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

4

Fig 1.3 Modulation and Demodulation Block Diagram

Basic Building Blocks of an RF System include;

a. RF-IC

Transmitter

Receiver

Transceiver

System-on-Chip (SoC); typically

transceiver with integrated

microcontroller

b. Crystal

Reference frequency for the LO and the carrier frequency

c. Balun

Balanced to unbalanced

Converts a differential signal to a single-ended signal or vice versa

d. Matching

e. Filter

Used if needed to pass regulatory requirements / improve selectivity

f. Antenna (2)

Page 14: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

5

Fig 1.4 Building Blocks

There are various ways of extending the range of an RF system, these include;

Increase the Output power

Add an external Power Amplifier (PA)

Increase the sensitivity

Add an external Low Noise Amplifier (LNA)

Increase both output power and sensitivity

Add PA and LNA

Use high gain antennas

Regulatory requirements need to be followed

Page 15: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

6

2.2 WIRELESS SIGNALING THROUGH RF MODULE

Radio Frequency (RF) communication is the most preferred and cheapest method of data

transmission. There are two way to transmit data normally;

parallel transmission

serial transmission

When we want to transmit parallel data we need a parallel number of links, the number of wires

for wired communication depend upon how many bit you want to transmit at a time. For instance

8 bit, 16 bit, 32bit, whereas, in series transmission, only one channel is require for wireless

transmission or one wire for wire communication. RF module uses serial communication

method.

There are two options for RF wireless communication;

with use of a microcontroller (which convert parallel data into serial data)

with use of encoder and decoder (which convert parallel data into serial data directly)

Fig 2.1 Wireless Communication through RF Module (3)

In this project, we will use the second method, without use of microcontroller due the cheapness

and simplicity involved in using of an encoder and decoder as opposed to using a

microcontroller. To make communication with the use of encoder and decoder we use here

HT12E Encoder for encoding and HT12D Decoder for decoding.

Before discussing the interfacing of encoder and decoder with RF MODULE, below are some of

the important things about RF MODULE; (3)

Page 16: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

7

2.3 RF MODULE

RF Modules are used to wirelessly transfer data. For many applications the medium of choice is

RF since it does not require line of sight, this makes them most suitable for remote control

applications. RF modules are widely used in electronic design owing to the difficulty of

designing radio circuitry.

The RF module is chosen depending on the type of application. For short range wireless control

applications, an ASK RF Transmitter-Receiver Module of frequency 315 MHz or 433 MHz is

most suitable. They are quite compact and cheap. RF modules are most often used in medium

and low volume products for consumer applications such as garage door openers, wireless alarm

systems, industrial remote controls, smart sensor applications, and wireless home automation

systems. They are sometimes used to replace older infra-red communication designs as they have

the advantage of not requiring line-of-sight operation. (4)

(5)

Fig 2.2 RF Module Pair Pin Configuration

Page 17: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

8

Pin No. Name Function

1 GND Ground

2 DATA Serial Data Output

3 NC No Connection

4 Vcc Supply Voltage (5V)

5 Vcc Supply Voltage (5V)

6 GND Ground

7 GND Ground

8 ANT Antenna Input Table 1 RF Pin function

Some important features of RF MODULE are...

Range in open space(Standard Conditions) : 100 Meters

Tx supply voltage : 3v - 6v

TX Output Power : 4 ~ 12 Dbm

Low Power Consumption

RX Receiver Frequency : 433 MHz

RX Typical Sensitivity : 105 Dbm

RX Supply Current : 3.5 mA

RX IF Frequency : 1MHz (4)

Encoding and Decoding can be explained as follows; encoding is wrapping up the data. The data

could be anything like simple binary data (in the form of 1's and 0's). The wrapped data is called

as a Packet. This packet is sent through a medium (―Through wire or wireless‖) to the decoder

part where it gets unwrapped or decoded. It is exactly similar to posting an envelope. Encoding is

when you put the letter into envelope, the postman is medium to take the envelope to the

recipient and when recipient opens the envelope then it is called decoding.

Page 18: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

9

2.4 ENCODER (HT12E)

Fig 2.3 HT12 Encoder

Here ‗12‘ in the name of the ic and indicates it has 8 address line and 4 data line. And 'E' and 'D'

letter indicates encoder and decoder respectively.

First considering the Encoding side. The encoder has four input lines. These lines are used to

give input which we want to encode. In encoding, we are wrapping up the data which means if

we want to send a binary signal ‗1001‘ to other end, we have to make data pins as ‗1001‘. Now,

to make data pin like this, we give high or 5 volts (which in digital means‗1‘) to pins ‗D0‘ and

‗D3‘ while providing pins ‗D1‘ and ‗D2‘ with 0 volt, (Ground). This altogether gives us ‗1001‘

which is transmitted out from the ‗Data out‘ pin of the HT12E. The input given to data pin is in

parallel form which is being transmitted into serial form from the data output pin.

HT12E is able to operate in a wide voltage range from 2.4V to 12V and has a built in oscillator

which requires only a small external resistor. Its power consumption is very low, standby current

is 0.1μA at 5V VDD and has high immunity against noise. It is available in 18 pin DIP (Dual

Inline Package) and 20 pin SOP (Small Outline Package) as given below.

Page 19: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

10

Fig 2.4 Pin Diagram and Description

HT12E – Pin Diagram

VDD and VSS are power supply pins which are used to connect positive and negative of

the power supply respectively.

OSC1 and OSC2 are used to connect external resistance for the internal oscillator.

OSC1 is the oscillator input pin and OSC2 is the oscillator output pin.

Fig 2.5 Oscillator of HT12E

TE is used for enabling the transmission and is an active low input.

A0 – A7 are the input address pins. By using these pins we can provide a security code

for the data. These pins can be connected to VSS or left open.

D8 – D11 are the input data pins. These pins can be connected to VSS or may left open

for sending LOW and HIGH respectively.

DOUT – It is the serial data output of the encoder and can be connected to a RF

transmitter.

Page 20: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

11

Fig 2.6 Transmission timing for HT12E

The HT12E 212

series encoder starts a 4 word transmission cycle upon receiving transmission

enable signal on TE input. This output cycle will `repeat as long as the transmission is enabled.

When the transmission enable (TE) signal switches to HIGH, the encoder output completes the

current cycle and stops as shown above. The encoder will be in the Standby mode when the

transmission is disabled.

Fig 2.7 Working flowchart for HT12E Fig 2.8 Typical application circuit for HT12E

Page 21: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

12

2.5 DECODER (HT12D)

Fig 2.9 HT12 Decoder

The encoded data which is coming from the transmitter side goes into the Data in (Din) pin. The

data which was in serial order gets decoded and the output is generated at the for data line pins in

same order as that on transmitter pin.

When we use single pair of encoder and decoder we does not need to connect the address lines

and therefore leave it open. But when we have many decoders in a circuit and only one encoder,

at that time we can use such address line for addressing decoder. This means a particular address

for a particular decoder. So our data does not leak to other decoder, which is the most important

thing in wireless communication.

HT12D is a CMOS LSI IC and is capable of operating in a wide voltage range from 2.4V to

12V. Its power consumption is low and has high immunity against noise. The received data is

checked 3 times for more accuracy. It has built in oscillator, we need to connect only a small

external resistor. As HT12E, it is available in 18 pin DIP (Dual Inline Package) and 20 pin SOP

(Small Outline Package) as given below.

Page 22: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

13

Fig 2.10 Pin Diagram and Description

HT12D – Pin Diagram

VDD and VSS are used to provide power to the IC, Positive and Negative of the power

supply respectively. As I said earlier its operating voltage can be in the range 2.4V to

12V

OSC1 and OSC2 are used to connect external resistor for internal oscillator of HT12D.

OSC1 is the oscillator input pin and OSC2 is the oscillator output pin as shown in the

figure below.

Fig 2.11 Oscillator of HT12D

A0 – A7 are the address input pins. Status of these pins should match with status of

address pin in HT12E (used in transmitter) to receive the data. These pins can be

connected to VSS or left open.

Page 23: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

14

DIN is the serial data input pin and can be connected to a RF receiver output.

D8 – D11 are the data output pins. Status of these pins can be VSS or VDD depending

upon the received serial data through pin DIN.

VT stands for Valid Transmission. This output pin will be HIGH when valid data is

available at D8 – D11 data output pins.

Fig 2.12 HT12D Decoder Timing

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.

Page 24: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

15

1Fig 2.13 Decoder working flowchart Fig 2.14 Typical decoder circuit diagram

We can say that clock pulses are "HEART BEATS" of digital system. To generate clock pulse

we need an oscillator. And here we also deal with digital data so we need oscillator, which is

inbuilt in both the encoder and decoder, we just need to connect resistor across it of typical value

such as for encoder between pin no.15 and 16 connect 270 kohm resistor and in case of decoder

between pin no. 15 and 16 connect 27k resistor.

VT pins (valid Transmission) :

Page 25: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

16

The valid transmission pin in the decoder shows that the transmitter address and the receiver

address are same and is ready to receive the data from the encoder side. (6)

Fig 2.15 Connection Diagram of RF Module with Encoder and Decoder (6)

2.6 7805 VOLTAGE REGULATOR 7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear voltage

regulator ICs. The voltage source in a circuit may have fluctuations and would not give the fixed

voltage output. The voltage regulator IC maintains the output voltage at a constant value. The xx

in 78xx indicates the fixed output voltage it is designed to provide. 7805 provides +5V regulated

power supply. Capacitors of suitable values can be connected at input and output pins depending

upon the respective voltage levels.

Page 26: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

17

2.16 Pin diagram (7)

Pin Description:

Pin No Function Name

1 Input voltage (5V-18V) Input

2 Ground (0V) Ground

3 Regulated output; 5V (4.8V-5.2V) Output

Table 2 LM7805 Pin Configuration

A regulated power supply is very much essential for several electronic devices due to the

semiconductor material employed in them have a fixed rate of current as well as voltage. The

device may get damaged if there is any deviation from the fixed rate. The AC power supply gets

converted into constant DC by this circuit. By the help of a voltage regulator DC, unregulated

output will be fixed to a constant voltage. The circuit is made up of linear voltage regulator 7805

along with capacitors and resistors with bridge rectifier made up from diodes. From giving an

Page 27: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

18

unchanging voltage supply to building confident that output reaches uninterrupted to the

appliance, the diodes along with capacitors handle elevated efficient signal conveyal. (7)

ICs regulator is mainly used in the circuit to maintain the exact voltage which is followed by the

power supply. A regulator is mainly employed with the capacitor connected in parallel to the

input terminal and the output terminal of the IC regulator. For the checking of gigantic

alterations in the input as well as in the output filter, capacitors are used. While the bypass

capacitors are used to check the small period spikes on the input and output level. Bypass

capacitors are mainly of small values that are used to bypass the small period pulses straightly

into the Earth.

A circuit diagram having regulator IC and all the above discussed components arrangement

revealed in the figure below.

Fig 2.17 Circuit Connection

Component Function

C1

This capacitor is known as bypass capacitor and is employed to bypass

extremely tiny duration spikes to the ground with no distress the other

components.

C2

C2 is the filter capacitor employed to steady the slow changes in the voltage

applied at the input of the circuit. Escalating the value of the capacitor amplify

the stabilization as well as the declining value of the capacitor reduces the

stabilization. Moreover this capacitor is not alone capable to ensure very

constricted period spikes emerge at the input.

C3

C3 is known as a filter capacitor employed in the circuit to steady the slow

alterations in the output voltage. Raising the value of the capacitor enlarges the

stabilization furthermore declining the value of the capacitor declined the

stabilization. Moreover this capacitor is not alone capable to ensure very fine

Page 28: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

19

Component Function

duration spikes happen at the output.

C4 C4 is known as bypass capacitor and worked to bypass very small period

spikes to the earth with no influence the other components.

U1

U1 is the IC with positive DC and it upholds the output voltage steady exactly

at a constant value even although there are major deviations in the input

voltage. (7)

SNO COMPONENT TYPE VALUE

1 C1 CAPACITOR 0.1 mfd

2 C2 CAPACITOR 1000 mfd

3 C3 CAPACITOR 1000 mfd

4 C4 CAPACITOR 0.1 mfd

5 U1 POSITIVE DC REGULATOR 7805

Advantages

78xx series ICs do not require additional components to provide a constant, regulated source of

power, making them easy to use, as well as economical and efficient uses of space. Other voltage

regulators may require additional components to set the output voltage level, or to assist in the

regulation process. Some other designs (such as a switched-mode power supply) may need

substantial engineering expertise to implement.

78xx series ICs have built-in protection against a circuit drawing too much power. They have

protection against overheating and short-circuits, making them quite robust in most applications.

In some cases, the current-limiting features of the 78xx devices can provide protection not only

for the 78xx itself, but also for other parts of the circuit. (7)

Disadvantages

The input voltage must always be higher than the output voltage by some minimum amount

(typically 2.5 volts). This can make these devices unsuitable for powering some devices from

certain types of power sources (for example, powering a circuit that requires 5 volts using 6-volt

batteries will not work using a 7805).

Page 29: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

20

As they are based on a linear regulator design, the input current required is always the same as

the output current. As the input voltage must always be higher than the output voltage, this

means that the total power (voltage multiplied by current) going into the 78xx will be more than

the output power provided. The extra input power is dissipated as heat. This means both that for

some applications an adequate heat sink must be provided, and also that a (often substantial)

portion of the input power is wasted during the process, rendering them less efficient than some

other types of power supplies. When the input voltage is significantly higher than the regulated

output voltage (for example, powering a 7805 using a 24 volt power source), this inefficiency

can be a significant issue. (7)

2.7 ATMEGA 32 MICROCONTROLLER. The high-performance, low-power Atmel 8-bit AVR RISC-based microcontroller combines

32KB of programmable flash memory, 2KB SRAM, 1KB 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) 32 Kbytes

Pin Count 44

Max. Operating Freq. (MHz) 16 MHz

CPU 8-bit AVR

No. of Touch Channels 16

Hardware QTouch Acquisition No

Max I/O Pin 32

Ext Interrupts 3 (8)

USB Speed No Table 3 ATmega 32 Key Parameters

Page 30: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

21

Fig 2.18 ATmega 32 Pin configuration

Pin Descriptions;

VCC Digital supply voltage.

GND Ground.

Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter. Port A

also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pin

scan provide internal pull-up resistors (selected for each bit). The Port A output buffers

have symmetrical drive characteristics with both high sink and source capability. When

pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current

if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset

condition becomes active, even if the clock is not running.

Page 31: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

22

Port B (PB7..PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port B output buffers have symmetrical drive

characteristics with both high sink and source capability. As inputs, Port B pins that are

externally pulled low will source current if the pull-up resistors are activated. The Port B

pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Port C (PC7..PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port C output buffers have symmetrical drive

characteristics with both high sink and source capability. As inputs, Port C pins that are

externally pulled low will source current if the pull-up resistors are activated. The Port C

pins are tri-stated when a reset condition becomes active, even if the clock is not running.

If the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI), PC3(TMS) and

PC2(TCK) will be activated even if a reset occurs. The TD0 pin is tri-stated unless TAP

states that shift out data are entered

Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port D output buffers have symmetrical drive

characteristics with both high sink and source capability. As inputs, Port D pins that are

externally pulled low will source current if the pull-up resistors are activated. The Port D

pins are tri-stated when a reset condition becomes active, even if the clock is not running.

RESET Reset Input. A low level on this pin for longer than the minimum pulse

length will generate a reset, even if the clock is not running. Shorter pulses are not

guaranteed to generate a reset.

XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock

operating circuit.

XTAL2 Output from the inverting Oscillator amplifier.

AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It

should be externally connected to VCC, even if the ADC is not used. If the ADC is used,

it should be connected to VCC through a low-pass filter.

AREF AREF is the analog reference pin for the A/D Converter.

(9)

Page 32: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

23

CHAPTER 3 DESIGN AND IMPLEMENTATION

3.1BASIC OPERATION STRUCTURE OF THE SYSTEM

The remote vehicle switching system consists of transmitting unit, receiving unit and the

intelligent vehicle interface unit. The data receiver is embedded in the vehicle intelligent control

system whereas the transmitter unit is kept with the vehicle owner. This enables an active

communication path between the vehicle and the owner (or driver), as long as the two ends are

within the operating range of 20-100m. The basic operating structure of the system is as shown

in the flow chart below.

The proposed system uses a microcontroller of the ATmel family and a rectified power supply.

An RF transmitter is connected to the transmitter end with the help of an encoder device. The

push buttons are connected to the encoder as input switches. The commands are sent by the push

buttons to the receiver to control the electrical loads.

An RF receiver is connected to the receiver end with the help of a decoder device. The electrical

loads are controlled by the microcontroller outputs

The electrical loads are controlled by the RF remote wherein the commands are sent by the

transmitter, and based on these commands, the receiver controls the electrical loads when

corresponding switches are pressed to turn ON and OFF.

At a single press of the lights on/off button, door shut/open button or ignition off button, a

unique 4-bit data is fed into the encoder (HT12E) in the transmitter unit. The encoder itself has

an 8-bit address. The 8-bit address coupled with the 4-bit data results in a 12-bit parallel data.

The encoder converts the parallel data into serial data which is easily transmitted wirelessly to

the receiver unit embedded in the vehicle. The receiver unit consists of a decoder (HT12D). The

decoder then converts the serial data received back into parallel data. The 8-bit address is first

compared to the decoder address if the addresses are similar, the 4-bit data from the encoder

appears at the decoder output.

The decoder output is then connected to a microcontroller (ATmega 32) input. The decoded tag

is then identified by the receiver microcontroller using a special data recovery algorithm, then

special signals will be generated to perform the specified operations specified by the different

data tags, i.e. shut/open door, lights on/off and ignition off.

To demonstrate the working principle of the vehicle switching system, a simple system was

designed, which incorporates the use of LED‘s to show the three desired vehicle switching

actions.

The inputs are three load buttons that can be operated remotely from the transmitting side. The

intended operating range in open space (standard conditions ) is 100 meters.

Page 33: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

24

Button 1 was used to switch the vehicle lights ON and OFF, button 2 to shut and open the

vehicle doors and button 3 to switch the vehicle ignition off. The data from the three inputs will

then be encoded by the HT12E encoder and transmitted wirelessly through the RF transmitting

module.

The receiving end will then receive the encoded data through the RF receiving module. The data

will then be decoded by the HT12D decoder and the data fed into our ATmega 32

microcontroller input. The microcontroller will then produce corresponding outputs in its output

pins.

The three LED‘s were connected to the output and each is used to denote the different commands

as follows;

LED 1 ON will show that the vehicle lights are switched ON and in turn OFF will show

the vehicle lights have been switched OFF.

LED 2 ON will indicate the vehicle door shut and OFF will indicate the door is opened.

LED 3 will always be ON at the initials stage of the demonstration to indicate that the

vehicle ignition is ON. LED 3 will then be switched OFF to indicate the vehicle ignition

is OFF. This is so because the design was intended to only enable switching the vehicle

ignition OFF remotely and not back ON.

At the actual implementation level, the vehicle electrical system would be incorporated in place

of the LEDs to interpret the signals accordingly and perform the corresponding tasks on the

vehicle.

The below flow charts summarized the designs used in the implementation of the above project;

Page 34: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

25

2.1 Block Diagram Transmitter

9v BATTERY

VOLTAGE REGUATOR

ENC

OD

ER

LOAD1

LOAD2

1

LOAD3

RF

MO

DU

LE T

RA

NSM

ITTE

R

C PROGRAM

9v

BATTERY

VOLTAGE

REGUATOR

DE

CO

DE

R ATMEGA 32

MICROCONTROLLER

RF

MO

DU

LE

TR

AN

SM

ITT

ER

LOAD

LEDS

3.2 Block Diagram Receiver

Page 35: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

26

3.2 IMPLEMENTATION.

The microcontroller ATmega 32 was chosen to implement the above design. In our days, there

have been many advancement in the field of Electronics and many cutting edge technologies are

being developed every day, but still 8 bit microcontrollers have its own role in the digital

electronics market dominated by 16-32 & 64 bit digital devices. Although powerful

microcontrollers with higher processing capabilities exist in the market, 8bit microcontrollers

still hold its value because of their easy-to-understand-operation, very much high popularity,

ability to simplify a digital circuit, low cost compared to features offered, addition of many new

features in a single IC and interest of manufacturers and consumers.

ATmega 32 microcontroller was chosen because it offered the following advantages;

PIN count: Atmega32 has got 40 pins. Two for Power (pin no.10: +5v, pin no. 11:

ground), two for oscillator (pin 12, 13), one for reset (pin 9), three for providing

necessary power and reference voltage to its internal ADC, and 32 (4×8) I/O pins.

About I/O pins: ATmega32 is capable of handling analogue inputs. Port A can be used

as either DIGITAL I/O Lines or each individual pin can be used as a single input channel

to the internal ADC of ATmega32, plus a pair of pins AREF, AVCC & GND together

can make an ADC channel.

Digital I/O pins: ATmega32 has 32 pins (4portsx8pins) configurable as Digital I/O pins.

Timers: 3 Inbuilt timer/counters, two 8 bit (timer0, timer2) and one 16 bit (timer1).

Communication Options: ATmega32 has three data transfer modules embedded in it.

They are

Two Wire Interface

USART

Serial Peripheral Interface

Memory: It has 32Kbytes of In-System Self-programmable Flash program memory,

1024 Bytes EEPROM, 2Kbytes Internal SRAM. Write/Erase Cycles: 10,000 Flash /

100,000 EEPROM.

External Interrupt: 3External interrupt is accepted. Interrupt sense is configurable.

More Features: Up to 16 MIPS (Million Instructions Per Second) throughput at 16MHz.

Most of the instruction executes in a single cycle. Two cycle on-chip multiplication. 32 ×

8 General Purpose Working Registers (10)

Given its above specifications, it proved appropriate for the above design.

C programming language was used to develop a programming code for the working of the

microcontroller unit (MCU). It is however important to note that other programming language

Page 36: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

27

options are available and equally as efficient in achieving the wanted MCU function e.g.

Assembly Language.

Below is a pseudo code showing how we intended to design the MCU to function;

Step 1: Initialize PORT D, pins 5, 6 and 7 as the outputs of the MCU

Step 2: Initialize PORT B, pins 0, 1 and 2 as the inputs of the MCU

Step 3: Allow PORT D, pin 7 of the MCU to be unconditionally HIGH

Step 4: When input button 1 is pressed, the LOGIC value at PORT D pin 5 is inverted

i.e. if it was initially LOW it goes HIGH and vice-versa

Step 5: When input button 2 is pressed, the LOGIC value at PORT D pin 6 is also

inverted

Step 6: When input button 3 is pressed, the LOGIC value at PORT D pin 7 which was

unconditionally set to HIGH, goes LOW

End code

Page 37: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

28

3.3 Working flowchart

3.2.1 SIMULATION

To ensure that our code would function as intended, it was simulated in a virtual environment,

using Proteus 8.

Start

Is button one

pressed?

Led two toggle

(on/off)

Is button two

pressed?

Is button three

pressed?

Led one toggle

(on/off)

Led three off

End

Yes

No

Yes

No

Yes

No

Page 38: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

29

Input switches were connected directly to the MCU inputs. Pull up resistors were used to pull up

the inputs to VCC and closing the switch connected the input to GND. This is how we achieved

the ‗bit is clear‘ function as required in the developed code.

Led indicators were connected to the MCU outputs pins.

Simulation Results:

When switch 1 was closed once, the LED 1 went ON, and on closing it again, the LED 1 went

OFF.

When switch 2 was closed once, the LED 2 went ON, and on closing it again, the LED 2 went

OFF.

LED 3 was always ON and upon closing the switch once, it went OFF and despite closing the

switch again, it did not go ON until the MCU was reset.

Conclusion:

We can therefore safely conclude that our programme code would work as required and expected

during the actual implementation.

3.2.2 Fabrication

Step 1: Actual loading of the HEX code into the MCU

In order to program any microcontroller you need the HEX file. It is nothing but the machine

code for the microcontroller. This file is generated by the corresponding assembler software,

which converts programming code into machine code.

The USBasp programmer was used to do the programme loading. The USBasp is a USB based

programmer for the AVR, and uses AVRdude for burning hex files into AVR microcontroller.

Below is a figure of the programmer;

Page 39: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

30

3.4 USBasp Programmer

One end connects into the computer. This allows for us to transfer the compiled program from

the computer to the USBASP. The other end of the USBASP normally gets connected either to a

6-pin or a 10-pin cable, which can then get hooked up easily to a breadboard through header

pins. The 10-pin cable pin out is shown below

3.5 Programmer Pin Configuration

Regardless of whether the 6-pin cable or 10-pin cable is used, and it really doesn't matter, there

are 6 pins we are really wiring up and these are the MISO, SCK, RST, VTG, MOSI, and GND

connections.

Basically, we're connecting the USBASP to the AVR chip's MISO, SCK, RST, VTG, MOSI, and

GND connections that we are programming. This allows direct communication between the

USBASP and the target AVR chip.

Below is an explanation of each pin and their function.

Page 40: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

31

MOSI- (Master Out Slave In) - it allows the master device to send data to slave or target device.

MISO- (Master In Slave Out) - it allows slave device/target to send information to master device.

SCK – (serial clock) - this mutual clock shared between master and slave device for

synchronized communication.

Reset- (target AVR MCU Reset) - The reset pin for the AVR chip being programmed must be

put in active low in order for programming to occur.

VCC- (Power) - The master and slave device both need power in order to operate.

GND- (Common Ground) - The master and slave device must share a common power ground for

operation.

With this setup, the USBASP is the master device and the AVR chip we are programming is the

target, or slave device. The best way to think of it is the master device is doing the programming,

while the slave device is the subordinate device that is need of being programmed. In order for a

master device to program a slave device, they need have communication amongst each other.

The master device needs to be able to write data to the slave device's flash memory and be able

to receive data from the slave data. This is done through the MOSI and MISO pins. The MOSI

pin stands for Master Out Slave In. This is the pin by which the master device outputs, or writes,

data to the target AVR which is being programmed. MISO stands for Master In Slave Out. This

is the pin by which the slave device (AVR being programmed) can send information to the

master device. Both these communication pathways are essential to program a device. So the

MOSI and MISO pins establish communication amongst the master device and the slave device

it is to program.

The SCK pin is the clock. It is essential because in order for the master and slave device to

communicate, they need to have a time signal to communicate data in synchrony. The common

clock signal shared between the master and slave device allow for efficient communication.

The RST pin is an essential connection because it must be put to an active low connection in

order for programming to occur between the master and slave device. It is normally held high,

but for programming to occur, it must be put low. It is an active low pin. When the RST pin is

put low, the master slave can communicate on the SCK, MISO, and MOSI lines.

The remaining 2 connections, VCC and GND, are the simplest; they are for power. The AVR

chip being programmed and the master device doing the programming both need to power in

order to operate. (11)

Step 2: Schematic development.

Eagle software was used to design the schematic for both the transmitter and receiver circuit. The

design was as indicated below;

Page 41: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

32

3.6 Transmitter Schematic Diagram

Page 42: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

33

3.7 Receiver Schematic Diagram

It is of importance to note a few differences between the simulated circuit and the fabricated

design, i.e.

Switch debouncing

The left-hand image below shows a simple push switch with a pull-up resistor. The right hand

image shows the trace at the output terminal, Vout, when the switch is pressed. As can be seen,

pressing the switch does not provide a clean edge. If this signal was used as an input to a digital

counter, for example, you'd get multiple counts rather than the expected single count. Note that

the same can also occur on the release for a switch.

Page 43: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

34

The problem is that the contacts within the switch don't make contact cleanly, but actually

slightly 'bounce'. The bounce is quite slow, so you can recreate the trace, and the problem quite

easily. (12)

3.8 Simple Switch pull-up Circuit

3.9 Switch bounce produced on switch press

In the switch waveform the bouncing lasts for about 150us.

There are many different approaches to cleaning up switch bounce. Below is a debouncing

circuit. The basic idea is to use a capacitor to filter out any quick changes in the switch signal.

3.10 Switch debouncing circuit

The circuit's operation can be explained by looking at the equivalent circuits formed in the two

switch states, open and closed.

Page 44: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

35

3.11 Debouncing circuit in switch open and closed states

(1)

Starting with the switch open.

The capacitor C1 will charge via R1 and D1 with the time constant

In time, C1 will charge and Vb will reach within 0.7V of Vcc.

Therefore the output of the inverting Schmitt trigger will be a logic 0.

Now closing the switch

The capacitor will discharge via R2.

In time, C1 will discharge and Vb will reach 0V.

Therefore the output of the inverting Schmitt trigger will be a logic 1.

Although, bouncing will cause slight charging and discharging of the capacitor, the hysteresis of

the Schmitt trigger input will stop the output from switching.

Well the resistor R2 is required as a discharge path for the capacitor, without it, C1 will be shorted

when the switch is closed. Without the diode, D1, both R1 and R2 would form the capacitor

charge path when the switch is open. The combination of R1 and R2 would increase the capacitor

charge time, slowing down the circuit. (12). In our design however, we only had one resistor

(the pull-up resistor), therefore the diode was not necessary in the circuit implementation.

Protection Resistors

3.2.2.1 Calculating correct resistor values for over current protection

Page 45: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

36

The main reason protection resistors were used was safe-guarding the electronic components from over

current. The values of the resistors needed for safe operation were calculated using Ohm‘s law.

A typical LED has a voltage drop of 1.8V and a current of about 25mA. The microcontroller Pin has an

output voltage of 5V.

Using these values in our calculation.

V = (power source) – (voltage drop) = 5V – 1.8V = 3.2 V

I = 25 mA

Finding R:

R = V/I

Substituting the values, you will get

R = 3.2/0.025 = 128 Ohms. (12)

3.2.2.2 Practical easiness over theoretical correctness

However the above resister value is not available because it is not a standard resistor value. It is an apt

example of choosing practical easiness over theoretical correctness. (13)

Below are the standard values and are easier to find rather than other values.

{ 100, 220, 470, 1000, 2200, 4700, 10000 }

Looking at these values, it was found that 100 Ohm is less than 128 Ohm (that we calculated) and is quite

risky. The next higher easily available value is 220 Ohm.

When you substitute R=220 in the equation I=V/R

I = 3.2/220 ~= 14mA

The value of the current was found to be around 14mA. LED‘s operate between 10-25mA. Also, since

LED‘s are non-linear devices, the difference in the current from 14mA to 25mA doesn‘t necessary mean a

proportional difference in the brightness. In most cases, you may not even be able to tell the difference.

So, choosing 220 Ohm instead of 128 Ohm is purely because of practical easiness. (13)

Transmitter

Component Relationship/Formula used in Calculation Value

R1 Typical value for inbuilt oscillator HT12 E 750K

Page 46: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

37

R2 Ohms law; R = V/I 470K

R3 Ohms law; R = V/I 470K

R4 Ohms law; R = V/I 470K

C1 Typical bypass capacitor for LM7805 100u

C2 Typical filter capacitor for LM7805 100n

C3 Typical filter capacitor for LM7805 100n

C4 Time Constant 220u

C5 Time Constant 220u

C6 Time Constant 220u

Receiver

R1 Typical value for inbuilt oscillator HT12 D 33K

R2 Ohms law; R = V/I 1K

R3 Ohms law; R = V/I 1K

R4 Ohms law; R = V/I 1K

C2 Recommended value for 16Mhz Oscillator 22p

C3 Typical bypass capacitor for LM7805 100u

C4 Typical filter capacitor for LM7805 100n

C5 Typical filter capacitor for LM7805 100n

C6 Typical bypass capacitor for LM7805 100u

C7 Recommended value for 16Mhz Oscillator 22p Table 4 Components Justification

STEP 3; loading mounting and soldering

After a satisfactory schematic design was achieved, the actual printable circuit board design was

developed. The designs were printed on a clear film paper and uv etching was done. After

developing the printed circuit boards, drilling, mounting and soldering took place and the final

product was achieved satisfactorily. Below are figures of the final product;

3.12 Final Transmitter Circuit 3.13 Final receiver circuit

Page 47: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

38

3.14 Transmitter 3.15 Receiver

Page 48: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

39

CHAPTER 4 TESTING, RESULTS AND ANALYSIS The final design was neat, compact and functional as required. Demonstration illustrated that the

RF was able to transmit and receive data up to a distance of approximately forty five (45) meters.

The achieved working sequence was as illustrated in the table below;

ACTION SIMULATED RESULTS ACTUAL RESULTS

At

standby

mode

Button 1

pressed

Button 2

pressed

Page 49: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

40

Button 3

pressed

Table 5 Results

4.1 DISCUSSION.

A system that could be used to realize vehicle switching was designed and implemented using

the ATmega 32 microcontroller, where the three vehicle inputs was via three buttons on a

transmitting remote control. From the above demonstrated results, we can conclude that the

above system can be successfully integrated with a vehicle electrical system to lock/open the

vehicle door, switch the vehicle lights on/off as well as switching the vehicle ignition off. Slight

challenges experienced included persistence of switch bouncing. The capacitors incorporated

across the input buttons helped a great deal in minimizing the ‗bounce‘ however it did not

completely eradicate it. To help curb this problem, both a hardware and software debounce was

incorporated in the design.

The range of rf transmission was also not as indicated in ideal situations. The practically

achieved range was slightly less¸ this can be attributed to environmental conditions, losses in the

antennas used and inefficiency of the RF module. However a satisfactory range of forty five (45)

meters was achieved.

4.2 RECOMMENDATIONS

This project envisioned the implementation of a vehicle switching system economically and

accurately. Since most of the times accuracy is foregone to economy, other more accurate but

expensive methods of implementation could be used. These would include the use of a better

designed RF module antennas, signal amplifier to increase the range of transmission and also

design of a more compact design especially for the transmitter so as to allow easier mobility and

easy fit into the motorist‘s pocket, handbag etc.

Page 50: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

41

Consequently, a more advanced microcontroller other than the ATmega 32 might be envisioned

in order to properly implement the recommended technology. These would include ATmega

328p or the use of the Cortex M variant (M3, M4 and M7) of 32 – bit ARM microcontrollers

which comprise of larger memory, more RAM (that ranges between 64KB and 256KB) and

higher processing capabilities than the ATmega 32 microcontroller.

References

1. normal abnormal academics. code 7700. [Online] [Cited: 03 10, 2015.] http://code7700.com/hf.html.

2. AsadA. Abidi. Power-Conscious design of Wireless circuits and systems. s.l. : KluwerAcademic

Publishers, 2002.

3. Harris. Radio Communication in digital Age. Vol. Volume 1.

4. RF Module. wikipaedia. [Online] [Cited: 03 10, 2015.] http://en.wikipedia.org/wiki/RF_module.

6. introduction to encoding and decoding. lets learn electronics. [Online] [Cited: 03 10, 2015.]

http://letslearnelectronics.blogspot.com/2012/07/introduction-to-encoding-and-decoding_1610.html.

7. IC 7805 (Voltage Regulator IC). Engineers Garage. [Online] [Cited: 03 10, 2015.]

http://www.engineersgarage.com/electronic-components/7805-voltage-regulator-ic.

8. ATmega32-16PU, MegaAVR, 32KB Flash, 5V, 40 DIP. rare components. [Online] [Cited: 03 10, 2015.]

http://rarecomponents.com/store/1156-atmega32-16pu-buy-online-india.

9. Corporation, Atmel. ATmega 32. rockbox. [Online] [Cited: 03 10, 2015.]

http://www.rockbox.org/wiki/pub/Main/SansaConnect/atmel_mega165.pdf.

10. ATmega 32. Circuits today. [Online] [Cited: 03 29, 2015.] http://www.circuitstoday.com/atmega32-

avr-microcontroller-an-introduction.

11. USBasp programmer. IOT Projects. [Online] [Cited: 03 29, 2015.] http://iot-

projects.com/index.php?id=how-to-use-usbasp.

12. online collection of electronics information. The lab book pages. [Online] [Cited: 03 29, 2015.]

http://www.labbookpages.co.uk/electronics/debounce.html.

13. hardwarefun. hardwarefun. [Online] [Cited: 03 29, 2015.]

http://hardwarefun.com/tutorials/calculating-correct-resistor-value-to-protect-arduino-pin.

Page 51: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

42

APPENDIX

i. BILL OF QUANTITIES

Customer Name: Owino Moses Oriare

Project Number: 69

Part Count:

55

Total cost:

6873

Part Number Part name Description Supplier Units QNTITY

Unit Cost COST

1 Resistor

Ktechnics

10 3 30

2 Capacitors (electrolytic)

Ktechnics

5 10 50

3 Capacitors (ceramic)

Ktechnics

6 3 18

4 Voltage Regulators-7805

Ktechnics

4 30 120

5 Microcontroller At-mega 32

Ktechnics

2 400 800

6 Encoder(HT12E) Ktechnics

2 200 400

7 Decoder (HT12D)

2 200 400

8 RF module

Ktechnics

2 400 800

9 Connecting Wires

Ktechnics

1 350 350

10 Bread Board

Ktechnics

2 250 500

11 LEDs

Ktechnics

10 3 30

12 USB asp Programmer

Ktechnics

1 1500 1500

13 DMM

Masimo

1 400 400

14 Soldier gun

Masimo

1 400 400

15 soldier wire WINSTAR Ktechnics

5 15 75

16 Miscellaneous

1 1000 1000

TOTAL 55 6873

ii. C LANGUAGE CODE

#define FCP_U 16000000

#include <avr/io.h>

#include<stdbool.h>

#include<util/delay.h>

Page 52: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

43

bool button_one_latch = false; //initialize latch one as low

bool button_two_latch = false; //initialize latch two as low

int main()

{

DDRD |=(1<<7)|(1<<6)|(1<<5); //initialize portD pin 7,5,6 as our outputs

DDRB &=~(1<<0)|(1<<1)|(1<<2); //initialize portB pin 0,1,2 as our inputs

PORTD |=(1<<7); //portD pin7 is unconditionally high

while (1)

{

if(bit_is_clear(PINB,0)) //if bit = 0, i.e. button 1 is pressed

{

_delay_ms(400); //software debounce

button_one_latch ^=1; //toggle from initial latch condition

}

if(bit_is_clear(PINB,1)) //if bit = 0, i.e. button 2 is pressed

{

Page 53: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

44

_delay_ms(400); //software debounce

button_two_latch ^=1; // toggle from initial latch condition

}

if(bit_is_clear(PINB,2)) //if bit = 0, i.e. button 3 is pressed

{

PORTD &=~(1<<7); //portD pin 7 is low

return (0); //keep doing it

}

else

{

PORTD |=(1<<7); //maintain portD pin 7 as high

}

if(button_one_latch ==1)

{

PORTD |=(1<<5); //led one on

}

else

{

PORTD &=~(1<<5); //otherwise off

Page 54: VEHICLE SWITCHING SYSTEM USING RF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie...14. Fig 2.8 Typical Application Circuit for HT12E 15. Fig 2.9 HT12 Decoder 16. Fig 2.10

45

}

if(button_two_latch ==1)

{

PORTD |=(1<<6); //led two on

}

else{

PORTD &=~(1<<6); //otherwise off

}

}

}


Recommended