Micro-controller Based Robotic Vaccum Cleaner (89c51)

Embed Size (px)

DESCRIPTION

.......................................

Citation preview

MICRO-CONTROLLER BASED ROBOTIC VACCUM CLEANER

Contents

1. Introduction

2. Block Diagram & its Description3. Circuit Diagram & its Description4. Data Sheets5. General Components

6. Construction Guidelines7. Applications & Future Developments

NOTE: Due to continuous improvement and development in the project design, project reports provided are accurate by 90%. The difference of 10% [if any] will be informed during project theory classes.

Micro-controller Based Robotic Vaccum Cleaner1. IntroductionA robot is defined as a re-programmable multi-functional manipulator. In simple words, it is a mechanical system which consists of sensing and executing organs; controlled by an electronic brain that can perform a number of operations independently within a confined space. The robot movements are controlled by a computer and future movements can be stored in micro-controller, and thus its job assignments can be changed by reprogramming micro-controller.

A computer controls the robot movements, and thus reprogramming can change its job assignments. The robot described here is a vehicle whose movements are controlled by computer. The main feature of this robotic system is that, this system adopts a wireless radio- link between the Controller i.e., Computer and the micro-controller resided inside the Robot. Here all the command signals from the computer are conveyed to the remotely located robot with the aid of RF communication. The commands received from the computer are verified by micro-controller and finds suitable then only executes them. Robotic vacuum cleaners in large factory halls find theRF way with the aid of sensors and a track in or on the floor. The track may consist of a white line painted on a dark floor, or another reflective substance. Such tracks can be detected with optical sensors. To avoid collisions with personnel and objects, most robotic vacuum cleaners have additional sensors, for instance, infrared detectors, cameras, or a kind of radar based on ultra-sonic waves, laser light or radio waves. To enable them to be stopped in the event of a collision or malfunction, these robot vehicles usually have a number of easily accessible switches.

Robots today are being employed to release man from heavy, tedious, monotonous work like arc welding or to work under conditions where human beings cannot function effectively. This project demonstrates the operation of an electric vehicle fitted with Vaccum Cleaner, which is capable of cleaning the intended area without any human intervention. This Robotic Vaccum Cleaner is very useful in factory or large halls or premises where cleaning the floor is major headache. In Brief: The Micro-controller Based Robotic Vaccum Cleaner project has two parts: Transmitter and Receiver. The Transmitter part consists of Computer & Software Module, Interface Module and VHF Transmitter. The commands are sent by the user through Computer and the intended software. These commands are in VHF [Recommended Code] form, and are transmitted to the Robotic Vehicle through Infra-Red / RFPackets.The Receiver part receives the VHF coded signals and fed to PIC micro-controller chip. This Micro-controller decodes VHF codes back to original commands and executes them as needed. Here the decoded signals are properly routed using switching circuit. The output of the switching circuit controls the movement of the Robotic Vehicle. If the command says to turn Right/ Left or move Forward/Reverse it does so by activating the respective motor, and thus fulfilling the need. The Receiver part thus has three motors: to and fro movement; Left/Right turn; and last one for vaccum cleaning. The project works in two modes: Auto & Manual. In Auto mode, one can program the schedule of Robotic Vehicles movement and move it accordingly. In Manual mode user can interact with the Robotic Vehicle in real time and move it according to his need.Introduction of RoboticsRobotic systems have developed much beyond the first deaf, blind and dumb generation of robots used in the industrial floor in the early days. Robots developed today are used in areas which would previously have been unimaginable: in surgery, in the after care of patients in hospitals, in guarding prisons, in space exploration, underwater expeditions, in restaurants and bars, in industries and even at homes.

Viewers of the recently screened movies, viz., Independence Day, Mars Attack, Artificial Intelligence, Star Wars, The Black Hole, The Empire Strikes Back, and For Your Eyes Only, were thrilled by the performance and capacity of the robots. One of the fastest developing technologies today is robotics, and companies well known in other fields, such as car manufacturing, are now contributing to the growth of industrial robots. Robots have assumed a great significance in the industrial world today, what follows is a brief introduction of this electronically controlled marvel.

The Czech writer Karel Capek coined the word Robot in 1920 to denote a machine in the form of a man. His play Rossums Universal Robots had a human named Rossum who created a race to serve the mankind. Later these robots discovered that they too had emotions like human beings, a sense of feeling (they cared for each other), and deciding that they could no longer serve the mankind, proceeded to take over the world.

Robots today are being employed to release man from heavy, tedious, monotonous work line arc welding or to work under conditions where human beings cannot function effectively, such as underwater explanation, space exploration, noxious gaseous environments, high operating temperatures shifting humidity, inaccessible locations like nuclear reactors etc.

Robots have been on the industrial scene since the early sixties. However, theRF high cost precluded wider acceptability. Today, by incorporating microprocessors, the cost is falling while theRF accuracy is increasing.

Countries like Japan, the USA, the USSR, West Germany and France have over 1500 robots each installed in theRF various factories, with the United States and Japan accounting for nearly 75 percent of theRF use. The factors responsible for this high percentage are shortage of labor in Japan and high labor cost in the USA. In India, HMT in Bangalore and Telco in Pune have begun manufacture of industrial robots.

Micro-controller in ROboticsMicro-controller has elevated electronics to a great height. It is being used in many industrial instruments, medical equipment, microcomputers and programmable logic controllers. Its speed of operations is amazing. Early eighties saw the advent of robots, especially in industries. The automatic industries of Japan, the USA and the UK have installed many robots in theRF assembly lines. This has improved the quality of theRF work and speed. Many types of robots were displayed in EXPO 85 of Japan in Tsukuba.

With the help of micro-controllers and robots, a new Micro-controller Based Industrial Automation concept has developed. Electronic equipment can be used in efficient man-machine interface, making the communications faster.

Having helped the industry, electronics has entered the house. Transistor, radio, tape recorders, television sets, toy and educational equipment are commonly household items. All these products have made the life more comfortable. Personal computers are being used in homes in many countries to keep track of accounts, family health details and such other information.

Remote controllers for TVs and VCRs enable viewers to switch off the set or change the channel from a distance. Bigger houses have intercoms so that a person need not get to another room for communication. Burglar alarm is energized before leaving the house. Whoever enters the house has to first put off the system by resetting it. The location is known available to disable it is only 10 to 25 seconds. An unauthorized visitor will not be able to reset the switch in that time and the alarm will alert the neighbors. Fire sensors, gas alarm are the other gadgets, which take care of fire mishaps. Time switches turn on and off any electrical appliance at the preset time. Video games and electronic toys help in providing leisure and comfort at home. However, these systems cannot generally be combined together for economical compatibility.AUTOMATION AT INDUSTRIESMicro-controller based Industrial Automation is aimed to reduce supervision of human and to create a comfortable & safe working environment. There are several big companies who are engaged in this Micro-controller Based Industrial Automation field. For example Allen Brandely, ABB, Simens are producing Programmable Logic Controllers [PLLs] and theRF related instruments, software, hardware and controlling panels. These PLLs are capable of controlling the small, medium or big industries with less human intervention.Micro-controller based Industrial Automation (IA) comprises four sub-systems to perform different functions [of course with the help of Computer]:Industrial keeping system: -A module called Home Terminal which comprises a telephone/intercom master unit, master and room monitor controller, TV, door and phone controllers and indicators is the heart of security & safety keeping system.

This sub-system controls temperature of water in furnace, keeps record of the consumption of electricity and water gets signals from burglar alarms, gas leaks, flame sensors etc, and gives warning. Besides, it receives the incoming phone calls, answers or sends messages at appropriate time and turns on/off time-punch machines for attendance purpose, lighting & vigilant cameras etc. Intercom at the main door lets the security person know the identity of a visitor. It ensures that the employee has enough safety and comfort by taking care of security of the industry, energy control, equipment control etc. It has modular construction and should be installed cent rally, mainly in new buildings as the wiring involved is to be taken care of.

