Sie sind auf Seite 1von 44

i

ABSTRACT

The purpose of this project is to develop an automatic railway gate system that
uses the microcontroller as a main function of design. The principle objective of this
project was to design an automatic railway gate control by microcontroller. This project
deals to develop a prototype of railway gate that function automatically by using
microcontroller. Besides that, the interfacing program also had been developed for the
integration part. The operation using microcontroller (AT89S52) that integrated with
other circuits involved such as power supply, IR sensor, light and buzzer, gate motor and
LCD display. All the circuits will be combining to demonstrate the operation of
microcontroller (AT89S52). This system will make improvement towards the manually
operation before this. Human supervision will be considered if there are problems
occurred while this system was operated.

CONTENTS

CHAPTER TITLE

PAGE

PROJECT TITLE

REPORT STATUS VERIFICATION FORM

ii

STUDENTS DECLARATION

iii

SUPERVISORS DECLARATION

iv

DEDICATION

ACKNOWLEDGEMENT

vi

ABSTRACT

vii

ABSTRAK

viii

CONTENTS

ix

LIST OF TABLES

xii

LIST OF FIGURES

xiii

LIST OF APPENDICES

xvi

INTRODUCTION

1.1

Project Introduction

1.2

Project Objectives

1.3

Problem Statement

1.4

Scope of Works

1.5

Methodology

1.6

Report Structure

II

LITERATURE REVIEW

2.1

Previous System

2.2

Block Diagram Description

2.3

2.2.1 Gate Control Unit

2.2.2 Announcement Unit

10

Microcontroller

10

2.3.1 AT89S52

11

2.4

Programming Language

13

2.5

Infrared Sensor

14

2.5.1 IR Transmitter

14

2.5.2 IR Receiver

15

2.6

Motor Theory

16

2.7

H-Bridge

17

2.7.1 L293D

III

18

2.8

LCD

19

2.9

Proteus VSM

20

2.10 PIC C Compiler

23

METHODOLOGY

26

3.1

Project Methodology

26

3.2

Project Flow Chart

28

3.3

System Flow

29

3.3.1 Process Procedure


3.4

Hardware Assembly

30
31

xi

IV

RESULTS AND DISCUSSION

33

4.1

System Explanation

33

4.2

The Designed Circuits

36

4.2.1 Sensor Circuit

36

4.2.2 Buzzer Circuit

38

4.2.3 Lighting Alarm Circuit

39

4.2.4 Voltage Regulator Circuit

40

4.2.5 LCD Circuit

41

4.2.6 Motor Circuit

44

4.2.7 AT89S52 Integration Circuit

46

The Simulation Result

47

4.3.1 Voltage Supply

47

4.3.2 AT89S52 Interfacing Result

48

4.4

The Programming Result

50

4.5

Hardware Description

53

4.5.1 The Constructed Circuits

53

4.5.2 The Prototype

57

4.3

IV

CONCLUSION AND RECOMMENDATION

59

5.1

Conclusion

59

5.2

Recommendation

60

REFERENCES

61

xii

LIST OF TABLES

NO.

TITLE

4.2.5 The pin structure of LCD module

PAGE
43

xiii

LIST OF FIGURES

NO.

TITLES

PAGE

2.2.1

Block diagram of the system

2.2.2

The functionality between microcontrollers

2.2.1.1 The diagram of gate control unit

2.3.1.1 AT89S52 pins/terminals

12

2.3.1.2 AT89S52 chip

12

2.5.1

14

Infrared sensor

2.5.1.1 IR transmitter circuit using 555 IC timer

14

2.5.2.1 IR receiver circuit using 555 IC timer

15

2.6.1

Stepper motor

16

2.6.2

Servo motor

16

2.6.3

DC motor

17

2.7.1

The diagram of basic H-bridge

17

2.7.1.1 The interfacing diagram

18

2.7.1.2 L293D IC chip

19

2.8

LCD

