0% found this document useful (0 votes)
157 views

"Gantry Crane Using 8051 Microcontroller": Bachelor of Technology IN Electrical and Electronics Engineering

This document discusses a major project report on designing a gantry crane using an 8051 microcontroller. It describes the objectives of the project which are to build a gantry crane controlled by a microcontroller that can move loads quickly and precisely without excessive swinging. It also provides background on gantry cranes and mentions some of the challenges in controlling them manually.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

"Gantry Crane Using 8051 Microcontroller": Bachelor of Technology IN Electrical and Electronics Engineering

This document discusses a major project report on designing a gantry crane using an 8051 microcontroller. It describes the objectives of the project which are to build a gantry crane controlled by a microcontroller that can move loads quickly and precisely without excessive swinging. It also provides background on gantry cranes and mentions some of the challenges in controlling them manually.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 77

GANTRY CRANE USING 8051 MICROCONTROLLER

Major Project report submitted in partial fulfillment of the requirements For the award of the degree of

BACHELOR OF TECHNOLOGY IN ELECTRICAL AND ELECTRONICS ENGINEERING


By SRINIVAS.K RAJU.E SHIVA KUMAR.K RAJASHEKAR.G.V (09245A0207) (09245A0211) (08241A0244) (08241A0233)

Under the guidance of

V.V.S.MADHURI Assistant Professor


Department of Electrical and Electronics Engineering GOKARAJU RANGARAJU INSTITUTE OF ENGINEERING & TECHNOLOGY, BACHUPALLY, HYDERABAD 2008 2012

DEPART CERTIFICATE

NT OF

This is to certify that the major project report entitled GANTRY CRANE USING 8051 MICROCONTROLLER that is being submitted by Srinivas.K, Raju.E, Shivakumar.K, Rajashekhar.G.V in partial fulfillment for the award of the Degree of Bachelor of Technology in Electrical and Electronics Engineering to the Jawaharlal Nehru Technological University is a record of bonafide work carried out by them under my guidance and supervision. The results embodied in this project report have not been submitted to any other University or Institute for the award of any Graduation degree.

Mr.P.M.Sarma HOD, EEE GRIET Hyderabad

Mrs.Madhuri Assistant Professor Dept. of EEE GRIET

External Examiner

ii

ACKNOWLEDGEMENT

There are many people who have helped us directly or indirectly in the successful completion of our project. We would like to take this opportunity to thank one and all. First of all, we would like to express our deep sense of gratitude towards our project guide to V.V.S.Madhuri, Assistant Professor, Department of Electrical and Electronics Engineering, G.R.I.E.T for always being available whenever we required his guidance as well as for motivating us throughout the project work. We also express my sincere thanks to Mr.P.M.Sarma, Head of the Department, G.R.I.E.T and for extending their help. We are also grateful to to Mr. P. S. Raju, Director, G.R.I.E.T guidance in the successful completion of our project. for his valuable

We also thank for Dr. J. N. Murthy, (Principal, GRIET), providing useful infrastructure. We are also grateful to Dr. S. N. Saxena, (Professor (EEE) & Dean Placements) for his valuable guidance throughout the seminars in the college. We would like to thank all our friends for the help and constructive criticism during our project period. Finally, we are very much indebted to our parents for their moral support and encouragement to achieve higher goals. We have no words to express our gratitude and we are very thankful to our parents who have shown us this world and for every support they gave us.

SRINIVAS.K RAJU.E SHIVAKUMAR.K

(09245A0207) (09245A0211) (08241A0244)

RAJASHEKHAR.G.V (09245A0233)

iii

ABSTRACT

The use of gantry crane systems for transporting payload is very common in building constructions. However, moving the payload using the crane is not an easy task especially when strict specifications on the swing angle and on the transfer time need to be satisfied. Various attempts in controlling gantry cranes system based on open- loop and closed-loop control systems were proposed. However, most of the proposed controllers were designed based on the model and parameter of the crane system. In general, modeling and parameter identifications are troublesome and time consuming task. To overcome this problem, in this paper, a practical and intelligent control method for automatic gantry crane is introduced and evaluated experimentally. The results show that the proposed method is not only effective for controlling the crane but also robust to parameter variation. Our project is the design of a controller for the point-to-point motion of a gantry cranes system using a MICROCONTROLLER. The gantry crane has been modeled and a controller has been developed to meet several performance specifications. The designs were implemented in proteus for software implementation.

iv

LIST OF THE FIGURES NAME OF THE FIG PAGE NO

Fig 1.1 Model Of Gantry Crane Fig 1.2 Schematic Of Laboratory Gantry Crane Fig2.1 Dc Motor Fig 2.2 Working Of Dc Motor Fig2.3 H-Bridge Topology Fig2.4 H-Bridge Topology - Forward Direction Fig2.5 H-Bridge Topology - Reverse Direction Fig3.1 Pin Diagram Of 8051 Fig4.1 Transformer Fig4.2 Full Wave Bridge Rectifier Fig4.3 The Positive Half-Cycle Of Fullwave Bridge Rectifier Fig4.4 The Negativehalf-Cycle Of Fullwave Bridge Rectifier Fig4.5 Resultant Output Waveform Of Bridge Rectifier Fig5.1 Pin Description Of Lcd Fig5.2 Disply Formar,Data Length Of Lcd Fig6.1 Kaypad Diagram Fig6.2 Switches In Keypad Fig8.1 Opening File Of Keil Fig8.2 New Uvision Project Of Keil Fig 8.3 Fig8.4 Fig8.5 Fig 8.6 Fig8.7 Fig8.8 Fig8.9 Fig 8.10 Fig 9.1 v

9 10 15 15 18 19 19 21 26 29 29 30 31 37 39 43 44 62 63 64 64 65 65 65 66 67 67 69

CONTENTS
TOPIC Chapter.1. INTRODUCTION 1.1 introduction about project 1.2 Introduction about gantry crane 1.2.1 Workstation Gantry Cranes 1.2.2 Rail Mounted or EOT Gantry Cranes 1.3 Characteristics of Gantry crane 1.3.1 Dynamics And Kinematics 1.3.2 Controls 1.3.3 Non-Minimum Phase Systems 1.3.4 Distributed Parameter Systems 1.3.5 Multi-Input-Multi-Output Systems (Mimo) 1.3.6 Robustness And Adaptive Control 1.3.7 Computer Interfacing Or Mechatronics Chapter.2. DC MOTOR AND H-BRIDGE 2.1 DC Motor 2.2 H-Bridge Principles 2.3 Operation 2.4 Direction Control - H-Bridge Topology PAGE NO

