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

Microcontroller Based Automatic Gate

The document describes the design and implementation of a microcontroller-based automatic gate. It contains sensors to detect vehicles and a microcontroller that controls opening and closing of the gate. It aims to automate gate operations to reduce labor costs and improve efficiency compared to manual gates.

Uploaded by

Andy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Microcontroller Based Automatic Gate

The document describes the design and implementation of a microcontroller-based automatic gate. It contains sensors to detect vehicles and a microcontroller that controls opening and closing of the gate. It aims to automate gate operations to reduce labor costs and improve efficiency compared to manual gates.

Uploaded by

Andy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Vol 6. No.

1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

Design and Implementation of a Microcontroller Based Automatic Gate


O. Shoewu
Department of Electronic and Computer Engineering
Lagos State University
Epe Campus, Lagos State, Nigeria.
[email protected]

O. Olatinwo
Department of Computer Engineering
Moshood Abiola Polytechnic, Abeokuta, Nigeria.
Department of Computer Science and Engineering
Ladoke Akintola University of Technology
Ogbomoso, Nigeria.
and [email protected]

ABSTRACT
The common gate found almost everywhere has a lot of problem in term of operation, it is energy consuming, stressful
and above all costly in term of paying for the man responsible for opening and closing of such gates, this then requires a
fast solution. The microcontroller based automatic gate control is a better solution for the elimination of these problems
caused by the manually controlled gates. The system monitors the gate as vehicles enter and exit the gate it is being
mounted. The microcontroller based automatic gate senses any vehicle approaching as it cut across the path of the Infra
red ray. After sensing this, the gate then automatically opens, wait for some time and closes after the time elapsed. The
systems also work as an automatic lock, when the lock button is pressed that is when it is ON the gate does not open even
if a vehicle cross the Infrared path. There is a special thing about this automatic gate I did in this project and that is it is
totally controlled by both software and hardware, if there is any need for modification it can be easily modified by
changing some part of the software since the microcontroller used can be reprogrammed, or if there is a hardware failure
this can be changed and the system will be alright..

Keywords- Microcontroller, Gate Automation, PIC16f84, Infrared Technology.

African Journal of Computing & ICT Reference Format:


O.Shoewu & O. Olatinwo (2013). Empirical Design and Implementation of a Microcontroller Based Automatic Gate.
Afr J. of Comp & ICTs. Vol 6, No. 1. Pp 21-32

1. INTRODUCTION

Microcontroller based systems refine, extend or Microcontroller based automatic gate is an alternative to
supplement human facilities and ability to observe, a manually controlled gate which is laborious, frustrating,
communicate, remember, calculate or reason and take costly and energy consuming. Many are the devices
certain decision when necessary. In a search for making which a microcontroller can be used in making some of
Electronics Applications think, act and respond like these are GSM phones, PDAs, Sound systems, Pumping
Human, the proposed system was developed. The machines, Robots e.t.c. The proposed system comprises
proposed system attempts to make life more interesting of several component, the first is the sensors which detect
by reducing unnecessary waste of man-power by any vehicle near it and send a signal to another set of
employing microcontrollers. There are changes everyday, component. It is interesting to note that this device can
many things are being discovered due to technology perform some things like opening automatically, closing
advancement, different devices are been discovered to automatically, lock up totally when the car park is filled
solve many of human’s problems. One of these problems up and no vehicle can gain an entrance into the park. This
can be solved using a microcontroller to control devices work can be employed in public car parks, markets,
thereby reducing the work of man. In addition to this libraries, hotel, homes and anywhere that require the use
development, human being is not resting in an effort to of gates. It has many advantages over a manned gate in
find a solution to all of there problems and this project is the sense that it eliminate stress and salary of a gateman,
in no exception. also it can determine what to do next when a vehicle has
come close to the gate.

21
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

2. SYSTEM OVERVIEW The proposed system on sensing an interruption from an