19

2.9.1

Proteus VSM

20

2.9.2

ISIS 7 Professional user interface

21

2.9.3

ARES 7 Professional user interface

21

2.9.4

Components selection

22

2.9.5

Parameter settings

22

xiv

2.9.6

Simulation buttons

23

2.10.3

Create new file/project

24

2.10.4

Example program

25

2.10.5

Compile summary

25

3.2

Project flow chart

28

3.3

System flow chart

29

3.3.1.1 The flow of the process in the system

30

3.4.1

The diagram of hardware assembly done

31

4.1.1

The system diagram with fully explanation

33

4.2.1.1

The designed IR sensor circuit

36

4.2.1.2 Example of IR module with pins/terminals

37

4.2.1.3

37

The diagram of suggested arrangement IR module

4.2.2.1 The designed buzzer circuit

38

4.2.3.1 The designed lighting alarm circuit

39

4.2.4.1

The designed voltage regulator circuit

40

4.2.5.1

The designed LCD circuit interface with AT89S52 circuit

41

4.2.6.1

The designed motor circuit interface with AT89S52 circuit

44

4.2.7.1

The designed overall AT89S52 interfacing circuit

46

4.3.1.1 The simulation result give value of 5V

47

4.3.2.1

The result after AT89S52 being triggered

48

4.3.2.2

The result after AT89S52 triggered to back normal condition

49

4.4.1

The programming result

52

4.5.1.1

The sensor circuit

53

4.5.1.2

The sensor circuit on PCB

53

4.5.1.3 The main circuit

54

4.5.1.4 LCD show the notification of closing the gate

55

xv

4.5.1.5 The gate motor used

55

4.5.1.6 The sensor located at side of the railway track

56

4.5.2.1 The prototype of model railway gate system

57

4.5.2.2 The prototype of model railway gate system

58

xvi

LIST OF APPENDICES

NO.

TITLES

PAGE

Gantt Chart

63

Microchip PIC16F87XA Data Sheet

65

CHAPTER I

INTRODUCTION

1.1

Project Introduction
In general, this project utilizes the importance of microcontroller as a main

design. It used to provide improvement into manual system that exist nowadays.
Microcontroller is a small unit of controller that acted following the instruction
programmed. All the circuits included in this prototype were designed following the
suitability of AT89S52.
This automatic railway gate system was operated after signal received from the
IR sensor. This signal used to trigger the AT89S52 for operating the gate motor and
alarm indicators by instruction programmed.
Electronic applications used to enable this system operated in automatic mode.
The computer usage must be fully utilized to building up a system that encourage
implementing of the technology.

2
1.2

Project Objectives
The microcontroller (AT89S52) is use to demonstrate the integration of computer

method in railway gate operation.The objectives of this project are:


i.

To develop a prototype of railway gate that function automatically by using


microcontroller.

ii.

To develop an interfacing program for the integration part of microcontroller


operation.

iii.

To design an automatic railway gate control by using microcontroller.


Furthermore, this project is aimed to replace the gatekeepers with an automatic

system. It is develop to apply the structure of interfacing program in between to give a


lot of advantages.

1.3

Problem Statement
Nowadays, the railway gate is operating by manual operation. It is operating in

the area that there are railway line junction with the road. The railway gate management
has to employ workers to be on duty for control the operation. Due to this, the worker
will manually open and close the gate with under supervision.
This prototype will introduce the automatic railway gate operation. This system
will make improvement towards the manually operation before this. Human supervision
will be considered if there are problems occurred while this system was operated.
This is an idea to perform computer integration with mechanical structure to
simulate what the system can do. Control system with computer applications will make
the management or consumer become more effective. Therefore, this is the best example
in develop railway gate management system become more efficient.

3
1.4

Scope of Works
This project covered the operation of automatic railway gate control by using