Chapter.3. MICROCONTROLLER 3.1 Introduction 3.2 Pin configuration of the AT89S52 3.3 Memory Organization 3.4 Interrupts Chapter.4. DETAILS OF THE COMPONENTS USED 4.1 Regulated power supply 4.2 Transformer 4.3 Rectifier 4.4 Bridge rectifier 4.5 Full Wave Bridge Rectifier: 4.6 Filters 4.7 Regulator 4.8 Applications of regulated power supply 4.9 1N4148 DIODE 4.9.1 Characteristics
4.9.2 VAROIUS APPLICATIONS

Chapter.5. LCD 5.1 Liquid Crystal Display 5.1.1 Pin Description 5.1.2 Commands And Instruction Set 5.2 Sending Commands To Lcd 5.3 Sending Data To Lcd

Chapter.6. KEYPAD

6.1Introduction
6.2 Constructing a Matrix Keypad 6.3Scanning a Matrix Keypad Chapter.7. SOFTWARE CODING

Chapter. 8. SOFTWARE TOOLS USED 8.1 KEIL -VISION 8.1.1 Steps For Creating And Debugging Files In Keil

Chapter.9. CIRCUIT SCHEMATIC 9.1 CIRCUIT OPERATION 9.2 Hardware circuit : Chapter.10. CONCLUSION Chapter.11. SCOPE Chapter.12.REFERENCES

CHAPTER 1
1.1 INTRODUCTION:

1.1.1 Introduction about project:


We have chosen the gantry crane because its dynamics are such that many concepts can easily be visualized in real-time. The main objective is to build a Gantry crane controlled by a micro-controller. Gantry cranes are widely used for transporting heavy loads and hazardous materials in building constructions. The crane should move the load as fast as possible without having any excessive payload motion at the final position. The swing motion can be reduced however it is often time consuming processes which eventually affect the productivity (operational efficiency) in building constructions. Moreover, the gantry crane needs a skilful operator to manually control it using his/her experience to immediately stop the swing at the right position. Furthermore to unload, the operator has to wait until the load stops swinging. The failure in controlling crane might also cause accident and harm people. Various attempts in controlling gantry cranes system based on open loop and closed-loop control system have been proposed. Gantry cranes, bridge cranes, and overhead cranes, are all types of cranes which lift objects by a hoist which is fitted in a hoist trolley and can move horizontally on a rail or pair of rails fitted under a beam. An overhead travelling crane, also known as an overhead crane or as a suspended crane, has the ends of the supporting beam resting on wheels running on rails at high level, usually on the parallel side walls of a factory or similar large industrial building, so that the whole crane can move the length of the building, while the hoist can be moved to and from across the width of the building. A gantry crane or portal crane has a similar mechanism supported by uprights, usually with wheels at the foot of the uprights allowing the whole crane to traverse. Some portal cranes may have only a fixed gantry, particularly when they are lifting loads such as railway cargoes that are already easily moved beneath them.

1.2

Introduction about gantry crane:


Gantry cranes using built-up style hoists are frequently used in modern systems. These built up hoists are used for heavy-duty applications such as steel coil handling and for users desiring long life and better durability. Also used are package hoists, built as one unit in a single housing, generally designed for ten-year life, but the life calculation is based on an industry standard when calculating actual life. See the Hoists Manufacturers Institute site for true life calculation which is based on load and hours used. In today's modern world for the North American market there are a few governing bodies for the industry. The Overhead Alliance is a group that represents Crane Manufacturers Association of America (CMAA), Hoist Manufacturers Institute (HMI), and Monorail Manufacturers Association (MMA). These product counsels of the Material Handling Industry of America have joined forces to create promotional materials to raise the awareness of the benefits to overhead lifting that also include gantry cranes. The members of this group are marketing representatives of the member companies. Two famous gantry cranes built in 1974 and 1969 respectively are Samson and Goliath, which reside in the largest dry dock in the world in Belfast, Northern Ireland. Each crane has a span of 140 meters and can lift loads of up to 840 tones to a height of 70
meters, making a combined lifting capacity of over 1,600 tones, one of the largest in the

world.

Fig 1.1 model of a gantry crane Overhead crane and gantry crane are particularly suited to lifting very heavy objects and huge gantry cranes have been used for shipbuilding where the crane straddles the ship allowing massive objects like ships' engines to be lifted and moved over the ship. However; gantry cranes are also available running on rubber tyres so that tracks are not needed, and small gantry cranes can be used in workshops, for example for lifting automobile engines out of vehicles.

1.2.1 Workstation Gantry Cranes:

Workstation gantry cranes are used to lift and transport smaller items around a working area in a factory or machine shop. Some workstation gantry cranes are equipped with an enclosed track, while others use an I-beam, or other extruded shapes, for the running surface. Most workstation gantry cranes are intended to be stationary when loaded, and mobile when unloaded. Workstation Gantry Cranes can be outfitted with either a Wire Rope hoist as shown in the above hoist (device) picture or a lower capacity Chain Hoist.

1.2.2 Rail Mounted or EOT Gantry Cranes:

Steam Crane using a line shaft for power produced by Stuckenholz AG, Wetter am der Ruhr, Germany. Design developed by Rudolf Bredt. Picture from ~1875. Electrical Overhead Travelling (EOT) cranes or Gantry Cranes are commonly found in factory applications such as steel yards, paper mills or locomotive repair shops. The EOT gantry crane functions similarly to an overhead bridge crane, but has rails installed on the ground and gantry-style legs to support the crane. Capacities range from 2 to 200 tons, and sometimes even greater capacities. Most are electrically powered and painted safety yellow. When bridge cranes and Gantry cranes became more popular in factories in the late 1800s a steam engine was sometimes used as a way to power these devices. The lifting and moving would be transferred from a fixed line shaft. the picture on the right shows an example of system powered by a line shaft and steam engine. The overhead crane is from 1875, and was one of the first systems to be powered in such a way.

1.3

CHARACTERISTICS OF THE GANTRY-CRANE


While the previous section showed an example of how the gantry-crane rig could be used in a project-based learning course for automatic controls, there were many controls concepts which were not touched on, but which could easily be included in the projects. Furthermore, there are many attributes of the gantry-crane rig that can be exploited in other courses. The following is a sample list of courses, along with the specific characteristics of the gantry-crane that can be used in each course.

1.3.1 DYNAMICS AND KINEMATICS:


Given the motor and drive mechanism, and the suspended load, the gantry crane has a rich set of dynamics. These can be extended by allowing the crane to move in two directions, or by using a double pendulum suspended load.

1.3.2 CONTROLS:
The following issues can be explored in more advanced control courses,

1.3.3 NON-MINIMUM PHASE SYSTEMS:


Depending on how the rig is set up, and on the choice of coordinates, the system can have non-minimum phase characteristics.

1.3.4 DISTRIBUTED PARAMETER SYSTEMS:


Instead of a pendulum, a flexible beam can be used as the suspended load to explore issues of controlling a distributed parameter system.

1.3.5 MULTI-INPUT-MULTI-OUTPUT SYSTEMS (MIMO):


