my project super intelligent robot

60
Super Intelligent Robot 1. Introduction: 1.1. Introduction to Embedded systems: An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, sometimes with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems have become very important today as they control many of the common devices we use. Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld computers share some elements with embedded systems — such as the operating systems and microprocessors which power them — but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected. An embedded system is some combination of computer hardware and software, either fixed in capability or 1 Department of ECE, KCE

Upload: pc-rajasekhar

Post on 03-Dec-2014

125 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: My Project Super Intelligent Robot

Super Intelligent Robot

1. Introduction:

1.1. Introduction to Embedded systems:

An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, sometimes with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems have become very important today as they control many of the common devices we use.

Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale.

Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld computers share some elements with embedded systems — such as the operating systems and microprocessors which power them — but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected.

An embedded system is some combination of computer hardware and software, either fixed in capability or programmable, that is specifically designed for a particular kind of application device. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible hosts of an embedded system

Input Output

Fig 1.1 a real time system interacts with environment

1

Department of ECE, KCE

Embedded system

Page 2: My Project Super Intelligent Robot

Super Intelligent Robot

Embedded systems that are programmable are provided with a programming interface, and embedded systems programming is a specialized occupation.

Certain operating systems or language platforms are tailored for the embedded market, such as Embedded Java and Windows XP Embedded. However, some low-end consumer products use very inexpensive microprocessors and limited storage, with the application and operating system both part of a single program. The program is written permanently into the system's memory in this case, rather than being loaded into RAM (random access memory), as programs on a personal computers.

We are living in the Embedded World. You are surrounded with many embedded products and your daily life largely depends on the proper functioning of these gadgets. Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you to do many of your tasks very effectively. Apart from all these, many controllers embedded in your car take care of car operations between the bumpers and most of the times you tend to ignore all these controllers.

In recent days, you are showered with variety of information about these embedded controllers in many places. All kinds of magazines and journals regularly dish out details about latest technologies, new devices; fast applications which make you believe that your basic survival is controlled by these embedded products. Now you can agree to the fact that these embedded products have successfully invaded into our world. You must be wondering about these embedded controllers or systems. What is this Embedded System?

The computer you use to compose your mails, or create a document or analyze the database is known as the standard desktop computer. These desktop computers are manufactured to serve many purposes and applications. You need to install the relevant software to get the required processing facility. So, these desktop computers can do many things. In contrast, embedded controllers carryout a specific work for which they are designed. Most of the time, engineers design these embedded controllers with a specific goal in mind. So these controllers cannot be used in any other place.

Theoretically, an embedded controller is a combination of a piece of microprocessor based hardware and the suitable software to undertake a specific task.

These days designers have many choices in microprocessors/microcontrollers. Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an experienced designer. Selecting a right microprocessor may turn out as a most difficult first step and it is getting complicated as new devices continue to pop-up very often.

2

Department of ECE, KCE

Page 3: My Project Super Intelligent Robot

Super Intelligent Robot

In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market acceptance of this particular family has driven many semiconductor manufacturers to develop something new based on this particular architecture. Even after 25 years of existence, semiconductor manufacturers still come out with some kind of device using this 8031 core.

1.2. Microcontroller Vs Microprocessor:

What is the difference between a Microprocessor and Microcontroller? By microprocessor is meant the general purpose Microprocessors such as Intel's X86 family (8086, 80286, 80386, 80486, and the Pentium) or Motorola's 680X0 family (68000, 68010, 68020, 68030, 68040, etc). These microprocessors contain no RAM, no ROM, and no I/O ports on the chip itself. For this reason, they are commonly referred to as general-purpose Microprocessors.

A system designer using a general-purpose microprocessor such as the Pentium or the 68040 must add RAM, ROM, I/O ports, and timers externally to make them functional. Although the addition of external RAM, ROM, and I/O ports makes these systems bulkier and much more expensive, they have the advantage of versatility such that the designer can decide on the amount of RAM, ROM and I/O ports needed to fit the task at hand. This is not the case with Microcontrollers.

A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM, ROM, I/O ports, and a timer all on a single chip. In other words, the processor, the RAM, ROM, I/O ports and the timer are all embedded together on one chip; therefore, the designer cannot add any external memory, I/O ports, or timer to it. The fixed amount of on-chip ROM, RAM, and number of I/O ports in Microcontrollers makes them ideal for many applications in which cost and space are critical.

In many applications, for example a TV remote control, there is no need for the computing power of a 486 or even an 8086 microprocessor. These applications most often require some I/O operations to read signals and turn on and off certain bits.

1.3. Microcontroller for Embedded systems

In the Literature discussing microprocessors, we often see the term Embedded System. Microprocessors and Microcontrollers are widely used in embedded system products. An embedded system product uses a microprocessor (or Microcontroller) to do one task only. A printer is an example of embedded system since the processor inside it performs one task only; namely getting the data and printing it. Contrast this with a Pentium based PC. A PC can be used for any number of applications such as word processor, print-server, bank teller terminal, Video game, network server, or Internet terminal. Software for

3

Department of ECE, KCE

Page 4: My Project Super Intelligent Robot

Super Intelligent Robot

a variety of applications can be loaded and run. of course the reason a pc can perform myriad tasks is that it has RAM memory and an operating system that loads the application software into RAM memory and lets the CPU run it.