microcontroller (AT89S52). The circuits involved such as power supply, IR sensor, light
and buzzer, gate motor and LCD display.
All of these operations will be combining to demonstrate the operation of
microcontroller (AT89S52).
The operations of microcontroller works follow the instruction programmed. The
combining circuits were constructed on Proteus software to seen whether that circuits
was right or not. After that, the hardware part was constructed after all the simulation
being done.
IR sensor circuit is providing signal to triggered the AT89S52. The sensed signal
wills active the gate motor and LCD display. Alarm and indication light circuit was
provided as additional part of this system.
Additional elements can be added without affecting the remaining elements. This
allows the flexibility of the developed system.

4
1.5

Methodology
This project began with the research of the proposed title. The result of that

research is then discussed with the supervisor. Once the title of project was approved, the
background of study for this project was explored.
AT89S52 was chosen as a microcontroller. Then, the circuits simulation was
performed. In the other hand, the instruction programmed also being built for the
interfacing part. After all being settled, the construction of hardware part was started
after the components were being chosen.
In all the steps done there are troubleshooting part to resolve the problems facing.
Between hardware part and instruction programmed built, there are integrated step that
allows the AT89S52 to simulate all the operations of the system.
After all the part is complete to built, some analysis should being made to show
what the solution of the problems occurred. It involving the comparison between the
research that had been done before this.

5
1.6

Report Structure
Chapter 1 introduced the project as a whole. The early and basic explanations

were mentioned in this chapter. This chapter consisted of the project introduction and
objectives, problem statements, scope of work, and the simplified methodology.
Chapter 2 is literature review. Past projects system were taken into consideration
when completing this chapter. The ways those projects and researches had been done
were compared with what this project. These comparisons were done to understand what
this project is all about and where it stands.
Chapter 3 is methodology. It explained how this project came to be. This chapter
explained the part most important of all, the flow this project. What had been researched
and what needed to be done was explained in this chapter.
Chapter 4 concentrated on the result and discussion of this project. What had
been done was explained in diagrams and written programs. The expected results also
mentioned in this chapter.
Chapter 5 was the final chapter in this report. The conclusions and
recommendations were placed in this chapter. In other words, the conclusion was the
summary of what had been done throughout this project. After the project was done,
recommendations were made and any expansions or upgrades that might be done in the
future were suggested.

CHAPTER II

LITERATURE REVIEW

2.1

Previous System
At present scenario, in the level crossing line the railway gate is operated

normally by a gate keeper. This happen when the railway line is cross over the road and
there are a gate that have to be controlled. The gate keeper work after receiving the
information about the train arrival from the nearer station. When the train starts to leave
the station, the particular station delivers the information to give the signal for gate
keeper to get ready. This is the operation are followed for operating the railway gates.
In addition, this automatic railway gate system can contribute a lot of benefit
either to the road user or to the railway management. This type of gate can be
implementing in the level crossing where the chances of accidents are higher. The
computer integration will be use to provide addition in the latest technology.

7
2.2

Block Diagram Description

Figure 2.2.1: Block diagram of the system


This prototype of project demonstrated the Automatic Railway Gate Control by
Using Microcontroller (AT89S52). The sensors are fixed at the certain distance on both
sides of the gate, that is before the train arrive and after the train departure. The sensed
signal is send to the microcontroller (AT89S52) and checked whether there are vehicles
or people between the gate. At the same time, alarm and indication light signal are
provided to the road users to warn the closing of gates.
In sequences, the gate motor will move forward direction to close the gate. It will
stay closed at certain time until the train has crossed the gate and reached the second
sensor activate the motor in backward direction so the gate will open.

8
Lighting signal also provided at the certain distance as pre cautionary step for
driver. Meanwhile, the nearer station also will provide an indication alarm to remind
them about the crossing train. If anything happened at the gates, this alarm will alert the
station. LCD display will show the arrival of the train to cross the gate as additional
features of this system.

Sensor

LCD

Motor
AT89S52
Microcontroller

Buzzer

Lighting
Alarm