By adding another actuator (for example, add an actuator to the suspended load or beam, provide another direction of travel for the crane, or allow the load to be raised in realtime) the rig can be transformed into a MIMO system.

1.3.6 ROBUSTNESS AND ADAPTIVE CONTROL:


The system can easily have varying parameters by lifting different loads, and by raising the load in real-time.

1.3.7 COMPUTER INTERFACING OR MECHATRONICS:


As mentioned earlier, the present laboratory rig is set up such that the controllers can be implemented either with a microprocessor or with a digital computer. This capability can be exploited in a microprocessor or mechatronics course, or in a computer- programming course. For example, this rig has been used as a final project in a freshman computerprogramming course in the C language (ENGR 0112). We were required to write a program that would interface the computer with the gantry crane, allowing the user to

either manually or automatically position the crane. Manual positioning was done using a hand-held potentiometer that adjusted the motor voltage supplied by the computer, while automatic control was done with simple position feedback from the crane. All data acquisition and control was handled by the program (through functions written by the students), and include dreading crane position measurements and manual voltage nputs, and writing motor control voltage to the power amplifiers. We were also required to graphically plot the crane's trajectory on the computer screen in real-time, and then compute a performance index to quantify which controller worked the best. Since this project was done in teams, it became somewhat of a competition to see which team created the best graphical interface, and also within teams, the program allowed them to see who could do the best manual control of the crane.

CHAPTER 2 DC MOTOR AND H-BRIDGE 2.1 DC MOTOR:


A DC motor is an electric motor that runs on direct current (DC) electricity. DC motors were used to run machinery, often eliminating the need for a local steam engine or internal combustion engine. DC motors can operate directly from rechargeable batteries, providing the motive power for the first electric vehicles. Today DC motors are still found in applications as small as toys and disk drives, or in large sizes to operate steel rolling mills and paper machines. Modern DC motors are nearly always operated in conjunction with power electronic devices. The brushed DC electric motor generates torque directly from DC power supplied to the motor by using internal commutation, stationary magnets (permanent or electromagnets), and rotating electrical magnets.Like all electric motors or generators, torque is produced by the principle of Lorentz force, which states that any currentcarrying conductor placed within an external magnetic field experiences a torque or force known as Lorentz force. Advantages of a brushed DC motor include low initial cost, high reliability, and simple control of motor speed. Disadvantages are high maintenance and low life-span for high intensity uses. Maintenance involves regularly replacing the brushes and springs which carry the electric current, as well as cleaning or replacing the commutator. These components are necessary for transferring electrical power from outside the motor to the spinning wire windings of the rotor inside the motor. Brushless DC motors use a rotating permanent magnet or soft magnetic core in the rotor, and stationary electrical magnets on the motor housing. A motor controller converts DC to AC. This design is simpler than that of brushed motors because it eliminates the complication of transferring power from outside the motor to the spinning rotor. Advantages of brushless motors include long life span, little or no maintenance, and high efficiency. Disadvantages include high initial cost, and more complicated motor speed controllers. Some such brushless motors are sometimes referred to as "synchronous

motors" although they have no external power supply to be synchronized with, as would be the case with normal AC synchronous motors.

Fig :2.1 DC Motor

WORKING
A DC motor works by converting electric power into mechanical work. This is accomplished by forcing current through a coil and producing a magnetic field that spins the motor. The simplest DC motor is a single coil apparatus, used here to discuss the DC motor theory. The process can be explained in further detail by observing the diagram below.

Fig : 2.2 Working of DC motor

The voltage source forces voltage through the coil via sliding contacts or brushes that are connected to the DC source. These brushes are found on the end of the coil wires and make a temporary electrical connection with the voltage source. In this motor, the brushes will make a connection every 180 degrees and current will then flow through the coil wires. In the 0 degrees diagram, the brushes are in contact with the voltage source and current is flowing. The current that flows through wire segment C-D interacts with the magnetic field that is present and the result is an upward force on the segment. The current that flows through segment A-B has the same interaction, but the force is in the downward direction. Both forces are of equal magnitude, but in opposing directions since the direction of current flow in the segments is reversed with respect to the magnetic field. In the 180 degrees diagram, the same phenomenon occurs, but segment A-B is forced up and C-D is forced down. In the 90 and 270-degree diagrams, the brushes are not in contact with the voltage source and no force is produced. In these two positions, the rotational kinetic energy of the motor keeps it spinning until the brushes regain contact.

2.2

H-Bridge Principles
An H-Bridge is an electronic power circuit that allows motor speed and direction to be controlled. Often motors are controlled from some kind of brain or micro controller to accomplish a mechanical goal. The micro controller provides the instructions to the motors, but it cannot provide the power required to drive the motors. An H-bridge circuit inputs the micro controller instructions and amplifies them to drive a mechanical motor. This process is similar to how the human body generates mechanical movement; the brain can provide electrical impulses that are instructions, but it requires the muscles to perform mechanical force. The muscle represents both the H-bridge and the motor combined. The H-bridge takes in the small electrical signal and translates it into high power output for the mechanical motor. This document will cover the electronic

principles in creating the H-Bridge portion of the muscle. If the reader requires further information consult the references included at the end ofthe document.

2.3

Operation:
The H-bridge arrangement is generally used to reverse the polarity of the motor, but can also be used to 'brake' the motor, where the motor comes to a sudden stop, as the motor's terminals are shorted, or to let the motor 'free run' to a stop, as the motor is effectively disconnected from the circuit. The following table summarizes operation, with S1-S4 corresponding to the diagram above. S1 S2 S3 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 S4 1 0 0 1 0 Result Motor moves right Motor moves left Motor free runs Motor brakes Motor brakes

2.4

Direction Control - H-Bridge Topology


Most DC Motors can rotate in two directions depending on how the battery is connected to the motor. Both the DC motor and the battery are two terminal devices that have positive and negative terminals. In order run the motor in the forward direction, connect the positive motor wire to the positive battery wire and negative to negative. However, to run the motor in reverse just switch the connections; connect the positive battery wire to the negative motor wire, and the negative battery wire to the positive motor wire. An H-Bridge circuit allows a large DC motor to be run in both directions with a low level logic input signal. The H-Bridge electronic structure is explicit in the name of the circuit - H Bridge. The power electronics actually form a letter H

configuration, as shown in Figure 2.1. The switches are symbolic of the electronic Power MOSFETs which are used for switching.

Figure 2.3: H-Bridge Topology If it is desired to turn the motor on in the forward direction, switches 1 and 4 must be closed to power the motor. Figure 2.2 below is the H-Bridge driving the motor in the forward direction. If it is desired to turn the motor on in the reverse direction, switches 2 and 3 must be closed to power the motor. Figure 2.3 below is the H-Bridge driving the motor in the reverse direction.

Figure 2.4: H-Bridge Topology - Forward Direction

Figure 2.5: H-Bridge Topology - Reverse Direction