In an Embedded system, there is only one application software that is typically burned into ROM. An x86 PC contains or is connected to various embedded products such as keyboard, printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on. Each one of these peripherals has a Microcontroller inside it that performs only one task. For example, inside every mouse there is a Microcontroller to perform the task of finding the mouse position and sending it to the PC. Table 1-1 lists some embedded products.

The generic 8051 architecture supports a Harvard architecture, which contains two separate buses for both program and data. So, it has two distinctive memory spaces of 64K X 8 size for both programmed and data. It is based on an 8 bit central processing unit with an 8 bit Accumulator and another 8 bit B register as main processing blocks. Other portions of the architecture include few 8 bit and 16 bit registers and 8 bit memory locations.

Each 8051 device has some amount of data RAM built in the device for internal processing. This area is used for stack operations and temporary storage of data.

This bus architecture is supported with on-chip peripheral functions like I/O ports, timers/counters, versatile serial communication port. So it is clear that this 8051 architecture was designed to cater many real time embedded needs.

The following list gives the features of the 8051 architecture:-

Optimized 8 bit CPU for control applications and extensive Boolean processing capabilities.64K Program Memory address space.64K Data Memory address space.128 bytes of on chip Data Memory.32 Bi-directional and individually addressable I/O lines.Two 16 bit timer/counters.Full Duplex UART.6-source / 5-vector interrupt structure with priority levels.On chip clock oscillator.

Now we may be wondering about the non-mentioning of memory space meant for the program storage, the most important part of any embedded controller. Originally this 8051 architecture was introduced with on-chip, ‘one time programmable’

4

Department of ECE, KCE

Page 5: My Project Super Intelligent Robot

Super Intelligent Robot

version of Program Memory of size 4K X 8. Intel delivered all these microcontrollers (8051) with user’s program fused inside the device. The memory portion was mapped at the lower end of the Program Memory area. But, after getting devices, customers couldn’t change anything in their program code, which was already made available inside during device fabrication.

1.3.1 Block Diagram of the 8051 Core:

Fig 1.3.1 Block Diagram of the 8051 Core

So, very soon Intel introduced the 8051 devices with re-programmable type of Program Memory using built-in EPROM of size 4K X 8. Like a regular EPROM, this memory can be re-programmed many times. Later on Intel started manufacturing these 8031 devices without any on chip Program Memory.

Now I go ahead giving more information on the important functional blocks of the 8051.

5

Department of ECE, KCE

Page 6: My Project Super Intelligent Robot

Super Intelligent Robot

8051 Microcomputer Pin out Diagram:

Fig 1.2 8051 Microcomputer Pin out Diagram

6

Department of ECE, KCE

Page 7: My Project Super Intelligent Robot

Super Intelligent Robot

1.3.2 Pin diagram of microcontroller:

Fig 1.3.2 Pin diagram of microcontroller

Pins description:

ALE/PROG:

Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator frequency, for external timing or clocking purposes, even when there are no accesses to external memory. (However, one ALE pulse is skipped during each access to external Data Memory.) This pin is also the program pulse input (PROG) during EPROM programming.

PSEN:

Program Store Enable is the read strobe to external Program Memory. When the device is executing out of external Program Memory, PSEN is activated twice each machine cycle (except that two PSEN activations are skipped during accesses to external Data Memory). PSEN is not activated when the device is executing out of internal Program Memory.

7

Department of ECE, KCE

Page 8: My Project Super Intelligent Robot

Super Intelligent Robot

EA/VPP:

When EA is held high the CPU executes out of internal Program Memory (unless the Program Counter exceeds 0FFFH in the 80C51). Making EA low forces the CPU to execute out of external memory regardless of the Program Counter value. In the 80C31, EA must be externally wired low. In the EPROM devices, this pin also receives the programming supply voltage (VPP) during EPROM programming.

XTAL1:

Input to the inverting oscillator amplifier.

XTAL2:Output from the inverting oscillator amplifier

Port 0:

Port 0 is an 8-bit open drain bidirectional port. As an open drain output port, it can sink eight LS TTL loads. Port 0 pins that have 1s written to them float, and in that state will function as high impedance inputs. Port 0 is also the multiplexed low-order address and data bus during accesses to external memory. In this application it uses strong internal pull-ups when emitting 1s. Port 0 emits code bytes during program verification. In this application, external pull-ups are required.

Port 1:

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Port 1 pins that have 1s written to them are pulled high by the internal pull-ups, and in that state can be used as inputs. As inputs, port 1 pins that are externally being pulled low will source current because of the internal pull-ups.

Port 2:

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. Port 2 emits the high-order address byte during accesses to external memory that use 16-bit addresses. In this application, it uses the strong internal pull-ups when emitting 1s.

Port 3:

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. It also serves the functions of various special features of the 80C51 Family as follows:

8

Department of ECE, KCE

Page 9: My Project Super Intelligent Robot

Super Intelligent Robot

Port Pin Alternate Function

P3.0 RxD (serial input port)P3.1 TxD (serial output port)

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

P3.6 WR (external data memory write strobe)

P3.7 RD (external data memory read strobe)

VCC: Supply voltage

VSS: Circuit ground potential