Figure 2.2.2: The functionality between microcontrollers


INTRODUCTION TO EMBEDDED SYSTEMS
2.1 EMBEDDED SYSTEM:
Embedded System is a combination of hardware and software used to achieve a
single specific task. An embedded system is a microcontroller-based, software driven,
reliable, real-time control system, autonomous, or human or network interactive,
operating on diverse physical variables and in diverse environments and sold into a
competitive and cost conscious market.

An embedded system is not a computer system that is used primarily for


processing, not a software system on PC or UNIX, not a traditional business or scientific
application. High-end embedded & lower end embedded systems. High-end embedded
system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital
Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit
Controllers used with an minimal operating systems and hardware layout designed for
the specific purpose. Examples Small controllers and devices in our everyday life like
Washing Machine, Microwave Ovens, where they are embedded in.
SYSTEM

DESIGN

2.1.1 EMBEDDED SYSTEM DESIGN CYCLE

CALLS:

V Diagram
In this place we need to discuss the role of simulation software, real-time systems
and data acquisition in dynamic test applications. Traditional testing is referred to as
static testing where functionality of components is tested by providing known inputs
and measuring outputs. Today there is more pressure to get products to market faster
and reduce design cycle times.
This has led to a need for dynamic testing where components are tested while in use
with the entire system either real or simulated. Because of cost and safety concerns,
simulating the rest of the system with real-time hardware is preferred to testing
components in the actual real system.
The diagram shown on this slide is the V Diagram that is often used to describe
the development cycle. Originally developed to encapsulate the design process of
software applications, many different versions of this diagram can be found to describe
different product design cycles. Here we have shown one example of such a diagram
representing the design cycle of embedded control applications common to automotive,
aerospace and defense applications.
In this diagram the general progression in time of the development stages is
shown from left to right. Note however that this is often an iterative process and the
actual development will not proceed linearly through these steps. The goal of rapid
development is to make this cycle as efficient as possible by minimizing the iterations

required for a design. If the x-axis of the diagram is thought of as time, the goal is to
narrow the V as much as possible and thereby reduce development time.
The y-axis of this diagram can be thought of as the level at which the system
components are considered. Early on in the development, the requirements of the
overall system must be considered. As the system is divided into sub-systems and
components, the process becomes very low-level down to the point of loading code onto
individual processors. Afterwards components are integrated and tested together until
such time that the entire system can enter final production testing. Therefore the top of
the diagram represents the high-level system view and the bottom of the diagram
represents a very low-level view.
Notes:

V diagram describes lots of applicationsderived from software development.

Reason for shape, every phase of design requires a complimentary test phase.
High-level to low-level view of application.

This is a simplified version.

Loop Back/Iterative process, X-axis is time (sum up).

2.1.2 CHARACTERISTICS OF EMBEDDED SYSTEM

An embedded system is any computer system hidden inside a product other than

a computer.
There will encounter a number of difficulties when writing embedded system
software in addition to those we encounter when we write applications

Throughput Our system may need to handle a lot of data in a short


period of time.

ResponseOur system may need to react to events quickly

TestabilitySetting up equipment to test embedded software can be


difficult

DebugabilityWithout a screen or a keyboard, finding out what the


software is doing wrong (other than not working) is a troublesome
problem

Reliability embedded systems must be able to handle any situation


without human intervention

Memory space Memory is limited on embedded systems, and you must


make the software and the data fit into whatever memory exists

Program installation you will need special tools to get your software
into embedded systems

Power consumption Portable systems must run on battery power, and


the software in these systems must conserve power

Processor hogs computing that requires large amounts of CPU time can
complicate the response problem

Cost Reducing the cost of the hardware is a concern in many embedded


system projects; software often operates on hardware that is barely
adequate for the job.

Embedded systems have a microprocessor/ microcontroller and a memory. Some


have a serial port or a network connection. They usually do not have keyboards,
screens or disk drives.

