Você está na página 1de 51

1

Technical details of the Projects


Origin of the Proposal In most college ragging becomes most popular issue. Various steps are taken by government & college management to stop this cruel activity, but all in vain due to lack of staff members in large space of college campus. Colleges are situated in space of hectares, so it is almost impossible to look after the fresher. Presently, college has made anti ragging squad, but still college campus unable to properly avoid this crucial task. To overcome this problem we get an idea Cellphone-Controlled Robot. It helps to capture culprit candidate who involves in unfair activity. GSM technology provides large range of working areas. Due to this feature we can operate this device over large range of areas in college campus. In Law enforcement and military engagements because of many reasons, CellphoneControlled Robot is used. The exposures to hazards are mitigated to the person who operates the vehicle from the location of relative safety. They are used by many police department bomb-squads to defuse or detonate explosives.

Objectives

To improve our militants security at LOC by getting information about opponent. Remote controlled vehicles are used in Law enforcement and military engagements because of many reasons. The exposures to hazards aremitigated to the person who operates the vehicle from the location of relative safety. They are used by many police department bomb-squads to defuse or detonate explosives. Current Unmanned Aerial Vehicles (UAVs) can hover around possible targets until they are positively identified before releasing their pay load of weaponry. Backpack sized UAVs will provide ground troops with over the horizon surveillance capabilities.

To achieve ragging free environment in college campus.


Presently, college has made anti ragging squad, but still college campus unable to properly avoid this crucial task.

To insure the safe areas in mines.


With the help of Cellphone-Controlled Robot, we can predict the areas where the explosion can occur, by the application of sound tracking webcam.

TABLE OF CONTENTS
DECLARATION CERTIFICATE ACKNOWLEDGEMENT ABSTRACT LIST OF TABLES AND FIGURES CHAPTER.1
1.1 INTRODUCTION

CHAPTER.2
2.1 PROJECT OVERVIEW

CHAPTER.3
3.1 CIRCUIT & COMPONENTS DESCRIPTION 3.2 ABOUT MICROCONTROLLER UNIT 3.3 CIRCUIT & INTERFACING DESCRIPTION 3.4 WORKING OF DTMF ROBOT 3.5 SOFTWARE OF DTMF ROBO IN MCU 8051

CHAPTER.4
4.1 PRAPOSED OUTCOME

CHAPTER.5
5.1 UTILIZATION OF OUTCOME OF THE PROJECT

REFERENCES

Mobile Controlled ROBOT Using DTMF Technology

1.1 Introduction

1.1.1 What is a Mobile controlled DTMF ROBOT? DTMF Mobile ROBOT is a machine that can be that makes a call to the mobile phone attached to the robot. In the course of a call, if any button is pressed, a tone corresponding to the button pressed is heard at the other end of the call. This tone is called "Dual Tone MultipleFrequency" (DTMF) tone. The robot perceives this DTMF tone with the help of the phone stacked on the robot. The received tone is processed by the microcontroller with the help of DTMF decoder. The microcontroller then transmits the signal to the motor driver ICs to operate the motors & our robot starts moving

1.1.2 Why build a DTMF ROBOT? Conventionally, Wireless-controlled robots use rf circuits, which have the drawbacks of limited working range, limited frequency range and the limited control. Use of a mobile phone for robotic control can overcome these limitations. It provides the advantage of robust control, working range as large as the coverage area of the service provider, no interference with other controllers and up to twelve controlles. Although the appearance and the capabilities of robots vary vastly, all robots share the feature of a mechanical, movable structure under some form of control. The Control of robot involves three distinct phases: perception, processing and action. Generally, the preceptors are sensors mounted on the robot , processing is done by the on-board microcontroller or processor, and the task is perfomed using motors or with other actuators.

POJECT OVERVIEW

In this project the robot, is controlled by a mobile phone that makes call to the mobile phone attached to the robot in the course of the call, if any button is pressed control corresponding to the button pressed is heard at the other end of the call. This tone is called dual tone multi frequency tone (DTMF) robot receives this DTMF tone with the help of phone stacked in the robot. The received tone is processed by the atmega16 microcontroller with the help of DTMF decoder MT8870 the decoder decodes the DTMF tone in to its equivalent binary digit and this binary number is send to the microcontroller, the microcontroller is preprogrammed to take a decision for any give input and outputs its decision to motor drivers in order to drive the motors for forward or backward motion or a turn. The mobile that makes a call to the mobile phone stacked in the robot acts as a remote. So this simple robotic project does not require the construction ofreceiver and transmitter units. DTMF signaling is used for telephone signaling over the line in the voice frequency band to the call switching center. The version of DTMF used for telephone dialing is known as touchtone. DTMF assigns a specific frequency (consisting of two separate tones) to each key s that it can easily be identified by the electronic circuit. The signal generated by the DTMF encoder is the direct al-gebric submission, in real time of the amplitudes of two sine(cosine) waves of different frequencies, i.e. ,pressing 5 will send a tone made by adding 1336hz and 770hz to the other end of the mobile. The tones and assignments in a dtmf system shown below

Fig. 1 Block Diagram of DTMF ROBOT

M Monbile

M I C R O C O N T R O L L O R Left Moto r
MOTO R
DRIVER

DTMF Decoder

Right Moto r

Figures shows the block diagram and circuit diagram of the microcontroller- based robot. The important components of this robot are DTMF decoder, Microcontroller and motor driver. An MT8870 series DTMF decoder is used here. All types of the mt8870 series use digital counting techniques to detect and decode all the sixteen DTMF tone pairs in to a four bit code

output. The built -in dual tone rejection circuit eliminated the need for pre- filtering. When the input signal given at pin2 (IN-) single ended input configuration is recognized to be effective, the correct four bit decode signal of the DTMF tone is transferred to Q1 . The ATMEGA16 is a low power, 8 bit, CMOS microcontroller based on the AVR enhanced RISC architecture. It provides the following feature: 16kb of in system programmable flash memory with read write capabilities, 512bytes of EEPROM, 1KB SRAM, 32 general purpose input/output lines. 32 general purpose working registers. All the 32 registers are directly connected to the arithmetic logic unit, allowing two independent registers to be accessed in one signal instruction executed in one clock cycle. The resulting architecture is more code efficient. Outputs from port pins PD0 through PD3 and PD7 of the microcontroller are fed to inputs IN1 through IN4 and enable pins (EN1 and EN2) of motor driver L293d respectively, to drive geared motors. Switch S1 is used for manual reset. the notations are : ic1 - mt8870 ic2 - atmega16 ic3 - l293d ic4 - cd7004 r1,r2 - 100k resistances r3 - 330k resistances r4-r8 - 10k resistances c1- 0.47 micro farad capacitor c2,c3,c5,c6 - 22pfarad capacitor c4 - 0.1micro farad capacitor xtal1 - 3.57 MHz crystal xtal2 - 12mhz crystal s1 - push to on switch m1,m2 - 6v 50rpm motor batt- 6v

