Top Banner
4 Legged Robot
90
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 4 Legged Robot

4 Legged Robot

Page 2: 4 Legged Robot

Contents

1. Objective

2. Introduction

3. Block diagram

4. Circuit Diagram

5. RF Modules

6. HT 12D/HT12E

7. DC Motor

8. LCD

9. 8051

10. C program

11. Conclusions

Page 3: 4 Legged Robot

ObjectiveObjective: - The main objective of this project to build a unique kind of robotic algorithm to

achieve a new kind of approachability in the field of robotics. The RF controlled 4 legged robot

is one of those types of different view for automation in machines. These robots are designed to

go at different places without man.

A robot is a virtual or mechanical artificial agent. In practice, it is usually an electro-mechanical

machine which is guided by computer or electronic programming, and is thus able to do tasks on

its own. Another common characteristic is that by its appearance or movements, a robot often

conveys a sense that it has intent or agency of its own.

The basic purpose of this robot is to provide automation for the utility machines that are

operated in manual mode for removing different obstructions form fixed terrain in a remote

location.

Page 4: 4 Legged Robot

IntroductionThis project controls a remote robot through RF. The ordinary 433 mhz RF modules are used in

this project. AT89s51 microcontroller is used in this project. It is also an 8051 microcontroller.

the motors attached with the legs of robot give the movement to move forword.

In this we are using Radio frequency as a medium to communicate between user and Rover. For

that we first use a 8051 microcontroller as a heart of system And a RF module TS 434 for the

transmission of data. We first make a +5v regulated Power supply for 8051 and other devices

then we add a HT12d IC which is a Radio frequency decoder and attach its parallel output to the

Port 3 of the 8051 . Then for the output we attach DC motor Driving ciruit by using a Opto

coupler control circuit which was operated by P817 which switch the device according to the

input of the RF data in the 8051

After that we make remote control and use a IC HT12E for the encoding of the data that is

addressed in the remote Key. when we press the key it encodes it and transmit it through the RF

module the receiver decodes it and gives the input to 8051 and gets a output respective to

program. We press the keys and the rover moves according to the commands

Page 5: 4 Legged Robot

Block Diagram

Page 6: 4 Legged Robot

Circuit diagramsControl Unit Circuit

Page 7: 4 Legged Robot

RF Receiver Circuit

Page 8: 4 Legged Robot

RF Transmitter Circuit

Page 9: 4 Legged Robot

RF ID

Page 10: 4 Legged Robot

A RFID system consists of three major components: a reader or integrator, which sends the

interrogation signals to a RFID transponder or tag, which is to be identified; a RFID tag, which

contains the identification code; and a middleware, which maintains the interface and the

software protocol to encode and decode the identification data from the reader into a mainframe

or a personal computer. Realizing the fact that the barcode and other means for identifications

and asset tracking are inadequate for recent demands, RFID technology has been taking the

world of logistics, supply chain managements, asset tracking, security access control, and many

other applications areas by storm.

Block diagram of a typical RFID system.

RFID is a multi-disciplinary technology which encompasses a variety of disciplines. These

include RF and microwave engineering, RF and digital integrated circuits, a big chunk of load

bestows on the antenna technology followed by software and computer engineering for encoding

and decoding of analog signals into meaningful codes for identifications and real time tracking.

Due the flexibility and numerous advantages of RFID systems compared to barcodes and other

identification systems, so far, RFID is now becoming a major player in mass market.

Patronization for RFID technology by major retail chains like Wall Mart, K-Mart, USA

Department of Defence, and similar consortia in Europe and Asia has accelerated the progress of

RFID technology significantly in the new millennium. As a result, significant advancement on

RFID technology has been gained within a short period of time. The RFID market has surpassed

a few billion dollars mark recently and this growth is exponential with its diversified applications

in all sectors like medicine and health care, agriculture, livestock, logistics, and retail chains

etc... Today, RFID is being researched and investigated by both industry and academic scientists

and engineers around the world.

Limitation of Barcodes and Emergence of RFID as an Enabling Technology Barcode labels have

been used to track items and stocks for sometime after their inception in the early 70’s. Though

Page 11: 4 Legged Robot

barcodes are printed in marks and spaces and very cheap to implement, they impose undeniable

obstacles in terms of their short range readability and un-automated tracking. These limitations