2.2 APPLICATIONS
1. MILITARY AND AEROSPACE
2. COMMUNICATION
3. INDUSTRIAL

EMBEDDED SOFTWARE APPLICATIONS

APPLICATIONS

AUTOMATION AND PROCESS CONTROL SOFTWARE

2.3 CLASSIFICATION
1.

Real Time Systems.

2.

RTS is one which has to respond to events within a specified deadline.

3.

A right answer after the dead line is a wrong answer

2.3.1 RTS CLASSIFICATION


1.

Hard Real Time Systems

2.

Soft Real Time System

2.3.1.1 HARD REAL TIME SYSTEM

"Hard" real-time systems have very narrow response time.

Example: Nuclear power system, Cardiac pacemaker.

POWER SUPPLY UNIT:


The input to the circuit is applied from the regulated power supply. The a.c. input
i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a
rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to
get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove
any a.c components present even after rectification. Now, this voltage is given to a
voltage regulator to obtain a pure constant dc voltage.

Circuit Diagram

Transformer:
Usually, DC voltages are required to operate various electronic equipment and these
voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c
input available at the mains supply i.e., 230V is to be brought down to the required
voltage level. This is done by a transformer. Thus, a step down transformer is employed
to decrease the voltage to a required level.

Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating
D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge
rectifier is used because of its merits like good stability and full wave rectification.

Filter:
Capacitive filter is used in this project. It removes the ripples from the output of rectifier
and smoothens the D.C. Output received from this filter is constant until the mains
voltage and load is maintained constant. However, if either of the two is varied, D.C.
voltage received at this point changes. Therefore a regulator is applied at the output
stage.

Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator is an
electrical regulator designed to automatically maintain a constant voltage level. In this
project, power supply of 5V and 12V are required. In order to obtain these voltage
levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents
positive supply and the numbers 05, 12 represent the required output voltage levels.
Notice in the above diagram that a relay uses an electromagnet. This is a device
consisting of a coil of wire wrapped around an iron core. When electricity is applied to
the coil of wire it becomes magnetic, hence the term electromagnet. The A B and C
terminals are an SPDT switch controlled by the electromagnet.

When electricity is

applied to V1 and V2, the electromagnet acts upon the SPDT switch so that the B and C
terminals are connected. When the electricity is disconnected, then the A and C terminals
are connected. It is important to note that the electromagnet is magnetically linked to
the switch but the two are NOT linked electrically.

CHAPTER 3
AT89S52
5.1 INTRODUCTION
Today, micro controllers have become an integral of all automatic and semiautomatic machines. Remote controllers, hand-held communication devices, dedicated
controllers, have certainly improved the functional, operational and performance based
specifications.
Microcontrollers are single chip microcomputers, more suited for control and
automation of machines and process. Microcontrollers have central processing unit
(CPU), memory, I/O units, timers and counters, analog to digital converters (ADC),
digital to analog converters (DAC), serial ports, interrupt logic, oscillator circuitry and
many more functional blocks on chip.
All these functional block on a single Integrated Circuit (IC), result into a
reduced size of control board, low power consumption, more reliability and ease of
integration within an application design. The usage of micro controllers not only reduces

the cost of automation, but also provides more flexibility

5.2 FEATURES
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
Two 16-bit Timer/Counters
Six Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes

5.3 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K
bytes of Flash programmable and erasable read only memory (PEROM). The device is
manufactured using Atmels high-density non-volatile memory technology and is
compatible with the industry-standard MCS-51 instruction set and pin out.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a
conventional on-volatile memory programmer. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which

provides highly-flexible and cost-effective solution to many embedded control


applications

PIN CONFIGURATION

Fig.5.1 Pin configuration

BLOCK DIAGRAM

Fig.5.2. Block diagram

5.6 PIN DESCRIBTION

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

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 pulledlow will source current (IIL) because of the internal pull ups. Port
1 also receives the low-order address bytes during Flash programming and verification.
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, it 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 also serves the functions of various special features of the
AT89C51 as listed below:

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)