CHAPTER 3 MICROCONTROLLER 3.1 INTRODUCTION:


The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of In-System Programmable Flash memory. The device is manufactured using Atmels high-density non-volatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin-out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a five-vector two-level interrupt architecture, a full duplex serial port, onchip oscillator, and clock circuitry. 8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52 In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next external interrupt or hardware reset.

3.2

Pin configuration of the AT89S52 is as follows:


40-Lead PDIP 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 bytes during program verification. External pull-ups are required during program verification.

Fig 3.1 pin diagram of 8051 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.

Port 1 also receives the low-order address bytes during Flash programming and verification. P1.5 P1.6 P1.7 MOSI (used for In-System Programming) MISO (used for In-System Programming) SCK (used for In-System Programming)

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 use 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 use 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 receives some control signals for Flash programming and verification. Port 3 also serves the functions of various special features of the AT89S51, as shown in the following table. Alternate functions of port 3, P3.0 P3.1 P3.2 RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0)

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

INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) 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. This pin drives High for 98 oscillator periods after the Watchdog times out. The DIS-RTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN: Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S51 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. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2: Output from the inverting oscillator amplifier.

3.3

Memory Organization:
Program Memory: If the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S51, if EA is connected to VCC, program fetches to addresses 0000H through FFFH are directed to internal memory and fetches to addresses 1000H through FFFFH are directed to external memory. Data Memory: The AT89S52 implements 128 bytes of on-chip RAM. The 128 bytes are accessible via direct and indirect addressing modes. Stack operations are examples of indirect addressing, so the 128 bytes of data RAM are available as stack space.

3.4

Interrupts:
Interrupts: The AT89S52 has a total of five interrupt vectors: two external interrupts (INT0 and INT1), two timer interrupts (Timers 0 and 1), 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. The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the next cycle.

CHAPTER 4 DETAILS OF THE COMPONENTS USED 4.1 Regulated power supply:


A power supply is a device that supplies electrical energy to one or more electric loads. The term is most commonly applied to devices that convert one form of electrical energy to another, though it may also refer to devices that convert another form of energy (e.g., mechanical, chemical, solar) to electrical energy. A regulated power supply is one that controls the output voltage or current to a specific value; the controlled value is held nearly constant despite variations in either load current or the voltage supplied by the power supply's energy source. Every power supply must obtain the energy it supplies to its load, as well as any energy it consumes while performing that task, from an energy source. Depending on its design, a power supply may obtain energy from:

Electrical energy transmission systems. Common examples of this include power supplies that convert AC line voltage to DC voltage.

Energy storage devices such as batteries and fuel cells. Electromechanical systems such as generators and alternators. Solar power. A power supply may be implemented as a discrete, stand-alone device or as an integral device that is hardwired to its load. Examples of the latter case include the low voltage DC power supplies that are part of desktop computers and consumer electronics devices. Commonly specified power supply attributes include:

The amount of voltage and current it can supply to its load. How stable its output voltage or current is under varying line and load conditions.

How long it can supply energy without refueling or recharging (applies to power supplies that employ portable energy sources).

Regulated power supply mainly consist of : 1) Transformer 2) Bridge rectifier 3) Filter 4) Regulator

4.2

Transformer:
A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductorsthe transformer's coils. A

varying current in the first or primary winding creates a varying magnetic flux in the transformer's core and thus a varying magnetic field through the secondary winding. This varying magnetic field induces a varying electromotive force (EMF), or "voltage", in the secondary winding. This effect is called inductive coupling.

Fig.4.1 Transformer

If a load is connected to the secondary, current will flow in the secondary winding, and electrical energy will be transferred from the primary circuit through the transformer to the load. In an ideal transformer, the induced voltage in the secondary winding (Vs) is in proportion to the primary voltage (Vp) and is given by the ratio of the number of turns in the secondary (Ns) to the number of turns in the primary (Np) as follows:

By appropriate selection of the ratio of turns, a transformer thus enables an alternating current (AC) voltage to be "stepped up" by making Ns greater than Np, or "stepped down" by making Ns less than Np. In the vast majority of transformers, the windings are coils wound around a ferromagnetic core, air-core transformers being a notable exception. Transformers range in size from a thumbnail-sized coupling transformer hidden inside a stage microphone to huge units weighing hundreds of tons used to interconnect portions of power grids. All operate on the same basic principles, although the range of designs is wide. While new technologies have eliminated the need for transformers in some electronic circuits, transformers are still found in nearly all electronic devices designed for household ("mains") voltage. Transformers are essential for high-voltage electric power transmission, which makes long-distance transmission economically practical.

4.3

Rectifier:
A rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), which flows in only one direction. The process is known as rectification. Physically, rectifiers take a number of forms, including vacuum tube diodes, mercury-arc valves, solid-state diodes, silicon-controlled rectifiers and other silicon-based semiconductor switches. Historically, even synchronous electromechanical switches and motors have been used. Early radio receivers,

called crystal radios, used a "cat's whisker" of fine wire pressing on a crystal of galena (lead sulfide) to serve as a point-contact rectifier or "crystal detector". Rectifiers have many uses, but are often found serving as components of DC power supplies and high-voltage direct current power transmission systems.

Rectification may serve in roles other than to generate direct current for use as a source of power. As noted, detectors of radio signals serve as rectifiers. In gas heating systems flame rectification is used to detect presence of flame. The simple process of rectification produces a type of DC characterized by pulsating voltages and currents (although still unidirectional). Depending upon the type of end-use, this type of DC current may then be further modified into the type of relatively constant voltage DC characteristically produced by such sources

as batteries and solar cells. A device which performs the opposite function (converting DC to AC) is known as an inverter.

4.4

Bridge rectifier:
A diode bridge is an arrangement of four (or more) diodes in a bridge circuit configuration that provides the same polarity of output for either polarity of input. When used in its most common application, for conversion of an alternating current (AC) input into direct current a (DC) output, it is known as a bridge rectifier. A bridge rectifier provides full-wave rectification from a two-wire AC input, resulting in lower cost and weight as compared to a rectifier with a 3-wire input from a transformer with a centertapped secondary winding.

4.5

Full Wave Bridge Rectifier:


Another type of circuit that produces the same output waveform as the full wave rectifier circuit above is that of the Full Wave Bridge Rectifier. This type of single phase rectifier uses four individual rectifying diodes connected in a closed loop "bridge" configuration to produce the desired output. The main advantage of this bridge circuit is that it does not require a special centre tapped transformer, thereby reducing its size and cost.

Fig 4.2 Full Wave Bridge Rectifier The four diodes labelled D1 to D4 are arranged in "series pairs" with only two diodes conducting current during each half cycle. During the positive half cycle of the supply, diodes D1 and D2 conduct in series while diodes D3 and D4 are reverse biased and the current flows through the load as shown below. The Positive Half-cycle:

Fig 4.3 The Positive Half-cycle of fullwave bridge rectifier

During the negative half cycle of the supply, diodes D3 and D4 conduct in series, but diodes D1 and D2switch "OFF" as they are now reverse biased. The current flowing through the load is the same direction as before. The Negative Half-cycle:

Fig 4.4 The Negative Half-cycle of fullwave bridge rectifier As the current flowing through the load is unidirectional, so the voltage developed across the load is also unidirectional the same as for the previous two diode full-wave rectifier, therefore the average DC voltage across the load is 0.637Vmax. However in reality, during each half cycle the current flows through two diodes instead of just one so the amplitude of the output voltage is two voltage drops ( 2 x 0.7 = 1.4V ) less than the input VMAX amplitude. The ripple frequency is now twice the supply frequency (e.g. 100Hz for a 50Hz supply) Although we can use four individual power diodes to make a full wave bridge rectifier, pre-made bridge rectifier components are available "off-the-shelf" in a range of different voltage and current sizes that can be soldered directly into a PCB circuit board or be connected by spade connectors. The image to the right shows a typical single phase bridge rectifier with one corner cut off. This cut-off corner indicates that the terminal nearest to the corner is the positive or +ve output terminal or lead with the opposite

(diagonal) lead being the negative or -ve output lead. The other two connecting leads are for the input alternating voltage from a transformer secondary winding.

4.6

Filters:
Electronic filters are electronic circuits which perform signalprocessing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones, or both.

The Smoothing Capacitor:


We saw in the previous section that the single phase half-wave rectifier produces an output wave every half cycle and that it was not practical to use this type of circuit to produce a steady DC supply. The full-wave bridge rectifier however, gives us a greater mean DC value (0.637 Vmax) with less superimposed ripple while the output waveform is twice that of the frequency of the input supply frequency. We can therefore increase its average DC output level even higher by connecting a suitable smoothing capacitor across the output of the bridge circuit as shown below.

Full-wave Rectifier with Smoothing Capacitor:

Fig 4.5

The smoothing capacitor converts the full-wave rippled output of the rectifier into a smooth DC output voltage. Generally for DC power supply circuits the smoothing capacitor is an Aluminium Electrolytic type that has a capacitance value of 100uF or more with repeated DC voltage pulses from the rectifier charging up the capacitor to peak voltage. However, their are two important parameters to consider when choosing a suitable smoothing capacitor and these are its Working Voltage, which must be higher than the no-load output value of the rectifier and its Capacitance Value, which determines the amount of ripple that will appear superimposed on top of the DC voltage. Too low a value and the capacitor has little effect but if the smoothing capacitor is large enough (parallel capacitors can be used) and the load current is not too large, the output voltage will be almost as smooth as pure DC. As a general rule of thumb, we are looking to have a ripple voltage of less than 100mV peak to peak. The maximum ripple voltage present for a Full Wave Rectifier circuit is not only determined by the value of the smoothing capacitor but by the frequency and load current, and is calculated as:

Bridge Rectifier Ripple Voltage:

Where: I is the DC load current in amps, is the frequency of the ripple or twice the input frequency in Hertz, and C is the capacitance in Farads. The main advantages of a full-wave bridge rectifier is that it has a smaller AC ripple value for a given load and a smaller reservoir or smoothing capacitor than an equivalent half-wave rectifier. Therefore, the fundamental frequency of the ripple voltage is twice that of the AC supply frequency (100Hz) where for the half-wave rectifier it is exactly equal to the supply frequency (50Hz). The amount of ripple voltage that is superimposed on top of the DC supply voltage by the diodes can be virtually eliminated by adding a much improved -filter (pifilter) to the output terminals of the bridge rectifier. This type of low-pass filter consists of two smoothing capacitors, usually of the same value and a choke or inductance across them to introduce a high impedance path to the alternating ripple component. Another more practical and cheaper alternative is to use a 3-terminal voltage regulator IC, such as a LM78xx for a positive output voltage or the LM79xx for a negative output voltage which can reduce the ripple by more than 70dB (Datasheet) while delivering a constant output current of over 1 amp. In the next tutorial about diodes, we will look at the Zener Diode which takes advantage of its reverse breakdown voltage characteristic to produce a constant and fixed output voltage across itself.

4.7

Regulator:
A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. A voltage regulator may be a simple "feed-forward" design or may include negative feedback control loops. It may use an electromechanical mechanism, or

electronic components. Depending on the design, it may be used to regulate one or more AC or DC voltages. Electronic voltage regulators are found in devices such as computer power supplies where they stabilize the DC voltages used by the processor and other elements. In automobile alternators and central power station generator plants, voltage regulators control the output of the plant. In an electric power distribution system, voltage regulators may be installed at a substation or along distribution lines so that all customers receive steady voltage independent of how much power is drawn from the line.

4.8

Applications of regulated power supply:


D.C. variable bench supply (a bench power supply usually refers to a power supply capable of supplying a variety of output voltages useful for bench

testing electronic circuits, possibly with continuous variation of the output voltage, or just some preset voltages; a laboratory (lab) power supply normally implies an accurate bench power supply, while a balanced or tracking power supply refers to twin supplies for use when a circuit requires both positive and negative supply rails). Mobile Phone power adaptors Regulated power supplies in appliances

4.9

1N4148 DIODE:
The 1N4148 is a standard silicon switching diode. Its name follows

the JEDEC nomenclature. The 1N4148 has a DO-35 glass package and is very useful at high frequencies with a reverse recovery time of no more than 4ns. The 1N4148 is a general-purpose signal diode having a maximum reverse voltage of 100 and forward current of 300 milliamps. The designation 1N4148 is an industrystandard part number from the Joint Electron Device Engineering Council, or JEDEC; numerous semiconductor manufacturers make the device with the same characteristics. The diode functions as a high-speed switch and signal detector in audio and radio applications.

4.9.1 Characteristics:
High switching speed: max. 4 ns Continuous reverse voltage: max. 75 V Repetitive peak reverse voltage: max. 100 V Repetitive peak forward current: max. 450 mA. Average Rectified Forward Current: 200mA DC Forward Current: 300mA Power Dissipation: 500 mW

4.9.2 VAROIUS APPLICATIONS: 1) Reverse Voltage:


A diode conducts electricity if the voltage across it is positive on the anode end and negative on the cathode. If you reverse this polarity, the diode blocks current flow. However, a large enough voltage will overwhelm the diode's ability to block current. This voltage, called peak inverse voltage (PIV) or peak reverse voltage (PRV), is an important diode rating. As the PIV of the 1N4148 is a relatively low 100 volts, it restricts the diode to low-level signal processing applications, such as sound processing or digital circuits.

2)

Forward Current:
A diode conducts current in the "forward" direction, blocking it in the "reverse"

direction. Its ability to conduct current is limited by its size and construction. A circuit that puts too much current through a diode will burn it up. The 1N4148 has a maximum continuous current of 200 milliamps and a pulsed maximum current of 450 milliamps.

