report minor

55
INSTITUTE OF ENGINEERING AND TECHNOLOGY, ALWAR, RAJASTHAN A MINOR PROJECT REPORT ON WIRELESS KEYPAD CONTROLLED ROBOT Submitted In The Partial Fulfillment Of The Requirement For The Award Of The Degree Of Bachelor Of Technology in ELECTRONICS AND COMMUNICATION ENGINEERING Submitted to: Submitted by: Mr. Rakesh Sharma Shashwat D. Mishra (Head of the deptt., ECE ) Roll No. : 09EIAEC113 and 1

Upload: twinkle-singh

Post on 06-Dec-2015

227 views

Category:

Documents


2 download

DESCRIPTION

Minor Project Report Engineering- Microcontroller based Robot

TRANSCRIPT

INSTITUTE OF ENGINEERING AND TECHNOLOGY,

ALWAR, RAJASTHAN

A MINOR PROJECT REPORT ON

WIRELESS KEYPAD CONTROLLED ROBOT

Submitted In The Partial Fulfillment Of The Requirement For The Award Of The Degree Of

Bachelor Of Technology in

ELECTRONICS AND COMMUNICATION ENGINEERING

Submitted to: Submitted by:

Mr. Rakesh Sharma Shashwat D. Mishra

(Head of the deptt., ECE ) Roll No. : 09EIAEC113

and

Guided by: Twinkle Singh

Mr. Anil K. Sharma ROLL No. :09EIAEC122

1

ACKNOWLEDGEMENT

WE TAKE THIS OPPORTUNITY, TO SHOW OUR GRATITUDE TO ALL THOSE

WHO HAVE HELPED US MAKE THIS PROJECT SUCCESSFUL.

WE THANK THE ELECTRONICS & COMMUNICATION ENGINEERING

DEPARTMENT, INSTITUTE of ENGINEERING & TECHNOLOGY, FOR GIVING

US THE OPPORTUNITY TO PLAN AND PUT FORWARD THE PROJECT THAT

WE HAVE PUT UP,FOR THE PARTIAL FULFILLMENT OF OUR DEGREE

COURSE, UNDER THE PRACTICE SCHOOL SCHEME.

WE TAKE THIS OPPORTUNITY TO EXTEND OUR DEEPEST THANKS TO OUR

ESTEEMED GUIDE AND PROFESSOR, MR. ANIL K. SHARMA(Faculty Deptt. of

Electronics & Communication Engg.)WITHOUT WHOSE PERSISTENT

ENCOURAGEMENT HELP AND GUIDANCE, THE COMPLETION OF THIS

PROJECT WOULD NOT HAVE BEEN POSSIBLE.

Twinkle Singh

Shashwat D. Mishra

2

ABSTRACT

The project outlines the strategy adopted for establishing wireless communication

between a mobile Robot and a user operated keypad.

Our aim is to be able to command and control the Robot wirelessly by the Robot and

User interfacing.

The principle task of this project was to program the AVR microcontroller

interfaced to a radio packet controller module(RF Module),operating at a frequency of

434 MHz, which would enable us to wirelessly control the Robot. The communication

protocols dealing with transmission and reception of data and wireless control of the Bot

have been successfully implemented.

This circuit uses RF module to control DC motors through a motor driver IC L293D.

Transmission is enabled by giving a low bit to pin14 (TE, active low) of encoder HT12E.

The controls for motor are first sent to HT12E. Pins 10 and 11 (D0-D1) are used to

control one motor while pins 12 and 13 (D2-D3) to control another motor. The data

signals of encoder HT12E work on negative logic. Therefore a particular signal is sent by

giving a low bit to the corresponding data pin of encoder.The parallel signals generated at

transmission end are first encoded (into serial format) by HT12E and then transferred

through RF transmitter (434 MHz) at a baud rate of around 1-10 kbps. The same signals

are received by RF receiver after which it is decoded by HT12D. The decoded signals are