All four ports in the 80C51 are bidirectional. Each consists of a latch (Special Function Registers P0 through P3), an output driver, and an input buffer. The output drivers of Ports 0 and 2, and the input buffers of Port 0, are used in accesses to external memory. In this application, Port 0 outputs the low byte of the external memory address, time-multiplexed with the byte being written or read. Port 2 outputs the high byte of the external memory address when the address is 16 bits wide. Otherwise, the Port 2 pins continue to emit the P2 SFR content.

All the Port 3 pins are multifunctional. They are not only port pins, but also serve the functions of various special features as listed below:

Port Pin Alternate Function

P3.0 RxD (serial input port) P3.1 TxD (serial output port)

P3.2 INT0 (external interrupt)

P3.3 INT1 (external interrupt)

P3.4 T0 (Timer/Counter 0 external input)

P3.5 T1 (Timer/Counter 1 external input)

P3.6 WR (external Data Memory write strobe)

P3.7 RD (external Data Memory read strobe)

9

Department of ECE, KCE

Page 10: My Project Super Intelligent Robot

Super Intelligent Robot

2. Equipment requires:

2.3 Hardware:

power supply

Microcontroller AT89S52

Quadruple Half-H Drivers

DTMF receiver

Dpdt Relays

DC motors

LDR

Smoke sensor

Mobile

2.2 Software:

Compiler: kiel compiler

Language: Embedded c Assembly

3. Overview of project:

Robotic manipulators are widely used to replace human operators in tasks that are repetitive in nature. However, there are many tasks that are non-repetitive, unpredictable, or hazardous to the human operators. Clearing up a nuclear power plant leak or exploring the extreme depths of ocean are just some examples. The most developed robot in practical use today is the robotic arm and it is seen in applications throughout the world. Robotic are used to carry out work in outer space where man cannot survive and also used to do work in

the medical field such as conducting experiments without exposing the researcher. In early days, robotic manipulators have been implemented in different control

techniques like mechanical control and the remote control or tele-opertation. But with the

10

Department of ECE, KCE

Page 11: My Project Super Intelligent Robot

Super Intelligent Robot

advent of high performance, a new way of control using mobile has been implemented which is introduced in this project.

Block diagram:

Fig 3.1 block diagram

Block diagram description:

All the above systems are controlled by the Microcontroller. In our project we are using the popular 8 bit microcontroller AT89S52. It is a 40 pin microcontroller.

The Microcontroller AT89S52 is used to control the dc motors. It gets the signals from the DTMF decoder and it drives the motors according to the DTMF inputs. Two DC motors are used to drive the robot in four directions i.e. Front, Back, Right, and Left. The robot is also developed to give an alert when any fire accidents occurs and to give alert when there

11

Department of ECE, KCE

MOBILE

DTMF DECODER

HT9170B

AT

89S52

FIRE SENSOR

LIGHT SENSOR

ULN2003

DRIVER

GAREMOTOR1

GAREMOTOR2

BUZZER

Page 12: My Project Super Intelligent Robot

Super Intelligent Robot

is no sufficient light. For this feature the fire sensor and LDR circuits are attached to the robot which alerts when there is less intensity of light or when any fire accident happens.

4. Hardware design:

4.1 power supply:

Regulated power supply:

A variable regulated power supply, also called a variable bench power supply, is one where you can continuously adjust the output voltage to your requirements. Varying the output of the power supply is the recommended way to test a project after having double checked parts placement against circuit drawings and the parts placement guide.

This type of regulation is ideal for having a simple variable bench power supply. Actually this is quite important because one of the first projects a hobbyist should undertake is the construction of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's much handier to have a variable supply on hand, especially for testing. Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need to build a regulated 5 volt source. Usually you start with an unregulated power to make a 5 volt power supply; we use a LM7805 and LM7812 voltage regulator ICs (Integrated Circuit). The IC is shown below.

Fig 4.1.1 voltage regulator pin diagram

12

Department of ECE, KCE

Page 13: My Project Super Intelligent Robot

Super Intelligent Robot

The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the Output pin.

Circuit features:

Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot

Circuit complexity: Very simple and easy to build

Circuit performance: Very stable +5V output voltage, reliable operation

Availability of components: Easy to get, uses only very common basic components

Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects

Applications: Part of electronics devices, small laboratory power supply

Power supply voltage: Unregulated DC 8-18V power supply

Power supply current: Needed output current + 5 mA

Component costs: Few dollars for the electronics components + the input transformer cost.

Block diagram:

13

Department of ECE, KCE

Page 14: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.1.2 Block diagram of linear power supply

Linear power supply circuit diagram:

14

Department of ECE, KCE

Page 15: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.1.3 linear power supply circuit

4.2 Microcontroller AT89S52:

Pin diagram of AT89S52:

Fig 4.2.1 Pin diagram of AT89S52

Features:

Compatible with MCS-51® Products8K Bytes of In-System Programmable (ISP) Flash MemoryEndurance: 1000 Write/Erase Cycles4.0V to 5.5V Operating RangeFully Static Operation: 0 Hz to 33 MHzThree-level Program Memory Lock256 x 8-bit Internal RAM32 Programmable I/O LinesThree 16-bit Timer/CountersEight Interrupt SourcesFull Duplex UART Serial ChannelLow-power Idle and Power-down ModesInterrupt Recovery from Power-down ModeWatchdog TimerDual Data PointerPower-off Flag

15

Department of ECE, KCE

Page 16: My Project Super Intelligent Robot