are costing large corporations millions of dollars per annum. The growing tendency today is to

replace the barcodes with RFID transponders which have unique ID codes in order to identify

items. Hence, the obstacles of reading range and automation would be solved using RFID. The

only reason why RFID tags haven’t replaced the barcode is due to the price of the tag which is

still much higher when compared to the price of the barcode. Hence, a huge amount of

investments and investigations focusing on lowering the price of the transponder have been put

in motion, and the price of the RFID tag is getting lower and lower every year. The development

of chipless transponders without silicon integrated circuits (ICs) has lowered the cost of the tags

even more, but at the expense of requiring smarter and agile RFID readers. Today’s RFID

readers are comprised of (i) smart antenna systems, (ii) dedicated digital signal processing units,

(iii) embedded systems alongside with (iv) middleware and (v) networking features. These

features allow easy integration of RFID readers in data networks complying with standardized

data transfer protocols. With versatile applications, range and speed of data communications, the

operational frequency and coding techniques used by RFID readers are very widely spread -

from low frequency (LF) systems to microwave systems. This creates a problem in having a

ubiquitous RFID system and acceptance of global standards.

An RFID reader consists three main parts shown in Fig. 3. These main three components are:

•Control section;

High frequency (HF) interface; and

• Antenna.

At the user end, the reader is connected to the host application such as enterprise software.

Page 12: 4 Legged Robot

Block diagram of a typical RFID reader.

the block diagram of the reader control section. The control section of the RFID reader performs

digital signal processing and procedures over the received data from the RFID transponder. Also,

the control section enables the reader to communicate with the transponders wirelessly by

performing modulation, anti-collision procedures and decoding the received data from the

transponders. This data is usually used to interrogate tags (read) or to reprogram the tag (write).

This section usually consists of a microprocessor, a memory block, a few analog-to digital

converters and a communication block for the software application.

Block diagram of the RFID reader control unit

the HF interface module of a RFID reader. The high frequency interface of the reader is used for

RF signal transmission and reception. HF interfaces are consisted of two separate signal paths to

correspond with the two directional data flows from and to the transponder.

RF Modules

Radio frequency (RF) is a rate of oscillation in the range of about 30 kHz to 300 GHz, which

corresponds to the frequency of electrical signals normally used to produce and detect radio

Page 13: 4 Legged Robot

waves. RF usually refers to electrical rather than mechanical oscillations, although mechanical

RF systems do exist

In order to receive radio signals an antenna must be used. However, since the antenna will pick

up thousands of radio signals at a time, a radio tuner is necessary to tune in to a particular

frequency (or frequency range). This is typically done via a resonator – in its simplest form, a

circuit with a capacitor and an inductor forming a tuned circuit. The resonator amplifies

oscillations within a particular frequency band, while reducing oscillations at other frequencies

outside the band. Often the inductor or the capacitor of the tuned circuit is adjustable allowing

the user to change the frequencies at which it resonates. The resonant frequency of a tuned

circuit is given by the formula

where f0 is the frequency in hertz, L is inductance in henries, and C is capacitance in farads.

Special properties of RF electrical signals

Electrical currents that oscillate at RF have special properties not shared by direct current

signals. One such property is the ease with which they can ionize air, creating a conductive path

through it. This property is exploited by 'high frequency' units used in electric arc welding,

although strictly speaking these machines do not typically employ frequencies within the HF

band. Another special property is that RF current cannot penetrate deeply into electrical

conductors but flows along the surface of conductors; this is known as the skin effect. Another

property is the ability to appear to flow through paths that contain insulating material, like the

dielectric insulator of a capacitor. The degree of effect of these properties depends on the

frequency of the signals.

Radio Frequency (RF) is the use of radio signals to communicate real-time data from the

warehouse floor to the WMS database and back to the floor. This expedites processing in the

warehouse. Scanners collect the data and transmit it via radio frequency to antennas located

throughout the warehouse. From the antennas, the signal proceeds to an access point that

communicates with the warehouse management system. This process reduces paper, data entry

time delays, cycle count processing, out of stock quantities, typing errors, and misshipments

Page 14: 4 Legged Robot

The receiver also operates at 433.92MHz, and has a sensitivity of 3uV.  The RWS-434 receiver

operates from 4.5 to 5.5 volts-DC, and has both linear and digital outputs.

RWS-434 Receiver