Port 3 also receives some control signals for Flash programming and verification.
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 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
AT89C51 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, for parts that
require 12-volt VPP.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.

OSCILLATOR CHARACTERISTICS

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a
quartz crystal or ceramic resonator may be used.
To drive the device from an external clock source, XTAL2 should be left unconnected
while XTAL1 is driven as shown in Figure 2. 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.
It should be noted that when idle is terminated by a hard ware 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 is terminated
by reset, the instruction following the one that invokes Idle should not be one that writes
to a port pin or to external memory.

Fig.5.3. Oscillator Connections

Note: C1, C2 = 30 pF 10 pF for Crystals


= 40 pF 10 pF for Ceramic Resonators

Fig.5.4.External Clock Drive Configuration


2X16 LCD:

Most LCD programmed in 8 bit configuration. Moreover LCD put


on equipment that show the value of measurement, i.e. temperature,
voltage, current, etc. There are a lot of tutorial show steps how to configure
out in order to LCD on. But each LCD has own characteristic

Basic Specifications
Power requirements

4.8 to 5.5Vdc @ 3Ma

User connector

5-pin header; 0.025" posts on 0.10" centers

Connector pinout

+5V GND SERIAL GND +5V

Serial Input

RS-232 or inverted TTL, 2400/9600, N81

Operating Temperature

0 to 50 C

Initialization

switches LCD power; performs soft init

Instruction prefix

ASCII 254 (0FE hex)

LCD type

Supertwist (STN), yellow-green

Optimum viewing direction

6 o'clock

LCD Instructions by Function


Function

ASCII Value

Clear screen

Home cursor

Blank display (retaining data)

Hide cursor

12

Show underline cursor

14

Move cursor 1 character left

16

Move cursor 1 character right

20

Scroll 1 character left

24

Scroll 1 character right

28

Set display address (position the cursor)

128 + location

Move to 1st character of 1st line

128

Move to nth character of 1st line

128 + n

Move to 1st character of 2nd line

192

Move to nth character of 2nd line

192 + n

Set character-generator address

64 + address

RELAYS:
History
Electromagnetic relays were once the main ingredient in automated machinery. Factories
used to control everything from conveyors to robots with huge panels filled with
hundreds of relays clacking away, each in turn. This method had several drawbacks, but
for years it was the only method available.
Recently, Programmable Logic Controllers (PLCs) have replaced banks of relays
for automation needs. Relays are still used in small applications where a PLC would be
overkill. They come in several varieties to suit a wide range of applications.
Relays have a huge number of uses, but a few very common ones constitute the vast
majority. Holding circuits are used to hold power on until the connection is Broken by
another signal. This is achieved by connecting one of the relay's own contacts to its coil
once the relay is turned on, it stays on. . Relays are also useful for allowing one signal
to switch connections at two or more different voltages since the contacts are isolated
from each other. But most often, they are used to switch connections that are at different
voltages than the control power.
In many cases, control power and signals generated by sensors are generated at
low voltages. This is for reasons of safety and efficiency. Low voltage signals, however,
are inefficient for doing high-wattage work, so a relay is used to allow the low voltage

signal to switch a higher-voltage connection to do work, such as pull in a large solenoid,


run a motor.

4.7.1 WHAT IS A RELAY?


A relay is an electrical switch that opens and closes under the control of another
electrical circuit. Relays are one of the oldest, simplest, and yet, easiest and most useful
devices. Before the advent of the mass
produced transistor, computers were made
from either relays or vacuum tubes, or both.

The classic electromagnetic relay is a


switch

which

is

thrown

by

an

electromagnet. A relatively low current


applied to the magnet can throw the switch,
allowing a higher current to flow through
that

switch.

The

solenoid

of

most

automobiles can be considered an electromagnetic relay.