3)

Voltage source:
The 1N4148 has a glass body with two leads for connecting it to circuits. This

format is handy for solder less breadboard, per board and printed circuit boards. Generally, this is a good diode for hobbyists and engineers looking to make small numbers of circuits. In 2011, mass-produced circuits use surface-mount components. They are physically smaller, lack leads and are optimized for machine handling.

4)

Switching Speed:
The 1N4148's high switching speed of 4 nanoseconds makes it useful for audio,

radio and some computer circuits. This is the time the diode takes to permit current flow after a signal changes its polarity from reverse to forward. A 4-nanosecond switching speed corresponds with a frequency of about 125 megahertz, but individual diodes may have much faster speeds. The 4-nanosecond figure is the maximum switching time, so some circumstances allow for higher speeds.

5)

AM Radio Detector:
In AM radio, an audio signal modulates the amplitude, or strength, of a high-

frequency carrier wave. A single-diode detector circuit, such as one using the 1N4148, recovers the audio from the carrier signal. A radio receiver has a tuner to select one carrier frequency from the AM band, and a diode detector and filter to remove the highfrequency signal, leaving the audio. The diodes switching action turns the carrier signals AC into DC. The amplitude of the DC is simply the audio in the broadcast.

6)

Rectifier:
All diodes function as rectifiers, converting alternating current, which reverses

direction, into direct current, which flows in one direction. DC power supplies typically use diodes with higher voltage- and current-handling capabilities than the 1N4148 as rectifiers. The 1N4001, for example, has a maximum current of one amp. For applications that do not exceed its 300-milliamp limit, the 1N4148 can act as a rectifier.

CHAPTER 5 LCD
5.1 LIQUID CRYSTAL DISPLAY
Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other which are compatible with HD44580. The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters, whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers.

5.1.1 PIN DESCRIPTION

Fig: 5.1 Pin description of LCD Pin No. 1 2 3 Name VSS VCC VEE Power supply (GND) Power supply (+5V) Contrast adjust 0 1 = Data input 0 = Write to LCD module = Instruction input Description

RS

R/W

1 = Read from LCD module Enable signal Data bus line 0 (LSB) Data bus line 1 Data bus line 2 Data bus line 3 Data bus line 4

6 7 8 9 10 11

EN D0 D1 D2 D3 D4

12 13 14 15 16

D5 D6 D7 LED+ LED-

Data bus line 5 Data bus line 6 Data bus line 7 (MSB) Back Light VCC Back Light GND

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. So whatever you send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only 16 characters are visible, so whatever you write after 16 chars is written in DDRAM but is not visible to the user. Now you might be thinking that when you send an ASCII value to DDRAM, how the character is displayed on LCD? So the answer is CGROM. The character generator ROM generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes. It can generate 208 5 x 8 dot character patterns and 32 5 x 10 dot character patterns. As clear from the name, CGRAM area is used to create custom characters in LCD. In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight character patterns can be written, and for 5 x 10 dots, four character patterns can be written. Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of delay for the LCD processing. To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF

= 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process. There are two 8-bit registers in HD44780 controller Instruction and Data register. Instruction register corresponds to the register where you send commands to LCD e.g. LCD shift command, LCD clear, LCD address etc. and Data register is used for storing data which is to be displayed on LCD. When send the enable signal of the LCD is asserted, the data on the pins is latched in to the data register and data is then moved automatically to the DDRAM and hence is displayed on the LCD. Data Register is not only used for sending data to DDRAM but also for CGRAM, the address where you want to send the data, is decided by the instruction you send to LCD.

5.1.2 COMMANDS AND INSTRUCTION SET


Only the instruction register (IR) and the data register (DR) of the LCD can be controlled by the MCU. Before starting the internal operation of the LCD, control information is temporarily stored into these registers to allow interfacing with various MCUs, which operate at different speeds, or various peripheral control devices. The internal operation of the LCD is determined by signals sent from the MCU. These signals, which include register selection signal (RS), read/write signal (R/W), and the data bus (DB0 to DB7), make up the LCD instructions (Table 3). There are four categories of instructions that: Set internal RAM addresses Perform data transfer with internal RAM Performs miscellaneous functions

Designate LCD functions, such as display format, data length, etc.

fig 5.2disply formar,data length of LCD Although looking at the table you can make your own commands and test them. Below is a brief list of useful commands which are used frequently while working on the LCD.

No. 1 2 3 4 5

Instruction Function Set: 8-bit, 1 Line, 5x7 Dots Function Set: 8-bit, 2 Line, 5x7 Dots Function Set: 4-bit, 1 Line, 5x7 Dots Function Set: 4-bit, 2 Line, 5x7 Dots Entry Mode Display off Cursor off

Hex 0x30 0x38 0x20 0x28 0x06

Decimal 48 56 32 40 6

(clearing display without clearing DDRAM 0x08 content)

7 8 9 10 12 13 14 15

Display on Cursor on Display on Cursor off Display on Cursor blinking Shift entire display left Shift entire display right Move cursor left by one character Move cursor right by one character Clear Display (also clear DDRAM content) Set DDRAM address or cursor position on display Set CGRAM address or set pointer to CGRAM location

0x0E 0x0C 0x0F 0x18 0x1C 0x10 0x14 0x01

14 12 15 24 30 16 20 1

16

0x80+add

128+add

17

0x40+add

64+add

5.2

SENDING COMMANDS TO LCD


To send commands we simply need to select the command register. Everything is same as we have done in the initialization routine. But we will summarize the common steps and put them in a single subroutine. Following are the steps: move data to LCD port select command register select write operation send enable signal wait for LCD to process the command

5.3

SENDING DATA TO LCD


To send data we simply need to select the data register. Everything is same as the command routine. Following are the steps: move data to LCD port select data register select write operation send enable signal wait for LCD to process the data

CHAPTER 6

KEYPAD
6.1 Introduction
Keypads are a part of HMI or Human Machine Interface and play really important role in a small embedded system where human interaction or human input is needed. Martix keypads are well known for their simple architecture and ease of interfacing with any microcontroller. In this part of tutorial we will learn how to interface a 4x4 matrix keypad with AVR and 8051 microcontroller. Also we will see how to program then in Assembly and C.

6.2

Constructing a Matrix Keypad

Constuction of a keypad is really simple. As per the outline shown in the figure below we have four rows and four columns. In between each overlapping row and column line there is a key.

fig 6.1 keypad So keeping this outline we can constuct a keypad using simple SPST Switches as shown below:

Fig 6.2 switches in keypad

Now our keypad is ready, all we have to do is connect the rows and columns to a port of microcontroller and program the controller to read the input.

6.3

Scanning a Matrix Keypad