2.1 DTMF Tone The DTMF technique outputs distinct representation of 16 common alphanumeric characters (0-9, A-D, *, #) on the telephone. The lowest frequency used is 697Hz and the highest frequency used is 1633Hz, as shown in Table 1.

Table 1: DTMF Keypad. FREQUENCY 697 Hz 770 Hz 852 Hz 941 Hz 1209 HZ 1 4 7 * 1336 HZ 2 5 8 0 1477 HZ 3 6 9 # 1633 HZ A B C D

The DTMF keypad is arranged such that each row will have its own unique tone frequency and also each column will have its own unique tone frequency. Above is a representation of the typical DTMF keypad and the associated row/column frequencies. By pressing a key, for example 5, will generate a dual tone consisting of 770 Hz for the low group and 1336 Hz for the high group.

2.2 DTMF Decoder The MT-8870 is a DTMF Receiver that integrates both band split filter and decoder functions into a single 18-pin DIP or SOIC package. It is manufactured using CMOS process technology. The MT-8870 offers low power consumption (35 mW max) and precise data handling.

Fig. 2 Pin configuration of MT-8870

Its filter section uses switched capacitor technology for both the high and low group filters and for dial tone rejection. Its decoder uses digital counting techniques to detect and decode all 16 DTMF tone pairs into a 4-bit code. External component count is minimized by provision of an on-chip differential input amplifier, clock generator, and latched tri-state interface bus. Minimal external components required includes a low-cost 3.579545 MHz color burst crystal, a timing resistor, and a timing capacitor. The filter section is used for separation of the low-group and high group tones and it is achieved by applying the DTMF signal to the inputs of two sixth order switched capacitor band pass filters, the bandwidths of which corresponds to the low and high group frequencies. The filter section also incorporates notches at 350 and 440 Hz for exceptional dial tone rejection. Each filter output is followed by a single order switched capacitor filter section which smoothes the signals prior to limiting. Limiting is performed by high-gain comparators which are provided with hysteresis to prevent detection of unwanted low-level signals. The outputs of the comparators provide full rail logic swings at the frequencies of the incoming DTMF signals. Following the filter section is a decoder employing digital counting techniques to determine the frequencies of the incoming tones and to verify that they correspond to the standard DTMF frequencies . Features Complete DTMF Receiver Low power consumption Internal gain setting amplifier Adjustable guard time Central office quality Power-down mode

Inhibit mode Backward compatible with MT8870C/MT8870C-1 Applications Receiver system for British Telecom (BT) or CEPT Spec (MT8870D-1) Paging systems Repeater systems/mobile radio Credit card systems Remote control Personal computers Telephone answering machine Description The MT8870D/MT8870D-1 is a complete DTMF receiver integrating both the bandsplit filter and digital decoder functions. The filter section uses switched capacitor techniques for high and low group filters; the decoder uses digital counting techniques to detect and decode all 16 DTMF tone-pairs into a 4-bit code.

ABOUT MICROCONTROLLER UNIT:


VARIOUS TYPE OF MICROCONTOLLERS:

3.1 First microcontroller is 8031 3.1.1 Features: It is Intels product. Neither a microprocessor nor a microcontroller. It is a 8-bit controller. Internally no ROM is provided i.e. code is outside the chip.

10

3.2.1 Second microcontroller is 8051


3.2.2 Features: It is a first complete 8-bit microcontroller. It is a name of a family. In which the instruction set, pin configuration, architecture are same, only memory storage capacity is different. Internally PROM (programmable read only memory) is provided so it called one time programmable (OTP). 3.3.1 Third microcontroller is ATMEGA16 3.3.2 Features: It is ATMELs product. It is a similar to 8051 microcontroller i.e. having same instruction set, pin configuration, architecture. It is a also 8-bit microcontroller. Its cost is only Rs10 more than 8051. It uses EPROM (erasable programmable read only memory) or FLASH memory. It is Multiple time programmable (MTP) i.e. 1000 times. So it is better than 8051. In AT89C51, C stands for CMOS technology used in the manufacturing of the I.C.

BLOCK DIAGRAM

Fig.3 Internal Diagram of 8051 Micro Controller

11

3.4.1 ATMEGA16 Description:

The ATMEGA16 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The deviceis

12

manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel ATMEGA16 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. 3.4.2 Pin Description

Fig. 4 Pin description of 8051 Micro Controller

The ATMEGA16 have a total of 40 pins that are dedicated for various functions such as I/O, RD, WR, address and interrupts. Out of 40 pins, a total of 32 pins are set aside for the four ports P0, P1, P2, and P3, where each port takes 8 pins. The rest of the pins are designated as Vcc, GND, XTAL1, XTAL, RST, EA, and PSEN. All these pins except PSEN and ALE are used by all members of the 8051 and 8031 families. In other words, they must be connected in

13

order for the system to work, regardless of whether the microcontroller is of the 8051 or the 8031 family. The other two pins, PSEN and ALE are used mainly in 8031 based systems. 3.4.3 Vcc Pin 40 provides supply voltage to the chip. The voltage source is +5 V. 3.4.4 GND Pin 20 is the ground. 3.4.5 XTAL1 and XTAL2 The 8051 have an on-chip oscillator but requires external clock to run it. Most often a quartz crystal oscillator is connected to input XTAL1 (pin 19) and XTAL2 (pin 18). The quartz crystal oscillator connected to XTAL1 and XTAL2 also needs two capacitors of 30 pF value. One side of each capacitor is connected to the ground.

Fig. 5 XTAL1 & XTAL2 Pins Circuit It must be noted that there are various speeds of the 8051 family. Speed refers here is the maximum oscillator frequency connected to the XTAL. For example, a 12 MHz chip must be connected to a crystal with 12 MHz frequency or less. Likewise,20MHz microcontroller requires a crystal frequency of no more than 20 MHz. When the 8051 is connected to crystal oscillator and is powered up, we can observe the frequency on the XTAL2 pin by just using oscilloscope. 3.4.6 RST Pin 9 is the reset pin. It is an input and is active high (normally low). Upon applying a high pulse to this pin, the microcontroller will reset and terminate all activities. This is often

14

referred to as a power on reset. Activating a power-on reset will cause all values in the registers to be lost. Notice that the value of Program Counter is 0000 upon reset, forcing the CPU to fetch the first code from ROM memory location 0000. This means that we must place the first line of source code in ROM location 0000 that is where the CPU wakes up and expects to find the first instruction. In order to RESET input to be effective, it must have a minimum duration of 2 machine cycles. In other words, the high pulse must be high for a minimum of 2 machine cycles before it is allowed to go low.

Fig.6 Circuit Connection of Reset Pin

3.4.7 EA All the 8051 family members come with on-chip ROM to store programs. In such cases, the EA pin is connected to the Vcc. For family members such as 8031 and 8032 in which there is no on-chip ROM, code is stored on an external ROM and is fetched by the 8031/32. Therefore for the 8031 the EA pin must be connected to ground to indicate that the code is stored externally. EA, which stands for external access, is pin number 31 in the DIP packages. It is input pin and must be connected to either Vcc or GND. In other words, it cannot be left unconnected.

3.4.8 PSEN This is an output pin. PSEN stands for program store enable. It is the read strobe to external program memory. When the microcontroller is executing from external memory, PSEN is activated twice each machine cycle. 3.4.9 ALE

15

ALE (Address latch enable) is an output pin and is active high. When connecting a microcontroller to external memory, potr 0 provides both address and data. In other words the microcontroller multiplexes address and data through port 0 to save pins. The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 chip. I/O port pins and their functions The four ports P0, P1, P2, and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as output, ready to be used as output ports. To use any of these as input port, it must be programmed. 3.4.10 Port 0 Port 0 occupies a total of 8 pins (pins 32 to 39). It can be used for input or output. To use the pins of port 0 as both input and output ports, each pin must be connected externally to a 10Kohm pull-up resistor. This is due to fact that port 0 is an open drain, unlike P1, P2 and P3. With external pull-up resistors connected upon reset, port 0 is configured as output port. In order to make port 0 an input, the port must be programmed by writing 1 to all the bits of it. Port 0 is also designated as AD0-AD7, allowing it to be used for both data and address. When connecting a microcontroller to an external memory, port 0 provides both address and data. The microcontroller multiplexes address and data through port 0 to save pins. ALE indicates if P0 has address or data. When ALE=0, it provides data D0-D7, but when ALE=1 it has address A0-A7. Therefore, ALE is used for de-multiplexing address and data with the help of latch 74LS373. 3.4.11 Port 1 Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used as input or output. In contrast to port 0, this port does not require pull-up resistors since it has already pull-up resistors internally. Upon reset, port 1 is configures as an output port. Similar to port 0, port 1 can be used as an input port by writing 1 to all its bits. 3.4.12 Port 2 Port 2 occupies a total of 8 pins (pins 21 to 28). It can be used as input or output. Just like P1, port 2 does not need any pull-up resistors since it has pull-up resistors internally. Upon reset port 2 is configured as output port. To make port 2 input, it must be programmed as such by writing 1s to it.

3.4.13 Port 3 Port 3 occupies a total of 8 pins (pins 10 to 17). It can be used as input or output. P3 does not need any pull-up resistors, the same as P1 and P2 did not. Although port 3 is configured as output port upon reset, this is not the way it is most commonly used. Port 3 has an additional function of providing some extremely important signals such as interrupts. Some of the alternate functions of P3 are listed below: P3.0 RXD (Serial input) P3.1 TXD (Serial output) P3.2 INT0 (External interrupt 0)

16

P3.3 P3.4 P3.5 P3.6 P3.7

INT1 (External interrupt 1) T0 (Timer 0 external input) T1 (Timer 1 external input) WR (External memory write strobe) RD (External memory read strobe)

3.5 MEMORY SPACE ALLOCATION:


The 8051 has three very general types of memory. To effectively program the 8051 it is necessary to have a basic understanding of these memory types. The memory types are illustrated in the following graphic. They are: On-Chip Memory, External Code Memory, and External RAM. 3.5.1 Onchip ROM The 89C51 has a 4K bytes of on-chip ROM. This 4K bytes ROM memory has memory addresses of 0000 to 0FFFh. Program addresses higher than 0FFFh, which exceed the internal ROM capacity will cause the microcontroller to automatically fetch code bytes from external memory. Code bytes can also be fetched exclusively from an external memory, addresses 0000h to FFFFh, by connecting the external access pin to ground. The program counter doesnt care where the code is: the circuit designer decides whether the code is found totally in internal ROM, totally in external ROM or in a combination of internal and external ROM. 3.5.2 Onchip RAM The 1289 bytes of RAM inside the 8051 are assigned addresses 00 to 7Fh. These 128 bytes can be divided into three different groups as follows: A total of 32 bytes from locations 00 to 1Fh are set aside for register banks and the stack. A total of 16 bytes from locations 20h to 2Fh are set aside for bit addressable read/write memory and instructions. A total of 80 bytes from locations 30h to 7Fh are used for read and write storage, or what is normally called a scratch pad. These 80 locations of RAM are widely used for the purpose of storing data and parameters by 8051 programmers.

17

Fig.7

ROM & RAM Memory in The 8051 Micro Controller

3.5.3 External Code Memory External Code Memory is code (or program) memory that resides off-chip. This is often in the form of an external EPROM. 3.5.4 External RAM External RAM is RAM memory that resides off-chip. This is often in the form of standard static RAM or flash refers to any memory (Code, RAM, or other) that physically exists on the microcontroller itself. On-chip memory can be of several types, but we'll get into that shortly. External RAM As an obvious opposite of Internal RAM, the 8051 also supports what is called External RAM. As the name suggests, External RAM is any random access memory which is found off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also slower. For example, to increment an Internal RAM location by 1 requires only 1 instruction and 1 instruction cycle. To increment a 1-byte value stored in External RAM

18

requires 4 instructions and 7 instruction cycles. In this case, external memory is 7 times slower! 3.5.5 Code Memory Code memory is the memory that holds the actual 8051 program that is to be run. This memory is limited to 64K and comes in many shapes and sizes: Code memory may be found on-chip, either burned into the microcontroller as ROM or EPROM. Code may also be stored completely off-chip in an external ROM or, more commonly, an external EPROM. Flash RAM is also another popular method of storing a program. Various combinations of these memory types may also be used--that is to say, it is possible to have 4K of code memory on-chip and 64k of code memory off-chip in an EPROM. 3.6 Registers In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. In the 8051 there us only one data type: 8 bits. With an 8- bit data type, any data larger than 8 bits has to be broken into 8-bit chunks before it is processed. The most commonly used registers of the 8051 are A(accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer) and PC (program counter). All the above registers are 8-bit registers except DPTR and the program counter. The accumulator A is used for all arithmetic and logic instructions.

19

Fig 8(a). Some 8051 8-bit registers

Fig 8(b). Some 8051 16-bit registers

A B R0 R1 R2 R3

DPH
R4 R5 R6 R7

DPL

DPTR PC(program conter) PC

3.6.1 Program Counter and Data Pointer The program counter is a 16- bit register and it points to the address of the next instruction to be executed. As the CPU fetches op-code from the program ROM, the program counter is incremented to point to the next instruction. Since the PC is 16 bit wide, it can access program addresses 0000 to FFFFH, a total of 64K bytes of code. However, not all the members of the 8051 have the entire 64K bytes of on-chip ROM installed. The DPTR register is made up of two 8-bit registers, DPH and DPL, which are used to furnish memory addresses for internal and external data access. The DPTR is under the control of program instructions and can be specified by its name, DPTR. DPTR does not have a single internal address, DPH and DPL are assigned an address each.

3.6.2 Flag bits and the PSW Register Like any other microprocessor, the 8051 have a flag register to indicate arithmetic conditions such as the carry bit. The flag register in the 8051 is called the program status word (PSW) register. The program status word (PSW) register is an 8-bit register. It is also referred as the flag register. Although the PSW register is 8-bit wide, only 6 bits of it are used by the microcontroller. The two unused bits are user definable flags. Four of the flags are conditional flags, meaning they indicate some conditions that resulted

20

after an instruction was executed. These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow). The bits of the PSW register are shown below: CY AC -RS1 RS0 OV F0 P PSW.7 PSW.6 PSW.5 PSW.6 PSW.3 PSW.2 PSW.1 PSW.0 Carry flag Auxiliary carry flag Available to the user for general purpose Register bank selector bit 1 Register bank selector bit 0 Overflow flag User definable bit Parity flag