Super Intelligent Robot

Description:

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pinot. 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 in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a Highly-flexible and cost-effective solution to many embedded control applications.

The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.

16

Department of ECE, KCE

Page 17: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.2.2 AT89S52 circuit block diagram

Pin Description:

VCC- Supply voltage.GND- Ground.Port 0:

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs.

Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups.

Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification.

17

Department of ECE, KCE

Page 18: My Project Super Intelligent Robot

Super Intelligent Robot

Port 1:Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output

buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups.

In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table.

Port 1 also receives the low-order address bytes during Flash programming and verification.

Table: 4.2.1 Alternate functions of port1Port 2:

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups.

Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During Accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.

Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.Port 3:

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups.

Port 3 receives some control signals for Flash programming and verification. Port 3 also serves the functions of various special features of the AT89S52, as shown in the following table.

18

Department of ECE, KCE

Page 19: My Project Super Intelligent Robot

Super Intelligent Robot

Table: 4.2.2 Functions of various special feature of port2

RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.

ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming.

In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory.

If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

PSEN: Program Store Enable (PSEN) is the read strobe to external program memory.When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

EA/VPP: External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH.

19

Department of ECE, KCE

Page 20: My Project Super Intelligent Robot

Super Intelligent Robot

Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions.This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming.

XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating

circuit.

XTAL2: Output from the inverting oscillator amplifier

Special Function Registers:A map of the on-chip memory area called the Special Function Register (SFR) space is

shown in Table 1.Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect.

User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0.

Timer 2 Registers:Control and status bits are contained in registers T2CON (shown in Table 2) and

T2MOD (shown in Table 6) for Timer2. The register pair (RCAP2H,RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.

Interrupt Registers:The individual interrupt enable bits are in the IE register. Two priorities can be set for

each of the six interrupt sources in the IP register.

20

Department of ECE, KCE

Page 21: My Project Super Intelligent Robot

Super Intelligent Robot

Table: 4.2.3 ASF Map and reset values

21

Department of ECE, KCE

Page 22: My Project Super Intelligent Robot

Super Intelligent Robot

Table 4.2.4 T2CON timer/counter2 control register

22

Department of ECE, KCE

Page 23: My Project Super Intelligent Robot

Super Intelligent Robot

Dual Data Pointer Registers:

To facilitate accessing both internal and external data memory, two banks of 16-bit Data Pointer Registers are provided: DP0 at SFR address locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1selects DP0 and DPS = 1 selects DP1. The user should ALWAYS initialize the DPS bit to the appropriate value before accessing the respective Data Pointer Register.

Power Off Flag:

The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON SFR. POF is set to “1” during power up. It can be set and rest under software control and is not affected by reset.

23

Department of ECE, KCE

Page 24: My Project Super Intelligent Robot

Super Intelligent Robot

Table: 4.2.5 AUXR1: Auxiliary Register 1

Memory Organization:

MCS-51 devices have a separate address space for Program and Data Memory. Up to 64K bytes each of external Program and Data Memory can be addressed.

Program Memory:

If the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to external memory.

Data Memory:

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy parallel address space to the Special Function Registers. This means that the upper 128bytes have the same addresses as the SFR space but are physically separate from SFR space.

When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions which use direct addressing access the SFR space.

For example, the following direct addressing instruction accesses the SFR at location

0A0H (which is P2).

MOV 0A0H, #data

Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).

24

Department of ECE, KCE

Page 25: My Project Super Intelligent Robot

Super Intelligent Robot

MOV @R0, #data

Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.

Watchdog Timer (One-time Enabled with Reset-out):

The WDT is intended as a recovery method in situations where the CPU may be subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog Timer Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H). When the WDT is enabled, it will increment every machine cycle while the oscillator is running. The WDT timeout period is dependent on the external clock frequency. There is no way to disable the WDT except through reset (either hardware reset or WDT overflow reset). When WDT overflows, it will drive an output RESET HIGH pulse at the RST pin.

Using the WDT:

To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by writing 01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter overflows when it reaches 16383 (3FFFH), and this will reset the device. When the WDT is enabled, it will increment every machine cycle while the oscillator is running. This means the user must reset the WDT at least every 16383 machine cycles. To reset the WDT the user must write 01EH and 0E1H to WDTRST. WDTRST is a write-only register. The WDT counter cannot be read or written. When WDT overflows, it will generate an output.

RESET pulse at the RST pin. The RESET pulse duration is 98xTOSC, where TOSC = 1/FOSC. To make the best use of the WDT, it should be serviced in those sections of code that will periodically be executed within the time required to prevent a WDT reset.

WDT during Power down and Idle:-

In Power-down mode the oscillator stops, which means the WDT also stops. While in Power-down mode, the user does not need to service the WDT. There are two methods of exiting Power-down mode: by a hardware reset or via a level-activated external interrupt

which is enabled prior to entering Power-down mode. When Power-down is exited with hardware reset, servicing the WDT should occur as it normally does whenever the AT89S52 is reset. Exiting Power-down with an interrupt is significantly different.

The interrupt is held low long enough for the oscillator to stabilize. When the interrupt is brought high, the interrupt is serviced. To prevent the WDT from resetting the device.

25

Department of ECE, KCE

Page 26: My Project Super Intelligent Robot

Super Intelligent Robot