There are many methods depending on how you connect your keypad with your controller, but the basic logic is same. We make the coloums as i/p and we drive the rows making them o/p, this whole procedure of reading the keyboard is called scanning.

In order to detect which key is pressed from the matrix, we make row lines low one by one and read the coloums. Lets say we first make Row1 low, then read the columns. If any of the key in row1 is pressed will make the corrosponding column as low i.e if second key is pressed in Row1, then column2 will give low. So we come to know that key 2 of Row1 is pressed. This is how scanning is done. So to scan the keypad completely, we need to make rows low one by one and read the columns. If any of the button is pressed in a row, it will take the corrosponding column to

a low state which tells us that a key is pressed in that row. If button 1 of a row is pressed then Column 1 will become low, if button 2 then column2 and so on.

CHAPTER 7 SOFTWARE CODING


#include<reg51.h> sbit rs=P3^0; sbit rw=P3^1; sbit e=P3^2; sbit fr=P2^4; sbit sw1=P3^4; sbit sw2=P3^5; sbit sw3=P3^6; sbit sw4=P3^7; unsigned char g,keys[4][4]={'1','2','3',' ', '4','5','6',' ', '7','8','9',' ', ' ','0',' ',' '}; unsigned char a,b; unsigned int h,o; void lcdcmd(unsigned char); void lcddata(unsigned char); void delay(int); void delay1(char); void lcd(item);

void lcd1(item1); void keypad(); void main() { unsigned char r,s,t,c; unsigned char item,item1; h=0; sw1=0; sw2=0; sw3=0; sw4=0; main: lcdcmd(0x01); lcd1(item1); lcdcmd(0x06); keypad(); lcdcmd(0x01); lcd(item); lcdcmd(0xc0); keypad(); r=P1; if(r==0x2A)

{ goto main; } r=r-0x30; keypad(); s=P1; if(s==0x2A) { goto main; } s=s-0x30; keypad(); t=P1; if(t==0x2A) { goto main; } t=t-0x30; c=(r*100+s*10+t); if(h==1&&o==1) { sw1=0;

sw2=1; delay1(c); sw1=0; sw2=0; h--; o--; goto main; } if(h==2&&o==1){ sw1=1; sw2=0; delay1(c); sw1=0; sw2=0; h--; h--; o--; goto main; } if(h==1&&o==2) { sw3=1;

sw4=0; delay1(c); o--; o--; h--; sw3=0; sw4=0; goto main; }

if(h==2&&o==2) { sw3=0; sw4=1; delay1(c); sw3=0; sw4=0; h--; h--; o--; o--; goto main;

} } void keypad() { int var=1; lcdcmd(0x38); lcdcmd(0x0e); lcdcmd(0x06);

P2=0x0F; y:var=1;P0=0x00; delay(20); if(P2==0x0F) goto y; delay(20); if(P2==0x0F) a=P2; P0=0x0e; if(P2!=0x0F) goto row1; P0=0x0d; if(P2!=0x0F)

goto row2; P0=0x0b; if(P2!=0x0F) goto row3; P0=0x07; if(P2!=0x0F) goto row4; else goto y;

row1:if(P2==0x0E&var==1) { lcddata(keys[0][0]); g=keys[0][0]; return; } else if(P2==0x0D) { lcddata(keys[0][1]); g=keys[0][1]; return;

} else if(P2==0x0B) { lcddata(keys[0][2]); g=keys[0][2]; return; } else if(P2==0x07) { lcddata(keys[0][3]); g=keys[0][3]; o++; h++; return; } goto y;

row2:if(P2==0x0E) { lcddata(keys[1][0]);

g=keys[1][0]; return; } else if(P2==0x0D) { lcddata(keys[1][1]); g=keys[1][1]; return; } else if(P2==0x0B) { lcddata(keys[1][2]); g=keys[1][2]; return; } else if(P2==0x07) { lcddata(keys[1][3]); g=keys[1][3];

o++; h++; h++; return; } goto y;

row3:if(P2==0x0E) { lcddata(keys[2][0]); g=keys[2][0]; return; } else if(P2==0x0D) { lcddata(keys[2][1]); g=keys[2][1]; return; } else if(P2==0x0B)

{ lcddata(keys[2][2]); g=keys[2][2]; return; } else if(P2==0x07) { lcddata(keys[2][3]); g=keys[2][3]; o++; o++; h++; return; } goto y; row4:if(P2==0x0E) { lcddata(keys[3][0]); g=keys[3][0]; return; }

else if(P2==0x0D) { lcddata(keys[3][1]); g=keys[3][1]; return; } else if(P2==0x0B) { lcddata(keys[3][2]); g=keys[3][2]; return; } else if(P2==0x07) { lcddata(keys[3][3]); o++; o++; h++; h++;

return;} goto y; }

void lcdcmd(unsigned char value) { rs=0; rw=0; e=1; delay(10); P1=value; e=0; return; }

void lcddata(unsigned char value) { rs=1; rw=0; e=1; delay(10);

P1=value; e=0; return; } void delay(int time) { int i,j; for(i=0;i<=time;i++)

for(j=0;j<=1250;j++); } void delay1(char time) { char i; int j,m; for(i=0;i<=time;i++) for(m=0;m<=10;m++) for(j=0;j<=1275;j++); } void lcd(unsigned char item) { int f,n,p,q;

if(h==1&&o==1) { unsigned char shree[]={'M','A','I','N',' ','F','O','R','W','A','R','D'}; for(f=0;f<12;f++) lcddata(shree[f]); return; } if(h==2&&o==1) { unsigned char shree1[]={'M','A','I','N',' ','R','E','V','E','R','S','E'}; for(n=0;n<12;n++) lcddata(shree1[n]); return; } if(h==1&&o==2) { unsigned char shree2[]={'S','U','B',' ','F','O','R','W','A','R','D'}; for(p=0;p<11;p++) lcddata(shree2[p]); return; } if(h==2&&o==2)

{ unsigned char shree3[]={'S','U','B',' ','R','E','V','E','R','S','E'}; for(q=0;q<11;q++) lcddata(shree3[q]); return; } } void lcd1(unsigned char item1) { int f; unsigned char shree[]={'W','E','L','C','O','M','E',' ','G','R','I','E','T'}; lcdcmd(0x06); lcdcmd(0x0e); for(f=0;f<13;f++) lcddata(shree[f]); return; }

CHAPTER 8 SOFTWARE TOOLS USED 8.1 KEIL -VISION


Vision is a window-based software development platform that combines a robust and modern editor with a project manager and make facility tool. It integrates all the tools needed to develop embedded applications including a C/C++ compiler, macro assembler, linker/locator, and a HEX file generator. Vision helps expedite the development process of embedded applications by providing the following: Full-featured source code editor. Device Database for configuring the development tool. Project Manager for creating and maintaining your projects. Integrated Make Utility functionality for assembling, compiling, and linking your embedded applications. Dialogs for all development environment settings. True integrated source-level and assembler-level Debugger with high-speed CPU and peripheral Simulator. Advanced GDI interface for software debugging on target hardware and for connecting to a Keil ULINK Debug Adapter. Flash programming utility for downloading the application program into Flash ROM. Links to manuals, on-line help, device datasheets, and user guides.