3.6.3 CY, the carry flag This flag is set whenever there is a carry out from the d7 bit. This flag bit is affected after an 8-bit addition or subtraction. It can also be set to 1 or 0 directly by an instruction such as SETB C and CLR C where SETB C stands for set bit carry and CLR C for clear carry. 3.6.4 AC, the auxiliary carry flag If there is carry from D3 to D4 during an ADD or SUB operation, this bit is set: otherwise cleared. This flag is used by instructions that perform BCD arithmetic. 3.6.5 P, the parity flag The parity flag reflects the number of 1s in the accumulator register only. If the register A contains an odd number of 1s, then P=1. Therefore, P=0 if Ahas an even number of 1s. 3.6.6 OV, the overflow flag This flag is set whenever the result of a signed number operation is too large, causing the high order bit to overflow into the sign bit. In general the carry flags is used to detect errors in unsigned arithmetic operations.

21

3.7 CIRCUIT & INTREFACING DESCRIPTION:

Fig. 3 Circuit Diagram The circuit diagram oh DTMF ROBO is shown in the figure above. In the circuit ICs MT8870 & 74LS04N form the DTMF decoder section with its all components,where IC MT8870 converts the output of mobile into digital binery signal & IC 74LS04N boosts the output of MT8870 and gives it to MCU . While L293D is motor driver IC which runs the motors, in the ROBO these three ICS are used beside the MCU. The description of its all subunits is as following on the next page:

3.8 POWER SUPPLY UNIT (+6V) Power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. For a 6V regulated supply :

Fig. 8 Each of the block has its own function as described below Transformer steps down high voltage AC mains to low voltage AC.

22

Rectifier converts AC to DC, but the DC output is varying. Smoothing smooths the DC from varying greatly to a small ripple. Regulator eliminates ripple by setting DC output to a fixed voltage.

3.8.1 Transformer: Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC and this is one of the reasons why mains electricity is AC. The two types of transformers Step-up transformers increase voltage, Step-down transformers reduce voltage.

Fig. 9 Transformer Most power supplies use a step-down transformer to reduce the dangerously high mains voltage (230V in UK) to a safer low voltage. The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils, instead they are linked by an alternating magnetic field created in the softiron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage. Turns ratio = Vp = Np Vs Ns

And Power Out = Power In Vs Is Vp Ip Where Vp = primary (input) voltage

23

Np = number of turns on primary coil Ip = primary (input) current Ns = number of turns on secondary coil Is = secondary (output) current Vs = secondary (output) voltage

3.8.2 Rectifier: A bridge rectifier can be made using four individual diodes, but it is also available in special packages containing the four diodes required. It is called a full-wave rectifier because it uses all the AC wave (both positive and negative sections). 1.4V is used up in the bridge rectifier because each diode uses 0.7V when conducting and there are always two diodes conducting, as shown in the diagram below. Bridge rectifiers are rated by the maximum current they can pass and the maximum reverse voltage they can withstand (this must be at least three times the supply RMS voltage so the rectifier can withstand the peak voltages). Please see the DIODES page for more details, including pictures of bridge rectifiers. In this alternate pairs of diodes conduct, changing over the connections so the alternating directions of AC are converted to the one direction of DC.

Fig. 10 OUTPUT Full-wave Varying DC

3.8.3 Smoothing: Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The diagram shows the unsmoothed varying DC (dotted line) and the smoothed DC (solid line). The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output.

Fig. 11 Capacitor Voltage

24

Note that smoothing significantly increases the average DC voltage to almost the peak value (1.4 RMS value). For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to almost the peak value giving 1.4 4.6 = 6.4V smooth DC. Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the equation below gives the required value for the smoothing capacitor. A larger capacitor will give less ripple. The capacitor value must be doubled when smoothing half-wave DC. Smoothing capacitor for 10% ripple, C = 5 Io Vs f Where, C = smoothing capacitance in farads (F) Io = output current from the supply in amps (A) Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC f = frequency of the AC supply in hertz (Hz), 50Hz in the UK

3.8.4 Regulator:

Fig. 12 Regulator Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. They are also rated by the maximum current they can pass. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ( 'overload protection') and overheating ( 'thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for attaching a heatsink if necessary.

3.8.5 Working Of Power Supply

3.8.5.1 Transformer

25

Fig. 13 Transformer Output The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for electronic circuits unless they include a rectifier and a smoothing capacitor.

3.8.5.2 Transformer + Rectifier

Fig. 14 Rectifier Stage Output

The varying DC output is suitable for lamps, heaters and standard motors. It is not suitable for electronic circuits unless they include a smoothing capacitor. 3.8.5.3 Transformer + Rectifier + Smoothing

26

Fig. 15 Filtered Output The smooth DC output has a small ripple. It is suitable for most electronic circuits.But now also there are very small ripples present there.

3.8.5.4 Transformer + Rectifier + Smoothing + Regulator

1 N 4 0 0 7

L 1 V

M I NV GND

7 O

0 2 U

5 T

+ 5 V

1 3 2 1

1 0 0 0 u f V
C 1

g n d
D 3

Fig. 16 Power Supply

The regulated DC output is very smooth with no ripple. It is suitable for all electronic circuit LCD UNIT: LCD Display: Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs. This is due to the declining prices of LCD, the ability to display numbers, characters and graphics, incorporation of a refreshing controller into the LCD, their by relieving the CPU of the task of refreshing the LCD and also the ease of programming for characters and graphics. HD 44780 based LCDs are most commonly used.

LCD pin description:

27

The LCD discuss in this section has the most common connector used for the Hitatchi 44780 based LCD is 14 pins in a row and modes of operation and how to program and interface with microcontroller is describes in this section.

1 1 1 1 1 1 1

9 8 7 6 5 4 3 2 1

6 5 4 3 2 1 0

1 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1

6 5 4 3 2 1 0

G V D D D D D D D D E R R C V G

n d c c 7 6 5 4 3 2 1 0 / S o c n W

n t r a 2s t c d
1

Fig.19 LCD Pin Description Diagram

VCC, VSS, VEE: The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for controlling LCD contrast. Variable voltage between Ground and Vcc is used to specify the contrast (or "darkness") of the characters on the LCD screen. RS (register select): There are two important registers inside the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction command code register is selected, then allowing to user to send a command such as clear display, cursor at home etc.. If RS=1, the data register is selected, allowing the user to send data to be displayed on the LCD. R/W (read/write): The R/W (read/write) input allowing the user to write information from it. R/W=1, when it read and R/W=0, when it writing.

EN (enable): The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high power, a high-to-low pulse must be applied to this pin in order to for the LCD to latch in the data presented at the data pins. D0-D7 (data lines):

28

The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCDs internal registers. To displays the letters and numbers, we send ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while making RS =1. There are also command codes that can be sent to clear the display or force the cursor to the home position or blink the cursor. We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the information. The busy flag is D7 and can be read when R/W =1 and RS =0, as follows: if R/W =1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking care of internal operations and will not accept any information. When D7 =0, the LCD is ready to receive new information. INTERFACING OF LCD WITH MICROCONTROLLER: An intelligent LCD has two lines with 20 characters each line.The display contains two internal byte wide registers, one for commands and second for characters to be displayed. It also contains a user programmed RAM area that can be programmed to generate any desired character that can be formed using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will be used to signify that the display RAM address 00h is chosen. From diagram Port 1 of microcontroller is used for 8 bit data display on the LCD. Data lines of the LCD Pin no.7 to pin no 14 are connected to the port 1 of the microcontroller. The control pin no.4 register select is connected to P3.5, pin no.5 of LCD for Read/write is connected to P3.6 and the enable pin (6) is connected to microcontroller

Fig. 20 LCD(JHD162A) interfaced with MCU Table: 2 LCD pin description:

29

Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Symbol VSS VCC VEE RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 VCC VSS

I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O I/O

Description Ground +5V power supply Power supply to control contrast RS=0 to select command register, RS=1 to select data register. R/W=0 for write, R/W=1 for read Enable The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus +5V power supply Ground

Motor Driver Circuit


L293D is a dual H-Bridge motor driver. So with one IC, two DC motors can be interfaced which can be controlled in both clockwise and counter clockwise directions and its direction of motion can also be fixed. The four I/Os can be used to connect upto four DC motors. L293D has output current of 600mA and peak output current of 1.2A per channel. Moreover for the protection of the circuit from back EMF, output diodes are included within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which has made L293D a best choice for DC motor driver. The name "HBridge" is derived from the actual shape of the switching circuit which controls the motion of the motor. It is also known as "Full Bridge".By using two motors the robot can be moved in any direction. This Steering mechanism of the robot is called differential drive.

CIRCUIT DIAGRAM

30

Fig. 17 MOTORS Interfaced with MCU

MAX-232 Level Converter Standard serial interfacing of microcontroller (TTL) with PC or any RS232C Standard device , requires TTL to RS232 Level converter . A MAX232 is used for this purpose. It provides 2-channel RS232C port and requires external 10uF capacitors. The driver requires a single supply of +6V .

31

Fig. 18 MAX 232 IC MAX-232 includes a Charge Pump, which generates +10V and -10V from a single 5v supply. MAX-232 Interfaced With MCU

MAX232 (+5V -> +-12V converter) Serial port male 9 pin connector (SER)

Fig. 19 Interfacing of MAX-232 IC

32

Setting Serial Port: SCON 8 bit UART ,RN enabled , TI & RI operated by program. - 50hex Timer 1 Count TH1 = 256 - ((Crystal / 384) / Baud) -PCON.7 is clear. TH1 = 256 - ((Crystal / 192) / Baud)-PCON.7 is set. so with PCON.7 is clear we get timer value = FDhex Reading & Writing the I/O ports The ports of Atmega128 microcontroller are bi-directional 8 bit I/O ports with optional internal pull-ups. Each individual pin of the I/O port can be separately configured as input or output pin. Each parallel I/O port has three associated I/O registers: A. Data direction register, DDRx B. Port driver register, PORTx C. Port pins register, PINx A. Data direction register (DDRx) The purpose of the data direction register is to determine which bits of the port are used for input and which bits are used for output. If logic one is written to DDRx, then the port pin is configured as an output pin. If logic one is written to DDRx, then the port pin is configured as an input pin. DDRA = 0xF0; //sets the 4 MSB bits of portA as output port and //4 LSB bits as input port B. Port drive register (PORTx) If the port is configured as output port, then the PORTx register drives the corresponding value on output pins of the port. DDRA = 0xFF; //set all 8 bits of PORTA as output PORTA = 0xF0; //output logic high on 4 MSB pins and logic low on 4 LSB pins For pins configured as input, we can instruct the microcontroller to supply a pull up register by writing a logic 1 to the corresponding bit of the port driver register DDRA = 0x00;//set all 8 bits of PORTA as input PORTA = 0xFF; //pull up register is assigned to all the pins; C. Port pins register (PINx) Reading from the inputs bits of port is done by reading port pin register x = PINA; //read all 8 pins of port A

33

DDRx PORTx I/O Pull-up Comment 0 0 Input No Tri-state (Hi-Z) 0 1 Input Yes Pin will source current if externally pulled low 1 0 Output No Output low (Sink) 1 1 Output No Output high (Source) Table: Port Pin Configuration Example: Write a code which continuously scans the bump switches connected to Port G (PG0 to PG4) and turns on the buzzer (PB7) if any of the five bump switches is closed. For pin PG0 to PG4 pull up is activated hence in the normal position, when switch is open, input to this pin is high, when the switch is closed input to this pin goes low.

#include <iom128v.h > #include <macros.h> #include <stdio.h> void port_init(void) { PORTB = 0x00; DDRB = 0x80; PORTG = 0x1F; DDRG = 0x00; }

//PB7 is configured as output pin //Pull up is assigned to pins PG0- PG4 //PORTG is configured as input

void buzzer_on (void) { unsigned char portb_copy = 0; portb_copy =PORTB | 0x80; PORTB = portb_copy; } // setting the MSB to turn on the buzzer // executing the command

34

void buzzer_off (void) { unsigned char portb_copy = 0; portb_copy = PORTB & 0x7F; PORTB = portb_copy; } void delay() { unsigned int i,j; for(i=0; i<1000; i++) for(j=0; j<1000; j++); } void main (void) { port_init( ); buzzer_on(); delay(); buzzer_off(); while(1); } Motion control of Robot // resetting the MSB to turn off the buzzer // executing the command

Fig: Interface block diagram of microcontroller and dc moto Direction Control

35

Two DC motors are connected to PortA of the microcontroller. IC L293D is used as a driver between the microcontroller and the DC motors. The L293D has quadruple high-current half-H drivers. The L293D is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V. Drivers are enabled in pairs, with drivers 1 and 2 being enabled by the Enable pin. When an enable input is high (1), the associated drivers are enabled and their outputs are active and in phase with their inputs. Direction of the motor is controlled by asserting one of the inputs to motor to be high (1) and the other to be low (0). To move the motor in opposite direction just interchange the logic applied to the two inputs of the motors. Asserting both inputs to logic high or logic low will stop the motor. Controlling the velocity of the motor To control the velocity of the motor, pulse width modulated (PWM) pulses are applied to Enable pins of L293 driver. PWM is the scheme in which the duty cycle of a square wave output from the microcontroller is varied to provide a varying average DC output. What actually happens by applying a PWM pulse is that the motor is switched ON and OFF at a given frequency. In this way, the motor reacts to the time average of the power supply. Timer3 of the microcontroller is configured to generate PWM with an 8 bit resolution. Timer3 counts from BOTTOM to MAX and then restarts from BOTTOM. The pulse width of the PWM for left and right motors is controlled by OCR3AL and OCR3BL registers of the timer. Timer3 generates a high pulse on PWM pin until the timer reaches the count mentioned in the OCR register and then switches to low until the timer reaches MAX count and then again the timer outputs a high pulse on the PWM pin and restarts counting from the BOTTOM.

Fig: Fast PWM mode timing diagram The duty cycle of the PWM waveform is controlled by modifying the OCR3 register. The extreme values for the OCR3 register represent special cases when generating a PWM

36

waveform output in the fast PWM mode. If OCR3 is set to BOTTOM, the output will be a narrow spike for each MAX+1 timer clock cycle. Setting OCR3 equal to MAX will result in a constantly high output i.e. the motor is rotating with max velocity. Control Registers for PWM generation Timer/Counter3 Control Register A (TCCR3A = 0xA1)

Bit 7 6 5 4 3 2 1 0

Name COM3A1 COM3A0 COM3B1 COM3B0 COM3C1 COM3C0 WGM31 WGM30

Value 1 0 1 0 0 0 0 1

Description Compare Output Mode for Channel A (Clear OC3A pin on compare match) Compare Output Mode for Channel B (Clear OC3B pin on compare match) Compare Output Mode for Channel C Timer/Counter Mode of Operation (Fast PWM, 8-bit)

Timer/Counter3 Control Register B (TCCR3B = 0x0B)

Bit 7 6 5 4 3 2 1 0

Name ICNC3 ICES3 WGM33 WGM32 CS32 CS31 CS30

Value 0 0 0 0 1 0 1 1

Description Input Capture Noise Canceller Input Capture Edge Select Waveform Generation Mode (Fast PWM, 8-bit) Clock Select Pre-scale factor (CLK /64)

To configure timer 3 to generate 8 bit fast PWM, set values of following the registers in an initialization function TCCR3A = 0xA1; //clear OC3A, OC3B pin on match, 8 bit fast PWM TCCR3B = 0x0B; //pre-scalar fclk/64 The PWM frequency for the output can be calculated by the following equation:

37

f clk N * 256 The N variable represents the pre scale factor. It can take a value from the following set {1, 8, 64, 256, or 1024}. f PWM = Position Control of robot using close loop For precise position control of the robot, position encoders are deployed near the wheels of the robot. Position encoder generates a single pulse after every 2.9083mm distance traveled by the robot. And 115 pulses are generated for 360 degrees rotation that is 3.130 degrees per count. A pulse generated by the position encoder generates a hardware interrupt INT0 (interrupt0) for right wheel and INT1 (interrupt1) for left wheel. Interrupt subroutines are used to measure the number of pulses generated and this number is stored in a register. Control Registers for setting Interrupt 7 External Interrupt Control Register A (EICRA = 0x0F)

ISC31, ISC30 ISC00, ISC00: External Interrupt 3 - 0 Sense Control Bits ISCn1 ISCn0 Description 0 0 1 1 0 1 0 1 The low level of INTn generates an interrupt request. Reserved The falling edge of INTn generates asynchronously an interrupt request. The rising edge of INTn generates asynchronously an interrupt request.

2. External Interrupt Mask Register (EIMSK = 0x83)

INT7 INT0: External Interrupt Request 7 - 0 Enable To configure the microcontroller to capture rising edge interrupt signals on INT0, INT1 pins load External Interrupt Control Register A with OFH(i.e. EICRA = 0x0F) and set the 0th and 1st bits in the External Interrupt Mask Register (EIMSK = 0x03). EICRA = 0x0F EIMSK = 0x03; // INT0, INT1 are triggered on rising edge // Enable Interrupt INT0, INT1

EICRA register and EIMSK register are initialized in the init_devices( ) function.

38

1.1 LCD Interface

Fig: Microcontroller LCD interface Interfacing the microcontroller with a LCD requires three control signals and 8 data lines. The three control lines are referred to as EN, RS, and RW. 1. The EN line is called "Enable" and it is connected to PORTAs 5th pin. This control line is used to tell the LCD that you have sent data to it or are ready to receive data from it. This is indicated by a high-to-low transition on this line. To send data to the LCD, your program should make sure that this line is low (0) and then set the other two control lines as required and put data on the data bus. When this is done, make EN high (1) and wait for the minimum amount of time as specified by the LCD datasheet, and end by bringing it to low (0) again. 2. The RS line is the "Register Select" line and it is connected to PORTAs 6th pin. When RS is low (0), the data is treated as a command or special instruction by the LCD (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is treated as text data which should be displayed on the screen. 3. The RW line is the "Read/Write" control line and it is connected to PORTAs 7 th pin. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading from) the LCD. The data bus is bidirectional, 8 bit wide and is connected to PORTC of the microcontroller. The MSB bit (DB7) of data bus is used as a Busy flag. When the Busy flag is 1, the LCD is in internal operation mode, and the next instruction will not be accepted. When RS = 0 and R/W = 1, the Busy flag is output on DB7. The next instruction must be written after ensuring that the Busy flag is 0.

39

Fig: LCD Interface timing diagram Before we can display any data on the LCD we need to initialize the LCD for proper operation. The first instruction we send must tell the LCD whether we'll be communicating with it using an 8-bit or 4-bit data bus. We also opt to use a 5x8 dot character font(as opposed to a 5x10 dot font). These two options are selected by sending the 38H to the LCD as a command. Remember that the RS line must be low if we are sending a command to the LCD. In the second and third instruction we reset and clear the display of the LCD. The fourth instruction sets the cursor to move in incremental direction. In fifth and sixth instruction we turn ON the display and place the cursor at the start. Check the Init_LCD( ) function to see how all this is put in code. init_devices ( ) initializes all the devices in the microcontroller. port_init( ) configures the port directions of the microcontroller. LCD_Busy( ) function checks for the completion of the previous data write operation to LCD. LCD_WriteControl( ) function writes a command word to the LCD. LCD_WriteData( ) function writes data to the LCD. Init_LCD( ) function initializes all the control registers of the LCD. LCD_Clear( ) clears the LCD screen. LCD_Home( ) places the cursor at the beginning of the screen. LCD_DisplayCharacter( ) displays a single character at the position of the cursor. LCD_DisplayString( ) displays a character string on the screen. LCD_Cursor( ) places the cursor on the row and column specified. LCD_print_integer( ) displays the content of LCD_value[8] array in integer format.

1.4 Reading analog sensor values (Using Analog to Digital converter of the microcontroller) The ATmega128 features a 10-bit successive approximation Analog to Digital Converter (ADC). The ADC is connected to an 8-channel Analog Multiplexer which allows 8 singleended voltage inputs constructed from the pins of Port F. The minimum value represents GND and the maximum value represents the voltage on the AREF pin (5 Volt). The result of ADC is calculated as follows for 8 bit of resolution VIN * 28 VIN * 256 ADC = = VREF VREF

40

Two registers control the analog to digital converter. The ADC Control and Status Register (ADCSR) controls the functioning of the ADC and the ADC Multiplexer Select Register (ADMUX) controls which of the eight possible inputs is being measured. ADC Registers 1. ADC control and status register (ADCSR= 0x8E)

Bit 7 6 5 4 3 2 1 0

Name ADEN ADSC ADFR ADIF ADIE ADPS2 ADSP1 ADPS0

Value 1 0 0 0 1 1 1 0

Description ADC Enable bit ADC Start Conversion bit ADC Free Running Select bit ADC Interrupt Flag (set by hardware at end of conversion) ADC Interrupt Mask bit ADC Pre-scaler select bit (CLK /64)

ADC Multiplexer Selection Register (ADMUX= 0x20)

Bit 7 6 5 4 3 2 1 0

Name REFS1 REFS0 ADLAR MUX4 MUX3 MUX2 MUX1 MUX0

Value 0 0 1 0 0 0 0 0

Description Voltage Reference Selection (AREF pin) ADC Left Adjust Select bit Analog channel Select bit (channel 0)

The ADC generates a 10-bit result which is present in the ADC Data Registers,(ADCH and ADCL). By default, the result is presented right-adjusted, (ADCH contain two MSB bits, ADCL contain the 8 LSB bits) but it can be optionally presented left-adjusted (ADCL contain 2 LSB bits, ADCH contain the 8 MSB bits) by setting the 5th bit (ADLAR) in ADMUX

41

register. If the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH. 3. ADC Data Register ADCH & ADCL (ADLAR = 1 )

To read ADC data, the microcontroller can be configured to wait until the conversion is completed, or else the ADC has its own interrupt which can be triggered when a conversion completes. To enable interrupt for ADC set ADIE (3rd bit ) of ADSCR to high. ADMUX = 0x20; ADCSRA = 0x8E; //select adc input 0 and left adjust the result //Enable ADC, Interrupt Enable, Select pre scalar

Before initializing the ADC make sure that PortF is configured as input and the pull up for the port is disabled. PORTF = 0x00; // Pull up for all the port pins is disabled DDRF = 0x00; //PORTF configured as input port Table below briefs us with the various sensors connected to the ADC port of the microcontroller. ADC PORT Description Channel pins ADC0 PORT F.0 Battery voltage ADC1 PORT F.1 (optional) ADC2 PORT F.2 Front infrared range finder ADC3 PORT F.3 Left infrared range finder ADC4 PORT F.4 Left white line sensor ADC5 PORT F.5 Middle white line sensor ADC6 PORT F.6 Right white line sensor ADC7 PORT F.7 Right infrared range finder Table: Channel utilization of ADC on microcontroller

1.5 Serial Communication Serial Communication with a desktop computer is carried out through PORTD, PD2 (RXD) and PD3 (TXD) pins. The baud rate for serial communication is fixed by adjusting the value of USART Baud Rate Register (UBRR).The 16 bit UBRR register and the down-counter connected to it, function as baud rate generator. The down-counter, running at system clock (fosc), is loaded with the UBRR value each time the counter has counted down to zero or when

42

the UBRRL Register is written. A clock is generated each time the counter reaches zero. The value of UBRR register is set using the formula, f osc UBRR = 1 16* BAUD The USART has to be initialized before any communication can take place. The initialization process normally consists of setting the baud rate, setting frame format and enabling the Transmitter or the Receiver depending on the usage. For interrupt driven USART operation, the global interrupt flag should be cleared (and interrupts globally disabled) during the initialization. USART Registers USART Control and Status Register A UCSR1A

Bit 7 6 5 4 3 2 1 0

Name RXC1 TXC1 UDRE1 FE1 DOR1 UPE1 U2X1 MPCM1

Value 0 0 0 0 0 0 0 0

Description USART Receive Complete USART Transmit Complete USART Data Register Empty Frame Error Data Over Run Parity Error Double the USART Transmission Speed Multi-Processor Communication Mode

USART Control and Status Register B (UCSR1B = 0x098)

Bit 7 6 5 4 3 2 1 0

Name RXCIE1 TXCIE1 UDRIE1 RXEN1 TXEN1 UCSZ1 RXB81 TXB81

Value 1 0 0 1 1 0 0 0

Description RX Complete Interrupt Enable TX Complete Interrupt Enable USART Data Register Empty Interrupt Enable Receiver Enable Transmitter Enable Character Size Receive Data Bit 8 Transmit Data Bit 8

USART Control and Status Register C (UCSR1C= 0x06)

43

Bit 6 5 4 3 2 1 0

Name UMSEL1 UPM11 UPM10 USBS1 UCSZ11 UCSZ10 UCPOL1

Value 0 0 0 0 1 1 0

Description USART Mode Select ( Asynchronous mode) Parity Mode (Disabled) Stop bit select (1 bit) Character size (8 bit) Clock Polarity

USART Baud Rate Registers (UBRR1L=0x47 and UBRR1H= 0x00)

To configure microcontroller for asynchronous serial communication port with baud rate of 9600 load the following registers. UCSR1B = 0x098 UCSR1C = 0x06 UBRR1L = 0x47 UBRR1H = 0x00 //RX interrupt, RX enable, TX enable //Asynchronous mode, 1 stop bit // 9600 baud rate

The USART Receiver is enabled by setting the Receive Enable (4th bit in the UCSR1B Register) to one. The baud rate, mode of operation and frame format must be set up before any serial reception can be done. The Receiver starts data reception when it detects a valid start bit. Each bit that follows the start bit will be sampled at baud rate, and shifted into the Receive Shift Register until the stop bit of a frame is received. When the stop bit is received, i.e., a complete serial frame is present in the Receive Shift Register, the contents of the Shift Register will be moved into the receive buffer. The receive buffer can then be read by reading the UDR1 register. The USART Transmitter is enabled by setting the Transmit Enable (3rd bit in the UCSR1B register) to one. A data transmission is initiated by loading the transmit buffer with the data to be transmitted. The CPU can load the transmit buffer by writing to the UDR1 register. The buffered data in the transmit buffer will be moved to the Shift Register when the Shift Register is ready to send a new frame. The Shift Register is loaded with new data if it is in idle state (no ongoing transmission) or immediately after the last stop bit of the previous frame is

44

transmitted. When the Shift Register is loaded with new data, it will transfer one complete frame at the rate given by the baud register. WORKING OF ROBOT: In order to control the robot, you have to make a call to the cellphone attached to the robot from any phone & the phone should be in auto answering mode,so that call is attended automaticly. now the call is picked by the phone on the robot through autoanswer mode(which is in the phn, just enable it). now when you press 2 the robot will move forward when you press 4 the robot will move left when you press 8 the robot will move backwards when you press 6 the robot will move right when you press 5 the robot will stop. Now let we know what happens inside the ROBO : when you press 2 the signal tone goes to the mobile hand free ,which is feed to DTMF decoder ,which converts it into the digital form ,then it is given to the booster IC, which after boosting gives it to the MCU. Now MCU checks the input signal and checks the instruction to follow for the input signal. For 2 the instruction says move RONO forward , then our MCU moves the ROBO forward, similarly for in the case : (i). If key pressed 4 ROBO moves Left. (ii). If key pressed 6 ROBO moves Right. (iii). If key pressed 8 ROBO moves Backward. (iv). If key pressed 5 ROBO Stops.

SOURCE POGRAME

45

Source program: Robit.c #include <mega16.h> void main(void) { unsigned int k, h; DDRA=0x00; DDRD=0XFF; while (1) { k =~PINA; h=k & 0x0F; switch (h) { case 0x02: //if I/P is 0x02 { PORTD=0x89;//O/P 0x89 ie Forward break; } case 0x08: //if I/P is 0x08 { PORTD=0x86; //O/P 0x86 ie Backward break; } case 0x04: { PORTD=0x85; // Left turn break; } case 0x06: { PORTD=0x8A; // Right turn break; } case 0x05: { PORTD=0x00; // Stop break; } }

46

} }?