fed to ATMEGA16 microcontroller. The proper (inverted) signals are then supplied to

L293D. L293D contains two inbuilt H-bridge driver circuits to drive two DC motors

simultaneously, both in forward and reverse direction.

The motor operations of two motors can be controlled by input logic at pins 2 & 7 and

pins 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10

will rotate it in clockwise and anticlockwise directions, respectively. Thus, depending

upon the signals generated at the transmission end, the two motors can be rotated in

desired directions.

3

CONTENTS

1. Introduction………………………………………………………………….. 5

2. Project requirements…………………………………………………………..6

3. ATmega 16 Microcontroller Board…………………………………………...7

Introduction…………………………………………………………………...7

Pin Description………………………………………………………………..8

Features……………………………………………………………………….9

Port Description Of Our Project………………………………………………12

Oscillator……………………………………………………………………...12

Voltage Regulator IC LM7805……………………………………………….15

Keypad Matrix………………………………………………………………..16

USBASP Connection Cable…………………………………………………..18

4. Motor Driver IC L293D………………………………………………………19

5. Radio Frequency Module……………………………………………………. 23

6. AVR Studio 4…………………………………………………………………29

7. Embedded C…………………………………………………………………. 35

8. Working Program Code………………………………………………………38

9. Application areas of Project…………………………………………………..39

10. References……………………………………………………………………40

ATmega16 Data Sheet

4

INTRODUCTION

In this project we are trying to establish wireless communication between the mobile

Robot and the remote controller in the hands of the user.The circuit will be formed as

shown in the diagram below. Control signal from the keypad will be transmitted as

parallel data. This data will act as input for pins 10-13 of encoder IC HT12E. Encoder

converts the received signals from parallel to serial format, making it compatible for

transmission through the RF Transmitter. Serial data is then input to pin 2 of 434 MHz

Transmitter. Data is then transmitted to the RF Receiver section also working at 434

MHz. After being received by the antenna at the receiver, the data is sent to decoder IC

HT12D through pin 2 of IC. Decoder converts the data again to parallel format and sends

as input to pin no. 14(PD0) of microcontroller ATMEGA16. The signals are then sent to

motor driver IC L293D which moves the motors forward, backword, right and left turn

according to the data received.

5

PROJECT REQUIREMENTS

OBJECTIVES

Benchmark the wireless modules.

Learn the working and functioning of the ATmega16 Microcontroller board.

Learn the working of a RF module.

Build a transmitter consisting of the ATmega16 microcontroller board interfaced

with a

program to the microcontroller so as to wirelessly control the Robot.

Program a application to communicate in a parallel manner with the ATmega16

microcontroller board.

Solder a ATmega16 microcontroller board.

Develop efficient code along with adequate internal and external documentation.

Check the performance of the packet transmission.

COMPONENTS USED

Microcontroller ATMEGA16

16 MHz Oscillator

RF Module 434 MHz

4x4 Keypad Matrix

5V DC Motor

Motor Driver IC L293D

Voltage Regulator 7805

Resistors

Capacitors

Power Source (battery)

6

ATMEGA16 MICROCONTROLLER

Introduction

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

combines 16KB of programmable flash memory, 1KB SRAM, 512B EEPROM, an 8-

channel 10-bit A/D converter. 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.

7

Pin Description

VCC: Digital supply voltage

GND: Ground

PortA(PA7...PA0): PortA serves as an 8-bit bi-directional I/O port. It also serves at the

input to the A/D converter. PortA pins are tri-stated when a reset condition becomes

active, even if the clock is not running.

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

resistors (selected for each bit). ThePort 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.

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.

8

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.

Features

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

Advanced RISC Architecture

 - 131 Powerful Instructions - Most Single Clock Cycle Execution

 - 32 x 8 General Purpose Working Registers

 - Up to 6 MIPS Throughput at 16MHz

 - Fully Static Operation

 - On-chip 2-cycle Multiplier