INTERFACE SYSTEM Also known as communication system, it allows the user to communicate with others. It works with high definite TV, cable TV (CATV), direct broadcasting system (DBS) etc. one can get the news or special announcements through video or audio or text form.People in some countries now do field work sitting in the comfort of theRF chamber through a personal computer connected to the office. On can also use it to control the instruments and share the status of the instruments with another field engineer who is far away & connected to the computer database system.

SUMMARYThe latest development in robotics in Industrial environment has been discussed here. A lot of research and development is being done in this field. Industrial robots will be doing most of the industrial hold chores and the workers will be relaxing (and occasionally scolding the robots?) or take up more productive jobs.MAIN FEATURES OF THE PROJECT:1. Simple in design,

2. Low power consumption, and compact size,

4. Linear, smooth & easy control of the vehicle due to employ of computer5. High reliability, due to the usage of power semiconductor devices and programmable Micro-controller,

6. Greater control range due the usage of Infra Red communication.

2. BLOCK DIAGRAM DESCRIPTION:

This Micro-controller Based Robotic Vaccum Cleaner project is divided into two parts: Transmitter & Receiver. The Transmitter part transmits the command signals to the Robotic Vehicle, where as Receiver part decodes this commands and executes them. This project works in two mode: Auto Mode, where movement of the Robotic Vehicle is pre-programmed and in Manual Mode user controls the Robotic vehicle in real-time. Both these modes make no change in hardware part of this project, only software changes its modes according to the mode.TRANSMITTER PARTThe Transmitter Part, as shown in Fig 2.1, consists of sub-blocks: PC & Software Module, Interface Stage[made of Buffer and Driver/Switching stage], VHF Transmitter and Power Supply Unit. Let us see what this part actually does and each block in detail.In Brief: The user enters his requirement or programmes his schedule using the software. This program is converted into command signals and fed to VHF Transmitter to transmit the commands. Here the computer accepts or deals with TTL Compatible signal levels only, Interface Stage is required between the Transmitter and Computer. For transmission of signals Infra Red rays are used. PC & Software Module: The Computer plays the role of main controller unit, and allows the user to program or control the movement of the Robotic Vehicle. The user interactive software provides two options to control the Robotic Vehicle. If user chooses Auto mode, then he is allowed to enter forward or reverse movement time, right or left turn command and ON/OFF time of the Vaccum Cleaner. Once the schedule is prepared with specified On/Off time, then software module changes it into command signals and sent to transmitter. If user is in Manual mode, then real-time interaction with Robotic Vehicle is possible. That means user can move the Robotic Vehicle Forward/Reverse or Right/Left turn with vaccum cleaner ON/OFF by pressing number keys [from 1 to 5] on the numeric key pad.There are totally five command signals coming out of the computer: Forward & Reverse Movement, Left & Right Turn, and Vaccum Cleaner On/Off signal. These commands are fed to VHF Transmitter through Interface Stage.

Interface Stage: The command signals coming out of the computer are in TTL Compatible levels. So the outer hardware part, which deals with various signal levels, must be properly isolated from the sensitive output port of the computer. This stage provides isolation between the computer and

rest of the hardware circuit. Not only this, it drives the switching stage, which in turn produces different command signal codes in VHF format. These VHF coded five commands are ready to transmit.

Let us see each sub-blocks description in separate heading.

Buffer: This stage provides the isolation between computer and rest of the external hardware part. And also boosts the weak command signals to sufficient level, such that it can be used for further processing.

Driver & Switching Stage: The boosted command signals are fed to driver section, which in turn drives the relays. The Switching stage performed by relays produces respective five VHF codes and fed to next stage for transmission.

VHF Transmitter: These five VHF coded command signals are transmitted to Robotic Vehicle in the form RF packets.

Power Supply Unit: This section provides the working voltage to this Transmitter part. This transmitter part needs +12V, +5V with 65milli Amperes current consumption. This specially constructed power supply provides both voltages with accuracy.

RECEIVER PARTThe Receiver Part, as shown in Fig 2.2, consists of sub-blocks: PC & Software Module, Interface Stage

[made of Buffer and Driver/Switching stage], VHF Transmitter and Power Supply Unit. This Receiver part is fitted on the Robotic Vehicle and receives the command signal for execution. Let us see what this part actually does and each block in detail.In Brief: The VHF coded five command signals are received through VHF Receiver block. These five VHF coded signals are decoded and fed to Micro-controller IC. This Micro-controller process this command signals and fed to driver stage for further execution. The driver stage boosts the command signals coming out of PIC micro-controller IC and actuates respective relays. Here the Indicator stage gives the indication to show which relay is activated. The relays form switching stage which smartly actuate respective relay and helps to execute the command. The five command signals helps user to control the movement of Robotic Vehicle: in forward or reverse direction; left or right turn; and vaccum cleaner ON/OFF.

The block diagram explanation goes like this:

VHF Receiver: The five command signals are received by this stage. This stage decodes that VHF coded signals and fed to PIC micro-controller chip for command execution.PIC [Micro-controller]: The heart of the Robotic Vehicle is this PIC micro-controller chip. This chip receives the decoded command signals and verifies whether they are valid one or not. If they are valid commands then process it and then fed to driver stage for switching proper relays.Driver: As the switching stage performed by relays need stronger signals to get actuate, this driver stage boosts the command signals to sufficient level. The output of this driver stage is fed to indicator section and to switching stage.Indicator: This stage provides visual indication of which relay is actuated and deactivated, by glowing respective LED. Switching Stage: The relays form this switching stage and actuate themselves, whenever respective command signal is sent by the transmitter part. This switching stage controls the movement of the Robotic Vehicle and causes it to move forward/reverse or to take left/right turn and to make vaccum cleaner ON/OFF.Motor Stage: This stage has three motors: M1 for Forward & Reverse direction movement of the Robotic Vehicle, M2 for Left or Right Turn of the Vehicle, and finally M3 to switch ON/OFF the Vaccum Cleaner Machine.Power Supply Unit: This stage provides working voltage to this Receiver part. As Transmitter Part, this part too needs two supplies, +9V & +5V for proper working voltage of the part. The +9V is produced by using a Power Pack which can hold six Alkaline batteries. The +5V is provided by regulated power supply constructed on three terminal regulator IC 7805.3. Circuit DescriptionAccording to circuit construction this Micro-controller Based Robotic vaccum Cleaner project is divided into two parts: Transmitter & Receiver part. The transmitter part is kept with the controlling unit, a computer, to transmit the command signals. And the receiver part is fitted on the Robotic Vehicle to receive the command signal and executes them.Transmitter PartThis part is constructed on the copper board as single module only, except the VHF Transmitter section. The Buffer, Driver & Switching Stages are integrated in single printed circuit board to avoid any data loss and weakening of signal level. The VHF Transmitter section is separately built to avoid any signal or noise interference with the command signals. The Power Supply is specially built to provide +5Volts and +12 volts as working voltage.Buffer, Driver & Switching Module