8.1.1 STEPS FOR CREATING AND DEBUGGING FILES IN KEIL


Step 1: Open keil mdk for ARM from start -> all programs -> keil uv-4.Then click on project in which options will be displayed on right for further selection.

Fig 8.1 file opening of keil Step2: Select New uvision project.

Fig 8.2

Step 3: Select destination folder if already created or else create a separate folder for it.

Fig 8.4 creating a folder Step4: Select your micro controller from the given list of families.

Fig 8.5

Step 5: Select NXP as we are using NXP founded by PHILLIPS.

Fig 8.6 Step6: Select LPC2148 from the list as we are using this controller.

Fig 8.7

Step 7: Select new file or ctrl+N to create new file.

Fig 8.8 Step 8: Write the code desired in to the file and save it as <filename>.c

Fig 8.9

Add the file to startup.s to debug it. Step 9: Click on debug or hit F7 key to build the program.

Fig 8.10

CHAPTER 9 CIRCUIT SCHEMATIC

Fig 9.1

9.1

CIRCUIT OPERATION
The 230 V power supply from AC Mains is given to step down transformer. The step down transformer step downs the 230 V AC to 12 V AC. This 12 V AC is given to the bridge rectifier to convert AC signal into pulsating DC signal.This pulsated DC signal is converted to pure DC signal by a capacitor. The IC 7812 voltage regulator is used to convert signal to 12 V and it is given to the microcontroller. Now coming to the main circuit operation the LDR dectects day/night by the amount of light falling on it and sends the signal to the microcontroller port 0.0. The PIR sensor detects the motion of human intruder and sends the signal to the microcontroller port 0.1. When it is day and a human intruder motion is being detected then the microcontroller communicates with LCD and MOTOR. When it is night and a human intruder motion is being detected then the microcontroller communicates with LCD and GSM MODEM. The LCD data pins are connected to the microcontroller port 0.10, port 0.11, port 0.12, and port 0.13. The LCD displays DOOR OPEN during day time when a human intruder motion is detected, DOOR CLOSE when there is no motion of the human intruder. It displays THEFT DETECTED during night time when a human intruder motion is detected. The MOTOR is connected to the microcontroller port 0.4 and port 0.5 with the help of L293D driver.During day time when a human intruder motion is detected the motion runs in forward direction to open the door and after some delay the motor runs in opposite direction to close the door.

9.2

Hardware circuit :
1N4007

T1 1 5 1 6 4 9-0-9 8 470uf \35v

U1 LM7805/TO 5v VIN VOUT 2 10uf \63v


HI

0
1N4007

0
micro control inputs
HI HI HI HI

mtr 1 mtr 2 mtr 1

2 7 10 15 5v
HI

IN1 IN2 IN3 IN4 EN1 EN2 VS VSS L293D

OUT1 OUT2 OUT3 OUT4

3 6 11 14

1 9 8 16

mtr 2

5v

HI

Fig 9.3

CHAPTER 10 CONCLUSION
We are very pleased with the progress and changes that we made with the project. The new equipment and competition created an environment where we vigorously pursued learning and applying control systems knowledge. The gantry crane setup provided an excellent challenge to us while not being overbearingly difficult.

CHAPTER 11 SCOPE:
This chapter applies to the marking, construction, installation, inspection, testing,maintenance and operation of the following overhead and gantry cranes, including semi-gantry, cantilever gantry, wall cranes, bridge cranes, and others having the same fundamental characteristics. These cranes may be top-running, under-running, single- or double-girder.Hoist units and trolleys are most commonly electric powered, but can be air powered or hand-chain operated. These cranes may be cab operated, pulpit operated, floor operated, orremotely operated. Such cranes are grouped together because all have trolleys and similar travel characteristics. The proper and safe use of overhead and gantry cranes is governed by the American Society of Mechanical Engineers (ASME) standards and the Occupational Safety and HealthAdministration (OSHA) regulations. This section implements required criteria fromDOE/RL-92-36 Hanford Site Hoisting and Rigging Manual and the following standards: ASME B30.2-2005 Overhead and Gantry Cranes (Top Running Bridge, Single or Multiple Girder, Top Running Trolley Hoist) ASME B30.17-2006 Overhead and Gantry Cranes (Top Running Bridge, Single Girder, Underhung Hoist) OSHA 29 CFR 1910.179 - Overhead and Gantry Cranes OSHA 29 CFR 1926 Subpart CC Overhead and Gantry Cranes (only applies to temporarily installed cranes) The responsible engineer may invoke Rules for Construction of Overhead and Gantry Cranes (Top Running Bridge, Multiple Girder) ASME NOG-1-2004 for crane used at nuclear facilities. ASME NOG-1 applies to the design, manufacture, testing, inspection, shipment, storage, and erection of overhead and gantry cranes (Top Running Bridge, Multiple Girder). The responsible engineer may invoke Rules for Construction of Cranes, Monorails, and Hoists (with Bridge or Trolley or Hoist of the Under-hung Type) ASME NUM-1-2004 for cranes used at nuclear facilities. ASME NUM-1 applies to the design, manufacture, testing, inspection,

shipment, storage, and erection of monorails and hoists (with Bridge or Trolley or Hoist of the Under-hung Type). This section implements the following criteria and the applicable national standards and/or federal specifications that are mandatory requirements for each item. ASME B30.2-2005 Overhead and Gantry Cranes (Top Running Bridge, Single or Multiple Girder, Top Running Trolley Hoist), ASME B30.17-2006 Overhead and Gantry Cranes (Top Running Bridge, Single Girder, Underhung Hoist).

CHAPTER 12 REFERENCES
[1] Butler, H., Honderd, G. and Van Amerongen, J., ModelReference Adaptive Control of a Gantry Crane ScaleModel, IEEE Control Systems Magazine, 11, no.1, Jan.1991, pp.57-62. [2] Quanser Consulting. Wincon 3.1 Manual, 2000. [3] Quanser Consulting. Systems & Procedures, 2000 [4]. Durfee, W. K., Teaching Microprocessors toMechanical Engineers: Lessons from aProjectBased,Creative Design Course, Proceedings of the ASME WinterAnnual Meeting, ASME 93WA/DSC-8, 1993, pp. 1-3. [5]. Marttinen, A., "Pole-Placement Control of a PilotGantry," Proceedings of the American Control Conference,1989, pp. 2824-2826. [6]. Marttinen, A., J. Virkkunin, and R. T. Salminen,"Control Study with a Pilot Crane," IEEE Transactions onEducation, 1990, Vol. 33, No. 3, pp. 298-305.

You might also like