Anda di halaman 1dari 34

MBARARA UNIVERSITY OF SCIENCE AND TECHNOLOGY

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

MUST technology LAB IC MSP DIP LED

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

CHAPTER ONE 1.0 INTRODUCTION/BACKGROUND


This project entitled Digital Visitor counter is designed and presented in order to count the visitors of an auditorium, hall, offices, malls, sports venue, etc. The system counts people entering the auditorium or hall or other places, where it is placed. Depending upon the interrupt from the sensors (switch), the system identifies the entry of the visitor. On the successful implementation of the system, it displays the number of visitors present in the auditorium or sports venue. This system can be economically implemented in all the places where the visitor counting is important in order to monitor the number of people in different rooms for security purposes. And also maximize the efficiency and effectiveness of employees, floor area and sales potential of an organization.

1.1 Problem statement.


Retail businesses today where accurate customer counting has become a key component as a holistic performance measurement are facing a problem to maximize profit and reduce costs .This is mainly due to incorrect and forged data provided by manual workers.

1.2 Objectives of the study 1.2.0 General objectives


To design and construct a microcontroller based digital visitor counter that automatically counts the number of visitors entering a conference hall or auditorium using a seven-segment display and a Switch.

1.2.1 Specific objectives


I. To build circuit that will be able to display a digit value when the counter is incremented on pressing a switch. II. To come up with an algorithm on how to build the system.

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.1.1 Significance to the researcher.


This project enhanced on the techniques and more knowledge on developing microcontroller based systems. Applied the skills acquired on circuit designing and circuit principles during the course of our study and programming tactics.

1.2.2 Significance to the users


a) This project can be used in conference hall or auditorium where accurate customer counting is a key component as a holistic performance measurement. b) In area of security this project can be used as an object counter. c) This system can also be used in Airports, Stadium, Parking lots and even in lecture rooms where attendance taking is very important.

1.4 Scope: 1.4.0 Physical scope:


This system is used for measurement of the visitors entering the conference hall or auditorium.

1.4.1Technical scope:
This microcontroller based digital visitor counter system used code composer studio as the programming platform and C programming language.

CHAPTER TWO LITERATURE REVIEW


The technology of a Digital Counter has been in existence, since the advent of digital authorizing systems. Theoretically, the system is based on basic electrical and electronic devices such as resistors, switches and microcontrollers. The building blocks of this project make use of these devices and many more, with effective design considerations. Students Sumedh.M.More(07-336) ,Sneha Newalkar(07-339) ,Prathamesh.B.Sarang(07-349) from vdyalankar Institute of Technology

,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.

CHAPTER THREE 3.0 Methodology.


This generally requires basic understanding of the project, its objectives and mode of operation of the units in the circuit to achieve the desired aim. The Design involved procedures and developing a diagrammatic representation of the circuit plus a method to incorporate software and hardware components of the system. The methodology used employs a number of phases to be followed as explained in detail below.
Project planning & feasibility study

Requirements Analysis & System Analysis

Design

Testing & Evaluation

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.

3.1 Assumptions made


a) I assumed that every visitor entering the conference or auditorium hall must press the button. b) I assumed that the visitor places the button once

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).

3.1.1 Formulas used in data collection


Interviews This formula was used to acquire information from the public. It was intended to attain different ideas, goals and perspectives the public has on coming up with the system. Software tools The software tools used in the designing of the system which provided the suitable working environment included: Code composer studio V4, a very good programming tool that has a number of inbuilt functions and predefined functions. C programming language was used to program the microcontroller to come up with a working system.

CHAPTER FOUR 4.0 OPERATION OF THE SYSTEM


In this chapter, I looked at the circuit design for constructing and designing the digital visitor counter. The project was constructed under four modules, the DC power supply, the microcontroller, seven segment displays and the push button. The push button is a switch, connected to the microcontroller, when pressed it sends a high logic to the microcontroller and when released it sends a low logic, the transition from low to high and back to low logic is called a clock so for every clock the microcontroller increase its count register by 1 and the counts are converted from binary to decimal before being displayed on the seven segment display. 6

