Design and Implementation of a Microcontroller Based Automatic Gate

5 downloads 345 Views 199KB Size Report
The microcontroller based automatic gate control is a better solution for the ... systems also work as an automatic lock, when the lock button is pressed that is ...
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] Segun 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 supplement human facilities and ability to observe, communicate, remember, calculate or reason and take certain decision when necessary. In a search for making Electronics Applications think, act and respond like Human, the proposed system was developed. The proposed system attempts to make life more interesting by reducing unnecessary waste of man-power by employing microcontrollers. There are changes everyday, many things are being discovered due to technology advancement, different devices are been discovered to solve many of human’s problems. One of these problems can be solved using a microcontroller to control devices thereby reducing the work of man. In addition to this development, human being is not resting in an effort to find a solution to all of there problems and this project is in no exception.

Microcontroller based automatic gate is an alternative to a manually controlled gate which is laborious, frustrating, costly and energy consuming. Many are the devices which a microcontroller can be used in making some of these are GSM phones, PDAs, Sound systems, Pumping machines, Robots e.t.c. The proposed system comprises of several component, the first is the sensors which detect any vehicle near it and send a signal to another set of component. It is interesting to note that this device can perform some things like opening automatically, closing automatically, lock up totally when the car park is filled up and no vehicle can gain an entrance into the park. This work can be employed in public car parks, markets, libraries, hotel, homes and anywhere that require the use of gates. It has many advantages over a manned gate in the sense that it eliminate stress and salary of a gateman, 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 is concerned with the design and construction of a microcontroller based automatic gate. The proposed system monitors and controls a gate, we employed a microcontroller that accepts data value from the interfacing circuit and take an instant decision.

The proposed system on sensing an interruption from an infrared receiver, opens and closes the gates, also it can deny an entrance or exit from the gate by just pressing of a button. These are the constituents of the automatic gate system; a sensor unit, a trigger circuitry, microcontroller module, gate control unit and a power supply unit. The 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 transmitted and receiver, sense and send a signal to the system, at one end an infrared transmitter is fitted which transmit a signal to another infrared receiver so if this signal is interrupted by a vehicle, there is an input to the trigger circuit which is held HIGH. The trigger circuit serves as an ADC (Analog-to Digital converter), which produces a HIGH when the beam is interrupted. The trigger circuitry sends a signal to the interface unit, which is made up of Programmable

Input/Output controller (PIO). The embedded software causes the microprocessor to send a signal to the output port of the interface unit in other to activate the dc motor to control the opening and closing of the gate. A LOW will never activate the gate, false triggering is taken care of by circuitry. There is a DC power unit supplier which supplies the required voltage by the system and this is constant because the microcontroller 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 divided into two modules which are hardware and software design considerations.

This is made up of two relays and two electric motor. It accepts the output from the sensor circuit. It is in such a way that only when there is an output from the sensing unit, the trigger circuitry goes HIGH else, it remain at LOW

2.2 Hardware Design Considerations 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 automobile through the entrance and the exit of the gate only if the infrared beam is interrupted from either side. Each pair of the sensor is separated by a reasonable distance such that the passage of a person or other moving object cannot obstruct the sensor pair separation. Also the height of the sensor is considered only the body of the vehicle can interrupt the light beam of the sensor and not the tires or its windows.