infrared receiver, opens and closes the gates, also it can
The proposed system is concerned with the design and deny an entrance or exit from the gate by just pressing of
construction of a microcontroller based automatic gate. a button. These are the constituents of the automatic gate
The proposed system monitors and controls a gate, we system; a sensor unit, a trigger circuitry, microcontroller
employed a microcontroller that accepts data value from module, gate control unit and a power supply unit. The
the interfacing circuit and take an instant decision. block diagram of the proposed system is below shown in
figure 1.

Fig 1: Block diagram of the proposed System.

The sensors in the system which are Infrared Input/Output controller (PIO). The embedded software
transmitted and receiver, sense and send a signal to the causes the microprocessor to send a signal to the output
system, at one end an infrared transmitter is fitted port of the interface unit in other to activate the dc
which transmit a signal to another infrared receiver so motor to control the opening and closing of the gate.
if this signal is interrupted by a vehicle, there is an
input to the trigger circuit which is held HIGH. The A LOW will never activate the gate, false triggering is
trigger circuit serves as an ADC (Analog-to Digital taken care of by circuitry. There is a DC power unit
converter), which produces a HIGH when the beam is supplier which supplies the required voltage by the
interrupted. The trigger circuitry sends a signal to the system and this is constant because the microcontroller
interface unit, which is made up of Programmable is highly sensitive to voltage supplied into it.

22
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

2.1 System Design 2.4 The Trigger Circuitry


In an attempt to implement the proposed system, it was This is made up of two relays and two electric motor. It
divided into two modules which are hardware and accepts the output from the sensor circuit. It is in such a
software design considerations. way that only when there is an output from the sensing
unit, the trigger circuitry goes HIGH else, it remain at
2.2 Hardware Design Considerations LOW
The hardware design of the proposed system consists
of: the sensor unit, the trigger circuit, the
microcontroller, the display unit, the gate control unit,
the power supply unit. These parts are discussed as
follows:

2.3 The Sensor Unit

The sensor unit consists of infrared diodes which are of


two types: A transmitter and a receiver.
The infrared transmitter has the ability to transmit
infrared beam but can only travel in a rectilinear
manner or a line of sight, which is received by the
infrared receiver at another end.

Fig 2: Infrared transmitter

Fig 4: Trigger Circuitry.


Fig 3: Infrared receiver

The circuit has the ability to detect the passage of an 2.5 PIC16F84 Microcontrollers
automobile through the entrance and the exit of the gate
only if the infrared beam is interrupted from either side. The PIC16F84 belongs to a class of 8-bit
Each pair of the sensor is separated by a reasonable microcontrollers of RISC architecture. The PIC chips
distance such that the passage of a person or other have two separate 'data' busses, one for instructions and
moving object cannot obstruct the sensor pair one for everything else. Instructions are essentially in
separation. Also the height of the sensor is considered ROM and dedicates the microcontroller to doing one
only the body of the vehicle can interrupt the light task, RAM is where variables are stored, there is very
beam of the sensor and not the tires or its windows. little RAM, a few dozen bytes, and this is reserved for
variables operated on by the program. There is also
very little 'data' storage, again a few dozen bytes, and
this is in EEPROM which is slow and clumsy to
change. EEPROM is used to hold values to be
remembered when the power is turned off

23
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

Fig 5: PIC16F84 block diagram

2.6 PIC16F84 Central Processing Unit (CPU)

The PIC16F84 CPU is one of the most powerful 8-bit microprocessor in the electronics world today. It is a sophisticated,
sequential, digital circuit that is designed to follow a sequence of instructions called a program. The program of
instructions put in memory for the microprocessor to execute makes it so versatile and flexible in that its operation can be
changed by simply changing the programs stored in memory (software) rather than rewire the electronics (hardware).It
has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and
executes the user program.

24
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

Figure 6: PIC16F84 microcontroller outline

2.7 PIC16f84 PIN Description