The TWS-434 and RWS-434 are extremely small, and are excellent for applications requiring

short-range RF remote controls.  The transmitter module is only 1/3 the size of a standard

postage stamp, and can easily be placed inside a small plastic enclosure.

TWS-434:  The transmitter output is up to 8mW at 433.92MHz with a range of approximately

400 foot (open area) outdoors.  Indoors, the range is approximately 200 foot, and will go through

most walls.....

Page 15: 4 Legged Robot

TWS-434A

The TWS-434 transmitter accepts both linear and digital inputs, can operate from 1.5 to 12

Volts-DC, and makes building a miniature hand-held RF transmitter very easy.  The TWS-434 is

approximately the size of a standard postage stamp.

Architecture of RFID Technology

Similar to any communication device, RFID technology consists of transmitters and receivers in

the form of RFID tags. These are microchips that have all the necessary information on them.

The information is comprehended with the help of an RFID card reader. An antenna is also

provided on the tags that helps in the transmission of the signal. Active and passive RFID tags

are the two types of RFID tags that are generally used. The active RFID tags transfer the

information directly to the reader without the use of an external battery or source, whereas, the

passive tags require external power for functioning.

Advantages of RFID Technology

RFID technology has a number of advantages.

RFID tags are very simple to install/inject inside the body of animals, thus helping to

keep a track on them. This is useful in animal husbandry and on poultry farms. The

installed RFID tags give information about the age, vaccinations and health of the

animals.

RFID technology is better than bar codes as it cannot be easily replicated and therefore, it

increases the security of the product.

Page 16: 4 Legged Robot

Supply chain management forms the major part of retail business and RFID systems play

a key role by managing updates of stocks, transportation and logistics of the product.

Barcode scanners have repeatedly failed in providing security to gems and jewelries in

shops. But nowadays, RFID tags are placed inside jewelry items and an alarm is installed

at the exit doors.

The RFID tags can store data up to 2 KB whereas; the bar code has the ability to read just

10-12 digits.

Disadvantages of RFID Technology

The RFID technology, though very beneficial, is expensive to install. Small and medium scale

enterprises find it costly to use it in their firms and offices.

It is difficult for an RFID reader to read the information in case of RFID tags installed in

liquids and metal products. The problem is that the liquid and metal surfaces tend to

reflect the radio waves, which makes the tags unreadable. The tags have to be placed in

various alignments and angles for taking proper reading. This is a tedious task when the

work involves big firms.

Interference has been observed if devices such as forklifts and walkie-talkies are in the

vicinity of the distribution centers. The presence of mobile phone towers has been found

to interfere with RFID radio waves. Wal-Mart, the retail sector giant, has installed

billions of RFID tags in their products throughout the world and they have encountered

such problems.

The USA and Europe, for instance, have different range of frequencies that allow RFID

tags to function. This makes it mandatory for international shipping companies and other

organizations to be aware of the working pattern of other nations also, which can be very

time-consuming.

RFID technology has been referred to as invasive technology. Consumers are

apprehensive about their privacy when they purchase products with RFID tags. Once the

radio chips are installed in the product, the customer can be tracked and his personal

information can be collected by the RFID reader. However, many stores have a facility

that deactivates the RFID tags after the product has been purchased.

Page 17: 4 Legged Robot

RFID technology can be the next tool for success and management of various businesses. With

more research, the flaws and limitations of this technology can be removed. This will make

RFID technology very useful for diverse sectors like retail, transport and jewelry businesses.

Page 18: 4 Legged Robot
Page 19: 4 Legged Robot

LCD

Liquid crystal display is very important device in embedded system. It offers high flexibility

to user as he can display the required data on it. But due to lack of proper approach to LCD

interfacing many of them fail. Many people consider LCD interfacing a complex job but

according to me LCD interfacing is very easy task, you just need to have a logical approach.

This page is to help the enthusiast who wants to interface LCD with through understanding.

Copy and Paste technique may not work when an embedded system engineer wants to apply

LCD interfacing in real world projects. You will know about the booster rockets on space

shuttle. Without these booster rockets the space shuttle would not launch in geosynchronous

orbit.

Page 20: 4 Legged Robot
Page 21: 4 Legged Robot
Page 22: 4 Legged Robot
Page 23: 4 Legged Robot

HT12D

212 Series of Decoders

