Automatic Railway Gate Control System
Automatic Railway Gate Control System
Automatic Railway Gate Control System
TOPICS
Certificates
Acknowledgement........
CHAPTER 1: INTRODUCTION
3.8 Buzzer.
REFERENCES
CHAPTER 1: INTRODUCTION
1.1 Introduction:
The objective of this paper is to provide an automatic railway gate at a level crossing replacing
the gates operated by the gatekeeper. It deals with two things. Firstly, it deals with the reduction of
time for which the gate is being kept closed. And secondly, to provide safety to the road users by
reducing the accidents
By the presently existing system once the train leaves the station, the stationmaster informs the
gatekeeper about the arrival of the train through the telephone. Once the gatekeeper receives the
information, he closes the gate depending on the timing at which the train arrives. Hence, if the train
is late due to certain reasons, then gate remain closed for a long time causing traffic near the gates.
By employing the automatic railway gate control at the level crossing the arrival of the train is
detected by the sensor placed near to the gate. Hence, the time for which it is closed is less compared
to the manually operated gates and also reduces the human labor. This type of gates can be employed
in an unmanned level crossing where the chances of accidents are higher and reliable operation is
required. Since, the operation is automatic; error due to manual operation is prevented.
Automatic railway gate control is highly economical microcontroller based arrangement,
designed for use in almost all the unmanned level crossings in the country.
1.2 Project Overview:
An embedded system is a combination of software and hardware to perform a
dedicated task. Some of the main devices used in embedded products are Microprocessors and
Microcontrollers.
Microprocessors are commonly referred to as general purpose processors as they
simply accept the inputs, process it and give the output. In contrast, a microcontroller not only accepts
the data as inputs but also manipulates it, interfaces the data with various devices, controls the data
and thus finally gives the result.
3
Presents the topic embedded systems. It explains the about what is embedded systems,
Presents the hardware description. It deals with the block diagram of the project and
explains the purpose of each block. In the same chapter the explanation of microcontroller, power
supplies, DC motor, limit switch, buzzer and IR transmitter and IR receiver are considered.
Chapter 4
Presents the software description. It explains the implementation of the project using PIC
C Compiler software.
Chapter 5 Presents the project Circuit diagram.
Chapter 6
Chapter 7
a few dedicated functions", and is thus appropriate to call "embedded". A modern example of
embedded system is shown in fig: 2.1.
One of the first recognizably modern embedded systems was the Apollo Guidance
Computer, developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At the project's
inception, the Apollo guidance computer was considered the riskiest item in the Apollo project as it
employed the then newly developed monolithic integrated circuits to reduce the size and weight. An
early mass-produced embedded system was the Autonetics D-17 guidance computer for
the Minuteman missile, released in 1961. It was built from transistor logic and had a hard disk for
main memory. When the Minuteman II went into production in 1966, the D-17 was replaced with a
new computer that was the first high-volume use of integrated circuits.
2.1.2 Tools:
Embedded development makes up a small fraction of total programming. There's also a
large number of embedded architectures, unlike the PC world where 1 instruction set rules, and the
UNIX world where there's only 3 or 4 major ones. This means that the tools are more expensive. It
also means that they're lowering featured, and less developed. On a major embedded project, at some
point you will almost always find a compiler bug of some sort.
Debugging tools are another issue. Since you can't always run general programs on
your embedded processor, you can't always run a debugger on it. This makes fixing your program
difficult. Special hardware such as JTAG ports can overcome this issue in part. However, if you stop
on a breakpoint when your system is controlling real world hardware (such as a motor), permanent
equipment damage can occur. As a result, people doing embedded programming quickly become
masters at using serial IO channels and error message style debugging.
2.1.3 Resources:
To save costs, embedded systems frequently have the cheapest processors that can do
the job. This means your programs need to be written as efficiently as possible. When dealing with
large data sets, issues like memory cache misses that never matter in PC programming can hurt you.
Luckily, this won't happen too often- use reasonably efficient algorithms to start, and optimize only
when necessary. Of course, normal profilers won't work well, due to the same reason debuggers don't
work well.
Memory is also an issue. For the same cost savings reasons, embedded systems usually
have the least memory they can get away with. That means their algorithms must be memory efficient
(unlike in PC programs, you will frequently sacrifice processor time for memory, rather than the
7
reverse). It also means you can't afford to leak memory. Embedded applications generally use
deterministic memory techniques and avoid the default "new" and "malloc" functions, so that leaks
can be found and eliminated more easily. Other resources programmers expect may not even exist.
For example, most embedded processors do not have hardware FPUs (Floating-Point Processing
Unit). These resources either need to be emulated in software, or avoided altogether.
2.1.4 Real Time Issues:
Embedded systems frequently control hardware, and must be able to respond to them
in real time. Failure to do so could cause inaccuracy in measurements, or even damage hardware such
as motors. This is made even more difficult by the lack of resources available. Almost all embedded
systems need to be able to prioritize some tasks over others, and to be able to put off/skip low priority
tasks such as UI in favor of high priority tasks like hardware control.
2.2 Need For Embedded Systems:
The uses of embedded systems are virtually limitless, because every day new products
are introduced to the market that utilizes embedded computers in novel ways. In recent years,
hardware such as microprocessors, microcontrollers, and FPGA chips have become much cheaper. So
when implementing a new form of control, it's wiser to just buy the generic chip and write your own
custom software for it. Producing a custom-made chip to handle a particular task or set of tasks costs
far more time and money. Many embedded computers even come with extensive libraries, so that
"writing your own software" becomes a very trivial task indeed. From an implementation viewpoint,
there is a major difference between a computer and an embedded system. Embedded systems are often
required to provide Real-Time response. The main elements that make embedded systems unique are
its reliability and ease in debugging.
2.2.1 Debugging:
Embedded debugging may be performed at different levels, depending on the facilities
available. From simplest to most sophisticate they can be roughly grouped into the following areas:
Interactive resident debugging, using the simple shell provided by the embedded operating
system (e.g. Forth and Basic)
External debugging using logging or serial port output to trace operation using either a
monitor in flash or using a debug server like the Remedy Debugger which even works for
heterogeneous multi core systems.
An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via a
JTAG or Nexus interface. This allows the operation of the microprocessor to be controlled
externally, but is typically restricted to specific debugging capabilities in the processor.
An in-circuit emulator replaces the microprocessor with a simulated equivalent, providing full
control over all aspects of the microprocessor.
A complete emulator provides a simulation of all aspects of the hardware, allowing all of it to
be controlled and modified and allowing debugging on a normal PC.
Unless restricted to external debugging, the programmer can typically load and run software
through the tools, view the code running in the processor, and start or stop its operation. The
view of the code may be as assembly code or source-code.
Because an embedded system is often composed of a wide variety of elements, the
debugging strategy may vary. For instance, debugging a software(and microprocessor) centric
embedded system is different from debugging an embedded system where most of the processing is
performed by peripherals (DSP, FPGA, co-processor). An increasing number of embedded systems
today use more than one single processor core. A common problem with multi-core development is
the proper synchronization of software execution. In such a case, the embedded system design may
wish to check the data traffic on the busses between the processor cores, which requires very lowlevel debugging, at signal/bus level, with a logic analyzer, for instance.
2.2.2 Reliability:
Embedded systems often reside in machines that are expected to run continuously for
years without errors and in some cases recover by themselves if an error occurs. Therefore the
software is usually developed and tested more carefully than that for personal computers, and
unreliable mechanical moving parts such as disk drives, switches or buttons are avoided.
Specific reliability issues may include:
The system cannot safely be shut down for repair, or it is too inaccessible to repair. Examples
include space systems, undersea cables, navigational beacons, bore-hole systems, and
automobiles.
9
The system must be kept running for safety reasons. "Limp modes" are less tolerable. Often
backup s is selected by an operator. Examples include aircraft navigation, reactor control
systems, safety-critical chemical factory controls, train signals, engines on single-engine
aircraft.
The system will lose large amounts of money when shut down: Telephone switches, factory
controls, bridge and elevator controls, funds transfer and market making, automated sales and
service.
A variety of techniques are used, sometimes in combination, to recover from errors
both software bugs such as memory leaks, and also soft errors in the hardware:
Watchdog timer that resets the computer unless the software periodically notifies the watchdog
Designing with a Trusted Computing Base (TCB) architecture[6] ensures a highly secure &
reliable system environment
In this design, the software simply has a loop. The loop calls subroutines, each of which
manages a part of the hardware or software.
Some embedded systems are predominantly interrupt controlled. This means that tasks
performed by the system are triggered by different kinds of events. An interrupt could be generated
for example by a timer in a predefined frequency, or by a serial port controller receiving a byte. These
kinds of systems are used if event handlers need low latency and the event handlers are short and
simple.
Usually these kinds of systems run a simple task in a main loop also, but this task is not
very sensitive to unexpected delays. Sometimes the interrupt handler will add longer tasks to a queue
structure. Later, after the interrupt handler has finished, these tasks are executed by the main loop.
This method brings the system close to a multitasking kernel with discrete processes.
Cooperative Multitasking:
Primitive Multitasking:
In this type of system, a low-level piece of code switches between tasks or threads
based on a timer (connected to an interrupt). This is the level at which the system is generally
considered to have an "operating system" kernel. Depending on how much functionality is required, it
introduces more or less of the complexities of managing multiple tasks running conceptually in
parallel.
As any code can potentially damage the data of another task (except in larger systems
using an MMU) programs must be carefully designed and tested, and access to shared data must be
controlled by some synchronization strategy, such as message queues, semaphores or a non-blocking
synchronization scheme.
Because of these complexities, it is common for organizations to buy a real-time
operating system, allowing the application programmers to concentrate on device functionality rather
than operating system services, at least for large systems; smaller systems often cannot afford the
11
overhead associated with a generic real time system, due to limitations regarding memory size,
performance, and/or battery life.
the operating system kernel allocates memory and switches the CPU to different threads of execution.
User mode processes implement major functions such as file systems, network interfaces, etc.
In general, microkernels succeed when the task switching and intertask communication
is fast, and fail when they are slow. Exokernels communicate efficiently by normal subroutine calls.
The hardware and all the software in the system are available to, and extensible by application
programmers. Based on performance, functionality, requirement the embedded systems are divided
into three categories:
2.3.2 Stand Alone Embedded System:
These systems takes the input in the form of electrical signals from transducers or
commands from human beings such as pressing of a button etc.., process them and produces desired
output. This entire process of taking input, processing it and giving output is done in standalone mode.
Such embedded systems comes under stand alone embedded systems
Eg: microwave oven, air conditioner etc..
2.3.3 Real-time embedded systems:
Embedded systems which are used to perform a specific task or operation in a specific
time period those systems are called as real-time embedded systems. There are two types of real-time
embedded systems.
not done in a particular time period then there is a cause of damage to the entire equipment.
Eg: consider a system in which we have to open a valve within 30 milliseconds. If this valve is
not opened in 30 ms this may cause damage to the entire equipment. So in such cases we use
embedded systems for doing automatic operations.
12
Eg: Consider a TV remote control system, if the remote control takes a few milliseconds delay it will
not cause damage either to the TV or to the remote control. These systems which will not cause damage when
they are not operated at considerable time period those systems comes under soft real-time embedded systems.
Consider a web camera that is connected to the computer with internet can be used to
spread communication like sending pictures, images, videos etc.., to another computer
with internet connection throughout anywhere in the world.
the desktop of your computer which is connected to internet. This gives an alerting message with
image on to the desktop of your computer, and then you can open the door lock just by clicking the
mouse. Fig: 2.2 show the network communications in embedded systems.
13
Among these Microcontroller is of low cost processor and one of the main advantage of
microcontrollers is, the components such as memory, serial communication interfaces, analog
to digital converters etc.., all these are built on a single chip. The numbers of external
components that are connected to it are very less according to the application.
Microprocessors are more powerful than microcontrollers. They are used in major applications
with a number of tasking requirements. But the microprocessor requires many external
components like memory, serial communication, hard disk, input output ports etc.., so the
power consumption is also very high when compared to microcontrollers.
Digital signal processing is used mainly for the applications that particularly involved with
processing of signals
14
Fig2.6: Robot
In critical industries where human presence is avoided there we can use robots which
are programmed to do a specific operation.
15
3.1 Introduction:
In this chapter the block diagram of the project and design aspect of independent
modules are considered. Block diagram is shown in fig: 3.1:
FIG 3.1: Block diagram of Microcontroller based automatic railway gate control system
The main blocks of this project are:
1. Microcontroller (16F877A)
2. Reset button
3. Crystal oscillator
4. Regulated power supply (RPS)
17
5. Led indicator
6. IR Transmitter and receiver module
7. DC motor with driver
8. Limit switch
9. Buzzer
3.2 Micro controller:
3.2.2 Description:
Introduction to PIC Microcontrollers:
PIC stands for Peripheral Interface Controller given by Microchip Technology to
identify its single-chip microcontrollers. These devices have been very successful in 8-bit
microcontrollers. The main reason is that Microchip Technology has continuously upgraded the
device architecture and added needed peripherals to the microcontroller to suit customers'
requirements. The development tools such as assembler and simulator are freely available on the
internet at www.microchip.com .
Low - end PIC Architectures:
Microchip PIC microcontrollers are available in various types. When PIC
microcontroller MCU was first available from General Instruments in early 1980's, the
microcontroller consisted of a simple processor executing 12-bit wide instructions with basic I/O
functions. These devices are known as low-end architectures. They have limited program memory and
are meant for applications requiring simple interface functions and small program & data memories.
Some of the low-end device numbers are
19
12C5XX
16C5X
16C505
Mid range PIC Architectures:
Mid range PIC architectures are built by upgrading low-end architectures with more number of
peripherals, more number of registers and more data/program memory. Some of the mid-range
devices are
16C6X
16C7X
16F87X
Program memory type is indicated by an alphabet.
C = EPROM, F = Flash, RC = Mask ROM
Popularity of the PIC microcontrollers is due to the following factors.
1. Speed: Harvard Architecture, RISC architecture, 1 instruction cycle = 4 clock cycles.
2. Instruction set simplicity: The instruction set consists of just 35 instructions (as opposed to 111
instructions for 8051).
3. Power-on-reset and brown-out reset. Brown-out-reset means when the power supply goes
below a specified voltage (say 4V), it causes PIC to reset; hence malfunction is avoided. A
watch dog timer (user programmable) resets the processor if the software/program ever
malfunctions and deviates from its normal operation.
4. PIC microcontroller has four optional clock sources.
Power-on reset
Watchdog timer
Peripheral features:
21
Timer0: 8-bit timer/counter with 8-bit prescaler can be incremented during sleep via external
crystal/clock
Timer2:8-bit timer/counter with 8-bit period register prescaler and post scalar.
Analogue comparators
In-circuit programming
Internal oscillator
22
Pin 11, 12 and31, 32 are used for voltage supply Vdd(+)and Vss(-)
PIC 16F877A Specification:
RAM
368 bytes
EEPROM
256 bytes
8k words
Operating Frequency
DC to 20MHz
I/O port
Port A,B,C,D,E
This is the specification for PIC16F877A from Microchip. A single microcontroller
which is very brilliant and useful is also very easy to be assembled, program and also the price is very
cheap. It cost less than 10 dollar. The good thing is that single unit can be purchased at that 10 dollar
price. Unlike some other Integrated Circuit that must be bought at a minimum order quantity such as
1000 units or 2000 units or else you wont be able to purchase it.
One unit of PIC16F877A microcontroller can be programmed and erased so many times.
Some said about 10 000 times. If you are doing programming and downloading your code into the
PIC 20 times a day that means you can do that for 500 days which is more than a year!
The erasing time is almost unnoticeable because once new program are loaded into the PIC,
the old program will automatically be erased immediately. During my time of Degree study, I did not
use PIC but I use other type of microcontroller. I have to wait for about 15 to 30 minutes to erase the
EEPROM before I can load a new program and test the microcontroller. One day I can only modify
my code and test it for less than 10 times. 10x15 minutes = 150 minutes.
RAM:
24
PIC16F877A already made with 368 bytes of Random Access Memory (RAM) inside it. Any
temporary variable storage that we wrote in our program will be stored inside the RAM. Using this
microcontroller you dont need to buy any external RAM.
EEPROM:
256 bytes of EEPROM are available also inside this microcontroller. This is very useful to
store information such as PIN Number, Serial Number and so on. Using EEPROM is very important
because data stored inside EEPROM will be retained when power supply is turn off. RAM did not
store data permanently. Data inside RAM is not retained when power supply is turn off.
The size of program code that can be stored is about 8k words inside PIC16F877A ROM. 1
word size is 14 bits. By using the free version of the CCS C compiler only 2k words of program can
be written and compiled. To write 8k words of C program you have to purchase the original CCS C
compiler and it cost less than 700 dollar.
Crystal oscillator:
The crystal oscillator speed that can be connected to the PIC microcontroller range from DC to
20Mhz. Using the CCS C compiler normally 20Mhz oscillator will be used and the price is very
cheap. The 20 MHz crystal oscillator should be connected with about 22pF capacitor. Please refer to
my circuit schematic.
There are 5 input/output ports on PIC microcontroller namely port A, port B, port C, port D
and port E. Each port has different function. Most of them can be used as I/O port.
25
term is most commonly applied to electrical energy supplies, less often to mechanical ones, and rarely
to others.
A power supply may include a power distribution system as well as primary or
secondary sources of energy such as
Conversion of one form of electrical power to another desired form and voltage, typically
involving converting AC line voltage to a well-regulated lower-voltage DC for electronic devices.
Low voltage, low power DC power supply units are commonly integrated with the devices they
supply, such as computers and household electronics.
Batteries.
Solar power.
Generators or alternators.
26
Fig 3.3.3 Circuit diagram of Regulated Power Supply with Led connection
27
230V AC MAINS
TRANSFORMER
BRIDGE RECTIFIER(DIODES)
CAPACITOR
RESISTOR
Transformation: The process of transforming energy from one device to another is called
transformation. For transforming energy we use transformers.
Transformers:
A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors without changing its frequency. 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 mutual
induction.
If a load is connected to the secondary, an electric current will flow in the secondary
winding and electrical energy will be transferred from the primary circuit through the transformer to
the load. This field is made up from lines of force and has the same shape as a bar magnet.
If the current is increased, the lines of force move outwards from the coil. If the current
is reduced, the lines of force move inwards.
If another coil is placed adjacent to the first coil then, as the field moves out or in, the
moving lines of force will "cut" the turns of the second coil. As it does this, a voltage is induced in the
second coil. With the 50 Hz AC mains supply, this will happen 50 times a second. This is called
MUTUAL INDUCTION and forms the basis of the transformer.
28
The input coil is called the PRIMARY WINDING; the output coil is the
SECONDARY WINDING. Fig: 3.3.4 shows step-down transformer.
For example, if the secondary has half the primary turns; the secondary will have half
the primary voltage.
Another example is if the primary has 5000 turns and the secondary has 500 turns, then
the turns ratio is 10:1.
If the primary voltage is 240 volts then the secondary voltage will be x 10 smaller = 24
volts. Assuming a perfect transformer, the power provided by the primary must equal the power taken
by a load on the secondary. If a 24-watt lamp is connected across a 24 volt secondary, then the
primary must supply 24 watts.
To aid magnetic coupling between primary and secondary, the coils are wound on a
metal CORE. Since the primary would induce power, called EDDY CURRENTS, into this core, the
core is LAMINATED. This means that it is made up from metal sheets insulated from each other.
Transformers to work at higher frequencies have an iron dust core or no core at all.
Note that the transformer only works on AC, which has a constantly changing current
and moving field. DC has a steady current and therefore a steady field and there would be no
induction.
29
Some transformers have an electrostatic screen between primary and secondary. This is
to prevent some types of interference being fed from the equipment down into the mains supply, or in
the other direction. Transformers are sometimes used for IMPEDANCE MATCHING.
We can use the transformers as step up or step down.
Step Up transformer:
In case of step up transformer, primary windings are every less compared to secondary
winding. Because of having more turns secondary winding accepts more energy, and it releases more
voltage at the output side.
Step down transformer:
Incase of step down transformer, Primary winding induces more flux than the
secondary winding, and secondary winding is having less number of turns because of that it accepts
less number of flux, and releases less amount of voltage.
Battery power supply:
A battery is a type of linear power supply that offers benefits that traditional lineoperated power supplies lack: mobility, portability and reliability. A battery consists of multiple
electrochemical cells connected to provide the voltage desired. Fig: 3.3.5 shows Hi-Watt 9V battery
following voltages: 1.5, 3, 6, 9, 22.5, 45, and 90. During the discharge of a carbon-zinc battery, the
zinc metal is converted to a zinc salt in the electrolyte, and magnesium dioxide is reduced at the
carbon electrode. These actions establish a voltage of approximately 1.5 V.
The lead-acid storage battery may be used. This battery is rechargeable; it consists of
lead and lead/dioxide electrodes which are immersed in sulfuric acid. When fully charged, this type of
battery has a 2.06-2.14 V potential (A 12 volt car battery uses 6 cells in series). During discharge, the
lead is converted to lead sulfate and the sulfuric acid is converted to water. When the battery is
charging, the lead sulfate is converted back to lead and lead dioxide A nickel-cadmium battery has
become more popular in recent years. This battery cell is completely sealed and rechargeable. The
electrolyte is not involved in the electrode reaction, making the voltage constant over the span of the
batteries long service life. During the charging process, nickel oxide is oxidized to its higher oxidation
state and cadmium oxide is reduced. The nickel-cadmium batteries have many benefits. They can be
stored both charged and uncharged. They have a long service life, high current availabilities, constant
voltage, and the ability to be recharged. Fig: 3.3.6 shows pencil battery of 1.5V.
31
supplies and as detectors of radio signals. Rectifiers may be made of solid-state diodes, vacuum tube
diodes, mercury arc valves, and other components.
A device that it can perform the opposite function (converting DC to AC) is known as
an inverter.
When only one diode is used to rectify AC (by blocking the negative or positive
portion of the waveform), the difference between the term diode and the term rectifier is merely one
of usage, i.e., the term rectifier describes a diode that is being used to convert AC to DC. Almost all
rectifiers comprise a number of diodes in a specific arrangement for more efficiently converting AC to
DC than is possible with only one diode. Before the development of silicon semiconductor rectifiers,
vacuum tube diodes and copper (I) oxide or selenium rectifier stacks were used.
Bridge full wave rectifier:
The Bridge rectifier circuit is shown in fig: 3.3.7, which converts an ac voltage to dc
voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the
figure. The circuit has four diodes connected to form a bridge. The ac input voltage is applied to the
diagonally opposite ends of the bridge. The load resistance is connected between the other two ends of
the bridge.
For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load
resistance RL and hence the load current flows through RL.
For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct
whereas, D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load
resistance RL and hence the current flows through RL in the same direction as in the previous half
cycle. Thus a bi-directional wave is converted into a unidirectional wave.
Input
Output
32
33
34
Units of Capacitance:
Microfarad (F) 1F = 1/1,000,000 = 0.000001 = 10-6 F
Nanofarad (nF) 1nF = 1/1,000,000,000 = 0.000000001 = 10-9 F
Pico farad (pF) 1pF = 1/1,000,000,000,000 = 0.000000000001 = 10-12 F
Operation of Capacitor:
Think of water flowing through a pipe. If we imagine a capacitor as being a storage
tank with an inlet and an outlet pipe, it is possible to show approximately how an electronic capacitor
works.
First, let's consider the case of a "coupling capacitor" where the capacitor is used to
connect a signal from one part of a circuit to another but without allowing any direct current to flow.
So a coupling capacitor allows "alternating current" to pass through because the ball
valve doesn't get a chance to close as the waves go up and down. However, a steady current quickly
fills the tank so that all flow stops.
A capacitor will pass alternating current but (apart from an initial surge) it will not pass
d.c.
Regulation:
The process of converting a varying voltage to a constant regulated voltage is called as
regulation. For the process of regulation we use voltage regulators.
Voltage Regulator:
36
A voltage regulator (also called a regulator) with only three terminals appears to be a
simple device, but it is in fact a very complex integrated circuit. It converts a varying input voltage
into a constant regulated output voltage. Voltage Regulators are available in a variety of outputs like
5V, 6V, 9V, 12V and 15V. The LM78XX series of voltage regulators are designed for positive input.
For applications requiring negative input, the LM79XX series is used. Using a pair of voltagedivider resistors can increase the output voltage of a regulator circuit.
It is not possible to obtain a voltage lower than the stated rating. You cannot use a 12V
regulator to make a 5V power supply. Voltage regulators are very robust. These can withstand overcurrent draw due to short circuits and also over-heating. In both cases, the regulator will cut off before
any damage occurs. The only way to destroy a regulator is to apply reverse voltage to its input.
Reverse polarity destroys the regulator almost instantly. Fig: 3.3.11 shows voltage regulator.
Resistors are elements of electrical networks and electronic circuits and are ubiquitous in most
electronic equipment. Practical resistors can be made of various compounds and films, as well as
resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).
The primary characteristics of a resistor are the resistance, the tolerance, maximum working
voltage and the power rating. Other characteristics include temperature coefficient, noise, and
37
inductance. Less well-known is critical resistance, the value below which power dissipation limits the
maximum permitted current flow, and above which the limit is applied voltage. Critical resistance is
determined by the design, materials and dimensions of the resistor.
Resistors can be made to control the flow of current, to work as Voltage dividers, to
dissipate power and it can shape electrical waves when used in combination of other components.
Basic unit is ohms.
Theory of operation:
Ohm's law:
The behavior of an ideal resistor is dictated by the relationship specified in Ohm's law:
V = IR
Ohm's law states that the voltage (V) across a resistor is proportional to the current (I)
through it where the constant of proportionality is the resistance (R).
Power dissipation:
The power dissipated by a resistor (or the equivalent resistance of a resistor network) is
calculated using the following:
38
3.4. LED:
A light-emitting diode (LED) is a semiconductor light source. LEDs are used as
indicator lamps in many devices, and are increasingly used for lighting. Introduced as a practical
electronic component in 1962, early LEDs emitted low-intensity red light, but modern versions are
available across the visible, ultraviolet and infrared wavelengths, with very high brightness. The
internal structure and parts of a led are shown in figures 3.4.1 and 3.4.2 respectively.
Working:
39
The structure of the LED light is completely different than that of the light bulb.
Amazingly, the LED has a simple and strong structure. The light-emitting semiconductor material is
what determines the LED's color. The LED is based on the semiconductor diode.
When a diode is forward biased (switched on), electrons are able to recombine with
holes within the device, releasing energy in the form of photons. This effect is called
electroluminescence and the color of the light (corresponding to the energy of the photon) is
determined by the energy gap of the semiconductor. An LED is usually small in area (less than
1 mm2), and integrated optical components are used to shape its radiation pattern and assist in
reflection. LEDs present many advantages over incandescent light sources including lower energy
consumption, longer lifetime, improved robustness, smaller size, faster switching, and greater
durability and reliability. However, they are relatively expensive and require more precise current and
heat management than traditional light sources. Current LED products for general lighting are more
expensive to buy than fluorescent lamp sources of comparable output. They also enjoy use in
applications as diverse as replacements for traditional light sources in automotive lighting
(particularly indicators) and in traffic signals. The compact size of LEDs has allowed new text and
video displays and sensors to be developed, while their high switching rates are useful in advanced
communications technology. The electrical symbol and polarities of led are shown in fig: 3.4.3.
High-efficiency
40
No UV Rays
Visual signal application where the light goes more or less directly from the LED to the human
eye, to convey a message or meaning.
Illumination where LED light is reflected from object to give visual response of these objects.
Generate light for measuring and interacting with processes that do not involve the human
visual system.
3.5 IR sensor:
IR transmitter and receiver
Basics of IR transmitter and receiver transmitter and receiver are commonly used in engineering
projects for remote control of objects. In particularly, in Robotic system uses transmitter and receiver.
Here i would like to describe the basics if IR transmitter and receiver
Basics of IR transmitter:
41
An electroluminescent IR LED is a product which requires care in use. IR LEDs are fabricated from
narrow band hetero structures with energy gap from 0.25 to 0.4 eV. Infra red transmitter emits IR rays
in planar wave front manner. Even though infra red rays spread in all directions, it propagates along
straight line in forward direction. IR rays have the characteristics of producing secondary wavelets
when it collides with any obstacles in its path. This property of IR is used here.
When IR rays gets emitted from LED, it moves in the direction it is angled. When any obstacle
interferes in the path, the IR rays get cut and it produces secondary wavelets which propagates mostly
in return direction or in a direction opposite to that of the primary waves, which produces the net
result like reflection of IR rays.
Basics of IR receiver:
Infrared photo receiver is a two terminal PN junction device, which operates in a reverse bias. It has a
small transparent window, which allows light to strike the PN junction. A photodiode is a type of
photo detector capable of converting light into either current or voltage, depending upon the mode of
operation. Most photodiodes will look similar to a light emitting diode. They will have two leads, or
wires, coming from the bottom. The shorter end of the two is the cathode, while the longer end is the
anode.
A photodiode consists of PN junction or PIN structure. When a photon of sufficient energy strikes the
diode, it excites an electron thereby creating a mobile electron and a positively charged electron hole.
42
If the absorption occurs in the junction's depletion region, or one diffusion length away from it, these
carriers are swept from the junction by the built-in field of the depletion region. Thus holes move
toward the anode, and electrons toward the cathode, and a photocurrent is produced.
43
The transmitter section consists of a 555 timer IC functioning in astable mode. It is wired as
shown in figure. The output from astable mode is fed to an IR LED via resistor which limits its
operating current. Infrared LED in the transmitter section emits IR radiation which is focused by a
plastic lens (optics) in to a narrow beam.
2. Receiver section:
The receiver section consists of a silicon phototransistor to convert the infrared radiation to an
electric current. It responds only to the rapidly pulsing signal created by the transmitter, and filters out
slowly changing infrared radiation from ambient light. The receiver section comprises an infrared
receiver module, and a led indicator. When the signals are interrupted, the IR Led goes off after a few
seconds depending upon the value of RC combination.
We can increase the distance between the IR transmitter and receiver just by placing the lens
between them. After connecting the IR transmitter and receiver circuit, we can get the output by
applying 6V Power supply to the circuit. We can use this circuit with any application very simply. For
example a buzzer circuit is placed at the output of IR circuit, when the signals are interrupted, the
buzzer produces sound. Both the transmitter and receiver parts can be mounted on a single bread
board or PCB. The infrared receiver must be placed behind the IR Led to avoid false indication due to
infrared leakage. An object moving nearby actually reflects the IR rays emitted by the IR Led.
Photo Diodes:
A photodiode is a semiconductor diode that functions as a photo detector. Photodiodes are
packaged with either a window or optical fiber connection, to let in the light to the sensitive part of the
device. They may also be used without a window to detect vacuum UV or X-rays.
A phototransistor is in essence nothing more than a bipolar transistor that is encased in a
transparent case so that light can reach the base-collector junction. The phototransistor works like a
photodiode, but with a much higher responsivity for light, because the electrons that are generated by
photons in the base-collector junction are injected into the base, and this current is then amplified by
the transistor operation.
44
Principle of operation:
A photodiode is a p-n junction or p-i-n structure. When a photon of sufficient energy
strikes the diode, it excites an electron thereby creating a mobile electron and a positively charged
electron hole. If the absorption occurs in the junction's depletion region, or one diffusion length away
from it, these carriers are swept from the junction by the built-in field of the depletion region,
producing a photocurrent.
Photodiodes can be used under either zero bias (photovoltaic mode) or reverse bias
(photoconductive mode). In zero bias, light falling on the diode causes a current across the device,
leading to forward bias which in turn induces "dark current" in the opposite direction to the
photocurrent. This is called the photovoltaic effect, and is the basis for solar cells in fact; a solar cell is
just a large number of big photodiodes. Reverse bias induces only little current (known as saturation
or back current) along its direction.
But a more important effect of reverse bias is widening of the depletion layer (therefore
expanding the reaction volume) and strengthening the photocurrent. Circuits based on this effect are
more sensitive to light than ones based on the photovoltaic effect and also tend to have lower
capacitance, which improves the speed of their time response. On the other hand, the photovoltaic
mode tends to exhibit less electronic noise.
Avalanche photodiodes have a similar structure, but they are operated with much higher
reverse bias. This allows each photo-generated carrier to be multiplied by avalanche breakdown,
resulting in internal gain within the photodiode, which increases the effective responsivity of the
device.
Features:
45
46
2. The Vr also introduces noise current, which reduces the S/N ratio. Therefore, a reverse bias is
recommended for higher bandwidth applications and/or applications where a wide dynamic
range is required.
3. A PN photodiode is more suitable for lower light applications because it allows for unbiased
operation.
electrical
energy
from
mechanical
energy,
is
accomplished
by
an alternator, generator or dynamo. Many types of electric motors can be run as generators, and vice
versa. The input of a DC motor is current/voltage and its output is torque (speed).
47
Operation:
The DC motor you will find in modem industrial applications operates very similarly to the
simple DC motor described earlier in this chapter. Figure 12-9 shows an electrical diagram of a simple
DC motor. Notice that the DC voltage is applied directly to the field winding and the brushes. The
armature and the field are both shown as a coil of wire. In later diagrams, a field resistor will be added
in series with the field to control the motor speed.
When voltage is applied to the motor, current begins to flow through the field coil from the negative
terminal to the positive terminal. This sets up a strong magnetic field in the field winding. Current
also begins to flow through the brushes into a commutator segment and then through an armature coil.
The current continues to flow through the coil back to the brush that is attached to other end of the
coil and returns to the DC power source. The current flowing in the armature coil sets up a strong
magnetic field in the armature.
the brushes. As an individual commutator segment moves under the brush connected to positive
voltage, it will become positive, and when it moves under a brush connected to negative voltage it
will become negative. In this way, the commutator segments continually change polarity from positive
to negative. Since the commutator segments are connected to the ends of the wires that make up the
field winding in the armature, it causes the magnetic field in the armature to change polarity
continually from north pole to south pole. The commutator segments and brushes are aligned in such a
way that the switch in polarity of the armature coincides with the location of the armature's magnetic
field and the field winding's magnetic field. The switching action is timed so that the armature will not
lock up magnetically with the field. Instead the magnetic fields tend to build on each other and
provide additional torque to keep the motor shaft rotating.
When the voltage is de-energized to the motor, the magnetic fields in the armature and the
field winding will quickly diminish and the armature shaft's speed will begin to drop to zero. If
voltage is applied to the motor again, the magnetic fields will strengthen and the armature will begin
to rotate again.
Types of DC motors:
1. DC Shunt Motor,
2. DC Series Motor,
3. DC Long Shunt Motor (Compound)
4. DC Short Shunt Motor (Compound)
The rotational energy that you get from any motor is usually the battle between two magnetic fields
chasing each other. The DC motor has magnetic poles and an armature, to which DC electricity is fed,
The Magnetic Poles are electromagnets, and when they are energized, they produce a strong magnetic
field around them, and the armature which is given power with a commutator, constantly repels the
poles, and therefore rotates.
In a 2 pole DC Motor, the armature will have two separate sets of windings, connected to a
commutator at the end of the shaft that are in constant touch with carbon brushes. The brushes are
static, and the commutator rotate and as the portions of the commutator touching the respective
positive or negative polarity brush will energize the respective part of the armature with the respective
polarity. It is usually arranged in such a way that the armature and the poles are always repelling.
The general idea of a DC Motor is, the stronger the Field Current, the stronger the magnetic field, and
faster the rotation of the armature. When the armature revolves between the poles, the magnetic field
of the poles induce power in the armature conductors, and some electricity is generated in the
armature, which is called back emf, and it acts as a resistance for the armature. Generally an armature
has resistance of less than 1 Ohm, and powering it with heavy voltages of Direct Current could result
in immediate short circuits. This back emf helps us there.
When an armature is loaded on a DC Shunt Motor, the speed naturally reduces, and therefore the back
emf reduces, which allows more armatures current to flow. This results in more armature field, and
therefore it results in torque.
50
51
DC Motor Driver:
The L293 and L293D are quadruple high-current half-H drivers. The L293 is designed to
provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293D is
designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V. Both
devices are designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping
motors, as well as other high-current/high-voltage loads in positive-supply applications.
All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a
Darlington transistor sink and a pseudo-Darlington source. Drivers are enabled in pairs, with drivers 1
and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN.When an enable input is high, the
associated drivers are enabled and their outputs are active and in phase with their inputs.
52
When the enable input is low, those drivers are disabled and their outputs are off and in the
high-impedance state. With the proper data inputs, each pair of drivers forms a full-H (or bridge)
reversible drive suitable for solenoid or motor applications. On the L293, external high-speed output
clamp diodes should be used for inductive transient suppression. A VCC1 terminal, separate from
VCC2, is provided for the logic inputs to minimize device power dissipation. The L293and L293D are
characterized for operation from 0C to 70C.
53
Applications of DC Motors:
1. Electric Train: A kind of DC motor called the DC Series Motor is used in Electric Trains. The DC
Series Motors have the property to deliver more power when they are loaded more. So the more the
people get on a train, the more powerful the train becomes.
2. Elevators: The best bidirectional motors are DC motors. They are used in elevators. Compound DC
Motors are used for this application.
54
3. PC Fans, CD ROM Drives, and Hard Drives: All these things need motors, very miniature motors,
with great precision. AC motors can never imagine any application in these places.
4. Starter Motors in Automobiles: An automobile battery supplies DC, so a DC motor is best suited
here. Also, you cannot start an engine with a small sized AC motor,
5. Electrical Machines Lab in Colleges.
Limit Switches & Limit Switch Information: A mechanical limit switch interlocks a
mechanical motion or position with an electrical circuit. A good starting point for limit-switch
selection is contact arrangement. The most common limit switch is the single-pole contact block with
one NO and one NC set of contacts; however, limit switches are available with up to four poles.
55
Limit switches also are available with time-delayed contact transfer. This type is useful in
detecting jams that cause the limit switch to remain actuated beyond a predetermined time interval.
Other limit switch contact arrangements include neutral-position and two-step. Limit switches
feature a neutral-position or center-off type transfers one set of contacts with movement of the lever in
one direction. Lever movement in the opposite direction transfers the other set of contacts. Limit
switches with a two-step arrangement, a small movement of the lever transfers one set of contacts, and
further lever movement in the same direction transfers the other set of contacts.
Maintained-contact limit switches require a second definite reset motion. These limit switches
are primarily used with reciprocating actuators, or where position memory or manual reset is required.
Spring-return limit switches automatically reset when actuating force is removed.
WORKING:
Limit switch is one type Of " Contact Sensor" , In that there is Normally Open Contact &
Normally Close Contact, In limit switch there is Plunger it is Directly Connected to NO & NC
Contact if we press the plunger NO contact become NC & NC contact become NO, Working Principle
same as Contactor ( DOL starter ) main difference is in contactor There is Coil to attract the Plunger
But In Limit Switch Plunger is Operated Mechanically. Limit Switches is used mainly for Safety
Purpose & to take Feed back for PLC in Automation industries........
Limit switches are classified based on their actuating mechanism and application. The limit
switch may be operated by mechanical power, electricity, pneumatic or hydraulic. The types of limit
switches are many and some of them are: linear limit switch, programmable limit switch, plunger
switch, limit micro switch, mechanical SPST switch, solid state DPDT switch, SPST mechanical
switch, low cost roller carriage, limit switch DPDT, mechanical switch SPST, programmable type,
electrical high limit switch, micro limit switch, etc.
56
Actuator heads: Fixed type with back and forward motion or rotary type.
Casing: The limit switch assembly is enclosed in casings that have to conform to NEMA standards.
They can be made of plastic or metal.
The actuating levers are available in various types like lever type spring return; push roller
spring return, side push vertical roller, and side push horizontal roller. A careful selection must be
done depending on the type of design and requirement.
Torque force to operate (maximum and minimum): This attribute ensures that the machine
operator does not trip the limit switch due to accidental contact.
Travel to operate: This refers to the maximum distance the actuator has to depress before the limit
switch operates.
The maximum throw of the limit switch.
Travel to reset: The distance or length of travel for the switch to reset to its initial state and work
again. After the contact pressure is removed, the limit switch returns back to its initial position.
Applications:
Limit switches are used in automatic machine tools to control the carriage and toll slide movement.
They are typically used in capstan and turret lathes, radial drills, milling and boring machines,
grinding machines, honing, gun drilling, crank shaft and cam grinding machines, heat treatment
equipment, machine door guards, etc.
They are also used in scissor lifts, conveyor systems, transfer machines, material packing and
handling equipment, elevators, escalators, hoists and cranes, industrial trucks and tractors, cranes and
hoists, overhead door limit switches, and general safety equipment.
57
3.8 Buzzer
Basically, the sound source of a piezoelectric sound component is a piezoelectric diaphragm. A
piezoelectric diaphragm consists of a piezoelectric ceramic plate which has electrodes on both sides
and a metal plate (brass or stainless steel, etc.). A piezoelectric ceramic plate is attached to a metal
plate with adhesives. Applying D.C. voltage between electrodes of a piezoelectric diaphragm causes
mechanical distortion due to the piezoelectric effect. For a misshaped piezoelectric element, the
distortion of the piezoelectric element expands in a radial direction. And the piezoelectric diaphragm
bends toward the direction. The metal plate bonded to the piezoelectric element does not expand.
Conversely, when the piezoelectric element shrinks, the piezoelectric diaphragm bends in the direction
Thus, when AC voltage is applied across electrodes, the bending is repeated, producing sound waves
in the air.
To interface a buzzer the standard transistor interfacing circuit is used. Note that if a different
power supply is used for the buzzer, the 0V rails of each power supply must be connected to provide a
common reference.
If a battery is used as the power supply, it is worth remembering that piezo sounders
draw much less current than buzzers. Buzzers also just have one tone, whereas a
piezo sounder is able to create sounds of many different tones.
To switch on buzzer -high 1
To switch off buzzer -low 1
59
60
them into your Express PCB directory. At this point start the program and get ready to setup the
workspace to suit your style.
Click View -> Options. In this menu, setup the units for mm or in depending on
how you think, and click see through the top copper layer at the bottom. The standard color scheme
of red and green is generally used but it is not as pleasing as red and blue.
4.1.2 The Interface:
When a project is first started you will be greeted with a yellow outline. This yellow
outline is the dimension of the PCB. Typically after positioning of parts and traces, move them to their
final position and then crop the PCB to the correct size. However, in designing a board with a certain
size constraint, crop the PCB to the correct size before starting.
Fig: 4.1 show the toolbar in which the each button has the following functions:
The select tool: It is fairly obvious what this does. It allows you to move
and manipulate
parts. When this tool is selected the top toolbar will show buttons to move traces to the top /
bottom copper layer, and rotate buttons.
The place pad: button allows you to place small soldier pads which are useful for board
connections or if a part is not in the part library but the part dimensions are available. When
this tool is selected the top toolbar will give you a large selection of round holes, square holes
and surface mount pads.
The place component: tool allows you to select a component from the top toolbar and then by
clicking in the workspace places that component in the orientation chosen using the buttons
next to the component list. The components can always be rotated afterwards with the select
tool if the orientation is wrong.
61
The place trace: tool allows you to place a solid trace on the board of varying thicknesses. The
top toolbar allows you to select the top or bottom layer to place the trace on.
The Insert Corner in trace: button does exactly what it says. When this tool is selected,
clicking on a trace will insert a corner which can be moved to route around components and
other traces.
The remove a trace button is not very important since the delete key will achieve the same
result.
Some projects like power supplies or amps can benefit from having a solid plane to use
for ground. In power supplies this can reduce noise, and in amps it minimizes the distance between
parts and their ground connections, and keeps the ground signal as simple as possible. However,
care must be taken with stubborn chips such as the TPA6120 amplifier from TI. The TPA6120
datasheet specifies not to run a ground plane under the pins or signal traces of this chip as the
capacitance generated could effect performance negatively.
4.2 PIC Compiler:
PIC compiler is software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which is to be
dumped into the microcontroller for further processing. PIC compiler also supports C language code.
Its important that you know C language for microcontroller which is commonly
known as Embedded C. As we are going to use PIC Compiler, hence we also call it PIC C. The PCB,
PCM, and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for 14-bitopcodes, and
PCH is for 16-bit opcode PIC microcontrollers. Due to many similarities, all three compilers are
covered in this reference manual. Features and limitations that apply to only specific microcontrollers
are indicated within. These compilers are specifically designed to meet the unique needs of the PIC
microcontroller. This allows developers to quickly design applications software in a more readable,
high-level language. When compared to a more traditional C compiler, PCB, PCM, and PCH have
some limitations. As an example of the limitations, function recursion is not allowed.
This is due to the fact that the PIC has no stack to push variables onto, and also
because of the way the compilers optimize the code. The compilers can efficiently implement normal
C constructs, input/output operations, and bit twiddling operations. All normal C data types are
supported along with pointers to constant arrays, fixed point decimal, and arrays of bits.
PIC C is not much different from a normal C program. If you know assembly, writing
a C program is not a crisis. In PIC, we will have a main function, in which all your application
specific work will be defined. In case of embedded C, you do not have any operating system running
in there. So you have to make sure that your program or main file should never exit. This can be done
with the help of simple while (1) or for (;;) loop as they are going to run infinitely.
We have to add header file for controller you are using, otherwise you will not be able
to access registers related to peripherals.
63
4.3 Proteus:
Proteus is software which accepts only hex files. Once the machine code is converted
into hex code, that hex code has to be dumped into the microcontroller and this is done by the Proteus.
Proteus is a programmer which itself contains a microcontroller in it other than the one which is to be
programmed. This microcontroller has a program in it written in such a way that it accepts the hex file
from the pic compiler and dumps this hex file into the microcontroller which is to be programmed. As
the Proteus programmer requires power supply to be operated, this power supply is given from the
power supply circuit designed and connected to the microcontroller in proteus. The program which is
to be dumped in to the microcontroller is edited in proteus and is compiled and executed to check any
errors and hence after the successful compilation of the program the program is dumped in to the
microcontroller using a dumper.
4.4 Procedural steps for compilation, simulation and dumping:
4.4.1 Compilation and simulation steps:
For PIC microcontroller, PIC C compiler is used for compilation. The compilation
steps are as follows:
You will be prompted to choose a name for the new project, so create a separate folder where
all the files of your project will be stored, choose a name and click save.
64
Click Project, New, and something the box named 'Text1' is where your code should be
written later.
Now you have to click 'File, Save as' and choose a file name for your source code ending with
the letter '.c'. You can name as 'project.c' for example and click save. Then you have to add
this file to your project work.
65
66
You can then start to write the source code in the window titled 'project.c' then before testing
your source code; you have to compile your source code, and correct eventual syntax errors.
Fig 4.4: Picture of checking errors and warnings using PIC C compiler
This is how we compile a program for checking errors and hence the compiled program is
saved in the file where we initiated the program.
67
After compilation, next step is simulation. Here first circuit is designed in Express PCB
using Proteus 7 software and then simulation takes place followed by dumping. The simulation steps
are as follows:
Now it displays PCB where circuit is designed using microcontroller. To design circuit
components are required. So click on component option.
10. Now click on letter p, then under that select PIC16F877A ,other components related to the
project and click OK. The PIC 16F877A will be called your 'Target device, which is the final
destination of your source code.
68
2. Select Tools option and click on Check Communication for establishing a connection as shown
in below window
69
Fig 4.7: Picture of checking communications before dumping program into microcontroller
3. After connecting the dumper properly to the microcontroller kit the window is appeared as shown
below.
70
4. Again by selecting the Tools option and clicking on Check Communication the microcontroller
gets recognized by the dumper and hence the window is as shown below.
72
73
5. Import the program which is .hex file from the saved location by selecting File option and
clicking on Import Hex as shown in below window.
74
75
6. After clicking on Import Hex option we need to browse the location of our program and click the
prog.hex and click on open for dumping the program into the microcontroller.
76
77
78
79
Advantages:
1. Automatic opening and closing of railway gate.
2. Automatic sensing of arrival and departure of train.
3. Efficient and low cost design.
4. Low power consumption.
Disadvantages:
Applications:
This system can be used in real time to control any gate openings and door opening systems.
CHAPTER 7: RESULTS
7.1 Result:
80
81
REFERENCES
The sites which were used while doing this project:
1. www.wikipedia.com
2. www.allaboutcircuits.com
3. www.microchip.com
4. www.howstuffworks.com
Books referred:
1. Raj kamal Microcontrollers Architecture, Programming, Interfacing and System Design.
2. Mazidi and Mazidi Embedded Systems.
3. PCB Design Tutorial David.L.Jones.
4. PIC Microcontroller Manual Microchip.
5. Embedded C Michael.J.Pont.
APPENDIX
82
Program Code:
The program code which is dumped in the microcontroller of our project is shown
below.
#include <16F877A.h>
#use
// Microcontroller used
delay (clock=20000000)
// clock frequency
int open_flag = 0;
void main()
{
//Health Check of Microcontroller
output_high(PIN_D2);
output_high(PIN_D3);
delay_ms(1000);
output_low(PIN_D2);
output_low(PIN_D3);
delay_ms(1000);
output_high(PIN_D2);
output_high(PIN_D3);
delay_ms(1000);
output_low(PIN_D2);
output_low(PIN_D3);
delay_ms(1000);
close_gate();
while(1)
{
if(input(PIN_A0)) //IR_1
{
output_high(PIN_D2);
//Motor_1(200,0);
if(open_flag == 1)
{
open_gate();
open_flag = 0;
83
}
}
if(input(PIN_B7)) //IR_2
{
output_high(PIN_D3);
//Motor_1(200,1);
close_gate();
}
output_low(PIN_D2);
output_low(PIN_D3);
delay_ms(1000);
}
}
84