Nonvolatile Program and Data Memories

 - 16k Bytes of In-System Self-Programmable Flash

 - Optional Boot Code Section with Independent Lock Bits

 - 512K Bytes EEPROM

 - Programming Lock for Software Security

JTAG (IEEE std. 1149.1 Compliant) Interface

 - Boundary-scan Capabilities According to the JTAG Standard

 - Extensive On-chip Debug Support

 - Programming of Flash, EEPROM, Fuses, and Lock Bits through the JAGS Interface

Peripheral Features 

 - On-chip Analog Comparator

 - Programmable Watchdog Timer with Seperate On-chip Oscillator

 - Master/Slave SPI Serial Interface

9

 - Two 8-bit Timer/Counters with Separate Pre-scalar, Compare 

 - One 16-bit Timer/Counter with Separate Pre-scalar, Compare and Capture mode

 - Real Time Counter with Separate Oscillator

 - Four PWM Channels

 - 8-channel, 10-bit ADC

 - Byte-oriented Two-wire Serial Interface

 - Programmable Serial USART

Special Microcontroller Features

 - Power-on Reset and Programmable Brown-out Detection

 - Internal Calibrated RC Oscillator

 - External and Internal Interrupt Sources

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

Extended Standby

I/O and Packages

 - 32 Programmable I/O Lines

 - 40-pin PDIP, 44-lead TQFP, and 44-pad MLF

Operating Voltages

 - 4.5-5.5V for ATmega16

Speed Grades

 - 0-16 MHz for ATmega16

Power Consumption at 4 MHz, 3V, 35 °C

 - Active: 1.1mA

 - Idle Mode: 0.35mA

 - Power-down Mode: < 1µA

The ATmega16 board was developed by the both of us without any assistance at the best

of our knowledge’s. The ATmega16 board is intended to be used as a tool for learning

10

assembly, C programming, and microcontroller architecture. Besides a tool for learning,

it also provides a stable platform for the development of other projects requiring a

microcontroller.

ATmega16 Development Board Block Diagram

PORT DESCRIPTION OF THE PROJECT

11

In the project developed by us, we made use of AVRStudio for performing our coding

operations. The language taken into use was Embedded C. From the 4 ports available on

the microcontroller ATmega16, 3 of the ports were used for making the project work.

Port A, pin number 33-40 has been used as the input port where the input from the

keypad will be obtained. The robot will take the input from the keypad through port A

and will perform the operation of movement which has been assigned to it through the

program. The pull-up registers of port A are also enabled using the codes.

Port B, pin number 1-8 on the microcontroller is used as the output port. Being used as

output port implies that the device providing the required output in the form of forward,

backward, right and left movement, is depicted by the motor driver IC’s after being

decoded from port B of microcontroller. Thus, the pins of the motor driver IC L293D

have been connected at the port B. The motor driver in turn runs the motors and hence the

movement takes place in the tires of the robot.

Port D, pin number 14- 21 in the circuit configuration acts as the second port for the

connection of the keypad matrix and is declared as the output port. Basically what

happens during the program is that the data is read from pins of port A and written to the

pins of port D.

OSCILLATOR

For providing the required oscillations and the clock pulse to the microcontroller

ATmega16, a 16 MHz oscillator has been provided in the circuit. The oscillator used is a

crystal oscillator and the whole circuit is capable of providing a throughput of about 6

MIPS with the 16 MHz frequency. The frequency cycles are fed to the microcontroller

through two pins, pin number 12 and 13, as a frequency of 8 MHz to each pin.

A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance

of a vibrating crystal of piezoelectric material to create an electrical signal with a very

precise frequency. This frequency is commonly used to keep track of time (as in quartz

12

wristwatches), to provide a stable clock signal for digital integrated circuits, and to

stabilize frequencies for radio transmitters and receivers. The most common type of

piezoelectric resonator used is the quartz crystal, but other piezoelectric materials