In digital applications, it has been surpassed by the solid state relay. These relays have
no moving parts, so they can switch very quickly in response to a control signal. They
are built from semiconductors, and they cannot handle the current that an
electromagnetic relay could but their advantage is speed. High current solid-state relays
often require heat sinks to drain excess heat.

4.7.2 Relay Construction


Relays are amazingly simple devices.
There are four parts in every relay:

Electromagnet

Armature that can be attracted by the electromagnet

Spring

Switching contacts
relays construction

Relay Contact Information:


Relay contacts on most of our kits and in the industrial world are labeled with
NO (Normally Open), NC (Normally Closed), and CT (Common Terminal).
A relay contact is a switch, nothing more, nothing

less. It does not provide power; it

simply opens and closes an electrical circuit, just like the light switch on a wall.
When the relay is de-energized or turned off there is an electrical connection between
NC and Common hence normally closed. In the off state there is not a connection
between NO and common, hence normally open.
When the relay is energized or turned on the NO and C makes an electrical connection
and the electrical connection between NC and C is removed.

4.7.3 RELAYS WORKING:


When a current flows through the coil, the
resulting

magnetic

field

attracts

an

armature that is mechanically linked to a


moving contact. The movement either
makes or breaks a connection with a fixed
contact. When the current to the coil is
switched off, the armature is returned by a
force approximately half as strong as the
magnetic force to its relaxed position.
Usually this is a spring, but gravity is also used commonly in industrial motor starters.
Most relays are manufactured to operate quickly. In a low voltage application, this is to
reduce noise. In a high voltage or high current application, this is to reduce arcing.

If the coil is energized with DC, a diode is frequently installed across the coil, to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a spike of voltage and might cause damage to circuit components. If
the coil is designed to be energized with AC, a small copper ring can be crimped to the
end of the solenoid. This "shading ring" creates a small out-of-phase current, which
increases the minimum pull on the armature during the AC cycle.

Relay operation

4.7.4

CHOOSING OF RELAY:

1.Physical size and pin arrangement


If you are choosing a relay for an existing PCB you will need to ensure that its
dimensions and pin arrangement are suitable. You should find this information in the
supplier's catalogue.
2.Coil voltage
The relay's coil voltage rating and resistance must suit the circuit powering the relay
coil. Many relays have a coil rated for a 12V supply but 5V and 24V relays are also
readily available. Some relays operate perfectly well with a supply voltage which is a
little lower than their rated value.
3.Coil resistance
The circuit must be able to supply the current required by the relay coil. You can use
Ohm's law to calculate the current:

Relay coil current =

supply voltage
coil resistance

For example: A 12V supply relay with a coil resistance of 400

passes a current of

30mA. This is OK for a 555 timer IC (maximum output current 200mA), but it is too
much for most ICs and they will require a transistor to amplify the current.

4.Switch ratings (voltage and current)


The relay's switch contacts must be suitable for the circuit they are to control. You will
need to check the voltage and current ratings. Note that the voltage rating is usually
higher for AC, for example: "5A at 24V DC or 125V AC".
5.Switch contact arrangement (SPDT, DPDT etc)
Most relays are SPDT or DPDT which are often described as "single pole changeover"
(SPCO) or "double pole changeover" (DPCO). For further information please see the
page on switches.
4.7.5 Advantages:
1.The complete electrical isolation improves safety by ensuring that high voltages and
currents cannot appear where they should not be.

2.Relays come in all shapes and sizes for different applications and they have various
switch contact configurations. Double Pole Double Throw (DPDT) relays are common
and even 4-pole types are available. You can therefore control several circuits with one
relay or use one relay to control the direction of a motor.
3.It is easy to tell when a relay is operating - you can hear a click as the relay switches
on and off and you can sometimes see the contacts moving.
4.7.6

Disadvantages :