PROPOSED OUTCOME/ FINDINGS

47

Conventionally, wireless-controlled robots use RF circuits, which have the drawbacks of limited working range, limited frequency range and limited control. Use of a mobile phone for robotic control can overcome these limitations. It provides the advantages of robust control, working range as large as the coverage area of the service provider, no interference with other controllers and up to twelve controls. Although the appearance and capabilities of robots vary vastly, all robots share the features of a mechanical, movable structure under some form of control. The control of robot involves three distinct phases: preception, processing and action. Generally, the preceptors are sensors mounted on the robot, processing is done by the onboard microcontroller or processor, and the task (action) is performed using motors or with some other actuators.

POSSIBLE IMPROVEMENTS

48

1)-A ROBOTIC Arm can also be attached to it , itcan pick up small things. 2)-A metal detector can also be attached to it & can be used in the borders for disposing hidden land mines . 3)-General improvements like using a low dropout voltage regulator, lighter chassis etc 4)-Instead of 12-v motor, low voltage motors can be used

DETAILS OF FACILITIES PROVIDED BY THE INSTITUTION

49

1) Laboratory for working on the project 2) PCB Fabrication 3) Testing and Debugging 4) Various software needed 5) Some basic components 6) An experienced guide to help us throughout the project

UTILIZATION OF OUTCOME OF PROJECT