including polycrystalline ceramics are used in similar circuits.

Quartz crystals are manufactured for frequencies from a few tens of kilohertz to tens of

megahertz. More than two billion crystals are manufactured annually. Most are used for

consumer devices such as wristwatches, clocks, radios, computers, and cellphones.

Quartz crystals are also found inside test and measurement equipment, such as counters,

signal generators, and oscilloscopes.

A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a

regularly ordered, repeating pattern extending in all three spatial dimensions.

Almost any object made of an elastic material could be used like a crystal, with

appropriate transducers, since all objects have natural resonant frequencies of vibration.

For example, steel is very elastic and has a high speed of sound. It was often used in

mechanical filters before quartz. The resonant frequency depends on size, shape,

elasticity, and the speed of sound in the material. High-frequency crystals are typically

cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used

in digital watches, are typically cut in the shape of a tuning fork. For applications not

needing very precise timing, a low-cost ceramic resonator is often used in place of a

quartz crystal.

When a crystal of quartz is properly cut and mounted, it can be made to distort in an

electric field by applying a voltage to an electrode near or on the crystal. This property is

known as piezoelectricity. When the field is removed, the quartz will generate an electric

field as it returns to its previous shape, and this can generate a voltage. The result is that a

quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with

a precise resonant frequency.

13

Example of connection of oscillator in circuit

Oscillators are connected externally with the microcontroller to provide high frequency

signal to the oscillator circuit in the microcontroller. The oscillator circuit provides the

clock signal to the microcontroller. It is mainly used to control any process in micro

second, so clock timer is very important without waiting for input from any source,

oscillator produces the output even without any input signal and gives high frequency at

initial input for processor. The clock also provides an opportunity for the programmer to

perform time keeping of several types. In the PICmicro, the clock also drives the

hardware dedicated to timekeeping. The applications may include keeping “real time”, or

timing sensitive processes such as serial data communication. The accuracy of these

timing applications is dependent upon the accuracy of the clock oscillator.

VOLTAGE REGULATOR IC LM7805

14

Voltage Regulator (regulator), usually having three legs, converts varying input voltage

and produces a constant regulated output voltage. They are available in a variety of

outputs. The most common part numbers start with the numbers 78 or 79 and finish with

two digits indicating the output voltage. The number 78 represents positive voltage and

79 negative one. The 78XX series of voltage regulators are designed for positive input.

And the 79XX series is designed for negative input.

 

Examples:  

·         5V DC Regulator Name: LM7805 or MC7805

·         -5V DC Regulator Name: LM7905 or MC7905

·         6V DC Regulator Name: LM7806 or MC7806

·         -9V DC Regulator Name: LM7909 or MC7909

The LM78XX series typically has the ability to drive current up to 1A. For application

requirements up to 150mA, 78LXX can be used. As mentioned above, the component has

three legs: Input leg which can hold up to 36VDC Common leg (GND) and an output leg

with the regulator's voltage. For maximum voltage regulation, adding a capacitor in

parallel between the common leg and the output is usually recommended. Typically a

0.1MF capacitor is used. This eliminates any high frequency AC voltage that could

otherwise combine with the output voltage. 

15

The goal is to provide a stable, low voltage supply to the microcontroller. The operation

of the microcontroller must not be affected by the power supply. The power supply itself

must be reliable and stable. The power supply should not cause problems during

development. When testing and developing little accidents happen; the odd short or a

wire pushed into the wrong hole. The power supply should be current limited so that little

accidents don't do any damage to the parts. In order to avoid such wrong happenings,

microcontroller development board has been supplied with a voltage regulator IC.

KEYPAD MATRIX

The matrices are actually an interface technique. It can be used to interface inputs like the

PC keyboard keys, but also to control multiple outputs like LEDs. According to this

technique, the I/O are divided into two sections: the columns and the rows. We can

imagine a matrix as an excel sheet.