Being mechanical though, relays do have some disadvantages over other methods of
electrical isolation:
1.Their parts can wear out as the switch contacts become dirty - high voltages and
currents cause sparks between the contacts.
2.They cannot be switched on and off at high speeds because they have a slow response
and the switch contacts will rapidly wear out due to the sparking.
3.Their coils need a fairly high current to energize, which means some micro-electronic
circuits can't drive them directly without additional circuitry.

4.The back-emf created when the relay coil switches off can damage the components
that are driving the coil. To avoid this, a diode can be placed across the relay coil, as
will be seen in any Electronics in Meccano circuits that use relays with sensitive
components.
4.7.7

Applications:
Relays are used:

1.To control a high-voltage circuit with a low-voltage signal, as in some types of


modems.
2.To control a high-current circuit with a low-current signal, as in the starter solenoid of
an automobile.
3.To detect and isolate faults on transmission and distribution lines by opening and
closing circuit breakers (protection relays).
4.To isolate the controlling circuit from the controlled circuit when the two are at
different potentials, for example when controlling a mains-powered device from a lowvoltage switch. The latter is often applied to control office lighting as the low voltage
wires are easily installed in partitions, which may be often moved as needs change. They
may also be controlled by room occupancy detectors in an effort to conserve energy.
5.To perform logic functions. For example, the Boolean AND function is realized by
connecting NO relay contacts in series, the OR function by connecting NO contacts in
parallel. The change-over or Form C contacts perform the XOR (exclusive or) function.
Similar functions for NAND and NOR are accomplished using NC contacts. Due to the
failure modes of a relay compared with a semiconductor, they are widely used in safety
critical logic, such as the control panels of radioactive waste handling machinery.
6.To perform time delay functions. Relays can be modified to delay opening or delay
closing a set of contacts. A very short (a fraction of a second) delay would use a copper
disk between the armature and moving blade assembly. Current flowing in the disk
maintains magnetic field for a short time, lengthening release time. For a slightly longer
(up to a minute) delay, a dashpot is used. A dashpot is a piston filled with fluid that is

allowed to escape slowly. The time period can be varied by increasing or decreasing the
flow rate. For longer time periods, a mechanical clockwork timer is installed.

SOFTWARE REQUIRED

The Keil tool chain consists of the following executables located in the c:\c51eval\bin
directory:
Vision uvw51e.exe
C Compiler c51.exe
Assembler a51.exe
Linker bL51.exe
dScopedsw51.exe
Vision IDE
Vision is a Windows based front end for the C Compiler and Assembler. It was
developed in the USA as was the printed manual set. Compiler, Assembler and Linker
options are set with simple mouse clicks. Vision runs on Windows 3.1, 95 and NT.
The Compiler, Assembler and Linker are DOS executables. They can be accessed with
your favorite batch files if you prefer. This provides maximum flexibility. This
Integrated Development Environment (IDE) has been expressly designed with the user
in mind. A full function editor is included. All IDE functions are intuitive via pull down
menus with prompted selections. An extensive Help utility is included. External
executables can be run from within Vision. This includes emulator software.

C51 C Compiler for the 8051, 8x931Hx and 8x931Ax [USB]


The C51 ANSI compiler along with the A51 assembler is designed specifically for the
Intel MCS8051 microcontroller family, including the 8x931 USB. The C51 is 100%
compatible with existing 8051programs. Extensions provide access to all 8051 hardware
components. Sample USB/931 code is available: www.keil.com/usb. C51 supports code
banking. The compiler can be run in either DOS mode or called from the Windows
based front end Vision. Run from Vision which is included with every Assembler
and Compiler package.

Evaluation Version of the Keil Tool Set:


The evaluation version of the Keil tool set is restricted to a 2K code size and the code
must be located at 0x4000. Useful object code is produced. Other than these restrictions,
the tool set works exactly as the full version does. This allows you to fully evaluate the
features and power of Keil products. The full version has no restrictions and is fully
ANSI compliant.

Das könnte Ihnen auch gefallen