When the user programs the schedule for the automation using GUI [Graphical User Interface] software, it actually sends 5-bit control signals to the circuit. The present circuit provides interfacing with the printer port of the Personal Computer and the controlling circuitry. This circuit takes the 5-bit control signal, isolates the PC from this circuitry, boosts control signals for required level and finally fed to the driver section to actuate relay. These five relays in turn sends VHF coded commands with respect to theRF relay position.First the components used in this Module are discussed and then the actual circuit is dealt in detail.HEX BUFFER / CONVERTER [NON-INVERTER] IC 4050: Buffers does not affect the logical state of a digital signal (i.e. logic 1 input results into logic 1 output where as logic 0 input results into logic 0 output). Buffers are normally used to provide extra current drive at the output, but can also be used to regularise the logic present at an interface. And Inverters are used to complement the logical state (i.e. logic 1 input results into logic 0 output and vice versa). Also Inverters are used to provide extra current drive and, like buffers, are used in interfacing applications. This 16-pin DIL packaged IC 4050 acts as Buffer as-well-as a Converter. The input signals may be of 2.5 to 5V digital TTL compatible or DC analogue the IC gives 5V constant signal output. The IC acts as buffer and provides isolation to the main circuit from varying input signals. The working voltage of IC is 4 to 16 Volts and propagation delay is 30 nanoseconds. It consumes 0.01 mill Watt power with noise immunity of 3.7 V and toggle speed of 3 Megahertz.

ULN 2004: Since the digital outputs of the some circuits cannot sink much current, they are not capable of driving relays directly. So, high-voltage high-current Darlington arrays are designed for interfacing low-level logic circuitry and multiple peripheral power loads. The series ULN2000A/L ICs drive seven relays with continuous load current ratings to 600mA for each input. At an appropriate duty cycle depending on ambient temperature and number of drivers turned ON simultaneously, typical power loads totalling over 260W [400mA x 7, 95V] can be controlled. Typical loads include relays, solenoids, stepping motors, magnetic print hammers, multiplexed LED and incandescent displays, and heaters. These Darlington arrays are furnished in 16-pin dual in-line plastic packages (suffix A) and 16-lead surface-mountable SOICs (suffix L). All devices are pinned with outputs opposite inputs to facilitate ease of circuit board layout.

The input of ULN 2004 is TTL-compatible open-collector outputs. As each of these outputs can sink a maximum collector current of 500 mA, miniature PCB relays can be easily driven. No additional free-wheeling clamp diode is required to be connected across the relay since each of the outputs has inbuilt free-wheeling diodes. The Series ULN20x4A/L features series input resistors for operation directly from 6 to 15V CMOS or PMOS logic outputs.

1N4148 signal diode: Signal diodes are used to process information (electrical signals) in circuits, so they are only required to pass small currents of up to 100mA. General purpose signal diodes such as the 1N4148 are made from silicon and have a forward voltage drop of 0.7V.

CIRCUIT DIAGRAM OF BUFFER, DRIVER & SWITCHING STAGE

Parts List:SEMICONDUCTORS

IC14050 HEX BUFFER/CONVERTER(NON-INVERTER) 1

IC22004 DARLINGTON ARRY1

RESISTORS

R1 to R5220 Ohm Watt Carbon Resistors5

R6 to R102.2 K Ohm Watt Carbon Resistors5

DIODES

D1to D51N4148 SIGNAL Diodes5

D6 to D10Red Indicator LEDs5

MISCELLANEOUS

RL1-RL512 V, 700 Ohm DPDT Reed Relays5

Circuit Description:

The Hex Buffer/Inverter IC1s working voltage of +5V is applied at pin-1 and five control signals are applied at input pins 3, 5, 7, 9 & 11. Thus the signal supplying circuit [i.e. PC] is isolated from this Buffer & Driver circuit. Further the grounding resistors R1 to R5 prevents the abnormal voltage levels passing inside the IC1. The buffered outputs are acquired at pins 2, 4, 6, 10, & 12. Thus the varying input is further stabilized and fed to signal diodes [D1 to D5]. As the load is inductive, there is a chance of producing back e.m.f. So to cope with this back e.m.f, signal diodes are used. But this signal level is not strong enough to drive the low impedance relay. So, IC2 Darlington driver is used. Its working voltage is +12 V and only five input/output pins are used. The output signal from the Darlington driver IC is strong enough to actuate five relays. These relays with +12V working voltage can be used to produce five command signals with VHF format. The N/O [Normally Open] contact of each relay produces one command signal with the help of VHF Transmitter Circuit. The five relays activation with theRF corresponding command signal production is tabulated as below:

RELAYCOMMAND NUMBERCOMMAND SIGNAL

RL1COM-1TURN LEFT

RL2COM-2TURN RIGHT

RL3COM-3MOVE BACKWARD

RL4COM-4MOVE FORWARD

RL5COM-5SWITCH ON/OFF THESucking Device

MOTHER BOARD 89C51

The 89C51 Micro-controller is heart of this project. It is the chip that processes the User Data and executes the same. The software inherited in this chip manipulates the data and sends the result for visual display.

INTRODUCTION OF Micro-controllerWhat is a microcontroller?The general definition of a microcontroller is a single chip computer, which refers to the fact that they contain all of the functional sections (cpu, ram, rom, i/o, ports and timers) of a traditionally defined computer on a single integrated circuit. Some experts even describe them as special purpose computers with several qualifying distinctions that separate them from other computers. Microcontrollers are "embedded" inside some other device (often a consumer product) so that they can control the features or actions of the product. Another name for a microcontroller, therefore, is "embedded controller."

Microcontrollers are dedicated to one task and run one specific program. The program is stored in rom (read-only memory) and generally does not change. Microcontrollers are often low-power devices. A desktop computer is almost always plugged into a wall socket and might consume 50 watts of electricity. A battery-operated microcontroller might consume 50 mill watts.

