iABSTRACTThe 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.CONTENTSCHAPTER TITLEPAGE
PROJECT TITLEi
REPORT STATUS VERIFICATION FORMii
STUDENTS DECLARATIONiii
SUPERVISORS DECLARATIONiv
DEDICATIONv
ACKNOWLEDGEMENTvi
ABSTRACTvii
ABSTRAKviii
CONTENTSix
LIST OF TABLESxii
LIST OF FIGURESxiii
LIST OF APPENDICESxvi
IINTRODUCTION1
1.1Project Introduction1
1.2Project Objectives2
1.3Problem Statement2
1.4Scope of Works3
1.5Methodology4
1.6Report Structure5
xIILITERATURE REVIEW6
2.1Previous System6
2.2Block Diagram Description7
2.2.1 Gate Control Unit9
2.2.2 Announcement Unit10
2.3Microcontroller10
2.3.1 AT89S5211
2.4Programming Language13
2.5Infrared Sensor14
2.5.1 IR Transmitter14
2.5.2 IR Receiver15
2.6Motor Theory16
2.7H-Bridge17
2.7.1 L293D18
2.8LCD19
2.9Proteus VSM20
2.10PIC C Compiler23
IIIMETHODOLOGY26
3.1Project Methodology26
3.2Project Flow Chart28
3.3System Flow29
3.3.1 Process Procedure30
3.4Hardware Assembly31
xiIVRESULTS AND DISCUSSION33
4.1System Explanation33
4.2The Designed Circuits36
4.2.1 Sensor Circuit36
4.2.2 Buzzer Circuit38
4.2.3 Lighting Alarm Circuit39
4.2.4 Voltage Regulator Circuit40
4.2.5 LCD Circuit41
4.2.6 Motor Circuit44
4.2.7 AT89S52 Integration Circuit46
4.3The Simulation Result47
4.3.1 Voltage Supply47
4.3.2 AT89S52 Interfacing Result48
4.4The Programming Result50
4.5Hardware Description53
4.5.1 The Constructed Circuits53
4.5.2 The Prototype57
IVCONCLUSION AND RECOMMENDATION59
5.1Conclusion59
5.2Recommendation60
REFERENCES61
xiiLIST OF TABLESNO.TITLEPAGE
4.2.5 The pin structure of LCD module43
xiiiLIST OF FIGURESNO.TITLESPAGE
2.2.1Block diagram of the system7
2.2.2The functionality between microcontrollers8
2.2.1.1The diagram of gate control unit9
2.3.1.1AT89S52 pins/terminals12
2.3.1.2AT89S52 chip12
2.5.1Infrared sensor14
2.5.1.1 IR transmitter circuit using 555 IC timer14
2.5.2.1IR receiver circuit using 555 IC timer15
2.6.1Stepper motor16
2.6.2Servo motor16
2.6.3DC motor17
2.7.1The diagram of basic H-bridge17
2.7.1.1The interfacing diagram18
2.7.1.2L293D IC chip19
2.8LCD19
2.9.1Proteus VSM20
2.9.2ISIS 7 Professional user interface21
2.9.3ARES 7 Professional user interface21
2.9.4Components selection22
2.9.5Parameter settings22
xiv2.9.6Simulation buttons23
2.10.3Create new file/project24
2.10.4Example program25
2.10.5Compile summary25
3.2Project flow chart28
3.3System flow chart29
3.3.1.1The flow of the process in the system30
3.4.1The diagram of hardware assembly done31
4.1.1The system diagram with fully explanation33
4.2.1.1The designed IR sensor circuit36
4.2.1.2Example of IR module with pins/terminals37
4.2.1.3The diagram of suggested arrangement IR module37
4.2.2.1The designed buzzer circuit38
4.2.3.1The designed lighting alarm circuit39
4.2.4.1The designed voltage regulator circuit40
4.2.5.1The designed LCD circuit interface with AT89S52
circuit41
4.2.6.1The designed motor circuit interface with AT89S52
circuit44
4.2.7.1The designed overall AT89S52 interfacing circuit46
4.3.1.1The simulation result give value of 5V47
4.3.2.1The result after AT89S52 being triggered48
4.3.2.2The result after AT89S52 triggered to back normal
condition49
4.4.1The programming result52
4.5.1.1The sensor circuit53
4.5.1.2The sensor circuit on PCB53
4.5.1.3The main circuit54
4.5.1.4LCD show the notification of closing the gate55
xv4.5.1.5 The gate motor used55
4.5.1.6 The sensor located at side of the railway track56
4.5.2.1The prototype of model railway gate system57
4.5.2.2The prototype of model railway gate system58
xviLIST OF APPENDICESNO.TITLESPAGE
AGantt Chart63
BMicrochip PIC16F87XA Data Sheet65
1CHAPTER IINTRODUCTION1.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.21.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.31.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.41.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.51.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.6CHAPTER IILITERATURE
REVIEW2.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.72.2 Block Diagram Description
Figure 2.2.1: Block diagram of the systemThis 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.8Lighting 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.
SensorLCDMotor
AT89S52MicrocontrollerBuzzerLighting
Alarm
Figure 2.2.2: The functionality between
microcontrollersINTRODUCTION 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 CALLS: 2.1.1 EMBEDDED SYSTEM DESIGN CYCLE
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 embedded software applications2.
Communication applications3. Industrial automation and process
control software2.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 CLASSIFICATION1. Hard Real Time Systems2. 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. Whenelectricityis applied to the coil of wire
it becomesmagnetic, hence the termelectromagnet.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
electromagnetismagnetically linkedto theswitchbut the two are NOT
linked electrically.
CHAPTER 3
AT89S525.1 INTRODUCTION
Today, micro controllers have become an integral of all
automatic and semi-automatic 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 configurationBLOCK DIAGRAM
Fig.5.2. Block diagram5.6 PIN DESCRIBTION
VCCSupply voltage.
GNDGround.
PORT 0Port 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 1Port 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 2Port 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 3Port 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 PINALTERNATE FUNCTIONS
P3.0RXD (serial input port)
P3.1TXD (serial output port)
P3.2INT0 (external interrupt 0)
P3.3INT1 (external interrupt 1)
P3.4T0 (timer 0 external input)
P3.5T1 (timer 1 external input)
P3.6WR (external data memory write strobe)
P3.7RD (external data memory)
Port 3 also receives some control signals for Flash programming
and verification.
RSTReset input. A high on this pin for two machine cycles while
the oscillator is running resets the device.
ALE/PROGAddress 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.
PSENProgram 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/VPPExternal 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.
XTAL1Input to the inverting oscillator amplifier and input to
the internal clock operating circuit.
XTAL2Output from the inverting oscillator amplifier.
OSCILLATOR CHARACTERISTICSXTAL1 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 MODEIn 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 ConnectionsNote: C1, C2 = 30 pF 10 pF for
Crystals
= 40 pF 10 pF for Ceramic Resonators
Fig.5.4.External Clock Drive Configuration2X16 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 hasown
characteristicBasic Specifications
Power requirements4.8 to 5.5Vdc @ 3Ma
User connector5-pin header; 0.025" posts on 0.10" centers
Connector pinout+5V GND SERIAL GND +5V
Serial InputRS-232 or inverted TTL, 2400/9600, N81
Operating Temperature0 to 50 C
Initializationswitches LCD power; performs soft init
Instruction prefixASCII 254 (0FE hex)
LCD typeSupertwist (STN), yellow-green
Optimum viewing direction6 o'clock
LCD Instructions by FunctionFunctionASCII Value
Clear screen1
Home cursor2
Blank display (retaining data)8
Hide cursor12
Show underline cursor14
Move cursor 1 character left16
Move cursor 1 character right20
Scroll 1 character left24
Scroll 1 character right28
Set display address (position the cursor)128 + location
Move to 1st character of 1st line128
Move tonthcharacter of 1st line128 +n
Move to 1st character of 2nd line192
Move tonthcharacter of 2nd line192 +n
Set character-generator address64 + address
RELAYS:
HistoryElectromagnetic 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.3RELAYS 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'slaw 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.5Advantages:
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.6Disadvantages :
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.7Applications:
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 low-voltage 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.