PIC16F84 has a total of 18 pins. It is most frequently found in a DIP18 (Dual In Package) type of case but can also be
found in Surface Mount Devices (SMD) case which is smaller from a DIP.

Figure 7: PIC16F84 PINS Layout

The Pins on PIC16F84 microcontroller have the Clock from the oscillator enters a microcontroller via
following meaning: OSC1 pin where internal circuit of a microcontroller
divides the clock into four even clocks Q1, Q2, Q3, and
2.8 PIC16F84 Clock/Instructions Q4 which do not overlap. These four clocks make up one
Clock is microcontroller's main starter, and is obtained instruction cycle (also called machine cycle) during
from an external component called an "oscillator”. The which one instruction is executed. Execution of
small instruction set, (37 instructions), and the 14 bit size instruction starts by calling an instruction that is next in
of instructions lead to a number of compromises. One string. Instruction is called from program memory on
cannot have two registers specified in a single instruction. every Q1 and is written in instruction register on Q4.
Each register takes 7 bits to specify its address, but one Decoding and execution of instruction are done between
also have to specify the instruction number and what to the next Q1 and Q4 cycles. On the following diagram we
do. By comparing a microcontroller with a time clock, can see the relationship between instruction cycle and
the "clock" would then be a ticking sound we hear from clock of the oscillator (OSC1) as well as that of internal
the time clock. In that case, oscillator could be compared clocks Q1-Q4. Program counter (PC) holds information
to a spring that is wound so time clock can run. Also, about the address of the next instruction.
force used to wind the time clock can be compared to an
electrical supply.

25
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

Table 1: PIC16F84 PINOUT Description

Note I= Input O= Output I/O = Input/Output P = Power ST = Trigger input TTL = TTL input __ = Not used

Figure 8: Clock/Instruction Cycle

2.8 Supplying the microcontroller

For a proper function of any microcontroller, it is necessary to provide a stable source of supply, a sure reset when you
turn it on and an oscillator. According to technical specifications by the manufacturer of PIC microcontroller, supply
voltage should move between 2.0V to 6.0V in all versions. The simplest solution to the source of supply is using the
voltage stabilizer LM7805 which gives stable +5V on its output. One such source is shown in the picture below.

26
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

Figure 9: Supplying PIC16F84 microcontroller

In order to function properly, or in order to have stable 3. SOFTWARE DESIGN CONSIDERATIONS


5V at the output (pin 3), input voltage on pin 1 of
LM7805 should be between 7V through 24V. Designing software for the automatic gate was not a
Depending on current consumption of device we will very simple task. In the development cycle of a
use the appropriate type of voltage stabilizer LM7805. Microcontroller-based system, decision is made on the
There are several versions of LM7805. For current parts of the system to be realized in hardware and the
consumption of up to 1A we should use the version in parts to be implemented in software. The software is
TO-220 case with the capability of additional cooling. decomposed into modules so that each module can be
If the total consumption is 50mA, we can use 78L05 individually tested as a unit and debugged before the
(stabilizer version in small TO - 92 packaging for modules are integrated and tested as a software system
current of up to 100mA). in order to ensure that the software design meets its
specification [10]. The program for the system is
2.9 Control Unit written in Assembly Language for speed optimization.
Assembly code represents halfway position between
The gate control unit consists of these components: machine code and a high level language. The assembly
NPN transistor, Diodes, Electric motors, and Relays. code is usually a mnemonic code derived from the
The NPN transistors are arranged in such that a pair instruction itself, i.e. LDA is derived from Load the
(NPN) controls the opening of the gate through the Accumulator. Assembly code is thus very easy to
operation of relays and motors and the other pair remember and use when writing programs. When
reverses the polarity of the motor by rotating it in the entering an assembly program into a microcontroller,
opposite direction to close the gate. There is a time the assembly code must first be converted into machine
interval of 5.0 Seconds between the openings of the code. For short programs, of a few lines, this is
gate. The software in the PIC varies this time interval. relatively easy and usually requires that the
The arrangement of the diodes serves to protect the Programmer has next to him or her, a table which
transistors from reverse biased polarity and the resistors contains the assembly mnemonics and the equivalent
serve to improve switching time. The motor is used to machine code.
control the opening and closing of gate. The electric
(DC) motor used is the one that have the ability to This technique is known as Hand Assembly and is
rotate in both directions simply by reversing the limited to programs of about one hundred lines or less.
polarity. In the case of longer programs, a separate program
called an assembler program is used to convert the
assembly code into machine code, which is placed
directly into the microcontroller memory. The program
modules are segmented into: the main program, the
sensor subroutine, delay subroutine, and the output
(Gate Control) subroutine.

