Beruflich Dokumente
Kultur Dokumente
INSTITUTE OF COMPUTER SCIENCE DESIGN AND CONSTRUCTION OF A DIGITAL VISITOR COUNTER BY NATUKUNDA PHIONAH 2009/BCE/050/PS A Project Report Submitted to the Institute of Computer Science for the Study Leading to a Project in Partial Fulfillment of the Requirements for the Award of Bachelor of Science (Honours) Degree in Computer Engineering of Mbarara University of Science and Technology. . Supervisor MR.KIGOZI JOHN
April, 2012
Declaration
I hereby declare that this work is as a result of my tireless effort, and has never been published or presented by any student to any institution for an award. NATUKUNDA PHIONAH Signature Date:
ii
Approval
This Project Report has been submitted for examination with the approval of my project supervisor. Signed: ... Date: .. Mr. John Kigozi
iii
Dedication I dedicate this work to mum Ms.Kyomugisha Angela, Mildred, Denis and the lord the creator.
iv
Acknowledgement
All appreciation goes to the Maker of all that is in the Heavens and on the Earth. I sincerely acknowledge my group mates Baker, Eldon and Walker for their tireless efforts to make this project a success. I also extend my sincere gratitude to my friends especially Gilbert for his guidance and encouragement. Special thanks go to my mother Angela for her unending love and support she gave me both financially and spiritually .I highly obliged to my supervisor Mr. Kigozi John for his noble spontaneous and timely help that carried me throughout my endeavor and finally made a grand success. I also extend my sincere thanks my uncles Dr.apollo, Muhumuza, my aunt Ruth and my best friend Mildred for their support. Special thanks go to Mr.Ongako Denis for his support during the course of my project. I also thank the staff and ICS administration at MUST for support they organised to equip me with the knowledge to carry out my proposed Project I did and for all the cooperation and friendly treatment given to me during project. I also appreciate Mr. Waligo George who spared his time to teach me the basics of the hardware I used for my project. Thank you for guiding me and above all the technical skills you shared with me.
Contents
Declaration.......................................................................................................................................ii Approval.........................................................................................................................................iii Dedication.......................................................................................................................................iv Acknowledgement...........................................................................................................................v Contents..........................................................................................................................................vi List of acronyms........................................................................................................................vii Abstract.........................................................................................................................................viii CHAPTER ONE..............................................................................................................................1 1.0 INTRODUCTION/BACKGROUND........................................................................................1 1.1 Problem statement......................................................................................................................1 1.2 Objectives of the study...............................................................................................................1 1.2.0 General objectives...................................................................................................................1 1.2.1 Specific objectives..................................................................................................................1 1.1.1 Significance to the researcher.................................................................................................2 1.2.2 Significance to the users.........................................................................................................2 1.4 Scope:.........................................................................................................................................2 1.4.0 Physical scope:........................................................................................................................2 1.4.1Technical scope:.......................................................................................................................2 CHAPTER TWO.............................................................................................................................3 LITERATURE REVIEW...............................................................................................................3 CHAPTER THREE.........................................................................................................................4 3.0 Methodology..............................................................................................................................4 3.1 Assumptions made.....................................................................................................................5 3.1.1 Formulas used in data collection.............................................................................................6 CHAPTER FOUR............................................................................................................................6 4.0 OPERATION OF THE SYSTEM.............................................................................................6 The circuit diagram..........................................................................................................................7 4.1 Hardware specifications.............................................................................................................7 4.1.0 MSP430G2231 MICROCONTROLLER...............................................................................7 vi
4.1.1 Resistors..................................................................................................................................8 4.1.2 Seven segment LED Display..................................................................................................8 4.1.3 Bread board.............................................................................................................................9 4.1.4 UTP wires...............................................................................................................................9 4.1.5 Power Supply..........................................................................................................................9 4.2 software specifications...............................................................................................................9 4.3 Flow charts...............................................................................................................................10 General flow chart. ........................................................................................................................10 Detailed flow chart.........................................................................................................................11 4.4 system output...........................................................................................................................12 4.4.0 Seven segment display..........................................................................................................12 The seven-segment display truth table.......................................................................................13 4.5 EXPLANATION OF THE SYSTEM......................................................................................13 4.5.0 The code................................................................................................................................14 CHAPTER FIVE...........................................................................................................................17 5.1 Evaluations...............................................................................................................................17 5.1.0 Limitations on the system.....................................................................................................17 5.1.1 Problems encountered...........................................................................................................17 5.1.2 Recommendations ................................................................................................................18 5.1.3 Conclusion ...........................................................................................................................18 References:.....................................................................................................................................19 The seven-segment display truth table.......................................................................................20 Gantt chart..................................................................................................................................21 Project Budget............................................................................................................................21 Appendix 2................................................................................................................................23
List of figures:
Figure 1:microntroller......................................................................................................................7 Figure 2:seven segment display.......................................................................................................8 Figure 3:snapshot of functional system.........................................................................................13 List of tables: Table 1:seven segment truth table..................................................................................................12
List of acronyms
GND VCC MC Ground Voltage Source Microcontroller vii
Mbarara University of science and Laboratory Integrated Circuit. Mixed Signal Processor. Dual Inline Package. Light Emitting Diode.
Abstract
The clamor for the need to stop Uganda as a dumping ground for all electronic devices, and the development of the talented Ugandan engineers, has gingered this sincere research. viii
Bearing in mind that, the field of microelectronics and embedded systems is very large, only control and security systems have gained interest, and has prompted the design and construction of a Digital Counter. A digital visitor counter is a device used for counting the occurrence of an event. The main purpose of designing and constructing this device is to provide an alternative to and perhaps a more effective way of counting the occurrence of an event. The device is able to count the number of visitors entering a conference hall or auditorium as long as the push button is pressed. Physical counting is important because of the need to know how much in order to cater for how many. This report presents a very simple, interactive, secured and low-cost design. The design uses a MSP430G2231 microcontroller chip. The microcontroller is interfaced with a seven segment display. Microcontroller was programmed using Microchips Code Composer Studio.
ix
III. To develop a c program to run the system. IV. To program a microcontroller to display the values on the seven segment display.
1.4.1Technical scope:
This microcontroller based digital visitor counter system used code composer studio as the programming platform and C programming language.
,India ,from the University of Mumbia designed a Microprocessor based Digital Visitor Counter.. These students were trying to solve the problem of physically counting people by standard manually tallying which involved human auditors that were at a great expense. However their digital counter system comprised of LCD 162 inch in the display unit and LDRs (Light dependent resistors) which was used as an analogue input whose resistance decreases with increasing incident light intensity .They used microcontroller of Atmel AT89 family which had an 8-bit RISC (Reduced Instruction Set Computer) processor. However for our case we designed a low cost and simplified digital visitor counter which had a digital input, which is a push button switch that will connect two points in a circuit when you press it. When the push button is open (un pressed) there is no connection between the two legs of the button so the pin is connected to ground(thru a pull down resistor) and we read a LOW when the button is closed(pressed) it makes connection between its legs connecting the pin to 5v, The display unit will be comprised of a seven segment display since seven-segment LED displays are reliable in a sense that they can be used in a wide range of environments from very hot to well 3
below freezing because there is no liquid inside the unit to freeze as there is in the LCDs display, a LED display can operate at low temperature. Also LED displays in general are extremely efficient over LCDs because it lowers power supply requirements and reduces on the cost of using devices. We are going to use Texas Instruments MSP430 family of a microcontroller of which has Ultralow-power architecture, 16-bit RISC (Reduced Instruction Set Computer) processor and von-Neumann architecture will enhance the speed to execute instructions which is far much better than used microcontroller of Atmel AT89 family for a simplified circuit.
Design
Implementation
Project planning and feasibility study This phase involved determining how to come up with the system, its viability, cost analysis, building the schedule for development and determining if there is a potential market for the system. Requirements Analysis & System Analysis This phase involved determining what functionality the system should have, components involved Design This phase mainly involved a systematic development of the system and assembly of all the hardware components in conjunction with the software to come up with algorithms for different individual parts to produce a working system. Testing & Evaluation Under this phase various tests were done to test whether all the hardware and software were working as planned for and possible improvements or adjustments were still done on Implementation This involves building the whole project.
c) I also considered visitors only entering the conference or auditorium hall. d) I also assumed that the visitor enters only once. Once you move out you will be counted again (thus paying for another ticket).
Switch button which is used as a sensor, it was used to count visitors entering. When a switch button is open, a low logic flows from ground to the microcontroller, P1.7. This is an interrupt input of the microcontroller so when the low logic is received, an interrupt occurs and the microcontroller goes to the counting routine, it checks if a switch button that sends the logic by checking the logic state of P1.7 since switch button was pressed and the low logic also flowed to P1.7 therefore the microcontroller increases the counter register.
MSP430G2231 microcontroller is a simple 16-bit microcontroller with a compact and economical CPU containing only 27 instructions and 16 registers. It operates under Low supply voltage range -1.8v to3.6 v
Figure 1
4.1.1 Resistors
The resistor is a two-terminal electronic component that produces a voltage across its terminals. One resistor is between the switch and power supply and another resistor is between the power supply and the seven segment display to regulate the amount of current flowing to the microcontroller.
Figure 5
10
11
When using the common anode that means sending 0s to the cathode of the LEDs. a, b, c, d, e, f, and g are the driver signals to the display elements. I first mapped each LED in the seven segment display to the ports on the microcontroller as shown below. P1.0 P1.1 P1.2 P1.3 P1.4 a b c d e P1.5 P1.6 P1.7 button(Input,0) f g switch
12
1 1 0 0 0 0 0 1 0 0
0 0 1 1 0 0 0 1 0 0
0 0 0 1 1 1 0 1 0 1
0 1 0 0 1 0 0 1 0 1
0 1 1 0 0 0 0 0 0 0
0 1 0 0 0 1 1 0 0 0
0 1 0 0 1 0 0 0 0 0
0x40 0x4F 0x24 0x30 0x19 0x12 0x02 0x78 0x00 0x18
Figure 3
14
15
16
Difficulties in balancing the course units, tests and assignments plus project research.
5.1.2 Recommendations
A bidirectional system can be made to cater for both people entering and leaving a certain hall, place and stadiums. Infrared sensors can be used instead of a switch to provide better results. A more elaborate system or access control system can be built that can store several PIN codes of different devices at different locations in a protected zone, to a central server for coordination, surveillance, and crime detection purposes as well as monitoring visitor circulation.
5.1.3 Conclusion
Digital visitor counter was successfully designed and constructed. The working project use the switch button as its input and microntroller msp4302231 monitors the state of the number of people entering the auditorium that press the switch and displays then on the seven segment display. Knowledge regarding architecture of microcontroller and how different types of displays work in real time applications were gained. . Detailed knowledge of programming language C, Code composer compiler, seven segment, switches and hardware and software interfaces for microcontroller was gained. The project has helped us get more knowledge on the embedded systems design, know how to come up with the good flow charts that will aid us to fully explain to the stakeholders who will be interested in the project .
18
All goals were achieved and the complete working project can work as a part of a conference facility in an auditorium.
References:
Books [1] John H. Davies,microcontroller basics [2] Morris Mano-Digital and Computer Logic Design [3] Boylestad, Nashelsky, Electronic Devices & Circuit Theory [4]Chuck Hollenbeck, Beginner's Guide to Embedded C Programming Volume 2: Timers, Interrupts, Communication, Displays and More. Publisher: CreateSpace. Published: 2009-06-22 [6] Hassan Parchizadeh, PIC Projects: A Practical Approach. Branislay Vuksanovic. [7] Dogan Ibrahim, Microcontroller Based Applied Digital Control. . Publisher: Wiley. Published: 2006-05-08. Encyclopedia Entry: [8] www.wikipedia.org,November2011 Online: [9] http://www.scribd.com/doc/38586802/Ir-Based-Bidirectional-VisitorCounter, November 2011. [10] http://www.softwaretestingprocess.com/testmethod/waterfall.html 19
Decim al Numb er 0 1 2 3 4 5 6 7 8 9
Hex
1 1 0 0 0 0 0 1 0 0
0 0 1 1 0 0 0 1 0 0
0 0 0 1 1 1 0 1 0 1
0 1 0 0 1 0 0 1 0 1
0 1 1 0 0 0 0 0 0 0
0 1 0 0 0 1 1 0 0 0
0 1 0 0 1 0 0 0 0 0
0x40 0x4F 0x24 0x30 0x19 0x12 0x02 0x78 0x00 0x18 20
Gantt chart
ACTIVITY Feasibility Study Data Collection Analysis Proposal Writing Design Coding&Valida tion Implementatio n Report Writing Presentation 2011 OCT NOV DEC JAN FEB 2012 MAR APR MAY
Project Budget
ITEM 7-segment display Circuit Board Computer(laptop) IR-LED Stationary(manil as printing binding) 21 papers, and QUANTITY 3 2 1 10 UNIT PRICE (Ush) 1000 7000 1000000 3000 40000 AMOUNT (Ush) 3000 14000 1000000 30000 40000
1 1
25000 200000
25000 200000
Total
1277000
1311000
22
Appendix 2
Main Program Code
/****************************************************************************** * Third year project: * Title: Design and Construction of Digital visitor counter * ***************************************************************************/
#include "msp430g2231.h" int counter = 0; int display[10]= {0x40,0x4F,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10}; int input = 0; int mask = 0x80; void _switch(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; //stop the watch dog timer P1DIR = 0x7F; //port direction bit0 to Bit6 are outputs, bit 7 is input P1OUT = 0x00;
while(21) {
23
input = P1IN; //read the port 1. This reads all the bits of the port 1 input &= mask; //This makes sure we are dealing with bit 7 check int mask = 0x80 if(input==0x00) //if the switch has not been pressed, if bit7 has logic 0 { _delay_cycles(5000); //delay to make sure the result is consistent if(input==0) // check again { P1OUT = display[counter]; //send output to the 7 segment } } //--------------------------------------------------------------------------/*************************************************************************** * in this below section, we are testing to see if the button has been pressed * if the button is pressed,(if bit 7 has logic 1), delay a bit to cater for * debouncing of the switch. Test a gain. If we have logic 1, that is if the * button has been pressed, increment the counter and display the value in the * current array with index counter. * */ else if(input==0x80) { _delay_cycles(5000); if(input==0x80) { counter+=1; P1OUT = display[counter]; _delay_cycles(5000000); P1OUT = 0x40; /*---If the counter reaches 9, take it back to zero to avoid unwanted output---*/ if(counter==9) {
24
counter = 0; } } } } }
25