A 4x4 keypad matrix has been used to control the working of the robot. The input device

is a standard 4x4 keypad. The keypad contains 16 keys, symmetrically arranged in four

rows with four keys each. Each column and row of the keypad is connected to an I/O pin.

16

All column inputs have pull-up resistors enabled so when a key is pressed the

microcontroller will record a low level on one of the column inputs.

So, for interfacing a keypad with microcontroller, we require four pins as output(for

selecting the row to be scanned) and four pins as input(for detecting the key pressed in a

particular row). Ths for detecting whether key 3 is pressed, we have to write the

following code:

DDRA= 0xf0; // higher nibble is made output for rows, lower nibble as input for columns

DDRB= 0xff; // for glowing LEDs when key 3 is pressed

while(1)

{ PORTA= 0b11101111;

if(PINA & 0b00000100)

{ PORTB= 0b11111111; }

else

PORTB= 0b00000000;

}

USBASP CONNECTION CABLE

17

For establishing connection between the microcontroller and the PC where the program

has been written and developed, a connector known as a USBASP is taken into use. The

connector is a USB(universal serial bus) consisting of 6 wires to connect to the

development board. The program code is stored into the microcontroller memory using

usbasp. USBasp is a USB in-circuit programmer for Atmel AVR controllers. It simply

consists of an ATMega88 or an ATMega8 and a couple of passive components. The

programmer uses a firmware-only USB driver, no special USB controller is needed.

Features

Works under multiple platforms. Linux, Mac OS X and Windows are tested.

No special controllers or smd components are needed.

Programming speed is up to 5kBytes/sec.

SCK option to support targets with low clock speed (< 1,5MHz).

Planned: serial interface to target (e.g. for debugging).

- AVRDUDE supports USBasp since version 5.2.

- BASCOM-AVR supports USBasp since version 1.11.9.6.

- Khazama AVR Programmer is a Windows XP/Vista GUI application for USBasp

and avrdude.

- eXtreme Burner - AVR is a Windows GUI Software for USBasp based USB

AVR programmers.

MOTOR DRIVER IC L293D

18

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

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

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

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

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

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

15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it

in clockwise and anticlockwise directions, respectively.

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

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

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

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

state.

19

In this way, we can have bidirectional control over two motor. Let’s have a summary of

connections:

There are two enable (EN) pins, pin 1 and pin 9. Pin 1 EN enables the motor M1

whereas pin 9 EN enables motor M2.

Connect motor M1 across OUTPUT1 and OUTPUT2 i.e. across pins 3 and 6.

Connect motor M2 across OUTPUT3 and OUTPUT4 i.e. across pins 11 and 14.

The inputs for motor M1 is given across INPUT1 and INPUT2 i.e. across pins 2

and 7.

The inputs for motor M2 is given across INPUT3 and INPUT4 i.e. across pins 10

and 15.

Connect GROUND pins 4, 5, 12 and 13 to ground.

Connect pin 16 to Vcc (=5V) and pin 8 to Vs (battery, 4.5V~36V).

As per the diagram, the inputs of motor M1 are M1-A and M1-B, whereas inputs of

motor M2 are M2-A and M2-B.

20

In the field of robotics, we use different types of motors – DC motors (mostly geared),

servo motors, stepper motors, etc. In this post we will discuss how to control DC Motors

(geared or gearless) using a MCU. Most DC motors are normally very easy to reverse. By

simply changing the polarity of the DC input, the direction of the drive shaft reverses.

This property makes DC motors very popular among enthusiast people involved in

robotics. In most cases, DC geared motors are used.

The changeover process (reverse in direction due to reverse in polarity) can be achieved

via a simple changeover switch (DPDT switch) or for a remote or electronic control, via a

suitable relay. For more information on changeover process, view this page. However,

when we use MCU in our circuit, we don’t need a relay. The necessary control signals

will be generated by the MCU. This signal will be passed to a Motor Driver IC, which in