2.5 PIC16F84 Microcontrollers The PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. The PIC chips have two separate 'data' busses, one for instructions and one for everything else. Instructions are essentially in ROM and dedicates the microcontroller to doing one task, RAM is where variables are stored, there is very 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 following meaning: 2.8 PIC16F84 Clock/Instructions Clock is microcontroller's main starter, and is obtained from an external component called an "oscillator”. The small instruction set, (37 instructions), and the 14 bit size of instructions lead to a number of compromises. One cannot have two registers specified in a single instruction. Each register takes 7 bits to specify its address, but one also have to specify the instruction number and what to do. By comparing a microcontroller with a time clock, the "clock" would then be a ticking sound we hear from the time clock. In that case, oscillator could be compared to a spring that is wound so time clock can run. Also, force used to wind the time clock can be compared to an electrical supply.

Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not overlap. These four clocks make up one instruction cycle (also called machine cycle) during which one instruction is executed. Execution of instruction starts by calling an instruction that is next in string. Instruction is called from program memory on every Q1 and is written in instruction register on Q4. Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On the following diagram we can see the relationship between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks Q1-Q4. Program counter (PC) holds information about the address of the next instruction.

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 5V at the output (pin 3), input voltage on pin 1 of LM7805 should be between 7V through 24V. Depending on current consumption of device we will use the appropriate type of voltage stabilizer LM7805. There are several versions of LM7805. For current consumption of up to 1A we should use the version in TO-220 case with the capability of additional cooling. If the total consumption is 50mA, we can use 78L05 (stabilizer version in small TO - 92 packaging for current of up to 100mA). 2.9 Control Unit The gate control unit consists of these components: NPN transistor, Diodes, Electric motors, and Relays. The NPN transistors are arranged in such that a pair (NPN) controls the opening of the gate through the operation of relays and motors and the other pair reverses the polarity of the motor by rotating it in the opposite direction to close the gate. There is a time interval of 5.0 Seconds between the openings of the gate. The software in the PIC varies this time interval. The arrangement of the diodes serves to protect the transistors from reverse biased polarity and the resistors serve to improve switching time. The motor is used to control the opening and closing of gate. The electric (DC) motor used is the one that have the ability to rotate in both directions simply by reversing the polarity.

3. SOFTWARE DESIGN CONSIDERATIONS Designing software for the automatic gate was not a very simple task. In the development cycle of a Microcontroller-based system, decision is made on the parts of the system to be realized in hardware and the parts to be implemented in software. The software is decomposed into modules so that each module can be individually tested as a unit and debugged before the modules are integrated and tested as a software system in order to ensure that the software design meets its specification [10]. The program for the system is written in Assembly Language for speed optimization. Assembly code represents halfway position between machine code and a high level language. The assembly code is usually a mnemonic code derived from the instruction itself, i.e. LDA is derived from Load the Accumulator. Assembly code is thus very easy to remember and use when writing programs. When entering an assembly program into a microcontroller, the assembly code must first be converted into machine code. For short programs, of a few lines, this is relatively easy and usually requires that the Programmer has next to him or her, a table which contains the assembly mnemonics and the equivalent machine code. This technique is known as Hand Assembly and is limited to programs of about one hundred lines or less. 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 RESULT The stages involved in the construction of the proposed system are: design validation, bread board and vero board implementations, testing, packaging and modeling. 4.1 Design Validation The best workable circuit was devised taking into consideration some parameters such as signal levels between components, compatibility of signals and components, cost and availability of components. The program to direct the operation of the gate was written in the Assembly Language and electronically written into the PIC (16F84A). A very important advantage to design validation is the use of software packages such as ORCAD PSPICE to simulate the design before implementation. 4.2 Breadboard Implementation The circuit design was implemented on the bread board after validating it on circuit simulator. During this stage, various parameters like voltage drops, input impedance, base current, pulse width were measured in order to ensure good result. The circuit design was tested on the board and found to be working properly before soldering.