27
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

28
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

Figure 10: Flowchart of microcontroller based automatic gate

29
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

4. SYSTEM CONSTRUCTION, TESTING AND The test instrument used for examining logic signal,
RESULT testing and troubleshooting applications in the course
of the project were: digital multimeter, logic probe, and
The stages involved in the construction of the proposed oscilloscope. Testing involve troubleshooting the
system are: design validation, bread board and vero hardware system to detect, isolate and correct internal
board implementations, testing, packaging and or external fault such as malfunction in the internal
modeling. circuitry, input or output shorted to ground or Vcc input
or output open circuited, short between two pins broken
4.1 Design Validation wire, poor of dry connection, bent or broken pins, or an
IC and faulty ICs socket. The hardware system was
The best workable circuit was devised taking into properly tested because the software cannot work when
consideration some parameters such as signal levels the hardware is not functioning properly.
between components, compatibility of signals and
components, cost and availability of components. The The testing of the entire circuit was carried out in
program to direct the operation of the gate was written stages
in the Assembly Language and electronically written 1. Each of the components was first tested using
into the PIC (16F84A). A very important advantage to the multimeter in order to check for their
design validation is the use of software packages such state of performance and accurate values.
as ORCAD PSPICE to simulate the design before 2. In the connection of each component on the
implementation. Vero board was then tested. This was done in
other to carry out the continuity, which is
4.2 Breadboard Implementation meant for proper connection of the circuit
and to detect any wrong connection.
The circuit design was implemented on the bread board 3. The sensor unit circuitry was tested to
after validating it on circuit simulator. During this ascertain the degree of sensitivity. A small
stage, various parameters like voltage drops, input prototype car (object was placed between the
impedance, base current, pulse width were measured in two pairs of the infrared diodes to obstruct
order to ensure good result. light rays. The voltage levels at the output
The circuit design was tested on the board and found to were observed with the aid to a digital
be working properly before soldering. multimeter. The result is shown in the table 2.

4.3 Vero Board Implementation Table 2: Voltage levels of the sensor unit

After proper verification on the breadboard, the design Test Result


was transferred to a Vero board for permanent Without object 0.65V
construction. The various module of the design were With object 5.00V
soldered and arranged on the Vero board such that each Object removed 0.70V
module can be easily identified.
Before proper soldering, component layout plan was Before the result was obtained, the variable
drawn paying particular attention to minimizing the resistor was adjusted to obtain the output voltages.
distances involve between point to be connected and 4. The output of the trigger circuitry was tested
the prevention of the overcrowding. All other by connecting LED across to check if it lit or
components were then connected up to implement the not a lit indicate the presence of a low logic
circuit. as shown in table 3 below.

4.4 Testing and Result Table 3: Trigger circuit logic level


With the advent of digital systems and in particular Sensor voltage levels Output logic.
microprocessor based ones, new tools and techniques V01 V02 F
have been developed for testing and to carry out
troubleshooting. Vast amount of digital information
flow, for example, over the busses of a microcomputer
0.70 0.70 0
system and even a single faulty chip or a single 0.70 5.00 0
incorrect bit can lead to a total system malfunction. It is 5.00 0.70 0
therefore of paramount importance to establish a highly 5.00 5.00 1
efficient testing techniques in other to minimize cost.

30
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

5. Also, the gate control circuit was tested by 6. RECOMMENDATIONS


applying logic 1 or 0 to point A and B of the
circuit. When logic 1 is applied to point A, The following suggestions should be considered in
The motor rotate in a clockwise direction carrying out further work on this study:
while logic 1 at point B changes the direction
of the motor. Logic 0 at both points will A more effective and sensitive sensor is
never activate the motor. The result is shown recommended for better performance. For
in table 4. example a sensor such as RADAR sensor that
could detect contraband goods in vehicles.
Table 4: Gate Control circuit truth table The achievement of a full automation, a real
time system may be employed and a
A B Motor biometric scanner that will provide a proper
direction monitoring and security purposes. This shall
0 0 Inactive be helpful in tracking the identity of the
0 1 Anticlockwise vehicle before the system is activated.
1 0 Clockwise
1 1 Inactive REFERENCES

6. After the proper testing of the peripherals and [1] Rafiquzzaman, M (2011) 'Microcontroller
found to be working perfectly, the entire Theory and Applications with the PIC 18F"
circuit was tested. Series of programs [2] Di Jasio, L (2008) "Programming 32-Bit
{software} were written and tested before the Microcontrollers in C: Exploring the PIC 32
working program was fully achieved. The (Embedded Technology)"
circuit worked perfectly as designed. The [3] Wilmshurst, T (2009) "DESIGNING
display unit was also observed during the Embedded Systems with PIC
testing. Microcontrollers: Principles and
Applications"
Packaging [4] Reese, R.B., Bruce, Bruce, J. W. And Jone,
B. A. (2008) "Microcontrollers: From
After proper testing was conducted, the packaging of Assembly Language to PC using the PIC
the design into a model and casing was considered. The Family"
connecting wires were properly connected and well [5] Morton, J (2005) "The PIC Microcontroller:
insulated, also the wires were well packed and bounded Your Personal Introductory Course"
together. [6] Huang, H and Chartrand, L (2004) "PIC
Microcontroller" An Introductory to Software
5. CONCLUSION and Hardware Interfacing"
[7] Sandhu, H (2008) "Making PIC
The use of microcontroller system has been achieved in Microcontroller Instruments and Controllers"
the design and implementation of this project. This [8] Bates, M. P (2011) "PIC Microcontrollers:
project can be easily tailored to any electric gate and all An Introduction to Microelectronics"
kinds and all forms of control, which has the use of [9] Van Dam, B (2008) "PIC Microcontrollers:
sensors. For an effective design of this kind of system it 50 Projects for Beginners and Experts" [10]
is imperative to have a good grasp of the basic sensor Prof. A.O Odinma, Software Engineering
characteristic, microcontroller characteristic and Lecture Notes
assembly language principles. The infrared photodiode [11] Prof. A.O Odinma and Engr. O. Shoewu,
which was used as a sensor serves as a transducer for Computer Aided Application Lecture Notes
vehicle detection while the programming language is [12] Engr. Lawrence Oborkhale, Microprocessor
fundamental to software design based on the system and Applications Lecture Notes
requirement, specification and operation of the system. [13] Engr. Balogun, Semiconductor Devices
The automatic gate designed can be used in companies, Lecture Notes
public car park, domestic parking lot and automobile [14] http://www.privatedoor.com
terminal, where little or no form of security is required. [15] http://www.access-automation.co.uk
[16] http://www.gateautomation.com
[17] http://www.twystedpair.com
[18] http://www.howstuffswork.com

31
Vol 6. No. 1, March 2013
African Journal of Computing & ICT

© 2013 Afr J Comp & ICT – All Rights Reserved - ISSN 2006-1781
www.ajocict.net

APPENDIX

The Main Circuit Diagram of the Proposed System

32

You might also like