The circuit diagram

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.

4.1 Hardware specifications. 4.1.0 MSP430G2231 MICROCONTROLLER


This is the brain in electronic circuit. The microcontroller was purchased blank and then programmed with a specific control program. Once programmed the microcontroller was built into a product to make the product more intelligent and easier to use. 7

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.

4.1.2 Seven segment LED Display


The circuit comprises one seven segment display to display the number of visitors entering the conference hall or auditorium.

Figure2: Atypical 7-segment display components, with decimal point

4.1.3 Bread board


Breadboards are thin rectangular pieces of insulating material used to hold electronic components when making circuit prototypes. The breadboard has many rows and columns of holes into which circuit components like resistors, transistors, LEDs can be inserted.

Figure 5

4.1.4 UTP wires


These are used to connect all the components in the circuit.

4.1.5 Power Supply


In my project, I used the computer as a power source for the project.

4.2 software specifications


In my project, I used code composer studio version 4 as a programming platform.

4.3 Flow charts General flow chart.

10

Detailed flow chart.

11

4.4 system output 4.4.0 Seven segment display


A seven-segment display consists of seven long, thin LEDs arranged in the pattern of an eight. I used a common anode display and this is how I generated out puts.

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

The seven-segment display truth table


Bit patterns Decim al Numb er 0 1 2 3 4 5 6 7 8 9 7 In put 0 0 0 0 0 0 0 0 0 0 6 g 5 f 4 e 3 d 2 c 1 b 0 a 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

4.5 EXPLANATION OF THE SYSTEM


The microcontroller was connected to the laptop which was my DC power supply. The breadboard was powered using the microcontroller voltage. The bread board supplies current to the components and these components are connected to the microcontroller through the bread board. The input from the push button which was used as sensor is fed into the microcontroller which is connected to the breadboard. The output device (seven segment display) gets its input from the microcontroller via the breadboard. The push button is open at first, when pressed the low logic is to the sent to the microcontroller and the counter register is incremented, it sends the output to the seven segment display that displays different digits as programmed. 13

Snapshot showing the functional and working system.

Figure 3

4.5.0 The code


We wrote the code in c programming language and we used Code composer studio version 4 as a programming environment. We debugged the program using code composer studio software and run it on the MSP430G2231 launch pad

14

15

16

CHAPTER FIVE 5.1 Evaluations


The project has helped me get more knowledge on the embedded systems design, know how to come up with the good flow charts that will aid me to fully explain to the stakeholders who will be interested in the project . This project enabled me to learn how to cooperate when working in a group and how to bring ideas together. I expected to use an infrared sensor as my input so as to detect a visitor entering but then I ended up using a push button switch as a sensor since the sensor was unavailable which is also working well.

5.1.0 Limitations on the system


I was limited by the number of ports on the microcontroller to interface more 7 segment displays. The system was limited to only visitors entering. Although LED technology exists to display more than this, seven-segment displays are limited to possible binary combinations of the four input leads, for a total of 16.

5.1.1 Problems encountered


During the design of my project I encountered a number of problems that delayed the entire design process which included the following: I expected the university to buy for me components which was not the case, they only provided me with the microcontroller .so getting money to buy as soon as possible was not easy. The first two segments I bought were faulty and getting a replace was not easy and wasted my money. Working with new equipments that big problem. Microcontrollers not being enough was the biggest challenge I faced because I had to share with other groups which delayed me. 17 I was not familiar with called for extensive research about the equipments to use for the project was another

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

Appendix 1 The seven-segment display truth table


7 In put 0 0 0 0 0 0 0 0 0 0 6 g 5 f 4 e Bit patterns 3 2 d c 1 b 0 a

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

Flash disk Microcontroller

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

Anda mungkin juga menyukai