turn drives the motors.

In the above block diagram, we can see that there is a microcontroller (MCU). Now, this

MCU may/may not take in inputs (inputs as in from sensors, other digital inputs, etc).

Next, as per our programming, the MCU will generate control signals. Please note that

the MCU will generate signals in form of HIGH (Vcc = 5v) or LOW (zero). But this

voltage is insufficient to drive a motor. That’s why we need to use a Motor Driver.

21

MCU Motor

Driver

M

InputHigh(+5V)/ Low (0V) Control Signal

Battery (9-24V)

+

A motor driver always has a battery input Vs (which depends upon the rating of the

motor). In simple terms, what a motor driver does is that it directs the Vs voltage to the

motors connected (or in fact, the output pins) to it. Thus, the motors behave as per the

control signals generated using the MCU with the excitation from the external battery

voltage.

In our project we have connected two L293D motor driver ICs in order to control the two

tires on which the Robot will be moving. Each motor driver IC can be programmed

differently to result in the different kinds of motion such as forward, backward, right turn

and left turn. The programming for this purpose was done using the USP controller of the

ATmega16 development board. These motor driver ICs have been connected to the port

B of ATmega16.

22

RADIO FREQUENCY(RF) MODULE

Radio Communication uses radio frequencies for communication between one device to

the other. The data to be sent is transmitted by the RF transmitter and received by the RF

receiver at the receiving end.

Radio Frequency

It is the rate of oscillation in the range of about 3 kHz to 300 GHz, which corresponds to

the frequency of radio waves, and the alternating currents which carry radio signals.

RF Module

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).

An RF Module is a (usually) small electronic circuit used to transmit, receive, or

transceive radio waves on one of a number of carrier frequencies. RF Modules are widely

used in consumer application such as garage door openers, wireless alarm systems,

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

systems. They are often used instead of infrared remote controls. Transmission through

RF is better than IR (infrared) because of many reasons. Firstly, signals through RF can

travel through larger distances making it suitable for long range applications. Also, while

IR mostly operates in line-of-sight mode, RF signals can travel even when there is an

obstruction between transmitter & receiver. Next, RF transmission is more strong and

reliable than IR transmission. RF communication uses a specific frequency unlike IR

signals which are affected by other IR emitting sources.

The RF module comprises of an RF Transmitter and an RF Receiver. The

transmitter/receiver (Tx/Rx) pair operates at a frequency of 434 MHz. An RF transmitter

23

receives serial data and transmits it wirelessly through RF through its antenna connected

at pin4. 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.

Pin configuration of RF Module

Transmitter Module Receiver Module

1. Antenna 1. Antenna

2. Vcc(Positive Supply) 2. GND

3. DATA(Data input) 3. GND

4. GND 4. Vcc(positive supply)

5. Vcc(positive supply)

6. DATA

7. DATA

8. GND

24

The RF module is often used alongwith a pair of encoder/decoder. The encoder is used

for encoding parallel data for transmission feed while reception is decoded by a decoder.

HT12E-HT12D, HT640-HT648, etc. are some commonly used encoder/decoder pair ICs.

Encoder IC HT12E

HT12E is an encoder integrated circuit of 212 series of encoders. They are paired with

212 series of decoders for use in remote control system applications. It is mainly used in

interfacing RF and infrared circuits. The chosen pair of encoder/decoder should have

same number of addresses and data format. Simply put, HT12E converts the parallel

inputs into serial output. It encodes the 12 bit parallel data into serial for transmission

through an RF transmitter. These 12 bits are divided into 8 address bits and 4 data bits.

 HT12E has a transmission enable pin which is active low. When a trigger signal is

received on TE pin, the programmed addresses/data are transmitted together with the

header bits via an RF or an infrared transmission medium. HT12E begins a 4-word

transmission cycle upon receipt of a transmission enable. This cycle is repeated as long as