Features

_ Operating voltage: 2.4V~12V

_ Low power and high noise immunity CMOS

technology

_ Low standby current

_ Capable of decoding 12 bits of information

_ Binary address setting

_ Received codes are checked 3 times

_ Address/Data number combination

_ HT12D: 8 address bits and 4 data bits

_ HT12F: 12 address bits only

_ Built-in oscillator needs only 5% resistor

_ Valid transmission indicator

_ Easy interface with an RF or an infrared transmission

medium

_ Minimal external components

_ Pair with Holtek_s 212 series of encoders

_ 18-pin DIP, 20-pin SOP package

Applications

_ Burglar alarm system

_ Smoke and fire alarm system

_ Garage door controllers

_ Car door controllers

_ Car alarm system

_ Security system

_ Cordless telephones

_ Other remote control systems

General Description

Page 24: 4 Legged Robot

The 212 decoders are a series of CMOS LSIs for remote control system applications. They are

paired with Holtek_s 212 series of encoders (refer to the encoder/decoder cross reference table).

For proper operation, a pair of encoder/decoder with the same number of addresses and data

format should be chosen. The decoders receive serial addresses and data from a programmed 212

series of encoders that are transmitted by a carrier using an RF or an IR transmission medium.

They compare the serial input data three times continuously with their local addresses. If no error

or unmatched codes are found, the input data codes are decoded and then transferred to the

output pins. The VT pin also goes high to indicate a valid transmission. The 212 series of

decoders are capable of decoding informations that consist of N bits of address and 12_N bits of

data. Of this series, the HT12D is arranged to provide 8 address bits and 4 data bits, and HT12F

is used to decode 12 bits of address information.

Page 25: 4 Legged Robot

Operation

The 212 series of decoders provides various combinations of addresses and data pins in ifferent

packages so as to pair with the 212 series of encoders. The decoders receive data that are

transmitted by an encoder and interpret the first N bits of code period as addresses and the last

12_N bits as data, where N is the address code number. A signal on the DIN pin activates

the oscillator which in turn decodes the incoming address and data. The decoders will then heck

the received address three times continuously. If the received address codes all match the

contents of the decoder_s local address, the 12_N bits of data are decoded to activate the output

pins and the VT pin is set high to indicate a valid transmission. This will last unless the address

code is incorrect or no signal is received. The output of the VT pin is high only when the

transmission is valid. Otherwise it is always low.

Output type

Of the 212 series of decoders, the HT12F has no data output pin but its VT pin can be used as a

momentary data output. The HT12D, on the other hand, provides 4 latch type data pins whose

data remain unchanged until new data are received.

Page 26: 4 Legged Robot

Flowchart

The oscillator is disabled in the standby state and activated when a logic _high_ signal applies to

the DIN pin. That is to say, the DIN should be kept low if there is no signal input.

Page 27: 4 Legged Robot

HT12E

Features

_ Operating voltage

_ 2.4V~5V for the HT12A

_ 2.4V~12V for the HT12E

_ Low power and high noise immunity CMOS

technology

_ Low standby current: 0.1_A (typ.) at

VDD=5V

_ HT12A with a 38kHz carrier for infrared

transmission medium

_ Minimum transmission word

_ Four words for the HT12E

_ One word for the HT12A

_ Built-in oscillator needs only 5% resistor

_ Data code has positive polarity

_ Minimal external components

_ HT12A/E: 18-pin DIP/20-pin SOP package

Applications

_ Burglar alarm system

_ Smoke and fire alarm system

_ Garage door controllers

_ Car door controllers

_ Car alarm system

_ Security system

_ Cordless telephones

_ Other remote control systems

General Description

The 212 encoders are a series of CMOS LSIs for remote control system applications. They are

capable of encoding information which consists of N address bits and 12_N data bits. Each

address/ data input can be set to one of the two logic states. The programmed addresses/data are

Page 28: 4 Legged Robot

transmitted together with the header bits via an RF or an infrared transmission medium upon

receipt of a trigger signal. The capability to select a TE trigger on the HT12E or a DATA trigger

on the HT12A further enhances the application flexibility of the 212 series of encoders. The

HT12A additionally provides a 38 kHz carrier for infrared systems.

Page 29: 4 Legged Robot
Page 30: 4 Legged Robot

Functional Description

Operation