While the interrupt pin is held low, the WDT is not started until the interrupt is pulled high. It is suggested that the WDT be reset during the interrupt service for the interrupt used to exit Power-down mode. To ensure that the WDT does not overflow within a few states of exiting Power-down, it is best to reset the WDT just before entering Power-down mode.

Before going into the IDLE mode, the WDIDLE bit in SFR AUXR is used to determine whether the WDT continues to count if enabled. The WDT keeps counting during IDLE.

(WDIDLE bit = 0) as the default state. To prevent the WDT from resetting the AT89S52while in IDLE mode, the user should always set up a timer that will periodically exit IDLE, service the WDT, and reenter IDLE mode. With WDIDLE bit enabled, the WDT will stop to count in IDLE mode and resumes the count upon exit from IDLE.

UART:

The UART in the AT89S52 operates the same way as the UART in the AT89C51 and AT89C52. For further information on the UART operation, refer to the ATMEL Web site (http://www.atmel.com). From the home page, select “Products”, then “8051-ArchitectureFlash Microcontroller”, then “Product Overview”.

Timer 0 and 1:

Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in the AT89C51 and AT89C52. For further information on the timers” operation, refer to the ATMEL Web site (http://www.atmel.com). From the home page, select “Products”, then “8051-Architecture Flash Microcontroller”, then “Product Overview”.

Timer 2:-

Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter.

The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2).

Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 5.

Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.

Table:

26

Department of ECE, KCE

Page 27: My Project Super Intelligent Robot

Super Intelligent Robot

Table: 4.2.6 Timer 2 Operating Modes

In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected.

Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle.

Capture Mode:

In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0,

Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This bit can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same operation, but a 1-to-0 transition at external input T2EX also causes the current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt. The capture mode is illustrated in Figure 1.

Auto-reload (Up or Down Counter):

Timer 2 can be programmed to count up or down when configured in its 16-bit auto reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the SFR T2MOD (see Table 6). Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the T2EX pin.

27

Department of ECE, KCE

Page 28: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.2.3 timer in capture mode

Figure 4.2.3 shows Timer 2 automatically counting up when DCEN = 0. In this mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at external input T2EX. This transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if enabled.

Setting the DCEN bit enables Timer 2 to count up or down, as shown in Figure 2. In this mode, the T2EX pin controls the direction of the count. A logic 1 at T2EX makes Timer 2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively. A logic 0 at T2EX makes Timer 2 count down. The timer underflows when TH2 and TL2 equal the values stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be reloaded into the timer registers.

The EXF2 bit toggles whenever Timer 2 overflows or underflows and can be used as a 17th bit of resolution. In this operating mode, EXF2 does not flag an interrupt.

28

Department of ECE, KCE

Page 29: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.2.4 timer 2 auto reload mode (DCEN=0)

Table: 4.2.7 T2MOD – Timer 2 Mode Control Register

29

Department of ECE, KCE

Page 30: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.2.5 timer 2 auto reload mode (DCEN=1)

Baud Rate Generator: Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON (Table 2). Note that the baud rates for transmit and receive can be different if Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other function.

Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure 4.

The baud rate generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are preset by software.The baud rates in Modes 1 and 3 are determined by Timer 2’s overflow rate according to the following equation.

The Timer can be configured for either timer or counter operation. In most applications, it is configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when it is used as a baud rate generator. Normally as the timer, it increments every machine cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it increments every state time (at 1/2 the oscillator frequency). The baud rate formula is given below.

where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit

unsigned integer.

30

Department of ECE, KCE

Page 31: My Project Super Intelligent Robot

Super Intelligent Robot

Timer 2 as a baud rate generator is shown in Figure 4. This figure is valid only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will not generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus, when Timer2 is in use as a baud rate generator, T2EX can be used as an extra external interrupt.

Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode,TH2 or TL2 should not be read from or written to. Under these conditions, the Timer is incremented every state time, and the results of a read or write may not be accurate.

The RCAP2 registers may be read but should not be written to, because a write might overlap a reload and cause write and/or reload errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.

Interrupts:The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and

INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are all shown in Figure 6. Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once.

Note that Table 5 shows that bit position IE.6 is unimplemented. User software should not write a 1 to this bit position, since it may be used in future AT89 products.Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in software.

The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.

31

Department of ECE, KCE

Page 32: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.2.6 interrupt enable and interrupt source

32

Department of ECE, KCE

Page 33: My Project Super Intelligent Robot

Super Intelligent Robot

Oscillator Characteristics:

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 7. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in Figure 8.

There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

Idle Mode:In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain

active.The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.

Note that when idle mode is terminated by a hardware reset, the device normally resumes program execution from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory.

Power-down Mode:In the Power-down mode, the oscillator is stopped, and the instruction that invokes

Power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the Power-down mode is terminated. Exit from Power down mode can be initiated either by a hardware reset or by an enabled external interrupt.

Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize

33

Department of ECE, KCE

Page 34: My Project Super Intelligent Robot

Super Intelligent Robot

Fig 4.2.7 Note: C1, C2 = 30 pF 10 pF for Crystals= 40 pF 10 pF for Ceramic Resonators

Table: 4.2.8 Status of External Pins during Idle and Power-down Mode

Program Memory Lock Bits:The AT89S52 has three lock bits that can be left un programmed (U) or can be

programmed (P) to obtain the additional features listed in the following table.

34

Department of ECE, KCE

Page 35: My Project Super Intelligent Robot

Super Intelligent Robot

Table: 4.2.9 Lock Bit Protection Modes

When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value and holds that value until reset is activated. The latched value of EA must agree with the current logic level at that pin in order for the device to function properly.

4.3 quadruple half-h driver L293D:

Pin diagram:

Fig 4.3.1 Pin diagram of L293D

Features of L293…NE:Wide supply voltage range: 4.5v to 36vSeparate input logic supplyInternal ESD protectionThermal shutdownHigh noise immunityOutput current 1A per channel

35

Department of ECE, KCE

Page 36: My Project Super Intelligent Robot

EN 3A M1 4A M2

H H Fast motor stop H Run

H L Run L Fast motor stop

L X Free-running motor stop X Free-running motor stop

L = low, H = high, X = don’t care

Super Intelligent Robot

Peak output current 2A per channel

Description/ordering information:The L293 and L293D are quadruple high-current half-H drivers. The L293 is designed

to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293D is designed to provide b i d i r e c t i o n a l d r i v e c u r r e n t s o f u p to 600-mA at voltages from 4.5 V to 36 V. Both devices are designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads

in positive-supply applications.All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a Darlington transistor sink and a pseudo- Darlington source. Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is high, the associated drivers are enabled, and their outputs are active and in phase with their inputs. When the enable input is low, those drivers are disabled, and their outputs are off and in the high-impedance state. With the proper data inputs, each pair of drivers forms a full-H (or bridge) reversible drive suitable for solenoid or motor applications.

Application information:

Vcc2 SES5001

3A 4A GND

10 11 15, 14, 16

8 Vcc1

9 EN

4, 5, 12, 13

GND

Fig 4.3.2 DC Motor Controls (connections to ground and to supply voltage)

36

Department of ECE, KCE

Page 37: My Project Super Intelligent Robot

EN 1A 2A FUNCTIONH L H Turn rightH H L Turn leftH L L Fast motor stopH H H Fast motor stopL X X Fast motor stop

L = low, H = high, X = don’t care

Super Intelligent Robot

Fig 4.3.3 Bidirectional DC Motor Control

Fig 4.3.4 bipolar stepping motor control

Mounting instructions:

The Rthj-amp of the L293 can be reduced by soldering the GND pins to a suitable copper area of the printed circuit board or to an external heat sink.

Figure shows the maximum package power PTOT and the JA as a function of the side of two

equal square copper areas having a thickness of 35 m. In addition, an external heat sink can be used.

37

Department of ECE, KCE

Page 38: My Project Super Intelligent Robot

Super Intelligent Robot

During soldering, the pin temperature must not exceed 260C, and the soldering time must not exceed 12 seconds.The external heat sink or printed circuit copper area must be connected to electrical ground.

4.4 DTMF Receiver:Here we are using HT9170 IC as the DTMF receiver.

Features:

Operating voltage: 2.5V~5.5VMinimal external componentsNo external filter is requiredLow standby current (on power down mode)Excellent performanceTristate data output for C interface3.58MHz crystal or ceramic resonator1633Hz can be inhibited by the INH pinHT9170B: 18-pin DIP packageHT9170D: 18-pin SOP package

General Description:

The HT9170 series are Dual Tone Multi Frequency (DTMF) receivers integrated with digital decoder and band split filter functions. The HT9170B and HT9170D types supply power-down mode and inhibit mode operations. All types of the HT9170 series use digital counting techniques to detect and decode all the 16

DTMF tone pairs into a 4-bit code output. Highly accurate switched capacitor filters are employed to divide tone (DTMF) signals into low and high group signals. A built-in dial tone rejection circuit is provided to eliminate the need for pre-filtering.

Pin Description:

Pin Name I/OInternal

Connection Description

VP IOPERATIONAL

AMPLIFIER Operational amplifier non-inverting input

VN I Operational amplifier inverting input

GS O Operational amplifier output terminal

VREF O VREF Reference voltage output, normally VDD/2

X1 I

OSCILLATOR

The system oscillator consists of an inverter, a bias resistor and the necessary load capacitor on chip.A standard 3.579545MHz crystal connected to X1 and X2 terminals implements the oscillator function.

X2 O

38

Department of ECE, KCE

Page 39: My Project Super Intelligent Robot

Super Intelligent Robot

PWDN I CMOS IN Pull-low

Active high. This enables the device to go into power down mode and inhibits the oscillator. This pin input is internally pulled down.

INH I CMOS IN Pull-low

Logic high. This inhibits the detection of tones representing characters A, B, C and D. This pin input is internally pulled down.

VSS Negative power supply

OE ICMOS IN Pull-high D0~D3 output enable, high active

D0~D3 O CMOS OUT Tristate

Receiving data output terminalsOE= H : Output enableOE= L : High impedance

DV O CMOS OUTData valid outputWhen the chip receives a valid tone (DTMF) signal, the DVgoes high; otherwise it remains low.

EST O CMOS OUT Early steering output (see Functional Description)

RT/GT I/O CMOS IN/OUTTone acquisition time and release time can be set through connection with external resistor and capacitor.

VDD Positive power supply, 2.5V~5.5V for normal operation

DVB O CMOS OUTOne-shot type data valid output, normal high, when the chip receives a valid time (DTMF) signal, the DVB goes low for10ms.

Absolute Maximum Ratings

Supply Voltage ................................. 0.3V to 6VStorage Temperature................. 50 C to 125 C Input Voltage .................VSS 0.3V to VDD+0.3V

Operating Temperature.............. 20 C to 75 C

Note: These are stress ratings only. Stresses exceeding the range specified under Absolute Maxi- mum Ratings may cause substantial damage to the device. Functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged expo- sure to extreme conditions may affect device reliability.

39

Department of ECE, KCE

Page 40: My Project Super Intelligent Robot

Super Intelligent Robot

Functional Description:

Overview:

The HT9170 series tone decoders consist of three band pass filters and two digital decode circuits to convert a tone (DTMF) signal into digital code output. An operational amplifier is built-in to adjust the input signal fig below.

Vi R1 VP vi1 c VP

c VN HT9170 series vi2 c VN

RF GS R3 R4 R5 HT9170 series

VREF GS

VREF

Fig 4.4.1 Fig 4.4.2

Fig Input operation for amplifier application circuit

4.4.1 Standard input circuit

4.4.2 Differential input circuit

The pre-filter is a band rejection filter which reduces the dialing tone from 350Hz to 400Hz. The low group filter filters low group frequency signal output whereas the high group filter filters high group frequency signal output.

Each filter output is followed by a zero-crossing detector with hysteresis. When each signal amplitude at the output exceeds the specified level, it is transferred to full swing logic signal.

When input signals are recognized to be effective, DV becomes high, and the correct tone code (DTMF) digit is transferred.

40

Department of ECE, KCE

Page 41: My Project Super Intelligent Robot

Super Intelligent Robot

DTMF dialing matrix:

DTMF data output table:

Low Group (Hz) High Group (Hz) Digit OE D3 D2 D1 D0

697 1209 1 H L L L H

697 1336 2 H L L H L

697 1477 3 H L L H H

770 1209 4 H L H L L

770 1336 5 H L H L H

770 1477 6 H L H H L

852 1209 7 H L H H H

852 1336 8 H H L L L

852 1477 9 H H L L H

941 1336 0 H H L H L

941 1209 * H H L H H

941 1477 # H H H L L

697 1633 A H H H L H

770 1633 B H H H H L

852 1633 C H H H H H

941 1633 D H L L L L

ANY L Z Z Z Z

Z=high impedance

Data output

The data outputs (D0~D3) are tri state outputs. When OE input becomes low,

the data outputs (D0~D3) are high impedance.

41

Department of ECE, KCE

Page 42: My Project Super Intelligent Robot

Super Intelligent Robot

4.5 Relays:

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and most have double throw (changeover) switch contacts as shown in the diagram.

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification.

COM = Common, always connect to this; it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off.

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

Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays with 4 sets of changeover contacts are readily available. For

42

Department of ECE, KCE

Fig 4.5.1 Circuit symbol for a Relay

Page 43: My Project Super Intelligent Robot

Super Intelligent Robot

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

Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay.

The supplier's catalogue should show you the relay's connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil.

The animated picture shows a working relay with its coil and switch contacts. You can see a lever on the left being attracted by magnetism when the coil is switched on. This lever moves the switch contacts. There is one set of contacts (SPDT) in the foreground and another behind them, making the relay DPDT.

4.6 DC Gear Motors:

The 1271 geared instrument dc motor is ideally suited to a wide range of applications requiring a combination of low speed operation and small unit size. The integral iron core DC motor provides smooth operation and a bidirectional variable speed capability while the gear head utilizes a multistage metal spur gear train rated for a working torque up to 0.2Nm. The unit, which is suitable for mounting in any attitude, provides reliable operation over a wide ambient temperature range and is equipped with an integral VDR (voltage dependant resistor) electrical suppression system to minimize electrical interference. The 1271 unit offers a range of gear ratio options for operating speeds from 5-200 rpm and is ideally suited to applications where small size and low unit price are important design criteria.

Features:

6 or 12Vdc operation Ratios from 10:1 to 392:1

Rated torque up to 20Ncm

4mm Output shaft

4.7 LDR:

43

Department of ECE, KCE

Page 44: My Project Super Intelligent Robot

Super Intelligent Robot

Light dependent resistors (LDRs) are made from cadmium sulphide containing no or very few free electrons when not illuminated. Its resistance is then quite high. When it absorbs light, electrons are liberated and the conductivity of the material increases. Cadmium sulphide (CdS) is, therefore, a photoconductor. The approximate relationship between the resistance and illumination is R = AE~a where E is illumination in lux, R is resistance in ohms, A and a are constants. The value of a depends on the cadmium sulphide used and on the manufacturing process. Values around 0.7 to 0.9 are quite common.

Basic structure of an LDR-Light dependent resistor:

Device consists of a pair of metal film contacts separated by a snake-like track of cadmium sulphide film, designed to provide the maximum possible contact area with the two metal films. The structure is housed in a clear plastic or resin case, to provide free acess to external light. Practical LDRs are available in a variety of sizes and package styles, the most popular size having a face diameter of roughly 10 mm.

LDRs are sensitive, inexpensive, and readily available devices. They have good power and voltage handling capabilities, similar to those of a conventional resistor. Their only significant defect is that they are fairly low acting, taking tens or hundreds of milli-seconds to respond to sudden changes in light level. Useful practical applications of LDR include light and dark-activated switches and alarms, light beam alarms and reflective smoke alarms etc.

4.8 Mobile:

The 12 keys on a cell phone (0, 1… 8, 9,*, #) has unique signal associated with itself. This is DTMF signal.

When the call is on, the pressing of any numerical key leads to generation of DTMF signal which is audible on the other side.

44

Department of ECE, KCE

Page 45: My Project Super Intelligent Robot

Super Intelligent Robot

TheDTMFtoneforeachkeyissumoftwosinusoidalwavesoffrequenciesasgiveninfollowingtable.ThuseachkeyhasuniquefrequencypairandthusuniqueDTMFtone.Forexample,DTMFtoneforkey6issumoftwosunusodialwavesoffrequency1477Hzand770Hz.

The extra keys A, B, C and D are not present on cell phone. They are actually specially used for special purposes. For example, public payphones that accept credit cards use these additional codes to send the information from the magnetic strip.

Output can be taken from speaker (that is near to your ear while calling) and using microphone to convert sound waves to electrical signals tedious work. The other way is through earphone jack.

3.5 MMEARPHONEJACK One wire comes from the ground terminal of the jack that is connected to common ground of the complete circuit. The other wire can be attached to anyone of two signal terminals.

DTMF SIGNAL THROUGH CELLULAR NETWORK The DTMF signals from source to destination follow the same path as that normal voice would have asyounormally talk on mobile passing through any base stations and even satellites in case of large distances.

45

Department of ECE, KCE

Page 46: My Project Super Intelligent Robot

Super Intelligent Robot

DTMF signal doesn’t means it is electrical signal or audible voice signal( as intuition may guess ). It is combination of two sinusoidal waves and sinusoidal waves may be present in any form. In fact the DTMF signal starts with electrical form on transmitter mobile, then encoded on electromagnetic wave, then again converted to electrical wave by receiver mobile and then to sound signal which is audible.

4.9 smoke detector:

This circuit uses a very simple approach to detecting smoke in the air. Quite simply, it uses a bulb as a light source, and an LDR (Light Dependent Resistor) as a light detector. As fire smoke comes between the bulb and LDR, the resistance of the LDR changes, which in turn trigger an alarm.

This probably is not an ideal approach given that ambient light levels are likely to cause false alarms, however it is an interesting experiment. Just please don’t set any fires while experimenting. And please don’t rely on it as a replacement for a real fire alarm device.

5. Software design:

5.1 KEIL compiler:

The Keil C51 C Compiler for the 8051 microcontroller is the most popular 8051 C compiler in the world. It provides more features than any other 8051 C compiler available today.

The C51 Compiler allows you to write 8051 microcontroller applications in C that, once compiled, have the efficiency and speed of assembly language. Language extensions in the C51 Compiler give you full access to all resources of the 8051.

46

Department of ECE, KCE

Page 47: My Project Super Intelligent Robot

Super Intelligent Robot

The C51 Compiler translates C source files into reloadable object modules which contain full symbolic information for debugging with the µVision Debugger or an in-circuit emulator. In addition to the object file, the compiler generates a listing file which may optionally include symbol table and cross reference information.

Features

Nine basic data types, including 32-bit IEEE floating-point,

Flexible variable allocation with bit, data, b data, idata, x data, and p data memory types,

Interrupt functions may be written in C,

Full use of the 8051 register banks,

Complete symbol and type information for source-level debugging,

Use of AJMP and ACALL instructions,

Bit-addressable data objects,

Built-in interface for the RTX51 Real-Time Kernel,

Support for dual data pointers on Atmel, AMD, Cypress, Dallas Semiconductor, Infineon, Philips, and Transcend microcontrollers,

Support for the Philips 8xC750, 8xC751, and 8xC752 limited instruction sets,

Support for the Infineon 80C517 arithmetic unit.

6. Conclusion:

The optimal clock source for a particular microcontroller application is determined by a combination of factors including accuracy, cost, and power consumption, environmental requirements. Microcontroller AT89C52 based robot checks the failure like network coverage.

One can like this with RF data encoder/decoder for wireless link.

47

Department of ECE, KCE

Page 48: My Project Super Intelligent Robot

Super Intelligent Robot

References:

1. http://robokits.co.in/datasheets/AT89s522. http://www.mediacollege.com/audio/tone/dtmf.html3. http://www.kpsec.freeuk.com/components/relay.htm4. http://www.engineersgarage.com/electronic-components/ht91705. http://www.alldatasheet.com/datasheet-pdf/pdf/22634/STMICROELECTRONICS/

L7805CV.html6. http://www.datasheetcatalog.com/datasheets_pdf/L/7/8/1/L7812CV.shtml7. http://en.wikipedia.org/wiki/Regulated_power_supply8. http://www.batteryspace.com/

dcmotorhightorquemini12vdcgearmotor200rpmforhobbyprojects.aspx9. http://www.batteryspace.com/

dcmotorhightorquemini12vdcgearmotor200rpmforhobbyprojects.aspx10. http://www.reuk.co.uk/Transformers-for-12V.htm

48

Department of ECE, KCE

Page 49: My Project Super Intelligent Robot

Super Intelligent Robot

49

Department of ECE, KCE