TE is kept low. As soon as TE returns to high, the encoder output completes its final

cycle and then stops.

25

Decoder IC HT12D

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 212series of encoders. The chosen pair of encoder/decoder

should have same number of addresses and data format. In simple terms, 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.

Typical Applications

Vehicle monitoring

Remote control

Telemetry

Small-range wireless network

Wireless meter reading

Access control systems

Wireless home security systems

Area paging

Industrial data acquisition system

Radio tags reading

RF contactless smart cards

Wireless data terminals

26

Wireless fire protection systems

Biological signal acquisition

Hydrological and meteorological monitoring

Robot remote control

Wireless data transmissions

Digital video/audio transmission

Digital home automation, such as remote light/switch

Industrial remote control, telemetry and remote sensing.

Alarm systems and wireless transmission for various types of low-rate digital signal.

Mobile web server for elderly people monitoring

Keeping in mind all the above features provided by the RF Module, we have also

employed it for the establishment of wireless communication between our remote keypad

and the microcontroller development board. The frequency brought into use is 434 MHz.

The 434 MHz RF Transmitter allows user to serially send data, robot control data or

other information wirelessly. Reliable wireless communication is as effortless as sending

serial data. An RF module consists of a Transmitter (Tx) section and a Receiver (Rx)

section both working at a frequency of 434 MHz.

Features:

High Speed data transfer at the rate of 1kbps to 10kbps.

SIP header allows for ease of use with breadboards.

Compatible with most microcontrollers including ATMEGA16.

Easy to use instructions

About 100 ms line of sight range

Operating range 2-12 volts.

27

For the basic functioning, the parallel data from the keypad inputs will enter into the

encoder IC HT12E. This IC will convert this parallel data into serial data. It is

necessary to get the data entered into the serial bit format so that it can be transmitted

over the RF transmitter. This serially transmitted data is received by the antenna at

the receiver end. The decoder IC HT12D present on the receiving end changes the

data again from the serial to the parallel form, to make it suitable to be supplied to the

microcontroller. This supplied data further feeds the motor driver IC and hence runs

the robot

28

AVR STUDIO 4

The AVR Studio 4 is an Integrated Development Environment for debugging AVR

software. The AVR Studio allows chip simulation and in-circuit emulation for the AVR

family of microcontrollers. The user interface is specially designed to be easy to use and

to give complete information overview. The AVR uses the same user interface for both

simulation and emulation providing a fast AVR Studio learning curve.

AVR studio is an Integrated Development Environment (IDE) by ATMEL for developing

applications based on 8-bit AVR microcontroller. Prior to installation of AVR Studio you

have to install the compiler WinAVR. This will allow AVR Studio to detect the compiler.

Step 1:

Step 2:

Click on new project

29

Step 3: 

Click on AVR GCC. Write the project name.

Select your project location.

Click on Next>>

Step 4:

Click on AVR Simulator in left block and then select your controller (e.g.: ATmega16).

Click on finish button.

30

Step5: 

Write the code in main body area.

Save the project file.

Step6: 

Go to PROJECT -> Configuration Options

 

31

Step 7: 

Write the crystal frequency if you are using external crystal.

Check the checkbox corresponding to Create Hex File and then click on OK.

Save the project again.

Step 8: 

Go to BUILD -> Compile.

This will compile your code and generate error if any.

32

 

For the first time it will generate two errors, ignore them.

 Step 9:

 

Again go to BUILD and click on Build.

This will generate hex file of the code.

Use that Hex file to burn your microcontroller.

Where you will find Hex file?

33

Just go to the location which you selected at the starting. Open that folder you will find

one more folder named Default. This is the default location of where the hex file is

generated.

While working in real time if you want to change the code, make changes and build the

file again. This will automatically update the previous hex file.

The above is the complete procedure to be followed for the simulation of a code on AVR

Studio4. All the steps are followed one after the other and the program is stored in the

microcontroller memory and the “run” to complete the execution process.