The 212 series of encoders begin a 4-word transmission cycle upon receipt of a transmission

enable (TE for the HT12E or D8~D11 for the HT12A, active low). This cycle will repeat itself as

long as the transmission enable (TE or D8~D11) is held low. Once the transmission enables

returns high the encoder output completes its final cycle and then stops as shown below.

Page 31: 4 Legged Robot
Page 32: 4 Legged Robot
Page 33: 4 Legged Robot

8051 Microcontroller

Embedded system employs a combination of software & hardware to perform a specific

function. It is a part of a larger system which may not be a “computer”Works in a reactive &

time constrained environment.

Any electronic system that uses a CPU chip, but that is not a general-purpose workstation,

desktop or laptop computer is known as embedded system. Such systems generally use

microprocessors; microcontroller or they may use custom-designed chips or both. They are

used in automobiles, planes, trains, space vehicles, machine tools, cameras, consumer and

office appliances, cell phones, PDAs and other handhelds as well as robots and toys. The

uses are endless, and billions of microprocessors are shipped every year for a myriad of

applications.

In embedded systems, the software is permanently set into a read-only memory such as a

ROM or flash memory chip, in contrast to a general-purpose computer that loads its

programs into RAM each time. Sometimes, single board and rack mounted general-purpose

computers are called "embedded computers" if used to cont

Embedded System Applications :-

Consumer electronics, e.g., cameras, cell phones etc.

Consumer products, e.g. washers, microwave ovens etc.

Automobiles (anti-lock braking, engine control etc.)

Industrial process controller & defense applications.

Computer/Communication products, e.g. printers, FAX machines etc.

Medical Equipments.

ATMs

Aircrafts

Page 34: 4 Legged Robot

DIFFERENCE BETWEEN MICROPROCESSORS

AND MICROCONTROLLERS:

A Microprocessor is a general purpose digital computer central processing

unit(C.P.U) popularly known as CPU on the chip. The Microprocessors contain

no RAM, no ROM, and no I/P O/P ports on the chip itself.

On the other hand a Microcontroller has a C.P.U(microprocessor) in addition to a

fixed amount of RAM, ROM, I/O ports and a timer all on a single chip.

In order to make a Microprocessor functional we must add RAM, ROM, I/O Ports

and timers externally to them,i.e any amount of external memory can be added to

it.

But in controllers there is a fixed amount of memory which makes them ideal for

many applications.

The Microprocessors have many operational codes(opcodes) for moving data

from external memory to the C.P.U

Whereas Microcontrollers may have one or two operational codes.

DISADVANTAGES OF MICROPROCESSORS

OVER MICROCONTROLLERS

System designed using Microprocessors are bulky

They are expensive than Microcontrollers

We need to add some external devices such as PPI chip, Memory, Timer/counter

chip, Interrupt controller chip,etc. to make it functional.

Types of microcontroller architecture:

There are two types of Microcontroller architecture designed for embedded system development.

These are:

1)RISC- Reduced instruction set computer

Page 35: 4 Legged Robot

2)CISC- Complex instruction set computer

Difference between CISC and RISC:

CISC stands for Complex Instruction Set Computer. Most PC's use CPU based on this

architecture. For instance Intel and AMD CPU's are based on CISC architectures. Typically

CISC chips have a large amount of different and complex instructions. In common CISC chips

are relatively slow (compared to RISC chips) per instruction, but use little (less than RISC)

instructions. MCS-51 family microcontrollers based on CISC architecture.

RICS stands for Reduced Instruction Set Computer. The philosophy behind it is that almost no

one uses complex assembly language instructions as used by CISC, and people mostly use

compilers which never use complex instructions. Therefore fewer, simpler and faster instructions

would be better, than the large, complex and slower CISC instructions. However, more

instructions are needed to accomplish a task. Atmell’s AVR microcontroller based on RISC

architecture.

History of 8051

Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981 this controller had 128

bytes of RAM, 4k bytes of on chip ROM, two timers, one serial port, and four ports all are on

single chip. The 8051 is an 8 bit processor, meaning that the CPU can work on only 8 bit data at

a time. Data larger than 8 bits broken into 8 bit pieces to be processed by CPU. It has for I/O 8

bit wide.

Features of the 8051:-

Feature Quantity

ROM 4K bytes

RAM 128 bytes

Timer 2

I/O pins 32