A microcontroller has a dedicated input device and often (but not always) has a small led or lcd display for output. A microcontroller also takes input from the device it is controlling and controls the device by sending signals to different components in the device.A microcontroller is often small and low cost. The components are chosen to minimize size and to be as inexpensive as possible. A microcontroller is often, but not always, ruggedized in some way. The microcontroller controlling a car's engine, for example, has to work in temperature extremes that a normal computer generally cannot handle. A car's microcontroller in KashmRF regions has to work fine in -30 degree F (-34 (C) weather, while the same microcontroller in Gujarat region might be operating at 120 degrees F (49 (C). When you add the heat naturally generated by the engine, the temperature can go as high as 150 or 180 degrees F (65-80 (C) in the engine compartment. On the other hand, a microcontroller embedded inside a vcr hasn't been ruggedized at all.Clearly, the distinction between a computer and a microcontroller is sometimes blurred. Applying these guidelines will, in most cases, clarify the role of a particular device.Why are they so popular?The programmability of modern desktop pcs makes them extraordinarily versatile. The functionality of the entire machine can be altered by merely changing its programming. Microcontrollers share this attribute with theRF desktop relatives. The chips are manufactured with powerful capabilities and the end user determines exactly how the device will function. Often, this makes a dramatic difference in the cost and complexity of a particular design. The true impact of this statement is best illustrated by example. For every clock pulse, the circuit produces one of the three bit numbers in the sequence 000, 100, 111, 010, 011. This design has been implemented with three flip-flops and seven discrete gates as well as a significant amount of wiring. The design of this system can be quite laborious. One must begin with a state graph followed by a state table. Then, the flip-flop t input equations must be derived from a set of Karnaugh maps. Next, the t input equations must be transformed into the actual t input network. All of this circuitry must then be wired together; a task that's time consuming and sometimes error prone. On the other hand, this can be accomplished with a simpler, less costly microcontroller design. Notice the dramatic difference in the amount of hardware and wiring. This simple circuit, along with about a dozen lines of code, will perform the same task as the first circuit. There are other benefits as well. The microcontroller implementation does not have to contend with the undetermined states that sometimes occur with discrete designs. Also consider for a moment what would be required to change the sequence of numbers in the first circuit. What if the output needs to be changed to eight bits instead of three? These are trivial modifications for the microcontroller while the discrete circuit would require a complete redesign.The example above is not an obscure case. The effects of this device are being felt in almost every facet of digital design. A sure method of determining the popularity of an electronic device is to note when they attain widespread use by hobbyists. It therefore becomes essential that the electronics engineer or hobbyist learn to program these microcontrollers to maintain a level of competence and to gain the advantages microcontrollers provide in his or her own circuit designs. Introducing the Intels Microcontroller 89C51Features

Compatible with MCS-51 Products

8K Bytes of In-System Reprogrammable Flash Memory

Endurance: 1,000 Write/Erase Cycles

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

Eight Interrupt Sources

Programmable Serial Channel

Low-power Idle and Power-down Modes

Description

The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pin out.

The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.

The AT89C52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, 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 AT89C52 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 hardware reset.

Pin Description

VCC

Supply voltage.

GND

Ground.

Port 0

Port 0 is an 8-bit open drain bi-directional 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 by test during program verification. External pull ups are required during program verification.

Port 1

Port 1 is an 8-bit bi-directional 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.

Port 1 also receives the low-order address bytes during Flash programming and verification. Port Pin Alternate Functions P1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2 EX (Timer/Counter 2 capture/reload trigger and direction control) AT89C52

Port 2

Port 2 is an 8-bit bi-directional 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 bi-directional 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 also receives some control signals for Flash programming and verification.

Port Pin Alternate Functions

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)

RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.

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

Special Function Registers

A map of the on-chip memory area called the Special Function Register (SFR) space. 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 AT89C52 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 and T2MOD for Timer2. The register paRF (RCAP2H, RCAP2L) is the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.

Interrupt Register

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

Symbol Function

TF2 Timer 2 overflow flag set by a Timer 2 overflow and must be cleared by software. TF2 will not be set when either RCLK = 1 or TCLK = 1.

EXF2 Timer 2 external flag set when either a capture or reload is caused by a negative transition on T2EX and EXEN2 = 1. When Timer 2 interrupt is enabled, EXF2 = 1 will cause the CPU to vector to the Timer 2 interrupt routine. EXF2 must be cleared by software. EXF2 does not cause an interrupt in up/down counter mode (DCEN = 1).

RCLKReceive clock enable. When set, causes the serial port to use Timer 2 overflow pulses for its receive clock in serial port Modes 1 and 3. RCLK = 0 causes Timer 1 overflow to be used for the receive clock.

TCLK Transmit clock enable. When set, causes the serial port to use Timer 2 overflow pulses for its transmit clock in serial port Modes 1 and 3. TCLK = 0 causes Timer 1 overflows to be used for the transmit clock.

EXEN2 Timer 2 external enable. When set, allows a capture or reload to occur as a result of a negative transition on T2EX if Timer 2 is not being used to clock the serial port. EXEN2 = 0 causes Timer 2 to ignore events at T2EX.

TR2

Start/Stop control for Timer 2. TR2 = 1 starts the timer.

C/T2 Timer or counter select for Timer 2. C/T2 = 0 for timer function. C/T2 = 1 for external event counter (falling edge triggered).

CP/RL2 Capture/Reload select. CP/RL2 = 1 causes captures to occur on negative transitions at T2EX if EXEN2 = 1. CP/RL2 = 0 causes automatic reloads to occur when Timer 2 overflows or negative transitions occur at T2EX when EXEN2 = 1. When either RCLK or TCLK = 1, this bit is ignored and the timer is forced to auto-reload on Timer 2 overflow.

Data Memory

The AT89C52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. That means the upper 128 bytes 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 that use direct addressing access 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).

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.

Timer 0 and 1

Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1 in the AT89C51.

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

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

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.

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 2s 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 a timer, it increments every machine cycle (at 1/12 the oscillator frequency).

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.

Programmable Clock Out

A 50% duty cycle clock can be programmed to come out on P1.0. This pin, besides being a regular I/O pin, has two alternate functions. It can be programmed to input the external clock for Timer/Counter 2

or to output a 50% duty cycle clock ranging from 61 Hz to 4 MHz at a 16 MHz operating frequency.

To configure the Timer/Counter 2 as a clock generator, bit C/T2 (T2CON.1) must be cleared and bit T2OE (T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and stops the timer.

UART

The UART in the AT89C52 operates the same way as the UART in the AT89C51.

Interrupts

The AT89C52 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. 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 shows that bit position IE.6 is unimplemented. In the A T89 C5 1, bit position IE.5 is also

unimplemented. User software should not write 1s to these bit positions, since they 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.

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.

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 theRF values until the power-down mode is terminated. The only exit from power-down is a hardware reset. 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.

Programming the Flash

The AT89C52 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The Low-voltage programming mode provides a convenient way to program the AT89C52 inside the users system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers.

The AT89C52 is shipped with either the high-voltage or low-voltage programming mode enabled. The AT89C52 code memory array is programmed byte-by-byte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the

Chip Erase Mode.

Programming Algorithm Before programming the AT89C52, the address, data and control signals should be set up according to the Flash programming mode table and Figure 9 and Figure 10. To program the AT89C52, take the following steps.

1. Input the desired memory location on the address lines.

2. Input the appropriate data byte on the data lines.

3. Activate the correct combination of control signals.

4. Raise EA/VPP to 12V for the high-voltage programming mode.

5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is

self-timed and typically takes no more than 1.5 ms.

Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the

object file is reached.

Data Polling

The AT89C52 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written data on PO.7. Once the write cycle has been completed, true data is valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. Ready/Busy The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate

BUSY.

P3.4 is pulled high again when programming is done to indicate READY. Program Verify If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that theRF features are enabled.

Chip Erase

The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. The chip erase operation must be executed before the code memory can be reprogrammed.

Reading the Signature Bytes

The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows.

(030H) = 1EH indicates manufactured by Atmel

(031H) = 52H indicates 89C52

(032H) = FFH indicates 12V programming

(032H) = 05H indicates 5V programming

Flash Programming Modes

Programming Interface

Every code byte in the Flash array can be written, and the entire array can be erased, by using the appropriate combination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to completion.

DC Characteristics

Absolute Maximum Ratings*

Operating Temperature.................................. -55C to +125C

Storage Temperature ..................................... -65C to +150C

Voltage on Any Pin with Respect to Ground .....................................-1.0V to +7.0V

Maximum Operating Voltage............................................ 6.6V

DC Output Current...................................................... 15.0 mA

Parts List of Power Supply

X112-0-12V Transformer1

IC17805 Regulator IC1

D1 & D21N4007 Rectifier Diode2

D3Red Indicator LED1

R1100 K Carbon Resistor1

C1 1000MFD/25V Electrolytic Capacitor1

C2 & C30.1F Ceramic Capacitor2

CIRCUIT DESCRIPTION

The mother board of 89C51 has following sections: Power Supply, 89C51 IC, Oscillator, Reset Switch & I/O ports. Let us see these sections in detail.Power supply:

This section provides the clean and harmonic free power to ic to function properly. The output of the full wave rectifier section, which is built using two rectifier diodes, is given to filter capacitor. The electrolytic capacitor C1 filters the pulsating dc into pure dc and given to Vin pin-1 of regulator IC 7805.This three terminal IC regulates the rectified pulsating dc to constant +5 volts. C2 & C3 provides ground path to harmonic signals present in the inputted voltage. The Vout pin-3 gives constant, regulated and spikes free +5 volts to the mother board.The allocation of the pins of the 89C51 follows a U-shape distribution. The top left hand corner is Pin 1 and down to bottom left hand corner is Pin 20. And the bottom right hand corner is Pin 21 and up to the top right hand corner is Pin 40. The Supply Voltage pin Vcc is 40 and ground pin Vss is 20. Oscillator:

If the cpu is the brain of the system then the oscillator, or clock, is the heartbeat. It provides the critical timing functions for the rest of the chip. The greatest timing accuracy is achieved with a crystal or ceramic resonator. For crystals of 2.0 to 12.0 mhz, the recommended capacitor values should be in the range of 15 to 33pf2. Across the oscillator input pins 18 & 19 a crystal x1 of 4.7 mhz to 20 mhz value can be connected. The two ceramic disc type capacitors of value 30pF are connected across crystal and ground, stabilizes the oscillation frequency generated by crystal.I/o ports:

There are a total of 32 i/o pins available on this chip. The amazing part about these ports is that they can be programmed to be either input or output ports, even "on the fly" during operation! Each pin can source 20 mA (max) so it can directly drive an led. They can also sink a maximum of 25 Ma current.

Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. The alternate function of each pin is not discussed here, as port accessing circuit takes care of that.

This 89C51 ic has four i/o ports and is discussed in detail:

P0.0 to p0.7PORT0 is an 8-bit [pins 32 to 39] open drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs and configured to be multiplexed low order address/data bus then has internal pull ups. External pull ups are required during program verification.

p1.0 to P1.7PORT1 is an 8-bit wide [pins 1 to 8], bi-directional port with internal pull ups. P1.0 and P1.1 can be configured to be the timer/counter 2 external count input and the timer/counter 2 trigger input respectively.p2.0 to P2.7PORT2 is an 8-bit wide [pins 21 to 28], bi-directional port with internal pull ups. The PORT2 output buffers can sink/source four TTL inputs. It receives the high-order address bits and some control signals during Flash programming and verification. p3.0 to P3.7PORT3 is an 8-bit wide [pins 10 to 17], bi-directional port with internal pull ups. The Port3 output buffers can sink/source four TTL inputs. It also receives some control signals for Flash programming and verification.psenProgram Store Enable [Pin 29] is the read strobe to external program memory.aleAddress Latch Enable [Pin 30] is an output pulse for latching the low byte of the address during accesses to external memory.

EA

External Access Enable [Pin 31] must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H upto FFFFH.RST

Reset input [Pin 9] must be made high for two machine cycles to resets the devices oscillator. The potential difference is created using 10MFD/63V electrolytic capacitor and 20KOhm resistor with a reset switch.LCD Interfacing

LCDs can add a lot to any application in terms of providing an useful interface for the user, debugging an application or just giving it a "professional" look. The most common type of LCD controller is the Hitatchi 44780 which provides a relatively simple interface between a processor and an LCD. Using this interface is often not attempted by inexperienced designers and programmers because it is difficult to find good documentation on the interface, initializing the interface can be a problem and the displays themselves are expensive.

The most common connector used for the 44780 based LCDs is 14 pins in a row, with pin centers 0.100" apart. The pins are wired as:

PinsDescription

1Ground

2Vcc

3Contrast Voltage

4"R/S" _Instruction/Register Select

5"R/W" _Read/Write LCD Registers

6"E" Clock

7 - 14Data I/O Pins

The interface is a parallel bus, allowing simple and fast reading/writing of data to and from the LCD.

The LCD Data Write Waveform will write an ASCII Byte out to the LCD's screen. The ASCII code to be displayed is eight bits long and is sent to the LCD either four or eight bits at a time. If four bit mode is used, two "nibbles" of data (Sent high four bits and then low four bits with an "E" Clock pulse with each nibble) are sent to make up a full eight bit transfer. The "E" Clock is used to initiate the data transfer within the LCD.

Sending parallel data as either four or eight bits are the two primary modes of operation. While there are secondary considerations and modes, deciding how to send the data to the LCD is most critical decision to be made for an LCD interface application.

Eight bit mode is best used when speed is required in an application and at least ten I/O pins are available. Four bit mode requires a minimum of six bits. To wire a microcontroller to an LCD in four bit mode, just the top four bits (DB4-7) are written to.

The "R/S" bit is used to select whether data or an instruction is being transferred between the microcontroller and the LCD. If the Bit is set, then the byte at the current LCD "Cursor" Position can be read or written. When the Bit is reset, either an instruction is being sent to the LCD or the execution status of the last instruction is read back (whether or not it has completed).

The different instructions available for use with the 44780 are shown in the table below:

R/SR/WD7D6D5D4D3D2D1D0Instruction/Description

451413121110987Pins

0000000001Clear Display

000000001*Return Cursor and LCD to Home Position

00000001IDSSet Cursor Move Direction

0000001DCBEnable Display/Cursor

000001SCRL**Move Cursor/Shift Display

00001DLNF**Set Interface Length

0001AAAAAAMove Cursor into CGRAM

001AAAAAAAMove Cursor to Display

01BF*******Poll the "Busy Flag"

10DDDDDDDDWrite a Character to the Display at the Current Cursor Position

11DDDDDDDDRead the Character on the Display at the Current Cursor Position

The bit descriptions for the different commands are:

"*" - Not Used/Ignored. This bit can be either "1" or "0"

Set Cursor Move Direction:

ID - Increment the Cursor After Each Byte Written to Display if Set

S - Shift Display when Byte Written to Display

Enable Display/Cursor

D - Turn Display On(1)/Off(0)

C - Turn Cursor On(1)/Off(0)

B - Cursor Blink On(1)/Off(0)

Move Cursor/Shift Display

SC - Display Shift On(1)/Off(0)

RL - Direction of Shift Right(1)/Left(0)

Set Interface Length

DL - Set Data Interface Length 8(1)/4(0)

N - Number of Display Lines 1(0)/2(1)

F - Character Font 5x10(1)/5x7(0)

Poll the "Busy Flag"

BF - This bit is set while the LCD is processing

Move Cursor to CGRAM/Display

A - Address

Read/Write ASCII to the Display

D - Data

Before you can send commands or data to the LCD module, the Module must be initialized. For eight bit mode, this is done using the following series of operations:

Wait more than 15 mSecs after power is applied.

Write 0x030 to LCD and wait 5 mSecs for the instruction to complete

Write 0x030 to LCD and wait 160 secs for instruction to complete

Write 0x030 AGAIN to LCD and wait 160 secs or Poll the Busy Flag

Set the Operating Characteristics of the LCD

Write "Set Interface Length"

Write 0x010 to turn off the Display

Write 0x001 to Clear the Display

Write "Set Cursor Move Direction" Setting Cursor Behaviour Bits

Write "Enable Display/Cursor" & enable Display and Optional Cursor

In describing how the LCD should be initialized in four bit mode, experts will specify writing to the LCD in terms of nibbles. This is because initially, just single nibbles are sent (and not two, which make up a byte and a full instruction). As mentioned above, when a byte is sent, the high nibble is sent before the low nibble and the "E" pin is toggled each time four bits is sent to the LCD. To initialize in four bit mode:

Wait more than 15 mSecs after power is applied.

Write 0x03 to LCD and wait 5 mSecs for the instruction to complete

Write 0x03 to LCD and wait 160 secs for instruction to complete

Write 0x03 AGAIN to LCD and wait 160 secs (or poll the Busy Flag)

Set the Operating Characteristics of the LCD

Write 0x02 to the LCD to Enable Four Bit Mode

All following instruction/Data Writes require two nibble writes.

Write "Set Interface Length"

Write 0x01/0x00 to turn off the Display

Write 0x00/0x01 to Clear the Display

Write "Set Cursor Move Direction" Setting Cursor Behaviour Bits

Write "Enable Display/Cursor" & enable Display and Optional Cursor

Once the initialization is complete, the LCD can be written to with data or instructions as required. Each character to display is written like the control bytes, except that the "R/S" line is set. During initializiation, by setting the "S/C" bit during the "Move Cursor/Shift Display" command, after each character is sent to the LCD, the cursor built into the LCD will increment to the next position (either right or left). Normally, the "S/C" bit is set (equal to "1") along with the "R/L" bit in the "Move Cursor/Shift Display" command for characters to be written from left to right (as with a "Teletype" video display).

Most LCD displays have a 44780 and support chip to control the operation of the LCD. The 44780 is responsible for the external interface and provides sufficient control lines for sixteen characters on the LCD. The support chip enhances the I/O of the 44780 to support up to 128 characters on an LCD. From the table above, it should be noted that the first two entries ("8x1", "16x1") only have the 44780 and not the support chip. This is why the ninth character in the 16x1 does not "appear" at address 8 and shows up at the address that is common for a two line LCD.

Here it is included the 40 character by 4 line ("40x4") LCD because it is quite common. Normally, the LCD is wired as two 40x2 displays. The actual connector is normally sixteen bits wide with all the fourteen connections of the 44780 in common, except for the "E" (Strobe) pins. The "E" strobes are used to address between the areas of the display used by the two devices. The actual pinouts and character addresses for this type of display can vary between manufacturers and display part numbers.

Note that when using any kind of multiple 44780 LCD display, programmer should probably only display one 44780's Cursor at a time.

Cursors for the 44780 can be turned on as a simple underscore at any time using the "Enable Display/Cursor" LCD instruction and setting the "C" bit. Expert don't recommend using the "B" ("Block Mode") bit as this causes a flashing full character square to be displayed and it really isn't that attractive.

The LCD can be thought of as a "Teletype" display because in normal operation, after a character has been sent to the LCD, the internal "Cursor" is moved one character to the right. The "Clear Display" and "Return Cursor and LCD to Home Position" instructions are used to reset the Cursor's position to the top right character on the display.

To move the Cursor, the "Move Cursor to Display" instruction is used. For this instruction, bit 7 of the instruction byte is set with the remaining seven bits used as the address of the character on the LCD the cursor is to move to. These seven bits provide 128 addresses, which matches the maximum number of LCD character addresses available. The table above should be used to determine the address of a character offset on a particular line of an LCD display.

The Character Set available in the 44780 is basically ASCII. It is "basically" because some characters do not follow the ASCII convention fully (probably the most significant difference is 0x05B or "\" is not available). The ASCII Control Characters (0x008 to 0x01F) do not respond as control characters and may display funny (Japanese) characters.

The last aspect of the LCD to discuss is how to specify a contrast voltage to the Display. Experts typically use a potentiometer wired as a voltage divider. This will provide an easily variable voltage between Ground and Vcc, which will be used to specify the contrast (or "darkness") of the characters on the LCD screen. You may find that different LCDs work differently with lower voltages providing darker characters in some and higher voltages do the same thing in others.

There are a variety of different ways of wiring up an LCD. Above, it is noted that the 44780 can interface with four or eight bits. To simplify the demands in microcontrollers, a shift register is often used (as is shown in the diagram below) to reduce the number of I/O pins to three.

It is evident that using this circuit with the PICMicro, 8051 and AVR and it really makes the wiring of an LCD to a microcontroller very simple. A significant advantage of using a shift register, like the two circuits shown here, data to the LCD is the lack of timing sensitivity that will be encountered. The biggest issue to watch for is to make sure the "E" Strobe's timing is within specification (i.e., greater than 450 nSecs), the shift register loads can be interrupted without affecting the actual write. This circuit will not work with Open-Drain only outputs.

One note about the LCD's "E" Strobe is that in some documentation it is specified as "high" level active while in others, it is specified as falling edge active. It seems to be falling edge active, which is why the 2-wire LCD interface presented below works even if the line ends up being high at the end of data being shifted in. If the falling edge is used (like in the 2-wire interface) then make sure that before the "E" line is output on "0", there is at least a 450 nSecs delay with no lines changing state.

Next the program is given in 8051 assembly language with necessary comments that can display a Numerous instructions Display clear, Cursor home, Display ON/OFF, Cursor ON/OFF, Blink character, Cursor shift, Display shift

The unit operates from a single 5V power supply

Liquid crystal panel service life 100,000 hours minimum at 25 oC -10 oC

3.3 definition of panel service life

Contrast becomes 30% of initial value

Current consumption becomes three times higher than initial value

Remarkable alignment deterioration occurs in LCK cell layer

Unusual operation occurs in display functions

Safety

If the LCD panel breaks, be careful not to get the liquid crystal in your mouth. If the liquid crystal touches your skin or clothes, wash it off immediately using soap and plenty of water.

Handling

Avoid static electricity as this can damage the CMOS LSI.

The LCD panel is plate glass; do not hit or crush it.

Do not remove the panel or frame from the module.

The polarizing plate of the display is very fragile; handle it very carefully

Mounting and Design

Mount the module by using the specified mounting part and holes.

To protect the module from external pressure, leave a small gap by placing transparent plates (e.g. acrylic or glass) on the display surface, frame, and polarizing plate

Design the system so that no input signal is given unless the power-supply voltage is applied.

Keep the module dry. Avoid condensation; otherwise the transparent electrodes may break.

Storage

Store the module in a dark place, where the temperature is 25 oC - 10 oC and the humidity below 65% RH.

Do not store the module near organic solvents or corrosive gases.

Do not crush, shake, or jolt the module (including accessories).

1. Step-down Transformer: The conventional supply, which is generally available to the user, is 230V AC. It is necessary to step down the mains supply to the desired level. This is achieved by using suitably rated step-down transformer. While designing the power supply, it is necessary to go for little higher rating transformer than the required one. The reason for this is, for proper working of the regulator IC (say KIA 7805) it needs at least 2.5V more than the expected output voltage

2. Rectifier stage: Then the step-downed Alternating Current is converted into Direct Current. This rectification is achieved by using passive components such as diodes. If the power supply is designed for low voltage/current drawing loads/circuits (say +5V), it is sufficient to employ full-wave rectifier with centre-tap transformer as a power source. While choosing the diodes the PIV rating is taken into consideration.

3. Filter stage: But this rectified output contains some percentage of superimposed a.c. ripples. So to filter these a.c. components filter stage is built around the rectifier stage. The cheap, reliable, simple and effective filtering for low current drawing loads (say upto 50 mA) is done by using shunt capacitors. This electrolytic capacitor has polarities, take care while connecting the circuit.

4. Voltage Regulation: The filtered d.c. output is not stable. It varies in accordance with the fluctuations in mains supply or varying load current. This variation of load current is observed due to voltage drop in transformer windings, rectifier and filter circuit. These variations in d.c. output voltage may cause inaccurate or erratic operation or even malfunctioning of many electronic circuits. For example, the circuit boards which are implanted by CMOS or TTL ICs.

The stabilization of d.c. output is achieved by using the three terminal voltage regulator IC. This regulator IC comes in two flavors: 78xx for positive voltage output and 79xx for negative voltage output. For example 7805 gives +5V output and 7905 gives -5V stabilized output. These regulator ICs have in-built short-circuit protection and auto-thermal cutout provisions. If the load current is very high the IC needs heat sink to dissipate the internally generated power.Circuit Description: A d.c. power supply which maintains the output voltage constant irrespective of a.c. mains fluctuations or load variations is known as regulated d.c. power supply. It is also referred as full-wave regulated power supply as it uses four diodes in bridge fashion with the transformer. This laboratory power supply offers excellent line and load regulation and output voltages of +5V & +12 V at output currents up to one amp. CIRCUIT DIAGRAM OF +5V & +12V FULL WAVE REGULATED POWER SUPPLY

Parts List:

SEMICONDUCTORS

IC1IC27812 Regulator IC7805 Regulator IC11

D1& D21N4007 Rectifier Diodes2

CAPACITORS

C11000 f/25V Electrolytic 1

C2 to C40.1F Ceramic Disc type3

MISCELLANEOUS

X1230V AC Pri,14-0-14 1Amp Sec Transformer1

1. Step-down Transformer: The transformer rating is 230V AC at Primary and 12-0-12V, 1Ampers across secondary winding. This transformer has a capability to deliver a current of 1Ampere, which is more than enough to drive any electronic circuit or varying load. The 12VAC appearing across the secondary is the RMS value of the waveform and the peak value would be 12 x 1.414 = 16.8 volts. This value limits our choice of rectifier diode as 1N4007, which is having PIV rating more than 16Volts.

2. Rectifier Stage: The two diodes D1 & D2 are connected across the secondary winding of the transformer as a full-wave rectifier. During the positive half-cycle of secondary voltage, the end A of the secondary winding becomes positive and end B negative. This makes the diode D1 forward biased and diode D2 reverse biased. Therefore diode D1 conducts while diode D2 does not. During the negative half-cycle, end A of the secondary winding becomes negative and end B positive. Therefore diode D2 conducts while diode D1 does not. Note that current across the centre tap terminal is in the same direction for both half-cycles of input a.c. voltage. Therefore, pulsating d.c. is obtained at point C with respect to Ground. 3. Filter Stage: Here Capacitor C1 is used for filtering purpose and connected across the rectifier output. It filters the a.c. components present in the rectified d.c. and gives steady d.c. voltage. As the rectifier voltage increases, it charges the capacitor and also supplies current to the load. When capacitor is charged to the peak value of the rectifier voltage, rectifier voltage starts to decrease. As the next voltage peak immediately recharges the capacitor, the discharge period is of very small duration. Due to this continuous charge-discharge-recharge cycle very little ripple is observed in the filtered output. Moreover, output voltage is higher as it remains substantially near the peak value of rectifier output voltage. This phenomenon is also explained in other form as: the shunt capacitor offers a low reactance path to the a.c. components of current and open circuit to d.c. component. During positive half cycle the capacitor stores energy in the form of electrostatic field. During negative half cycle, the filter capacitor releases stored energy to the load.

4. Voltage Regulation Stage: Across the point D and Ground there is rectified and filtered d.c. In the present circuit KIA 7812 three terminal voltage regulator IC is used to get +12V and KIA 7805 voltage regulator IC is used to get +5V regulated d.c. output. In the three terminals, pin 1 is input i.e., rectified & filtered d.c. is connected to this pin. Pin 2 is common pin and is grounded. The pin 3 gives the stabilized d.c. output to the load. The circuit shows two more decoupling capacitors C2 & C3, which provides ground path to the high frequency noise signals. Across the point E and F with respect to ground +5V & +12V stabilized or regulated d.c output is measured, which can be connected to the required circuit.Note: While connecting the diodes and electrolytic capacitors the polarities must be taken into consideration. The transformers primary winding deals with 230V mains, care should be taken with it.power supply unitThe circuit needs two different voltages, +5V & +9V, to work. The +9Volts is provided by power packt, which contains six alkaline batteries in series. The +5 voltage is supplied by this specially designed power supply.

Circuit Description: A d.c. power supply which maintains the output voltage constant irrespective of a.c. mains fluctuations or load variations is known as regulated d.c. power supply. It is also referred as full-wave regulated power supply as it uses two diodes in full wave fashion with centre tap transformer. 1.Step-down Transformer : The transformer rating is 230V AC at Primary and 12-0-12V, 1Ampers across secondary winding. This transformer has a capability to deliver a current of 1Ampere, which is more than enough to drive any electronic circuit or varying load. The 12VAC appearing across the secondary is the RMS value of the waveform and the peak value would be 12 x 1.414 = 16.8 volts. This value limits our choice of rectifier diode as 1N4007, which is having PIV rating more than 16Volts.

CIRCUIT DIAGRAM OF +5V FULL WAVE REGULATED POWER SUPPLYParts List:

SEMICONDUCTORS

IC17805 Regulator IC1

D1,D21N4007 Rectifier Diodes2

CAPACITORS

C11000 f/25V Electrolytic 1

C2,C30.1F Ceramic Disc type2

MISCELLANEOUS

X1230V AC Pri,12-0-12 1Amp Sec Transformer1

2. Rectifier Stage: The two diodes D1 & D2 are connected across the secondary winding of the transformer as a full-wave rectifier. During the positive half-cycle of secondary voltage, the end A of the secondary winding becomes positive and end B negative. This makes the diode D1 forward biased and diode D2 reverse biased. Therefore diode D1 conducts while diode D2 does not. During the negative half-cycle, end A of the secondary winding becomes negative and end B positive. Therefore diode D2 conducts while diode D1 does not. Note that current across the centre tap terminal is in the same direction for both half-cycles of input a.c. voltage. Therefore, pulsating d.c. is obtained at point C with respect to Ground.

3. Filter Stage: Here Capacitor C1 is used for filtering purpose and connected across the rectifier output. It filters the a.c. components present in the rectified d.c. and gives steady d.c. voltage. As the rectifier voltage increases, it charges the capacitor and also supplies current to the load. When capacitor is charged to the peak value of the rectifier voltage, rectifier voltage starts to decrease. As the next voltage peak immediately recharges the capacitor, the discharge period is of very small duration. Due to this continuous charge-discharge-recharge cycle very little ripple is observed in the filtered output. Moreover, output voltage is higher as it remains substantially near the peak value of rectifier output voltage. This phenomenon is also explained in other form as: the shunt capacitor offers a low reactance path to the a.c. components of current and open circuit to d.c. component. During positive half cycle the capacitor stores energy in the form of electrostatic field. During negative half cycle, the filter capacitor releases stored energy to the load.

4. Voltage Regulation Stage: Across the point D and Ground there is rectified and filtered d.c. In the present circuit KIA 7805 voltage regulator IC is used to get +5V regulated d.c. output. In the three terminals, pin 1 is input i.e., rectified & filtered d.c. is connected to this pin. Pin 2 is common pin and is grounded. The pin 3 gives the stabilized d.c. output to the load. The circuit shows two more decoupling capacitors C2 & C3, which provides ground path to the high frequency noise signals. Across the point E and ground +5V stabilized or regulated d.c output is measured, which can be connected to the required circuit.Note: While connecting the diodes and electrolytic capacitors the polarities must be taken into consideration. The transformers primary winding deals with 230V mains, care should be taken with it.IC DATA SHEET

IC 4050

HEX BUFFER / CONVERTER (NON-INVERTER)

GENERAL CHARACTERISTICS:1. Voltage Rating

:4V to 16V

2. Operating Temperature:0(C -65(C

3. Max Power Dissipation:0.01mW

4. Propagation Delay

:30 nsec typically

5. Max Toggle Speed

:3 MHz

6. Fan Out

:> 50

7. Noise Immunity

:3.7V

KIA 7805

VOLTAGE REGULATOR

General Characteristics:

1. Output voltage : 05V

2. Operating Temperature : 0(c - 70(c

3. Output Current

: 100mA

4. Dropout Voltage

: 1.7V

MCT 2E

ULN2003A

1

Note that the ULN2000A series (dual in-line package) and ULN2000L series (small-outline IC package) are electrically identical and share a common pin number assignment.

ABSOLUTE MAXIMUM RATINGS

Output Voltage, VCE

( ULN200X*, ULN2013A)

50V

( ULN202X*)

95V

Input Voltage, VIN

30V

Continuous Output Current, Ic

( ULN200X*, ULN202X*)

500mA

(ULN2013A)

600mA

Continuous Input Current, IIN

25mA

Power Dissipation, PD

(one Darlington pair)

1.0W

Operating Temperature Range, TA

-20(C to +85(C

Storage Temperature Range, Ts

-55(C to +150(C

6. Project Construction Guidelines

Read these hints carefully before start building your Project. Allow sufficient time to read & be sure you understand everything perfectly. Start your work where you can be comfortable and can leave the Project spread out between wiring sessions. Be cool & have patient... project construction should be educative and fun! Stopping at the end of the every stage and checking, step-by-step, will help you avoid needless mistakes. This can save you a lot of double checking and time consuming trouble-shooting later on. Before start assembling the Project, read some basic electronic theory about active & passive components, how they work, parameters, lead identifications etc. At one session, work only as long as you enjoys it.

Unpacking the Project Kit: Unpack the project carefully and check each component against the Component List.

Observe the PCB, Circuit diagram sheet & components for any physical damages.

Check that you got the Project Kit you actually intended for!

Assembling the Project Kit: Before starts assembling the project keep all the necessary needed tools on your workbench.

Check the PCB for the broken tracks, by testing continuity between each track.

By holding the PCB slightly inclined towards the light, one can check the copper layouts physical condition on the PCB.

Identify each section of the circuit on the PCB layout & get familiar with the board.

Check each component & be assuring that they are in good and working condition.

Special care should be taken while dealing with the sensors or sparingly available components.

Clean the component leads, tracks (if they are coated with corrosive layer), and pads.

Soldering the Project KitBefore start soldering keep all the necessary tools required for it viz., suitably rated Soldering Iron with clean tip, tweezers, nose-pliers, small & medium size screw drivers, flux, sharp knife etc.

The PCB has two sides. One is the copper foil side and the other, the component side. You have to mount the components on the component side, solder them on the copper layout side.

Keep below points in memory while soldering

Remember that 90% of all non-functioning of project are due to bad soldering & poor connections.

Switch OFF the fan, if it is running! Position the work so that gravity tends to keep the solder where you want it.

The new soldering irons tip should be filed to remove the steel or copper oxide coating. Then apply little solder on the hot tip.

The soldering iron will reach its operating temperature within 3 to 5 minutes, after it is switched on, and should be left on during the working period.

For good soldered connections, you must keep the soldering iron tip clean- wipe it often with a damp sponge or cloth.

Keep hot tip of the soldering iron on a piece of metal so that excess heat is dissipated.

Make sure that the connection to be soldered is clean. Wax frayed insulations and other foreign substances cause poor connections. Clean the component leads wires, lugs, etc., with a blade or a knife to remove the rust and dust before soldering.

Bend the lead at a 45( angle to the PCB.

Use just enough solder to cover the lead and the copper foil area of the connection to be soldered. Excess solder can bridge across from one foil path to another foil and cause a short circuit.

Apply enough heat to the foil and the lead to allow the solder to spread freely. A good soldered joint will look smooth, shining and solder equally spreaded along the pad.

Do not over heat the components or the PCB. Excess heat may spoil the PCB or damage the components. The general time of soldering is 2 to 3 seconds.

The PCB or components should not vibrate while soldering otherwise you will have a dry or a cold joint.

Remember larger metal surfaces take longer time to heat e.g. clamps of Coils, transformers, heat sinks etc.

While using the de-soldering pump to clear the plugged holes/pads special care should be taken, as the excessive heat or pulling action may damage the copper foils.

The leads of resistors, capacitors, and similar components are generally much longer than needed to make the required connections. Cut the leads with a diagonal cutter or a nail cutter to the proper length before installing the part; the leads should be just long enough to reach theRF connecting points.

Apply small amount of flux to the tinned & cleaned leads of the soldering components.

Start soldering your Project Kit from the power-supply section viz, step-down transformer, diodes, capacitors & regulators. First check the components, clean them, then solder one-by-one on the PCB. Next step is to check the voltages at different points, across transformer primary & secondary windings, after rectifier stage, filter stage & regulator stage respectively. Also check that this voltage is available at all points of the PCB, especially ICs +Vcc pins.

Now solder the next section of your circuit and check for its integrity with the whole project. This step-by-step procedure must continue throughout the project building session.

While soldering the order (usually from big-in-size towards small-in-size components) must be IC bases, transformers, transistors, electrolytic capacitors, coils, ceramic capacitors, resistors etc.

While soldering the sensors, special modules care should be taken that they are not connected in the reverse order or wrong polarity insertion took place.

To prepare a length of connecting wire or jumper wire, you will normally remove 4mm of insulation from each end. For stranded wire, apply solder to the ends to hold the strands together.

Resistors should be mounted in either vertical or horizontal fashion. Check the color code for the proper value before soldering them.

Observe the polarity of the electrolytic capacitors & values of the MKT, Ceramic Disc type capacitors. Push the leads of the capacitors into the holes until you cannot push them further. Bend the leads a little, solder and cut off excess lead lengths.

Check the transistors type, whether NPN or PNP, and identify the pins correctly on the PCB.

The band indicates Cathode in Diodes, + mark indicates positive polarity in Capacitors, dot or notch indicates the Collector lead of the Transistor.

Calibration/Fine Tuning/Adjusting/Aligning the Project Kit When the whole circuit is soldered and tested for integrity in step-by-step procedure as explained above, take a break!

This must be a fresh, new session for you. Because this session demands your cool and fresh mind-set, as lot of back tracking is supposed to do here.

A little time spent carefully performing the stated steps will be rewarded with excellent performance.

Before proceeding in this session gather all the necessary testing instruments on the workbench.

Carefully handle the testing instruments, as they are costly electronic-gadgets to get. Know how to operate them, before employing them in your project testing session.

Trouble-shooting the Project Kit: First visually check for the physical disorder, improper soldering or poor connections on the PCB.

Check the mains cord, transformer output and power-supply

Check that all Components are in theRF proper location and are installed correctly as per the Circuit diagram supplied with the Project Kit.

7 Application & Future DevelopmentsAPPLICATIONS

1) It can be used in industries for heavy, monotonous jobs.

2) It can be used in stores for moving objects from one place to another.

3) Robotic vacuum cleaner is used in industries for cleaning.

4) It can be used in stores for picking up objects.

Future Developments

The following modifications can be made to the present circuit, which leads to still smarter project building task.

This project is open for developments from all sides. It is the users imagination which limits the working of this project. One can go on adding the extra, rich features to this project. BIBLIOGRAPHY

The 8051 Microcontroller & Embedded Systems - Mazidi

Design with PIC microcontroller Peatman

The Microcontroller Idea Book - Axelson

www.electronicsforu.com

www.howstuffworks.com

N/C

COM-2

N/C

COM-1

N/C

X1

E

Ground

RL1

R6-R10

D6-D10

Commands

from PC

+12 V

Gnd

+5V

D1 TO D5

R1 TO R5

10

7

14

11

6

12

13

16

15

5

D

C

COM-5

N/C

COM-4

N/C

9

8

3

4

1

2

IC2

IC1

RL5

RL4

RL3

RL2

15

14

12

6

10

2

4

11

1

8

7

9

3

5

O

0

0

Data

Clock

Data

Processor

S/R

E Clock

R6

D0

D1

Dn

E

LCD

Shift Register LCD Data Write

10K pot

Pin-3 Contrast

LCD

+Vcc

LCD Contrast Circuit

lcd data write waveform

450 nSec

E

R/_W

R/_S

DATA

+5V

+12V

IC1

7805

C4

9V

D11

IC1

7812

C3

C2

D21

port 3

port 2

C1

port 1

port 0

C3

C1 C2

D3

R1

+VCC

IC1

D1 & D2

X1