34

EMBEDDED C

C is the most widely used programming language for embedded processors/controllers.

Assembly is also used but mainly to implement those portions of the code where very

high timing accuracy, code size efficiency,etc. are prime requirements.

As assembly languages programs are specific to a processor, assembly language didn’t

offer portability across systems. To overcome this disadvantage, several high level

languages, including C came up. Thus C, still has a strong-hold in embedded

programming. Due to wide acceptance of C in the Embedded Systems, various kind of

support tools like compilers and cross compilers. ICE, etc. came up and all this facilitated

development of embedded systems using C.

Embedded C Programming

Key characteristics of embedded systems, when compared to PCs are as follows:

Embedded devices have resource constraints(limited ROM, limited stack space,

less processing power)

Components used in embedded systems and PCs are different, embedded system

typically uses smaller, less power consuming components.

Embedded systems are more tied to the hardware.

Two salient features of embedded programming are code speed and code size. Code

speed is governed by the processing power, timing constraints, whereas code size is

35

governed by available program memory and use of programming language. Goal of

embedded system programming is to get maximum features in a minimum space and

minimum time.

Embedded systems are programmed using different types of languages:

Machine Code

Low level language,i.e. assembly

High level language like C, C++, Java, Ada, etc.

Application level language like Visual Basic, scripts, Access, etc.

Use of C in embedded systems is driven by the following advantages:

It is small and reasonably simpler to learn, understand, program and debug.

C Compilers are available for almost all embedded devices in use today, and there

is a large pool of experienced C programmers

C has advantage of processor-independence and is not specific to any particular

microprocessor/microcontroller.

C combines functionality of assembly language and features of high level

languages, thus 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.

Difference between C and Embedded C

Though C and Embedded C appear different and are used in different contexts, they

have more similarities than the differences. Most of the constructs are the same, the

difference lies in their applications. C is used for desktop computers, while embedded

C is for microcontroller based applications. C has the luxury to use resources of a

36

desktop like memory, OS, etc. Programming on desktop systems, we need not bother

about memory. However, embedded C has to make use of the limited RAM, ROM,

I/O on an embedded processor. Thus programming code must fit into the available

program memory, if code exceeds limits, the system is likely to crash.

Embedded C systems often have real-time constraints, which is usually not there with

desktop computer applications.

Embedded systems often do not have a console, which is available in case of desktop

applications.

Programming Using Embedded C

Embedded C uses most of the syntax and semantics of standard C e.g., main() function,

variable definition, data type declaration, conditional statements, loops, functions, arrays,

strings, etc.

There are also some specifics to embedded C mentioned below

1. Low Level Codes

2. In-Line Assembly Code

3. Features like Heap, Recursion

4. I/O Registers

5. Memory Pointers

6. Bit Access

7. Use of Variable Data Types

8. Use of Const and Volatile

All the working was done on AVR Studio, the work platform developed by the

ATMEL.

37

PROGRAM CODE

#include<avr/io.h>

#include<util/delay.h>

int main()

{

unsigned int a;

DDRA=0X00;

DDRB=0XFF;

DDRD=0XFF;

PORTA=0XFF;

while (1)

{ a= PINA & 0X0F;

PORTD=0X0E;

if(a==0X0E){PORTB=0b00000110;}

else if(a==0X0D){PORTB=0b00000100;}

else if(a==0X0B){PORTB=0b00000010;}

else if(a==0X07){PORTB=0b00001001;}

}

return 0;

}

38

APPLICATION AREAS OF PROJECT

The programmed robot will be capable of picking and dropping objects from one place to

the other and will follow the direction as controlled by the user making use of the keypad,

hence has a capability to reach any desired destination in order to complete the task.

39

REFERENCES

www.engineersgarage.com

www.8051projects.com

www.avrfreaks.com

www.extremeelectronics.com

www.wikipedia.com

40

ATMEGA16 DATASHEET

41