Serial port 1

Interrupt sources 6

Page 36: 4 Legged Robot

8051 Architecture Overview

The 8051 family is one of the most common microcontroller architectures used worldwide. 8051

based microcontrollers are offered in hundreds of variants from many different silicon

manufacturers

The 8051 is based on an 8-bit CISC core with Harvard architecture. It's an 8-bit CPU, optimized

for control applications with extensive Boolean processing (single-bit logic capabilities), 64K

program and data memory address space and various on-chip peripherals.

The 8051 microcontroller family offers developers a wide variety of high-integration and cost-

effective solutions for virtually every basic embedded control application. From traffic control

equipment to input devices and computer networking products, 8051 u.c deliver high

performance together with a choice of configurations and options matched to the special needs of

each application. Whether it's low power operation, higher frequency performance, expanded on-

chip RAM, or an application-specific requirement, there's a version of the 8051 microcontroller

that's right for the job.

When it's time to upgrade product features and functionality, the 8051 architecture puts you on

the first step of a smooth and cost-effective upgrade path - to the enhanced performance of the

151 and 251 microcontrollers.

Page 37: 4 Legged Robot

Block diagram of 8051

Page 38: 4 Legged Robot

Internal Architecture of 8051

Page 39: 4 Legged Robot

Pin configuration of 8051

Page 40: 4 Legged Robot

  

There are 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 ports

as an input port, it must be programmed.