The test instrument used for examining logic signal, testing and troubleshooting applications in the course of the project were: digital multimeter, logic probe, and oscilloscope. Testing involve troubleshooting the hardware system to detect, isolate and correct internal or external fault such as malfunction in the internal circuitry, input or output shorted to ground or Vcc input or output open circuited, short between two pins broken wire, poor of dry connection, bent or broken pins, or an IC and faulty ICs socket. The hardware system was properly tested because the software cannot work when the hardware is not functioning properly. The testing of the entire circuit was carried out in stages 1. Each of the components was first tested using the multimeter in order to check for their state of performance and accurate values. 2. In the connection of each component on the Vero board was then tested. This was done in other to carry out the continuity, which is meant for proper connection of the circuit and to detect any wrong connection. 3. The sensor unit circuitry was tested to ascertain the degree of sensitivity. A small prototype car (object was placed between the two pairs of the infrared diodes to obstruct light rays. The voltage levels at the output were observed with the aid to a digital multimeter. The result is shown in the table 2. Table 2: Voltage levels of the sensor unit

4.3 Vero Board Implementation After proper verification on the breadboard, the design was transferred to a Vero board for permanent construction. The various module of the design were soldered and arranged on the Vero board such that each module can be easily identified. Before proper soldering, component layout plan was drawn paying particular attention to minimizing the distances involve between point to be connected and the prevention of the overcrowding. All other components were then connected up to implement the circuit.

Before the result was obtained, the variable resistor was adjusted to obtain the output voltages. 4. The output of the trigger circuitry was tested by connecting LED across to check if it lit or not a lit indicate the presence of a low logic as shown in table 3 below.

4.4 Testing and Result

Table 3: Trigger circuit logic level

Test Without object With object Object removed

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

30

Result 0.65V 5.00V 0.70V

Sensor voltage levels V01 V02

Output logic. F

0.70 0.70 5.00 5.00

0 0 0 1

0.70 5.00 0.70 5.00

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 applying logic 1 or 0 to point A and B of the circuit. When logic 1 is applied to point A, The motor rotate in a clockwise direction while logic 1 at point B changes the direction of the motor. Logic 0 at both points will never activate the motor. The result is shown in table 4.

6. RECOMMENDATIONS The following suggestions should be considered in carrying out further work on this study: A more effective and sensitive sensor is recommended for better performance. For example a sensor such as RADAR sensor that could detect contraband goods in vehicles. The achievement of a full automation, a real time system may be employed and a biometric scanner that will provide a proper monitoring and security purposes. This shall be helpful in tracking the identity of the vehicle before the system is activated.

Table 4: Gate Control circuit truth table

6.

A

B

0 0 1 1

0 1 0 1

Motor direction Inactive Anticlockwise Clockwise Inactive

After the proper testing of the peripherals and found to be working perfectly, the entire circuit was tested. Series of programs {software} were written and tested before the working program was fully achieved. The circuit worked perfectly as designed. The display unit was also observed during the testing.

REFERENCES [1] [2] [3]

Packaging

[4]

After proper testing was conducted, the packaging of the design into a model and casing was considered. The connecting wires were properly connected and well insulated, also the wires were well packed and bounded together.

[5] [6]

5. CONCLUSION [7] The use of microcontroller system has been achieved in the design and implementation of this project. This project can be easily tailored to any electric gate and all kinds and all forms of control, which has the use of sensors. For an effective design of this kind of system it is imperative to have a good grasp of the basic sensor characteristic, microcontroller characteristic and assembly language principles. The infrared photodiode which was used as a sensor serves as a transducer for vehicle detection while the programming language is fundamental to software design based on the system requirement, specification and operation of the system. The automatic gate designed can be used in companies, public car park, domestic parking lot and automobile terminal, where little or no form of security is required.

[8] [9]

[11] [12] [13] [14] [15] [16] [17] [18]

31

Rafiquzzaman, M (2011) 'Microcontroller Theory and Applications with the PIC 18F" Di Jasio, L (2008) "Programming 32-Bit Microcontrollers in C: Exploring the PIC 32 (Embedded Technology)" Wilmshurst, T (2009) "DESIGNING Embedded Systems with PIC Microcontrollers: Principles and Applications" Reese, R.B., Bruce, Bruce, J. W. And Jone, B. A. (2008) "Microcontrollers: From Assembly Language to PC using the PIC Family" Morton, J (2005) "The PIC Microcontroller: Your Personal Introductory Course" Huang, H and Chartrand, L (2004) "PIC Microcontroller" An Introductory to Software and Hardware Interfacing" Sandhu, H (2008) "Making PIC Microcontroller Instruments and Controllers" Bates, M. P (2011) "PIC Microcontrollers: An Introduction to Microelectronics" Van Dam, B (2008) "PIC Microcontrollers: 50 Projects for Beginners and Experts" [10] Prof. A.O Odinma, Software Engineering Lecture Notes Prof. A.O Odinma and Engr. O. Shoewu, Computer Aided Application Lecture Notes Engr. Lawrence Oborkhale, Microprocessor and Applications Lecture Notes Engr. Balogun, Semiconductor Devices Lecture Notes http://www.privatedoor.com http://www.access-automation.co.uk http://www.gateautomation.com http://www.twystedpair.com http://www.howstuffswork.com

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

Suggest Documents