Scientific

50

Remote control vehicles have a various scientific uses including hazardous environments, working in the deep ocean , and space exploration. The majority of the probes to the other planets in our solar system have been remote control vehicles, although some of the more recent ones were partially autonomous. The sophistication of these devices has fueled greater debate on the need for manned space flights and exploration. The voyager I spacecraft is the first craft of any kind to leave the solar system. The Martian explorers Spirit and Opportunity have provided continuous data about the surface of Mars. Military and Law Enforcement Remote controlled vehicles are used in Law enforcement and military engagements because of many reasons. The exposures to hazards are mitigated to the person who operates the vehicle from the location of relative safety. They are used by many police department bomb-squads to defuse or detonate explosives. Current Unmanned Aerial Vehicles (UAVs) can hover around possible targets until they are positively identified before releasing their pay load of weaponry. Backpack sized UAVs will provide ground troops with over the horizon surveillance capabilities. Search and Rescue UAVs play an increased role in search and rescue all over the world. This was demonstrated by the successful use of UAVs hurricanes that struck Louisiana and Texas in US. Recreation and Hobby Small scale remote control vehicles span a wide range in terms of price and sophistication. There are many types like on-road cars, off-road truck, boats, aero planes and helicopters. Radio-controlled submarine also exist.

REFERENCE
Analog Edge, A Quick Sine Wave Generator, http://www.national.com/nationaledge/jun04/article.html

51

Dallas Semiconductor, Digitally Controlled Sine-Wave Generator, http://www.maxim-ic.com/appnotes.cfm/appnote_number/2081 Instructions, Parts List, and Schematic. Operational Amplifier Function Generator, CK103 Opamp Function Generator, October 2005. http://electronickits.com/kit/complete/meas/ck102.pdf Datasheet, UAF42AP, Burr-Brown (Texas Instruments) Universal Active Filter, http://focus.ti.com/lit/ds/symlink/uaf42.pdf. Burr-Brown Corporation, Texas Instruments, Inc. (1991, 2001). Filter42 [Computer program]. UAF42 Design Program. Tucson, AZ: Applications Engineering. (Application Program No. AB-035) http://focus.ti.com/docs/toolsw/folders/print/filter42.html http://en.wikipedia.org/wiki/Dual-tone_multi-frequency

http://en.wikipedia.org

Você também pode gostar