Port 0:- Port 0 occupies a total of 8 pins (pins 32-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 10K

ohm pull-up resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, and P3.Open

drain is a term used for MOS chips in the same way that open collector is used for TTL chips.

With external pull-up resistors connected upon reset, port 0 is configured as an output port. For

example, the following code will continuously send out to port 0 the alternating values 55H and

AAH

Port 0 as input:-  With resistors connected to port 0, in order to make it an input, the port must be

programmed by writing 1 to all the bits. In the following code, port 0 is configured first as an

input port by writing 1's to it, and then data is received from the port and sent to P1.                   

                       

                      Dual Role of Port 0 :-Port 0 is also designated as AD0-AD7, allowing it to be

used for both address and data. When connecting an 8051/31 to an external memory, port 0

Page 41: 4 Legged Robot

provides both address and data. The 8051 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 and data with the help of a 74LS373 latch.

Port 1:- Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or output. In

contrast to port 0, this port does not need any pull-up resistors since it already has pull-up

resistors internally. Upon reset, Port 1 is configured as an output port. For example, the

following code will continuously send out to port1 the alternating values 55h  & AAh

Port 1 as input:-To make port1 an input port, it must be programmed as such by writing 1 to all

its bits. In the following code port1 is configured first as an input port by writing 1’s to it, then

data is received from the port and saved in R7 ,R6 & R5.

Port 2 :-Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or output.

Just like P1, P2 does not need any pull-up resistors since it already has pull-up resistors

internally. Upon reset,Port 2 is configured as an output port. For example, the following code

will send out continuously to port 2 the alternating values 55h and AAH. That is all the bits of

port 2 toggle continuously.              

  Port 2 as input:- To make port 2 an input, it must programmed as such by writing 1 to all its

bits. In the following code, port 2 is configured first as an input port by writing 1’s to it. Then

data is received from that port and is sent to P1 continuously.

Dual role of port 2:- In systems based on the 8751, 8951, and DS5000, P2 is used as simple I/O.

However, in 8031-based systems, port 2 must be used along with P0 to provide the 16-bit

address for the external memory. As shown in pin configuration 8051, port 2 is also designed as

A8-A15, indicating the dual function. Since an 8031 is capable of accessing 64K bytes of

external memory, it needs a path for the 16 bits of the address. While P0 provides the lower 8

bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address. In other words, when

8031 is connected to external memory, P2 is used for the upper 8 bits of the 16 bit address, and it

cannot be used for I/O.

Port 3:- port 3 occupies a total of 8 pins, pins 10 through 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 an output port upon reset. Port 3 has the additional function of providing some

Page 42: 4 Legged Robot

extremely important signals such as interrupts. This information applies both 8051 and 8031

chips. There functions are as follows:-

 

        P3.0 and P3.1 are used for the RxD and TxD serial communications signals. Bits P3.2 and

P3.3 are set aside for external interrupts. Bits P3.4 and P3.5 are used for timers 0 and 1. Finally

P3.6 and P3.7 are used to provide the WR and RD signals of external memories connected in

8031 based systems.    

ALE/PROG

Address Latch Enable 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

PORT 3 Function pin

P3.0 RxD 10

P3.1 TxD 11

P3.2 ___

Int0

12

P3.3 ___

Int1

13

P3.4 T0 14

P3.5 T1 15

P3.6 ___

WR

16

P3.7 ___

RD

17

Page 43: 4 Legged Robot

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 is the read strobe to external program memory. When the AT89S8252 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. 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 when 12-volt programming is selected.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

AT89s8252

AT89S8252 is an ATMEL controller with the core of intel MCS-51. It has same pin

configuration as give above.

The AT89S8252 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes

of Downloadable Flash programmable and erasable read only memory and 2K bytes of

EEPROM. The device is manufactured using Atmel’s high density nonvolatile memory

technology and is compatible with the industry standard 80C51 instruction set and pinout. The

on-chip Downloadable Flash allows the program memory to be reprogrammed in-system through

an SPI serial interface or by a conventional nonvolatile memory programmer. By combining a

versatile 8-bit CPU with Downloadable Flash on a monolithic chip, the Atmel AT89S8252 is a

Page 44: 4 Legged Robot

powerful microcomputer which provides a highly flexible and cost effective solution to many

embedded control applications. The AT89S8252 provides the following standard features: 8K

bytes of Downloadable Flash, 2K bytes of EEPROM, 256 bytes of RAM, 32 I/O lines,

programmable 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 AT89S8252 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.

The Downloadable Flash can be changed a single byte at a time and is accessible through the SPI

serial interface. Holding RESET active forces the SPI bus into a serial programming interface

and allows the program memory to be written to or read from unless Lock Bit 2 has been

activated.

Features

• Compatible with MCS-51™Products

• 8K bytes of In-System Reprogrammable Downloadable Flash Memory

- SPI Serial Interface for Program Downloading

- Endurance: 1,000 Write/Erase Cycles

• 2K bytes EEPROM

- Endurance: 100,000 Write/Erase Cycles

• 4.0V to 6V Operating Range

• Fully Static Operation: 0 Hz to 24 MHz

• Three-Level Program Memory Lock

• 256 x 8 bit Internal RAM

• 32 Programmable I/O Lines

• Three 16 bit Timer/Counters

• Nine Interrupt Sources

• Programmable UART Serial Channel

Page 45: 4 Legged Robot

• SPI Serial Interface

• Low Power Idle and Power Down Modes

• Interrupt Recovery From Power Down

• Programmable Watchdog Timer

• Dual Data Pointer

• Power Off Flag

Pin Description

Furthermore, P1.4, P1.5, P1.6, and P1.7 can be configured as the SPI slave port select, data

input/output and shift clock input/output pins as shown in the following table.

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

Page 46: 4 Legged Robot

Hardware interfacings and programming

There are two types of programming language used for microcontroller programming:

1)Low Level Language(Assembly Language)

2) High Level Language(C Language)_

ALE/PROG

Address Latch Enable 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 is the read strobe to external program memory. When the AT89S8252 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. 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 when 12-volt programming is selected.

Page 47: 4 Legged Robot

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

Hardware interfacings and programming

There are two types of programming language used for microcontroller programming:

1)Low Level Language(Assembly Language)

2) High Level Language(C Language)

Advantages of C over Assembly language programming:

Knowledge of the processor instruction set is not required.

Details like register allocation and addressing of memory and data is managed by the

compiler.

Programs get a formal structure and can be divided into separate functions.

Programming and program test time is drastically reduced, this increases efficiency.

Keywords and operational functions can be used that come closer to how humans think.

The supplied and supported C libraries contain many standard routines such as numeric

conversions.

Reusable code: Existing program parts can be more easily included into new programs,

because of the comfortable modular program construction techniques.

The C language based on the ANSI standard is very portable. Existing programs can be

quickly adapted to other processors as needed.

Page 48: 4 Legged Robot

KEIL PROGRAMMINGOpen Keil from the Start menuThe Figure below shows the basic names of the windows referred in this document

Page 49: 4 Legged Robot

Select New Project from the Project Menu.

Page 50: 4 Legged Robot

Name the project ‘Toggle.a51’Click on the Save Button.

The device window will be displayed.Select the part you will be using to test with. For now we will use the Dallas Semiconductor part at89s52.

Page 51: 4 Legged Robot

Double Click on the Atmel Semiconductor.

Page 52: 4 Legged Robot

Scroll down and select the at89s52 PartClick OK

Click File Menu and select New.

Page 53: 4 Legged Robot
Page 54: 4 Legged Robot

A new window will open up in the Keil IDE.

Copy the example to the Right into the new window. This file willtoggle Ports 1 and 2 with a delay.ORG 0HMOV A, #55HAGAIN:MOV P1, A

Page 55: 4 Legged Robot

MOV P2, AACALL DELAYCPL ASJMP AGAINDELAY:MOV R3, #200OUTER: MOV R2, #0255INNER: DJNZ R2, INNERDJNZ R3, OUTERRETEND

Click on File menu and select SaveAs…

Name the file Toggle.a51Click the Save Button

Page 56: 4 Legged Robot

Expand Target 1 in the Tree Menu

Click on Project and select Targets, Groups, Files…

Page 57: 4 Legged Robot

Click on Groups/Add Files tab Under Available Groups select Source Group 1 Click Add Files to Group… button

Page 58: 4 Legged Robot

Change file type to Asm Source file(*.a*;*.src)Click on toggle.a51Click Add buttonClick Close ButtonClick OK button when you return to Target,Groups, Files… dialog box

Page 59: 4 Legged Robot

Expand the Source Group 1 in the Tree menu to ensure that the file was added to the project

Page 60: 4 Legged Robot

Click on Target 1 in Tree menu Click on Project Menu and select Options for Target 1

Page 61: 4 Legged Robot

Select Target Tab Change Xtal (Mhz) from 50.0 to 11.0592

Page 62: 4 Legged Robot

Select Output Tab Click on Create Hex File check box Click OK Button

Page 63: 4 Legged Robot
Page 64: 4 Legged Robot

Click on Project Menu and select Rebuild all Target Files In the Build Window it should report‘0 Errors (s), 0 Warnings’ You are now ready to Program your Part

Page 65: 4 Legged Robot

Comment out line ACALL DELAY by placing a Semicolon at the beginning. This will allow you to see the port change immediately. Click on the File Menu and select Save

Page 66: 4 Legged Robot

Click on Project Menu and select Rebuild all Target Files In the Build Window it should report ‘0 Errors (s), 0 Warnings’ Click on Debug Menu and Select Start/Stop Debug Session

Page 67: 4 Legged Robot

The Keil Debugger should be now be Running.

Page 68: 4 Legged Robot

Click on Peripherals. Select I/O Ports, Select Port 1

A new window should port will pop up. This represent the Port and

Page 69: 4 Legged Robot

Pins

Step through the code by pressing F11 on the Keyboard. The Parallel Port 1 Box should change asyou completely step through the code.

Page 70: 4 Legged Robot

To exit out, Click on Debug Menu and Select Start/Stop Debug Session

Page 71: 4 Legged Robot

C code for 8051 Microcontroller

#include<at89s52.h>

//////////////////////////////////////////////////////////////////

///*******************************************************************

void delay(unsigned int temp);

//********************************************************************

///////////////////delay routine///////////////////////////////////

void delay(unsigned int temp)

{

while(temp!=0)

{

temp--;

}

}

/////////////////////main program///////////////////////////////////////

void main()

{

bit a=0;

bit b=0;

bit c=0;

bit d=0;

P3=0xff;

P0=0x00;

while(1)

{

if(P3==0x7f)

{

delay(1000);

Page 72: 4 Legged Robot

if(a==1)

{

P0=0x09;

}

else if(a==0)

{

P0=0x00;

}

}

if(P3==0xbf)

{

delay(1000);

if(b==1)

{

P0=0x06;

}

else if(b==0)

{

P0=0x00;

}

}

if(P3==0xdf)

{

delay(1000);

if(c==1)

{

P0=0x08;

}

else if(c==0)

{

Page 73: 4 Legged Robot

P0=0x00;

}

}

if(P3==0xef)

{

delay(1000);

if(d==1)

{

P0=0x01;

}

else if(d==0)

{

P0=0x00;

}

}

delay(50000);

}

}

Page 74: 4 Legged Robot
Page 75: 4 Legged Robot