UNIVERSITY OF NAIROBI DEPARTMENT OF...
-
Upload
truongthuy -
Category
Documents
-
view
218 -
download
2
Transcript of UNIVERSITY OF NAIROBI DEPARTMENT OF...
![Page 1: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/1.jpg)
UNIVERSITY OF NAIROBI
DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING
PROJECT NO. 16
CUSTOMER VOLUME MONITORING SYSTEM
By
KAVOI STEPHEN MUTINDA
F17/2466/2008
SUPERVISOR: DR. GEORGE N. KAMUCHA
EXAMINER: DR. VASANT M. DHARMADHIKARY
A final year project report submitted to the University of Nairobi senate in partial fulfillment of
the requirements for the award of Bachelor of Science degree in Electrical and Electronic
Engineering.
Date of Submission: 28th
April, 2014
![Page 2: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/2.jpg)
i
CERTIFICATION
This final year project has been submitted for examination in the Department of Electrical and
Information Engineering, University of Nairobi, with my approval as the Supervisor.
Project Supervisor: Dr. George N. Kamucha
Signature:
Date:
![Page 3: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/3.jpg)
ii
DECLARATION OF ORIGINALITY
NAME OF STUDENT: Kavoi Stephen Mutinda
REGISTRATION NUMBER: F17/2466/2008
COLLEGE: Architecture and Engineering
FACULTY/SCHOOL/INSTITUTE: Engineering
DEPARTMENT: Electrical and Information Engineering
COURSE NAME: Bachelor of Science in Electrical and Electronic Engineering
TITLE OF WORK: CUSTOMER VOLUME MONITORING SYSTEM
1) I understand what plagiarism is and I am aware of the university policy in this regard.
2) I declare that this final year project report is my original work and has not been submitted
elsewhere for examination, award of a degree or publication. Where other people’s work
or my own work has been used, this has properly been acknowledged and referenced in
accordance with the University of Nairobi’s requirements.
3) I have not sought or used the services of any professional agencies to produce this work.
4) I have not allowed, and shall not allow anyone to copy my work with the intention of
passing it off as his/her own work.
5) I understand that any false claim in respect of this work shall result in disciplinary action,
in accordance with University anti-plagiarism policy.
Signature:
Date:
![Page 4: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/4.jpg)
iii
ACKNOWLEDGEMENT
First and foremost, I thank the Almighty God for bringing me this far, keeping me healthy and
enabling me put in the great effort required to successfully complete this Customer Volume
Monitoring System design and implementation.
My heartfelt gratitude goes to my Project Supervisor, Dr. George N. Kamucha, for his great
encouragement, guidance and support that enabled me ensure this project was a great success.
The numerous research assignments given always kept me on track and helped me gain an
accurate and deep understanding of the CVMS. As a result, I was able to come up with the
required hardware and software system specifications which resulted in successful system
design, implementation, testing and debugging until the system was working appropriately. The
great efforts put in by the Projects’ Coordinator, Prof. Elijah Mwangi, to facilitate the projects’
submission and selection exercise can also not go unnoticed. His thorough briefing on the final
year projects enabled me make a good choice of project based on my personal interests, strengths
and availability of information resources, hardware and software components.
In addition, I am greatly indebted to all my other lecturers, technicians and classmates. The
knowledge acquired through my interaction with you will go a long way in enabling me advance
well professionally and improve the quality of life of all the people I will serve. The studying
environment provided by all departmental staff and students was also conducive and for that I
am greatly thankful.
![Page 5: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/5.jpg)
iv
DEDICATION
To my loving mum, Mrs. Mary Kavoi, Ms. Mindy Winik, Esme Spanier, and Pradeep Kapadia
for your unfailing support and encouragement throughout my undergraduate studies. Even
amidst difficult circumstances in my life, you always had great faith in my ability to overcome
all obstacles on my way and this gave me great hope and strength to move on. May the Almighty
God bless you abundantly.
![Page 6: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/6.jpg)
v
TABLE OF CONTENTS
CERTIFICATION ....................................................................................................................................... i
DECLARATION OF ORIGINALITY ....................................................................................................... ii
ACKNOWLEDGEMENT ......................................................................................................................... iii
DEDICATION ........................................................................................................................................... iv
TABLE OF CONTENTS ............................................................................................................................ v
LIST OF FIGURES .................................................................................................................................. vii
LIST OF ABBREVIATIONS .................................................................................................................. viii
ABSTRACT ............................................................................................................................................... x
CHAPTER 1: INTRODUCTION ............................................................................................................. 11
1.1 Project Definition ............................................................................................................................ 11
1.2 Project Overview ............................................................................................................................ 11
1.3 Objectives ....................................................................................................................................... 11
1.3.1 Overall Objective ..................................................................................................................... 11
1.3.1 Specific Objectives .................................................................................................................... 2
1.4 Project Justification ........................................................................................................................... 2
1.4.1 Advantages of CVMS ................................................................................................................ 2
1.4.2 Applications of CVMS ............................................................................................................... 3
1.5 Project Scope .................................................................................................................................... 3
1.6 Project Organization ......................................................................................................................... 3
CHAPTER 2: LITERATURE REVIEW .................................................................................................... 5
2.1 Classification of Customer Counting Systems .................................................................................. 5
2.1.1 Manual Counting systems .......................................................................................................... 5
2.1.2 Automatic Counting systems...................................................................................................... 5
2.2 Block Diagram Description ............................................................................................................. 10
2.3 Hardware and Software Components .............................................................................................. 10
2.3.1 Microcontroller ........................................................................................................................ 10
2.3.2 Real Time Clock (RTC) Module .............................................................................................. 17
CHAPTER 3: DESIGN AND IMPLEMENTATION ............................................................................... 24
3.1 Project Description .......................................................................................................................... 24
3.2 System Algorithm ........................................................................................................................... 24
3.3 System Flowchart ............................................................................................................................ 26
3.4 Hardware Design ............................................................................................................................ 27
3.4.1 CVMS Hardware Connection .................................................................................................. 27
![Page 7: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/7.jpg)
vi
3.4.2 CVMS SCHEMATIC DIAGRAM........................................................................................... 28
3.4.3 CVMS PCB Fabrication ........................................................................................................... 28
3.7 Software Design .............................................................................................................................. 32
3.7.1 CVMS Counter ........................................................................................................................ 32
3.7.2 CVMS Database and GUI ........................................................................................................ 32
CHAPTER 4: RESULTS, ANALYSIS AND DISCUSSION ................................................................... 33
4.1 CVMS Results ................................................................................................................................ 33
4.1.1 Real-time and Hourly Customer Display ................................................................................. 33
4.1.2 Daily Customer Count Display ................................................................................................ 33
4.1.3 Monthly Customer Display ...................................................................................................... 34
4.2 Customer Data Analysis .................................................................................................................. 34
4.3 Discussion ....................................................................................................................................... 35
4.3.1 System Performance................................................................................................................. 35
4.3.2 Challenges Faced ..................................................................................................................... 35
CHAPTER 5: RECOMMENDATIONS AND CONCLUSION ............................................................... 37
5.1 Conclusion ...................................................................................................................................... 37
5.2 Recommendations ........................................................................................................................... 37
BIBLIOGRAPHY ..................................................................................................................................... 38
APPENDICES .......................................................................................................................................... 39
APPENDIX A: CVMS PROGRAM ......................................................................................................... 39
APPENDIX B: CVMS DATABASE AND GUI PROGRAM .................................................................. 43
APPENDIX C: PROJECT TIMELINE ..................................................................................................... 62
![Page 8: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/8.jpg)
vii
LIST OF FIGURES
Figure 1: Light Dependent Resistor ................................................................................................ 6
Figure 2: CVMS Block Diagram .................................................................................................. 10
Figure 3: Pin Configuration for ATMEGA328 ............................................................................ 12
Figure 4: Arduino Uno Board Components .................................................................................. 14
Figure 5: Arduino Uno Board ....................................................................................................... 14
Figure 6: DS1307 RTC Module for Arduino ................................................................................ 17
Figure 7: Pin Diagram of NE555 .................................................................................................. 19
Figure 8: NE555 Timer IC Block Diagram .................................................................................. 20
Figure 9: Frequency modulated transmitter circuit ....................................................................... 21
Figure 10: TSOP4838 IR Receiver ............................................................................................... 22
Figure 11: Block Diagram of TSOP4838 ..................................................................................... 22
Figure 12: TSOP4838 Application Circuit ................................................................................... 23
Figure 13: CVMS Flowchart ........................................................................................................ 26
Figure 14: CVMS Hardware Connection ..................................................................................... 27
Figure 15: CVMS Counter Circuit ................................................................................................ 27
Figure 16: CVMS Schematic Diagram ......................................................................................... 28
Figure 17: CVMS PCB Design ..................................................................................................... 29
Figure 18: CVMS Graphical User Interface ................................................................................. 32
Figure 19: Real-time and Hourly Customer Display .................................................................... 33
Figure 20: Real-time and Daily Customer Display....................................................................... 34
Figure 21: Customer Data Bar Graph ........................................................................................... 35
![Page 9: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/9.jpg)
viii
LIST OF ABBREVIATIONS
CVMS – Customer Volume Monitoring System
GPRS – General Packet Radio Services
CCTV – Closed Circuit Television
CPU – Central Processing Unit
IR – Infrared
LCD – Liquid Crystal Display
IP – Internet Protocol
PC – Personal Computer
MTBF – Mean time between failures
TOF – Time-of-flight
GUI – Graphical User Interface
ISP – In System Programmable
RAM – Random Access Memory
ROM – Read Only Memory
EEPROM –Electrically Erasable Programmable Read Only Memory
ADC – Analogue to Digital Converter
USB – Universal Serial Bus
ICSP – In-Circuit Serial Programming
LED – Light Emitting Diode
MIPS – Million Instructions Per Second
IC – Integrated Circuit
RTC – Real Time Clock
IDE – Integrated Development Environment
![Page 10: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/10.jpg)
ix
CMOS – Complementary Metal Oxide Semiconductor
SRAM – Static Random Access Memory
TTL – Transistor-Transistor Logic
BCD – Binary Coded Decimal
BJT – Bipolar Junction Transistor
FET – Field Effect Transistor
PCM – Pulse Code Modulation
PWM – Pulse Width Modulation
EMI – Electromagnetic Interference
AGC – Automatic Gain Control
![Page 11: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/11.jpg)
x
ABSTRACT
As businesses continue to strive each day to adequately meet different customers’ tastes and
preferences, maximize profits realized, and remain competitive in the market, there is an ever
increasing demand for data pertaining to the number of customers entering and leaving the
premises at any one time. The number of customers in the premises at any particular time is
crucial as it provides data that serves as an essential indicator of the level of business
performance and customer satisfaction. This acts as the basis for various planning and marketing
activities by the management. Counting the customers visiting the premises also helps to
maximize the efficiency and effectiveness of employees, floor area and sales potential of a
business. The Customer Volume Monitoring System (CVMS) design and implementation has
therefore been successfully undertaken to meet these needs. CVMS is an accurate, affordable and
reliable microcontroller system to quantify the number of customers in a business premises at
any one time and track periodic volumes in hours, days and months. The system counts the
customers entering or leaving the premises at any one time through a single passage serving both
as an entry and exit point. If a customer enters, the microcontroller counter is incremented by
one. When the customer leaves, the counter is decremented by one. The counter data is then send
to the computer, via the serial port, for storage and display in a Microsoft Visual C#.net database
system with a user-friendly graphical user interface. Consequently, CVMS is able to display the
number of customers in the premises in real time and also to store the number of customers that
visited the premises at a particular hour, day or month for future retrieval when required.
![Page 12: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/12.jpg)
xi
CHAPTER 1: INTRODUCTION
1.1 Project Definition
The Customer Volume Monitoring System comprehensively covers the design and
implementation of a microcontroller system to quantify the number of customers in a business
premises at any one time and track periodic customer volumes in hours, days and months. The
number of customers in the premises at any particular time provides very important data that
serves as an essential indicator of the level of business performance and customer satisfaction.
This acts as the basis for various planning and marketing activities by the management. Counting
the customers visiting the premises also helps to maximize the efficiency and effectiveness of
employees, floor area and sales potential of a business.
1.2 Project Overview
Customer Volume Monitoring System is an inexpensive, user-friendly and reliable system that
accurately counts the number of customers in a business premises at any one time and monitors
periodic customer volumes in hours, days and months. Two infrared receiver-transmitter pairs
are installed at a single passage which serves both as an entrance and exit. The ATMEGA328
microcontroller continuously monitors the infrared receivers. When a customer enters or leaves
the premises, the infrared rays falling on receivers 1 and 2 are obstructed. This obstruction is
sensed by the microcontroller. The infrared receiver signal is then processed by the central
processing unit (CPU) of the microcontroller. If infrared rays from transmitter 1 to receiver 1 and
transmitter 2 to receiver 2 are blocked respectively, then the microcontroller counter is
incremented by 1. On the contrary, when infrared rays from transmitter 2 to receiver 2 and
transmitter 1 to receiver 1 are blocked respectively, then the microcontroller counter is
decremented by 1. Computations within the microcontroller are then carried out to obtain the real
time number of customers within the business premises. The total number of customers in the
premises is then transmitted, via the Arduino Uno USB cable, to a personal computer for display
and storage in the customer database.
Microsoft Visual C#.net programming language has been used to develop the customer
information database as well as a user-friendly graphical user interface (GUI) for displaying the
customer data in real time or upon querying the system for data stored in the past. Consequently,
through the system, one is able to obtain a display of the current number of customers in the
premises at any particular moment. Moreover, upon being queried, the system is able to display
the information on the number of customers who visited the premises in a particular hour, day or
month.
1.3 Objectives
1.3.1 Overall Objective
To design and implement a microcontroller system to quantify the number of customers in a
business premises at any one time and track periodic volumes in hours, days and months.
![Page 13: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/13.jpg)
2
1.3.1 Specific Objectives
To design and implement a microcontroller based customer counter using Arduino Uno,
NE555 timers, infrared transmitters and receivers, among other system components.
To design and implement a Customer database and Graphical User Interface in Microsoft
Visual C#.net.
To interface the CVMS counter system with the database system for storage and display
of customer data.
1.4 Project Justification
The successful design and implementation of the CVMS will greatly improve business
management operations and increase customer satisfaction through fast service delivery.
1.4.1 Advantages of CVMS
CVMS achieves accurate counting of customers entering or exiting the business
premises through a single passage.
The system monitors customers entering or leaving the business premises without
their knowledge. This is because infrared rays are invisible to the eyes.
The system is not affected by any external sources of infrared light. This has been
possible through modulating the infrared light from the transmitters to be at 38 KHz,
which is the only frequency of infrared light that the TSOP4838 receivers have been
configured to detect.
The CVMS is simple to install and operate/use.
The system has high sensitivity.
CVMS is reliable and inexpensive. The system can count customers over a long
period of time without failure. It is also cheap because the hardware and software
components required in the system design/implementation are readily available in the
market.
The system eases congestion within the business premises. Increased customer traffic
within the business can be reduced through increase in the number of employees
offering services.
Assists in optimizing staffing in business premises which leads to improved service
delivery for their customers. With CVMS, it is easy to analyze the customer flow in a
more detailed way and to find how to make staffing more efficient. The result is
increased service delivery and sales figures.
Helps a business to evaluate the effect of commercial campaigns, customer events
and the visual merchandising in the premises.
Using the customer statistics enables the business management to know what hours
most customers visit the premises which makes it easy for management to do its staff
planning in a cost efficient way.
![Page 14: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/14.jpg)
3
1.4.2 Applications of CVMS
The system can be customized for use in many areas where monitoring and controlling of
visitors is important. Some of these areas include:-
In education institutions to count number of students and staff in the library or lecture
halls.
In seminar/conference halls to monitor the number of people in attendance.
In places of worship to enable religious ministers ascertain the actual size of their
congregation at any one moment so as to address and serve them better.
In stadia, entertainment joints, museums, etc to ensure only the required capacity of
attendants is accommodated.
In banks, supermarkets, shopping malls and manufacturing industries to count the number
of customers present and hence ease congestion through faster service delivery.
In airports, railway stations and bus stations to count the number of passengers boarding or
alighting from aircrafts, trains or vehicles.
In non-profit organizations as evidence when making applications for finance.
1.5 Project Scope This project covers CVMS hardware and software design and implementation. The hardware
system involved the design and construction of a properly working microcontroller customer
counter. On the other hand, the software system entailed design and implementation of Microsoft
Visual C#.net database with a user-friendly graphical user interface through which real time
customer count or queried customer data is accessed.
1.6 Project Organization
This project comprises five chapters, namely:
Chapter 1: Introduction
This gives the project definition, project overview, objectives, project justification and scope.
Chapter 2: Literature Review
The chapter gives types of customer counting systems, detailed description of hardware and
software components required in the CVMS design and implementation.
Chapter 3: Design and Implementation
This gives a comprehensive description of the technical aspects of the CVMS design and
implementation; project description, system algorithm, system flow chart, hardware and
software design.
![Page 15: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/15.jpg)
4
Chapter 4: Results, Analysis and Discussion
This chapter gives the CVMS results, customer data analysis and discussion of the system
performance and challenges faced.
Chapter 5: Conclusion and Recommendations
The chapter gives the conclusion and recommendations after completion of the final year
project. It covers assessment of whether project objectives and scope were achieved, a
highlight of areas for future development, bibliography and appendices.
![Page 16: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/16.jpg)
5
CHAPTER 2: LITERATURE REVIEW
2.1 Classification of Customer Counting Systems Customer counting systems are classified into two major categories:-
2.1.1 Manual Counting systems
In these systems, the number of customers entering or leaving a business premises at any one
time can be obtained through use of any of the following ways:-
Counting the number of business access permits or tickets yet to be collected back from
customers who received them when entering the premises.
Use of customer registration books to monitor customer inflows and outflows.
Engaging the business staff at ground level to observe and tally the number of customers
in the premises
Hiring human auditors to stand and tally the number of customers entering or leaving the
premises. The counting process can be done physically or by use of a tally counter or
clicker-counter. The tally counter is a hand-held device operated by the press of a button
whenever a customer enters or leaves the business. The operator would then have to turn
a knob to reset the counter. Upon resetting, most counters display "0000".
Evidently, human-based customer counting comes at a great expense.
2.1.2 Automatic Counting systems
These systems use customer counters. A customer counter is a device used to measure the
number and direction of customers traversing a certain passage per unit time. The resolution of
the measurement is entirely dependent on the sophistication of the technology employed. The
device is often used at the entrance of a building so that the total number of customers can be
recorded. Modern customer counting systems use many different technologies, each with its own
advantages and disadvantages. These technologies include:-
(i) Infrared Transmitter – Receiver System
This counting system uses single or dual beam infrared transmitter-receiver pairs placed across
the customer passage. When a customer enters or leaves the premises, light from the infrared
transmitters is blocked. The infrared receivers are then programmed sense that as a high (5V) or
low (0V) data signal. The data signal captured by the receivers is then fed to a microcontroller
counter which interprets it as a customer entry or exit. When a customer enters the premises, the
counter is incremented by 1 and when he/she leaves, the counter is decremented by 1. The
counter is then linked to a display system e.g. personal computer or LCD unit. The data can also
be sent via wireless links and GPRS. Accuracy of this system depends highly on the width of the
passage monitored and the volume of customer traffic. Horizontal beam counters usually require
a transmitter and a receiver mounted opposite the unit with a typical range up to 6 metres (20 ft),
although range finding beam counters which do not require a transmitter usually have a shorter
range of around 2.5 metres (8 ft 2 in).Vertical beams are somewhat more accurate than
horizontal ones, with accuracies of over 90% possible if the beams are very carefully placed.
![Page 17: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/17.jpg)
6
Advantages
High accuracy is achieved for carefully placed infrared transmitter – receiver pairs.
Infrared rays are not visible to human eyes thus enabling customers to be counted without
their knowledge.
Infrared light from transmitters to receivers can be frequency modulated so that the
customer counter is not affected by any other sources of IR light.
Infrared transmitters/receivers are inexpensive.
Counting of customers entering or exiting the business premises at the same passage can
be achieved by use of dual beam IR sensors.
The IR transmitter – receiver systems are simple to install and operate.
Disadvantages
High potential to become blocked by people standing in the entrance or by merchandise
or displays
Cannot count customers standing side by side. However, many of the other counting
systems have the same disadvantage.
Accuracy can be affected by very high traffic of customers.
(ii) Light Dependent Resistor Systems
A Light Dependent Resistor (LDR), photoresistor, photoconductor or cadmium sulfide (CdS)
cell is a resistor whose resistance decreases with increasing incident light intensity. A
photoresistor is made of a high resistance semiconductor. If light falling on the device is of high
enough frequency, photons absorbed by the semiconductor give bound electrons enough energy
to jump into the conduction band. The resulting free electron and its hole partner conduct
electricity, thereby lowering resistance.
A photoelectric device can be either intrinsic or extrinsic. An intrinsic semiconductor has its own charge carriers and is not an efficient semiconductor, e.g. silicon. In intrinsic devices the only
available charge carriers are electrons in the valence band, and hence the photon must have
enough energy to excite the electron across the entire bandgap. Extrinsic devices have dopants
(impurities) added whose ground state energy is closer to the conduction band; since the
electrons do not have as far to jump, lower energy photons (i.e. longer wavelengths and lower
frequencies) are sufficient to trigger the device. If a sample of silicon has some of its atoms
replaced by phosphorus atoms (impurities), there will be extra electrons available for conduction.
Figure 1: Light Dependent Resistor
![Page 18: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/18.jpg)
7
Light Dependent Resistors may be used in place of the IR transmitter – receiver system but
are nowadays not commonly used as they are easily triggered by sunlight or any other sources
of light.
(iii) Computer Vision Systems
Computer Vision Systems typically use either a CCTV camera or IP camera to feed a signal into
a computer or embedded device. Some computer vision systems have been embedded directly
into standard IP network cameras. This allows for distributed, cost efficient and highly scalable
systems where all image processing is done on the camera using the standard built-in CPU. This
also dramatically reduces bandwidth requirements as only the counting data has to be sent over
the Ethernet.
Accuracy varies between systems and installations as background information needs to be
digitally removed from the scene in order to recognize, track and count customers. This means
that CCTV based counters can be vulnerable to light level changes and shadows, which can lead
to inaccurate counting. However, robust and adaptive algorithms have lately been developed that
can compensate for this behaviour and excellent counting accuracy can today be obtained for
both outdoor and indoor counting using computer vision systems.
Advantages
High accuracy(sometimes over 95% in correct conditions)
Directional counting information is acquired
Flexible in customization
Highly scalable when embedded in IP cameras
Integration with other systems
Networkable to cover wide entrances
Possible to anonymize images to avoid people recognition.
Disadvantages
Higher cost than IR transmitter – receiver systems
Lower lifetime and higher power consumption than thermal systems
Some systems require PCs that are not fully embedded
Accuracy can be affected by shadow, floor background and differing light levels.
(iv) Thermal Imaging Systems
These systems use array sensors which detect heat sources, rather than using cameras as in
computer vision systems. The systems are typically implemented using embedded technology
and are mounted overhead for high accuracy. Since thermal imaging systems detect the heat
emitted by people, they can be susceptible to external weather conditions that reduce the amount
of heat emitted from a person walking in from an outdoor environment.
![Page 19: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/19.jpg)
8
Advantages
Provide directional counting information
Not affected by differing light levels
Can count in complete darkness
Non-intrusive, usually ceiling mounted
Identifiable images of people are not taken
Very long lifetime; Mean time between failures (MTBF) >25 years
Highly scalable, fully embedded IP systems
Networkable to cover wide entrances
High accuracy (upto 92% under suitable conditions)
Disadvantages
Higher cost than IR transmitter – receiver systems
More complex implementation than IR transmitter – receiver systems
Lower field of view than video systems
Cannot be used with ceiling heights below 2.2m
Susceptible to external weather conditions
Hard to know exactly how large an area or “spot” the sensor is “seeing” and measuring
Takes considerable training to get the most from a thermal imager, which can be quite
costly
(v) Synthetic Intelligence Systems
A Synthetic Intelligence System employs multiple IR transceivers to create a count zone at ankle
height. The artificial intelligence counters function in a similar way to the human brain, in other
words, each event is evaluated in terms of features to determine the correct outcome i.e. count
per direction. As a customer passes the count zone a pattern is generated. The onboard processor
extracts the features of the pattern and based on what it has been taught makes a decision
regarding the event by brute force calculation.
Advantages
High accuracy ( 96% or higher)
Directional customer counting information
Discriminates between human and non-human objects
Sensors can count in outdoor environments
Can count in all lighting conditions including in complete darkness
Disadvantages
Larger, more obtrusive design than other types of sensing technology.
![Page 20: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/20.jpg)
9
High potential to become blocked by people standing in an entrance or by merchandise or
displays.
Cannot accurately count high volume or uninterrupted traffic of customers.
(vi) 3D Camera Technology
Various technologies exist for acquiring a 3D image of the scene;
Two video cameras in order to reproduce the human 3D vision (stereo-vision)
The quality is based on image processing and 3D camera technology.
Time-of-flight (TOF) sensors use pulsed or modulated emitted IR light to acquire the 3D image of the scene
Structured light sensors acquire the 3D image of the scene using projected light pattern
The active technologies (those emitting light) have some difficulties in outdoor environments
with direct or indirect sunlight, but the raw 3D point cloud is generally more robust for further processing such as counting applications.
Advantages
Even under difficult conditions it achieves a counting accuracy of 98%.
Can count in all lighting conditions including in complete darkness. Unfavourable, variable
lighting or the casting of shadows does not affect the counting.
Disadvantages
The active technologies (those emitting light) have some difficulties in outdoor
environments with direct or indirect sunlight.
![Page 21: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/21.jpg)
10
2.2 Block Diagram Description
The basic block diagram of the Customer Volume Monitoring System is as shown below.
Figure 2: CVMS Block Diagram
2.3 Hardware and Software Components
Arduino Uno, Breadboard, Two 5mm size Infrared LED transmitters, Two NE555 Timer ICs,
Two TSOP4838 Infrared receivers, DS1307 Real Time Clock (RTC) Module for Arduino,
Resistors (two 1.8 KΩ, two 18 KΩ, two 220 Ω, two 100 Ω), Ceramic capacitors (two 0.001 µF,
two 0.01 µF, two 0.1 µF), Connecting Wires (2 metres), Personal Computer (PC) running
Microsoft Visual Studio 2010
2.3.1 Microcontroller
A microcontroller can be defined as a single-chip computer that is specifically manufactured for
embedded computer control applications. These devices are very low-cost and can be used very
easily in digital control applications. Most microcontrollers have the built-in circuits necessary
for computer control applications. For example, a microcontroller may have Analogue/Digital
converters so that the external signals can be sampled. They also have parallel input – output
ports so that digital data can be read or output from the microcontroller. Some devices have
built-in Digital/Analogue converters and the output of the converter can be used to drive the
plant through an actuator (e.g. an amplifier). Microcontrollers may also have built-in timer and
![Page 22: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/22.jpg)
11
interrupt logic. Using the timer or the interrupt facilities, we can program the microcontroller to
implement the control algorithm accurately.
A microcontroller can be compared to a small stand-alone computer. It is a very powerful device,
which is capable of executing a series of pre-programmed tasks and interacting with other
hardware devices. Nowadays, microcontrollers are so cheap and easily available that it is
common to use them instead of simple logic circuits like counters for the sole purpose of gaining
some design flexibility and saving some space. Most recent microcontrollers are 'In System
Programmable', meaning that you can modify the program being executed, without removing the
microcontroller from its place.
Microcontrollers have traditionally been programmed using the assembly language of the target
device. As a result, the assembly languages of the microcontrollers manufactured by different
firms are totally different and the user has to learn a new language before being able program a
new type of device. Nowadays, microcontrollers can be programmed using high-level languages
such as BASIC, PASCAL or C.
Advantages of High-level languages over Assembly Language
It is easier to develop programs using a high-level language.
Program maintenance is much easier if the program is developed using a high-level
language.
Testing a program developed in a high-level language is much easier.
High-level languages are more user-friendly and less prone to making errors.
It is easier to document a program developed using a high-level language.
Disadvantages of High-level languages over Assembly Language
The length of the code in memory is usually larger when high-level languages are used.
The programs developed using the assembly language usually run faster than those
developed using high-level languages.
Microcontrollers are different from microprocessors, which are integrated circuits having only
the CPU inside them (i.e. only the processing power) e.g. the Intel’s Pentium 1, 2, 3, 4, core 2
duo, core i3, core i5, core i7 and core i9. It does not have random access memory (RAM), read
only memory (ROM) and other peripherals on the chip. They have to be added externally for
purposes of functionality. On the contrary, microcontrollers have the CPU, RAM, ROM and
other peripherals all embedded on a single chip.
Choice of Microcontroller
The factors are considered when choosing the microcontroller to use include:-
a) It should be able to meet the computing needs of the task at hand efficiently and cost
effectively. Here we look at factors like Speed, Packaging, Power consumption, amount
of RAM and ROM on chip, the number of Input/Output pins and the timer on chip, how
![Page 23: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/23.jpg)
12
easy it is to upgrade to higher-performance or lower power-consumption versions and the
cost per unit.
b) Availability of software development tools such as compilers, assemblers, and debuggers
c) Wide availability and reliable sources of the microcontroller
Based on the above factors I selected ATMEGA328P.
ATMEGA328P
The features of ATMEGA328P include:-
It has three 8-bit bidirectional I/O ports with internal pull-up resistors, 32KB of Flash Memory,
1KB EEPROM, 2KB of RAM, 2 instruction words/vector, 8-channel 10-bit successive
approximation ADC, Programmable Serial USART, 23 Programmable I/O Lines and Operating
Voltage 1.8 - 5.5V
PB0/ICP1/CLKO/PCINT014
PB1/OC1A/PCINT115
PB3/MOSI/OC2A/PCINT317
PB2/SS/OC1B/PCINT216
PD6/AIN0/OC0A/PCINT2212
PD5/T1/OC0B/PCINT2111
PD4/T0/XCK/PCINT206
PD3/INT1/OC2B/PCINT195
PD2/INT0/PCINT184
PD1/TXD/PCINT173
PD0/RXD/PCINT162
PB4/MISO/PCINT418
PB5/SCK/PCINT519
PB7/TOSC2/XTAL2/PCINT710
PB6/TOSC1/XTAL1/PCINT69
PC6/RESET/PCINT141
PC5/ADC5/SCL/PCINT1328
PC4/ADC4/SDA/PCINT1227
PC3/ADC3/PCINT1126
PC2/ADC2/PCINT1025
PC1/ADC1/PCINT924
PC0/ADC0/PCINT823
AVCC20
AREF21
PD7/AIN1/PCINT2313
U1
ATMEGA328P
Figure 3: Pin Configuration for ATMEGA328
The Arduino
Arduino is a tool for making computers that can sense and control more of the physical world. It
is an open-source physical computing platform based on a simple microcontroller board, and a
development environment for writing software for the board. Arduino can be used to develop
interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety
of lights, motors, and other physical outputs. Arduino projects can be stand-alone, or they can be
communicating with software running on your computer (e.g. Flash, Processing, and MaxMSP.)
The boards can be assembled by hand or purchased preassembled. The open-source IDE can be
downloaded for free.
The open-source Arduino environment allows one to write code and load it onto the Arduino
board's memory. The development environment is written in Java and based on Processing,
AVR-GCC, and other open source software. The Arduino programming language is an
implementation of wiring, a similar physical computing platform, which is based on the
Processing multimedia programming environment. The Arduino software is published as open
source tools, available for extension by experienced programmers. The language can be
![Page 24: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/24.jpg)
13
expanded through C++ libraries, and people wanting to understand the technical details can
make the leap from Arduino to the AVR C programming language on which it is based.
Similarly, AVR-C code can be added directly into the Arduino programs if one so wishes.
The Arduino is based on Atmel's ATMEGA family of microcontrollers namely ATMEGA 48,
ATMEGA 88, ATMEGA 168 or ATMEGA 328. They are low-power CMOS 8-bit
microcontrollers based on the AVR enhanced RISC architecture. By executing powerful
instructions in a single clock cycle, the ATMEGA48PA/88PA/168PA/328P achieves throughputs
approaching 1 MIPS per MHz allowing the system designed to optimize power consumption
versus processing speed. The ATmega48PA, ATmega88PA, ATmega168PA and ATmega328P
differ only in memory sizes, boot loader support, and interrupt vector sizes.
Advantages of Arduino
It comprises the Programmer, Voltage Regulators and Serial to USB converter
The open-source IDE can be downloaded for free.
It is reasonably cheap
Arduino Uno
The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital
input/output pins (of which 6 can be used as PWM outputs), 6 analogue inputs, a 16 MHz
ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It
contains everything needed to support the microcontroller; simply connect it to a computer with
a USB cable or power it with an AC-to-DC adapter or battery to get started. The Arduino Uno
differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip.
Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-
serial converter. Arduino Uno uses ATmega328 Microcontroller, Operating Voltage 5V, Input
Voltage (recommended) 7-12V, Input Voltage (limits) 6-20V, Digital I/O Pins 14 (of which 6
provide PWM output), Analog Input Pins 6, DC Current per I/O Pin 40 mA, DC Current for
3.3V Pin 50 mA, Flash Memory 32 KB (ATMega328) of which 0.5 KB used by bootloader,
SRAM 2 KB (ATMega328), EEPROM 1 KB (ATMega328), Clock Speed 16 MHz
![Page 25: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/25.jpg)
14
The diagrams below illustrate the physical appearance of the Arduino Uno and components it
consists of:
Figure 4: Arduino Uno Board Components
Figure 5: Arduino Uno Board
![Page 26: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/26.jpg)
15
Specifications of Arduino Uno
(i) Power Supply
The Arduino Uno can be powered via the USB connection or with an external power supply. The
power source is selected automatically. External (non-USB) power can come either from an AC-
to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-
positive plug into the board's power jack. Leads from a battery can be inserted in the GND and
Vin pin headers of the Power connector. The board can operate on an external supply of 6 to
20V. If supplied with less than 7V, however, the 5V pin may supply less than 5V and the board
may be unstable. If using more than 12V, the voltage regulator may overheat and damage the
board. The recommended range is 7 to 12V.
The power pins are as follows:
VIN: The input voltage to the Arduino board when it is using an external power source (as opposed to 5V from the USB connection or other regulated power source). You can
supply voltage through this pin, or, if supplying voltage via the power jack, access it
through this pin.
5V: The regulated power supply used to power the microcontroller and other components
on the board. This can come either from VIN via an on-board regulator, or be supplied by
USB or another regulated 5V supply.
3.3V: A 3.3V supply generated by the on-board regulator. Maximum current draw is 50 mA.
GND: Ground pins.
(ii) Memory
The Atmega328 has 32 KB of flash memory for storing code (of which 0.5 KB is used for the
bootloader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written
with the EEPROM library).
(iii)Input and Output
Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using
pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5V. Each pin can provide
or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of
20-50 KΩ. In addition, some pins have specialized functions:
Serial; 0 (RX) and 1 (TX): Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL
Serial chip.
External Interrupts; 2 and 3: These pins can be configured to trigger an interrupt on a
low value, a rising or falling edge, or a change in value. The attachInterrupt() function is
used to achieve this.
PWM; 3, 5, 6, 9, 10, and 11: Provide 8-bit PWM output with the analogWrite() function.
SPI; 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK): These pins support SPI communication, which, although provided by the underlying hardware, is not currently
included in the Arduino language.
![Page 27: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/27.jpg)
16
LED; 13: There is a built-in LED connected to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it is off.
The Arduino Uno has 6 analogue inputs, each of which provides 10 bits of resolution (i.e. 1024 different values). By default they measure from ground (0V) to 5V, though is it
possible to change the upper end of their range using the AREF pin and the
analogReference() function.
I2C; 4 (SDA) and 5 (SCL): Support I2C (TWI) communication using the Wire library.
AREF: Reference voltage for the analog inputs. Used with analogReference() function.
Reset: Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board.
(iv) Communication
The Arduino Uno has a number of facilities for communicating with a computer, another
Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial
communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the
board channels this serial communication over USB and appears as a virtual COM port to
software on the computer. The '8U2 firmware uses the standard USB COM drivers, and no
external driver is needed. However, on Windows, an *.inf file is required.
The Arduino software includes a serial monitor which allows simple textual data to be sent to
and from the Arduino board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial
communication on pins 0 and 1). A Software Serial library allows for serial communication on
any of the Arduino Uno's digital pins. The ATmega328 also supports I2C (TWI) and SPI
communication. The Arduino software includes a Wire library to simplify use of the I2C bus.
(v) Programming
The Arduino Uno can be programmed with the Arduino software. The ATmega328 on the
Arduino Uno comes pre-burned with a boot-loader that allows you to upload new code to it
without the use of an external hardware programmer. It communicates using the original
STK500 protocol. You can also bypass the boot-loader and program the microcontroller through
the ICSP (In-Circuit Serial Programming) header. The ATmega8U2 firmware source code is
available. The ATmega8U2 is loaded with a DFU boot-loader, which can be activated by
connecting the solder jumper on the back of the board (near the map of Italy) and then resetting
the 8U2. You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS
X and Linux) to load a new firmware. Or you can use the ISP header with an external programmer (overwriting the DFU boot-loader).
(vi) Automatic Software Reset
Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is
designed in a way that allows it to be reset by software running on a connected computer. One of
the hardware flow control lines (DTR) of the ATmega8U2 is connected to the reset line of the
ATmega328 via a 100 nF capacitor. When this line is asserted (taken low), the reset line drops
long enough to reset the chip. The Arduino software uses this capability to allow you to upload
code by simply pressing the upload button in the Arduino environment. This means that the boot-
![Page 28: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/28.jpg)
17
loader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start
of the upload.
This setup has other implications. When the Arduino Uno is connected to either a computer
running Mac OS X or Linux, it resets each time a connection is made to it from software (via
USB). For the following half-second or so, the boot-loader is running on the Arduino Uno. While
it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will
intercept the first few bytes of data sent to the board after a connection is opened. If a sketch
running on the board receives one-time configuration or other data when it first starts, make sure
that the software with which it communicates waits a second after opening the connection and
before sending this data. The Arduino Uno contains a trace that can be cut to disable the auto-
reset. The pads on either side of the trace can be soldered together to re-enable it. It's labeled
"RESET-EN". You may also be able to disable the auto-reset by connecting 110Ω resistor from
5V to the reset line.
(vii) USB Overcurrent Protection
The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts
and overcurrent. Although most computers provide their own internal protection, the fuse
provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse
will automatically break the connection until the short or overload is removed.
(viii) Physical Characteristics
The maximum length and width of the Arduino Uno PCB are 2.7 and 2.1 inches respectively,
with the USB connector and power jack extending beyond the former dimension. Three screw
holes allow the board to be attached to a surface or case. Note that the distance between digital
pins 7 and 8 is 160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins.
Applications of Microcontrollers
Microcontrollers are used in the following areas: Robotics, Aerospace, Automobiles (climate
control, diagnostics, engine control), Automotive applications, Environmental control
(greenhouse, factory), Appliances (television, stereos, microwave oven, and refrigerators) and
Instrumentation.
2.3.2 Real Time Clock (RTC) Module
Figure 6: DS1307 RTC Module for Arduino
![Page 29: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/29.jpg)
18
Features of RTC Module
Memory storage: 24C32 32K I2C EEPROM, LIR2032 rechargeable lithium battery and
rechargeable circuit, reading and writing function, using time: about 1 year (when fully
charged), provides clock signal for microcontroller, cascade other I2C devices, full BCD clock
calendar chip of 56byte non-volatile RAM, address and data transmission via serial cable with
dual-line dual-direction, the chip can provide different time information (i.e. second, minute,
hour etc), AM/PM mark (for working 24-hour or 12-hour), built-in power sensor circuit in the
chip (with brownout detection and battery switch function), Under battery backup mode, power
consumption is below 500µA and accurate calendar upto year 2100.
2.3.3 Customer Detection System
The customer detection system comprises two major parts, namely;
(i) Infrared Transmitter Circuit
(ii) Infrared Receiver Circuit
(i) Infrared Transmitter Circuit
Infrared (IR) radiation is electromagnetic radiation of a wavelength longer than that of visible
light, but shorter than that of microwaves. The name infrared means “below red” (from the Latin
word infra which means below), red being the color of visible light with the longest wavelength.
Infrared radiation has wavelengths of between about 750 nm and 1 mm, spanning five orders of
magnitude. A longer wavelength means it has a lower frequency than red, hence “below”.
Objects generally emit infrared radiation across a spectrum of wavelengths, but only a specific
region of the spectrum is of interest because sensors are usually designed only to collect
radiation within a specific bandwidth.
Infrared radiation is used in e.g. IrDA devices and remote controls which use infrared light-emitting diodes (LEDs) to emit infrared radiation which is focused by a plastic lens into a narrow
beam. The receiver uses a silicon photodiode to convert the infrared radiation to an electric
current. It responds only to the rapidly pulsing signal created by the transmitter, and filters out
slowly changing infrared radiation from ambient light. IR light does not penetrate walls and so
does not interfere with other devices in adjoining rooms.
The infrared transmitter circuit diagram has two NE555 timer ICs configured to function as basic astable multivibrators or free running oscillators. The astable multivibrators generate square
waves whose period is determined by the circuits external to the NE555 ICs. The astable
multivibrators do not require any external trigger to change the state of the output hence the
name free running oscillator. The time during which the output is either high or low is
determined by the two resistors and a capacitor which are externally connected to the
NE555 timers. The IR transmitter circuit is used to generate the modulated 38 KHz IR signal.
Then you point it over the TSOP4838 sensor and its output will go low (0V) when it senses the
IR signal of 38 kHz and high (5V) when the IR signal is blocked from reaching it by a customer
entering or leaving the premises. As a result, the system is able to greatly conserve power.
![Page 30: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/30.jpg)
19
NE555 Timer IC
The NE555 monolithic timing circuit is a highly stable controller capable of producing accurate
and highly stable time delays or oscillation. The timer basically operates in one of the two
modes: either as a monostable (one-shot) multivibrator or as an astable (free-running)
multivibrator. With a monostable operation, the time delay is controlled by one external resistor
and one capacitor. With an astable operation, the frequency and duty cycle are accurately
controlled by two external resistors and one capacitor. The circuit may be triggered and reset on
falling waveforms, and the output structure can source or sink up to 200 mA.
Features of NE555 Timer
Turn-off time less than 2 microseconds
Maximum operating frequency greater than 500 kHz
Timing from microseconds to hours
Operates in both astable and monostable modes
High output current drive capability. Output Can Sink or Source upto 200 mA
Adjustable duty cycle
TTL-Compatible.
Temperature stability of 0.005% per °C
Applications of NE555 Timer
Precision timing
Pulse generation
Sequential timing
Time delay generation
Pulse width modulation
The figure below shows the pin diagram of the NE555 timer IC.
Figure 7: Pin Diagram of NE555
![Page 31: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/31.jpg)
20
NE555 Timer IC Block Diagram
Figure 8: NE555 Timer IC Block Diagram
Purpose of NE555 Timer in CVMS
As earlier mentioned, the CVMS uses infrared rays emitted by infrared LED transmitters to detect
customers entering and leaving a business premises. These rays can be detected by the TSOP4838
infrared sensors only if they are modulated at 38 kHz. Therefore, a driving circuit comprising NE555
timer configured as an astable multivibrator is needed to feed the infrared LEDs with the required
modulated square wave of frequency 38 kHz.
Astable Multivibrator Circuit
The 38 kHz square wave signal required by the infrared LEDs can be generated using an astable
multivibrator circuit. An astable multivibrator, also called free running multivibrator, generates a square
wave of known period. It does not have any permanent stable state but has two quasi-stable states. The
circuit changes state continuously from one quasi-state to the other after a predetermined length of time
and no external trigger pulse is needed. This length of time is determined by the circuit time constants and
parameters. This circuit can be implemented in a variety of ways. It can be realized by a pair of
regeneratively coupled active devices (BJTs and FETs), negative resistance devices (UJTs, tunnel diodes,
etc) and operational amplifiers. Upon research, I found out that 555 timer would be a suitable choice
because of its compactness, reliability and frequency stability. In this project, NE555 timers have
therefore been used to produced frequency modulated IR light to the TSOP4838 receivers.
![Page 32: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/32.jpg)
21
Each of the two LED transmitter circuits is connected as shown below with the astable multivibrator
modulating the infrared light from the transmitter to be at 38 KHz, the frequency of infrared light detected
by the TSOP4838 infrared receiver used.
R1= 1.8KΩ, R= 18KΩ, C1= 0.001µF, C2= 0.01µF
Figure 9: Frequency modulated transmitter circuit
The 38KHz frequency of infrared light from LED transmitter, f, is obtained by varying R1, R2
and C1. Generally, the following equation is used to calculate f whenever values of R1, R2 and
C1 are chosen by the oscillator designer. From my transmitter circuit design, the frequency of
infrared light from LED transmitter is given as:
f = [1.44/(R1+2R2)*C1]
= [1.44/(1.8KΩ+36KΩ)* 0.001µF]
= 38 KHz
TSOP4838 Infrared Receiver
This is a miniaturized receiver for infrared remote control systems. A PIN diode and a
preamplifier are assembled on a lead frame with the epoxy package acting as an IR filter. The
demodulated output signal can be directly connected to a digital input. The TSOP4838 is a
legacy product for all common IR remote control data formats. This receiver offers high, fixed
gain – detection threshold does not change with changes in ambient light and optical noise in
environment. The IR LED transmitter emits modulated 38 KHz IR signal which is detected by the
TSOP4838 infrared receiver. The output goes high when there is an interruption and it returns back to low
after the time period determined by the capacitor and resistor in the circuit, typically around 1 second.
![Page 33: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/33.jpg)
22
Figure 10: TSOP4838 IR Receiver
Features of TSOP4838 IR Receiver
Photo detector and preamplifier in one package
Internal filter for PCM frequency
Improved shielding against Electromagnetic Interference(EMI)
Improved immunity against ambient light
Insensitive to supply voltage ripple and noise
Fast reaction time – works with continuous 38 kHz signal (Operating/Carrier frequency)
Supply Voltage Range: 2.5V to 5.5V
Low Supply Current consumption (950µA)
Opto Case Style: Through Hole
Operating Temperature Range: -25°C to +85°C
Package Dimensions (mm): 6.9 H x 5.6 W x 6.0 L
Package Pinning: 1= OUT, 2= GND, 3= Vs
Diode Type: Amplified Photodiode
Mounting: Leaded (Lead Length: 23.55mm)
Application: Remote control
AGC: Legacy, for long burst remote control (AGC2)
Block Diagram of TSOP4838
1= OUT, 2= GND, 3= Vs
Figure 11: Block Diagram of TSOP4838
![Page 34: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/34.jpg)
23
The IR receiver (detector) has a band pass filter to reject spurious signals like fluorescent lights
and Automatic Gain Control (AGC) to help in reception of weak signals. AGC is used to control
the dynamic range of radio receivers. Some long range sensors adjust their detection threshold
depending on the amount of ambient light and optical noise present in the environment. With
noise, the gain of the amplifier is reduced to avoid false detections. When exposed to lower light
levels, the adjustable gain makes the receiver too sensitive. It will detect reflected or stray light.
TSOP4838 eliminates this problem by having a fixed gain. During sensor development, the
power applied to the emitter is adjusted for the maximum brightness level expected in the
sensor’s operating environment. The sensitivity of the infrared receiver can be optimally adjusted
by changing the size of the aperture and the use of attenuation filters. The TSOP4838 sensor will
have the same response regardless of the ambient light.
Some long range sensors require the infrared beam to be interrupted for up to 5 ms before
detecting an object. However, with the TSOP4838, response time is much faster; requiring the
signal to be interrupted for only 300 μs before responding. For the shortest response time a
continuous 38 kHz signal should be used. For the longest distance, the TSAL6200 infrared LED
transmitter should be driven with a higher current using a 38 kHz burst pattern.
TSOP4838 Application Circuit
Figure 12: TSOP4838 Application Circuit
Each of the two TSOP4838 infrared receivers used in the customer detection system is connected
as illustrated in the above circuit. The external components R1 and C1 are optional to improve
the robustness against electrical overstress (typical values are R1= 100Ω, C1= 0.1 µF). R1 and
C1 are used as an input filter to keep noise on the power supply from causing false triggers in the
TSOP4838 receiver. The receiver output only has weak pull up resistor (33 KΩ), so an external
resistor R1 is used to augment this.
The TSOP4838 infrared receivers are designed to suppress spurious output pulses due to noise or
disturbance signals. The devices can distinguish data signals from noise due to differences in
frequency, burst length, and envelope duty cycle. The data signal should be close to the device’s
band-pass center frequency (i.e. 38 kHz). When a data signal is applied to TSOP4838 infrared
receiver in the presence of a disturbance, the sensitivity of the receiver is automatically reduced
by the AGC to ensure that no spurious pulses are present at the receiver’s output.
![Page 35: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/35.jpg)
24
CHAPTER 3: DESIGN AND IMPLEMENTATION
3.1 Project Description
After comprehensive research on various technologies employed in both manual and automatic
customer counting systems, the Infrared Transmitter – Receiver System was selected for
customer detection due to its numerous advantages. Consequently, a low-cost microcontroller-
based customer counter was designed and implemented for use in order to know the number of
customers in a business at any one time and track periodic customer volumes in hours, days and
months. The components required in the system were all inexpensive and readily available in the
market.
Two infrared transmitter – receiver pairs were installed at a single passage serving as customer
entry/exit point. The Customer Volume Monitoring System (CVMS) consists of 5 major
sections:
(i) Customer Detection Section
The main purpose of this system is to detect customers who are entering or exiting the business
premises. Two Infrared LED transmitters, two NE555 timers, two TSOP4838 infrared receivers
(proximity sensors), among other circuit components were used.
(ii) Customer Data Processing Section
This uses the Central Processing Unit of the ATmega328 microcontroller.
(iii) Customer Database System
This was developed using Microsoft Visual C#.net installed in a PC.
(iv) Customer Display System
This was achieved through development of a user-friendly graphical user interface using
Microsoft Visual C#.net installed in a PC.
(v) Time Monitoring System
This utilizes the DS1307 RTC Module for Arduino in monitoring the time at which the customer
counter data is to be send to the serial port of the PC for reading, storage and display in the
C#.net database system.
3.2 System Algorithm
Step 1: Start the Customer Volume Monitoring System operation.
Step 2: A beam of infrared light signal is continuously transmitted from the infrared LED
transmitters to the infrared TSOP4838 receivers.
Step 3: The customer motion and the counter value are both initialized to zero. Motion can either
be 0 for waiting state, 1 for move in state or 2 for move out state. On the other hand, the counter
![Page 36: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/36.jpg)
25
can only take a value greater than or equal to zero as dictated by the number of customers within
the premises at any one moment.
Step 4: When the CVMS receives an interrupt from sensor 1 followed by an interrupt from
sensor 2, this is interpreted by the microcontroller as an entry and then the counter is
incremented by 1. The CVMS database is then updated and current number of customers in the
premises is displayed on the C#.net graphical user interface.
Step 5: When the CVMS receives an interrupt from sensor 2 followed by an interrupt from
sensor 1, this is interpreted by the microcontroller as an exit and then the counter is decremented
by 1. The CVMS database is then updated and current number of customers in the premises is
displayed on the C#.net graphical user interface.
Step 6: The Customer Volume Monitoring System operation continues every time the
interruption of the infrared light occurs.
Step7: When 24 minutes (representing the 24 hours in a day) elapse, the microcontroller carries
out computation to get the total customers for that day and this is displayed on the GUI and also
saved in the database for future use.
Step 8: When 720 minutes (representing the total hours in a month of 30 days) elapse, the
microcontroller carries out computation to get the total customers for that month and this is
displayed on the GUI and also saved in the database for future use.
![Page 37: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/37.jpg)
26
3.3 System Flowchart
Figure 13: CVMS Flowchart
![Page 38: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/38.jpg)
27
3.4 Hardware Design
3.4.1 CVMS Hardware Connection
The figures below shows an interconnection of the various hardware components required for the
Customer Volume Monitoring System.
Figure 14: CVMS Hardware Connection
Figure 15: CVMS Counter Circuit
![Page 39: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/39.jpg)
28
3.4.2 CVMS SCHEMATIC DIAGRAM
The following is the schematic diagram of CVMS as designed using Proteus 7 Professional:
Figure 16: CVMS Schematic Diagram
3.4.3 CVMS PCB Fabrication
PCB Fabrication Overview
A printed circuit board (PCB) refers to the board used for physically supporting and wiring
surface-mounted and through-hole mounted components in many electronic circuits. Presently,
there are different software available in the market for making of the PCB design/layout e.g.
Express PCB, Proteus, Eagle, etc.
![Page 40: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/40.jpg)
29
The following diagram shows the CVMS printed circuit board (PCB) design done using Express
PCB.
Figure 17: CVMS PCB Design
Materials Required in PCB Fabrication
a) Copper clad board
b) Ferric chloride
c) Glossy paper
d) Iron box
e) Three trays
f) Thinner
g) Marker
h) Immersion heater
FCB Fabrication and holes’ drilling
The following was the procedure followed:
i) An ordinary laser jet printer was used for obtaining a print out of the PCB artwork in a
glossy paper. During printing, toner from the laser jet printer was transferred onto the
glossy paper.
![Page 41: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/41.jpg)
31
ii) The copper clad board and printed glossy paper were both cut to fit the PCB artwork.
iii) The surface of the copper clad board was then cleaned using steel wool.
iv) The artwork was then placed facing the copper surface. A warm iron box was afterwards
placed on top of the glossy paper in order to stick it to the copper clad board.
v) The artwork was then firmly ironed onto the copper clad. A heat resistant material was
used to hold the copper clad board and the artwork in place. Then, sufficient pressure was
applied on the iron box so that the toner in the glossy paper was transferred properly from
the paper onto the copper clad board. A lot of care was taken so as not to skid the artwork
while ironing. The principle of operation was that the hot ironing transferred the toner in
glossy paper onto the copper clad thus making the circuit layout on the copper clad board.
After 3 – 4 minutes of ironing, it was possible to see the circuit layout begin to be visible
on the ironing face as veins of a leaf. At that juncture, it was clear that the artwork had
been successfully transferred onto the copper clad board. Caution was taken not to burn
hands with the now hot copper clad board.
vi) The copper clad board was then let to cool for about 5 minutes to prevent the board from
sudden contraction when placed in cold water. Afterwards, the copper clad board was
placed in a tray of cold water for about 5 minutes in order to remove the paper from the
board. Sodium hydrogen carbonate was used to make the process faster. After the paper
was loosened by the water, it was slowly removed by hand. The unnecessary paper from
the copper clad between pad and in between drill holes was also carefully removed. The
missing pads were joined using a marker. Now the circuit only had circuit layout. This
was the mask which resisted Ferric Chloride from etching the copper tracks in the PCB
design.
vii) Water was then boiled using the immersion heater. Then, the hot water was put in the
second tray which was bigger than all the rest. This second tray was just about half full of
the hot water. Ferric Chloride solution was then put in the last tray and the copper clad
board was immersed therein. The tray with the copper clad board was then immersed in
the bigger tray with hot water. The two trays were then slightly shaken to speed up the
etching process. In about 10-15 minutes the copper clad board was completely etched and
the copper tracks were clearly visible on the board. The board was then rinsed in cold
water.
viii) A drill with an appropriate bit size was then used for drilling holes for each of the PCB
components. Proper alignment of holes was done so that inserting ICs into the PCB would be
easy. Afterwards, the print mask was removed from the PCB using thinner.
Soldering
The components’ legs were cleaned with steel wool before soldering as oxide layer on
them would have resulted in cold solder.
![Page 42: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/42.jpg)
32
All the circuit components were then soldered into their respective areas as per the PCB
design.
The continuity test, using multimeter in diode mode, was used to make sure the adjacent
pins of ICs were not shorted while soldering.
The flux between pins was then cleaned.
3.7 Software Design
3.7.1 CVMS Counter
The program for counting the number of customers entering or exiting the business at any one
time was written using the Arduino 1.5.2 software. It was then uploaded into the ATMEGA328P
microcontroller. The code was then tested and debugged until it was error-free and running as
expected.
3.7.2 CVMS Database and GUI
The code for the CVMS database and GUI was written in Microsoft Visual Studio C#.net. The
figure below shows the system graphical user interface developed.
Figure 18: CVMS Graphical User Interface
![Page 43: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/43.jpg)
33
CHAPTER 4: RESULTS, ANALYSIS AND DISCUSSION
4.1 CVMS Results
4.1.1 Real-time and Hourly Customer Display
After successful system design and implementation, the Customer Volume Monitoring System
was found to accurately count and display the actual number of customers within a business
premises in real-time as well as track periodic changes in customer volumes in hours. For the
sake of project presentation and results generation, a minute was taken to represent an hour. As a
result, the CVMS counter was slightly modified to give the number of customers within the
premises at any one time and track periodic changes in customer volumes as minutes elapsed.
However, in the physical deployment of the system, an hour would be after 60 minutes have
elapsed. The table below shows the results obtained.
Figure 19: Real-time and Hourly Customer Display
4.1.2 Daily Customer Count Display
Following successful system design and implementation, the Customer Volume Monitoring
System was found to accurately count and display the actual number of customers who visited
the business premises as days elapsed. For the sake of project presentation and results generation,
a day was taken to represent 24 minutes. As a result, the CVMS counter was slightly modified to
give the number of customers who had visited the premises at every period of 24 minutes.
However, in the physical deployment of the system, a day would mean 24 hours will have
elapsed. The results obtained were as follows:
![Page 44: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/44.jpg)
34
Figure 20: Real-time and Daily Customer Display
4.1.3 Monthly Customer Display
The program for detection and display of the number of customers who visited the business
premises at the end of every month (30 days period) was successfully written and debugged. Due
to limited time at my disposal, it was not possible to wait for the system to count customers
entering and leaving the premises for a period of 720 minutes or 12 hours (since 24 minutes
would represent a day). Nevertheless, it is expected that the system would have worked perfectly
and efficiently to give the monthly count of customers visiting the premises.
4.2 Customer Data Analysis
Below is a table showing a sample customer data and analysis through a bar chart. The customer
data for all the hours in a day, days in a week and months in a year is analyzed in a similar
manner.
![Page 45: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/45.jpg)
35
Hours Current Customers
0600 hrs 10
0700 hrs 25
0800 hrs 5
0900 hrs 49
1000 hrs 64
1100 hrs 30
1200 hrs 18
Table 1: Customer Data
0
10
20
30
40
50
60
70
Current Customers
0600 hrs
0700 hrs
0800 hrs
0900 hrs
1000 hrs
1100 hrs
1200 hrs
Figure 21: Customer Data Bar Graph
4.3 Discussion
4.3.1 System Performance
4.3.2 Challenges Faced
The successful design and implementation of the Customer Volume Monitoring System (CVMS)
has not been without challenges. The main challenges encountered were:-
Limited time within which to design and implement a properly working CVMS Counter,
Database and Graphical User Interface.
![Page 46: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/46.jpg)
36
Delay in delivery of the hardware components required for the project. Due to time
constraints and commitment to deliver a properly working CVMS, I was forced to look
for means of personally purchasing the required components.
Thankfully, I was able to overcome the aforementioned challenges and the project design and
implementation was a great success.
![Page 47: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/47.jpg)
37
CHAPTER 5: RECOMMENDATIONS AND CONCLUSION
5.1 Conclusion
Customer Volume Monitoring System was successfully designed and implemented using
Arduino Uno R3, DS1307 Real Time Clock module, TSAL6200 infrared LED transmitters,
NE555 timers, TSOP4838 infrared receivers, Microsoft Visual C#.net software among other
system components. This type of design is well suited for implementation in all business
premises and other places where the number of persons in a building at any time is required. The
system can also be employed to ease congestion in places where the space is limited. Based on
this system design and implementation, CVMS can also be queried to ascertain the number of
customers who visited the premises at a particular hour, day or month. This assists the business
management in doing periodical assessment of the level of business performance and customer
satisfaction as evidenced by the sales data or frequent customer visits to the premises.
5.2 Recommendations
Customer counting is not just limited to the capture and storage of the number of customers
entering and leaving a business but has a wide range of applications that provide information to
management on the volume and flow of people throughout a location. The Customer Volume
Monitoring System can thus be further be developed so that;
It can generate system reports which can be printed out by the business management staff
so as to make analysis of the customer data collected easier.
Sending of the customer data to a remote location using mobile or internet is possible.
The CVMS can also be interfaced with a GSM modem to send the customer counter data
through SMS.
CVMS can easily be integrated with a business’ Point of Sale (POS) system or workforce
management system. Through using this integration, a business can achieve important
key values such as the number of transactions per the number of customers and hence put
the customer statistics in relation to a business’ turnover, as well as increase the
efficiency in staff planning.
![Page 48: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/48.jpg)
38
BIBLIOGRAPHY
[1] J. Blum, Exploring Arduino: Tools and Techniques for Engineering Wizardry, John Wiley &
Sons, 2013
[2] Massimo Banzi, Getting Started with Arduino, Second Edition, O’Reilly Media Inc., 2011
[3] B. Evans, Beginning Arduino Programming, 1st Edition, Apress, 2011
[4] M. Margolis, Arduino Cookbook, O’Reilly
[5] http://www.homeandlearn.co.uk/csharp(Accessed on 28/11/2013 – 5/01/2014)
[6] http://arduino.cc/en/Guide/ (Accessed on 19/11/2013 – 20/11/2013)
[7] www.vishay.com (Accessed on 12/12/2013)
[8] http://www.ladyada.net/learn/arduino/ (Accessed on 17/11/2013)
[9] www.datasheets4u.com (Accessed on 05/01/2014)
[10] www.datasheetcatalog.com (Accessed on 13/01/2014)
![Page 49: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/49.jpg)
39
APPENDICES
APPENDIX A: CVMS PROGRAM
//PROJECT NO.16: CUSTOMER VOLUME MONITORING SYSTEM
//STUDENT: KAVOI STEPHEN MUTINDA F17/2466/2008
//SUPERVISOR: DR.GEORGE N. KAMUCHA
//EXAMINER: DR. VASANT M. DHARMADHIKARY
#include <Wire.h>
#include "RTClib.h"
RTC_Millis rtc;
int pin_out = 0; // Interrupt 0 is on DIGITAL PIN 2!
int pin_in = 1;
volatile int motion = 0; // 0 = waiting state, 1 = motion in, and 2 = motion out.
int counter = 0;
int previous_counter = 0;
int current_hour = 0;
int previous_hour = 0;
void setup()
Serial.begin(9600);
//Attach the interrupt to the input pin and monitor for ANY Change
attachInterrupt(pin_out, Interrupt_out_Routine, RISING );
attachInterrupt(pin_in, Interrupt_in_Routine, RISING );
// following line sets the RTC to the date & time this sketch was compiled
rtc.begin(DateTime(__DATE__, __TIME__));
DateTime now = rtc.now();
![Page 50: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/50.jpg)
40
previous_hour = (now.minute());
delay(3000);
void loop()
DateTime now = rtc.now();
current_hour = (now.minute());
if ( current_hour != previous_hour)
Serial.println(previous_hour);
delay(2000);
Serial.println(counter);
previous_hour = current_hour;
// Serial.print(" ");
// Serial.println(data[1]);
// Serial.print(" ");
// Serial.println(counter_out);
// delay(3000);
else
;// Serial.println("same hour");
if (previous_counter != counter)
Serial.println("112233");
![Page 51: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/51.jpg)
41
delay(1000);
Serial.println(counter);
previous_counter = counter;
delay(1000);
else
;
void Interrupt_in_Routine()
if(motion != 0)
motion = 0;
else
motion = 1;
(counter)++;
void Interrupt_out_Routine()
if(motion != 0)
motion = 0;
![Page 52: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/52.jpg)
42
else
motion = 2;
if(counter <= 0)
counter = 0;
else
(counter)--;
![Page 53: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/53.jpg)
43
APPENDIX B: CVMS DATABASE AND GUI PROGRAM
//PROJECT NO.16: CUSTOMER VOLUME MONITORING SYSTEM (CVMS)
//STUDENT: KAVOI STEPHEN MUTINDA F17/2466/2008
//SUPERVISOR: DR.GEORGE N. KAMUCHA
//EXAMINER: DR. VASANT M. DHARMADHIKARY
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO.Ports;
using System.Threading;
namespace connection
public partial class Form1 : Form
// Global variables
delegate void SetTextCallback(string text);
string x = "x";
SerialPort mySerialPort;
static string indata;
int Incoming_data = 0; //0 = waiting for new data, 1 = first data and 2 = second data.
static string hour;
static string Number_of_people;
int index = 1;
int index_days = 1;
int index_months = 1;
int index_years = 1;
int inc_hours = 0;
int inc_days = 0;
int inc_months = 0;
int inc_years = 0;
int max_row_hours = 0;
int max_row_days = 0;
int max_row_months = 0;
int max_row_years = 0;
int day_sum = 0;
int month_sum = 0;
int year_sum = 0;
string[] array_days = "Monday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
![Page 54: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/54.jpg)
44
"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday",
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ;
string[] array_months = "January", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December", "January",
"February", "March", "April", "May", "June", "July", "August", "September", "October",
"November", "December" ;
string[] array_years = "2014", "2014", "2015", "2016", "2017", "2018", "2019", "2020",
"2021", "2022", "2023" ;
SqlConnection cn = new SqlConnection(@"Data
Source=.\SQLEXPRESS;AttachDbFilename= Data
Source=.\SQLEXPRESS;AttachDbFilename=M:\Kavoi\Kamnehpets\Kavoi
Project\CVMS\connection\connection\Database1.mdf;Integrated Security=True;User
Instance=True");
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
public Form1()
InitializeComponent();
private void Form1_Load(object sender, EventArgs e)
cmd.Connection = cn;
loadlist();
NavigateRecords();
SetText("EMPTY");
table_index();
private void loadlist()//clears the list boxes and loads new data from the database(table
info).
listBox1.Items.Clear();
listBox2.Items.Clear();
listBox3.Items.Clear();
cn.Open();
if (radioButtonHours.Checked)
cmd.CommandText = "select * from info";
// cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
while (dr.Read())
listBox1.Items.Add(dr[0].ToString());
listBox2.Items.Add(dr[1].ToString());// + ".00 HOURS");
listBox3.Items.Add(dr[2].ToString());
![Page 55: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/55.jpg)
45
else if (radioButtonDays.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
while (dr.Read())
listBox1.Items.Add(dr[0].ToString());
listBox2.Items.Add(dr[1].ToString());
listBox3.Items.Add(dr[2].ToString());
else if (radioButtonMonths.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tblmonths";
dr = cmd.ExecuteReader();
if (dr.HasRows)
while (dr.Read())
listBox1.Items.Add(dr[0].ToString());
listBox2.Items.Add(dr[1].ToString());
listBox3.Items.Add(dr[2].ToString());
else if (radioButtonYears.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tblyears";
dr = cmd.ExecuteReader();
if (dr.HasRows)
while (dr.Read())
listBox1.Items.Add(dr[0].ToString());
listBox2.Items.Add(dr[1].ToString());
listBox3.Items.Add(dr[2].ToString());
cn.Close();
![Page 56: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/56.jpg)
46
private void number_of_rows()
cn.Open();
if (radioButtonHours.Checked)
cmd.CommandText = "select * from info";
//cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_hours = 0;
while (dr.Read())
max_row_hours++;
// MessageBox.Show(max_row_hours.ToString(), "number of rows");
else if (radioButtonDays.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_days = 0;
while (dr.Read())
max_row_days++;
// MessageBox.Show(max_row_days.ToString(), "number of rows");
else if (radioButtonMonths.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tblmonths";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_months = 0;
while (dr.Read())
max_row_months++;
![Page 57: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/57.jpg)
47
// MessageBox.Show(max_row_days.ToString(), "number of rows");
else if (radioButtonYears.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tblyears";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_years = 0;
while (dr.Read())
max_row_years++;
// MessageBox.Show(max_row_days.ToString(), "number of rows");
cn.Close();
private void NavigateRecords()
cn.Open();
if (radioButtonHours.Checked)
cmd.CommandText = "select * from info";
//cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
int rec = 0;
while (dr.Read())
if (rec == inc_hours)
textBox1.Text = (dr[0].ToString());
textBox2.Text = (dr[1].ToString());// + ".00 HOURS");
textBox3.Text = (dr[2].ToString());
rec++;
else if (radioButtonDays.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
int rec = 0;
while (dr.Read())
if (rec == inc_days)
![Page 58: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/58.jpg)
48
textBox1.Text = (dr[0].ToString());
textBox2.Text = (dr[1].ToString());
textBox3.Text = (dr[2].ToString());
rec++;
else if (radioButtonMonths.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tblmonths";
dr = cmd.ExecuteReader();
int rec = 0;
while (dr.Read())
if (rec == inc_months)
textBox1.Text = (dr[0].ToString());
textBox2.Text = (dr[1].ToString());
textBox3.Text = (dr[2].ToString());
rec++;
else if (radioButtonYears.Checked)
//cmd.CommandText = "select * from info";
cmd.CommandText = "select * from tblyears";
dr = cmd.ExecuteReader();
int rec = 0;
while (dr.Read())
if (rec == inc_years)
textBox1.Text = (dr[0].ToString());
textBox2.Text = (dr[1].ToString());
textBox3.Text = (dr[2].ToString());
rec++;
cn.Close();
private void listBox3_SelectedValueChanged(object sender, EventArgs e)
ListBox l= sender as ListBox;
if (l.SelectedIndex != -1)
![Page 59: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/59.jpg)
49
listBox1.SelectedIndex = l.SelectedIndex;
listBox2.SelectedIndex = l.SelectedIndex;
listBox3.SelectedIndex = l.SelectedIndex;
textBox1.Text = listBox1.SelectedItem.ToString();
textBox2.Text = listBox2.SelectedItem.ToString();
textBox3.Text = listBox3.SelectedItem.ToString();
private void btndelete_Click(object sender, EventArgs e)
if (textBox1.Text != "" & textBox2.Text != "")
cn.Open();
if (radioButtonHours.Checked)
cmd.CommandText = "delete from info where ID= '" + textBox1.Text + "' and
HOUR= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
//cmd.CommandText = "delete from tbldays where ID= '" + textBox1.Text + "' and
DAY= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.ExecuteNonQuery();
cn.Close();
// MessageBox.Show("RECORD DELETED");
loadlist();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
else if (radioButtonDays.Checked)
// cmd.CommandText = "delete from info where ID= '" + textBox1.Text + "' and
HOUR= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.CommandText = "delete from tbldays where ID= '" + textBox1.Text + "' and
DAY= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.ExecuteNonQuery();
cn.Close();
// MessageBox.Show("RECORD DELETED");
loadlist();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
else if (radioButtonMonths.Checked)
// cmd.CommandText = "delete from info where ID= '" + textBox1.Text + "' and
HOUR= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.CommandText = "delete from tblmonths where ID= '" + textBox1.Text + "' and
MONTH= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.ExecuteNonQuery();
![Page 60: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/60.jpg)
50
cn.Close();
// MessageBox.Show("RECORD DELETED");
loadlist();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
else if (radioButtonYears.Checked)
// cmd.CommandText = "delete from info where ID= '" + textBox1.Text + "' and
HOUR= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.CommandText = "delete from tblyears where ID= '" + textBox1.Text + "' and
YEAR= '" + textBox2.Text + "' and PEOPLE= '" + textBox3.Text + "'";
cmd.ExecuteNonQuery();
cn.Close();
// MessageBox.Show("RECORD DELETED");
loadlist();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
NavigateRecords();
private void btnopenserialport_Click(object sender, EventArgs e)
mySerialPort = new SerialPort("COM44");
mySerialPort.BaudRate = 9600;
mySerialPort.Parity = Parity.None;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits = 8;
mySerialPort.Handshake = Handshake.None;
mySerialPort.DataReceived += new
SerialDataReceivedEventHandler(DataReceivedHandler);
mySerialPort.Open();
if (mySerialPort.IsOpen)
btnopenserialport.Enabled = false;
btncloseserialport.Enabled = true;
private void SetText(string text)
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.txtCustomers.InvokeRequired)
![Page 61: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/61.jpg)
51
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] text );
else
this.txtCustomers.Text = text;
public void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
SerialPort sp = (SerialPort)sender;
indata = sp.ReadLine();
if (int.Parse(indata) == 112233)
Incoming_data = 3;
//MessageBox.Show("equal");
else
if (Incoming_data == 0)
Incoming_data = 1;
fill_buffer();
else if (Incoming_data == 1)
Incoming_data = 2;
fill_buffer();
else if (Incoming_data == 3)
SetText(indata.ToString() + "");
Incoming_data = 0;
else ;
//fill_buffer();
private void btncloseserialport_Click(object sender, EventArgs e)
if (mySerialPort.IsOpen)
mySerialPort.Close();
btnopenserialport.Enabled = true;
btncloseserialport.Enabled = false;
![Page 62: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/62.jpg)
52
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
if (mySerialPort.IsOpen) mySerialPort.Close();
public void fill_buffer()
if (Incoming_data == 1)
hour = indata;
else if (Incoming_data == 2)
Number_of_people = indata;
Incoming_data = 0;
// update = 0;
write_data();
public void write_data()
//updating the hourly table
cn.Open();
cmd.CommandText = "insert into info (ID,HOUR,PEOPLE) values ('" + index + "','" +
(hour + ".00 HOURS") + "','" + Number_of_people + "')";
cmd.ExecuteNonQuery();
cmd.Clone();
//MessageBox.Show("record inserted");
cn.Close();
int day_end = int.Parse(hour);
//cheking if the day has come to an end
if (day_end == 23)//should be 24
//accessing the hourly table to sum up the the day's count.
cn.Open();
cmd.CommandText = "select * from info";
dr = cmd.ExecuteReader();
if (dr.HasRows)
day_sum = 0;
while (dr.Read())
day_sum += int.Parse(dr[2].ToString());
cn.Close();
//MessageBox.Show(day_sum.ToString(), "sum for the day");
//updating the daily table.
// int month_end = index_days;// int.Parse(hour);//came from a line indicated below.
cn.Open();
![Page 63: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/63.jpg)
53
cmd.CommandText = "insert into tbldays (ID,DAY,PEOPLE) values ('" +
index_days + "','" + array_days[index_days] + "','" + day_sum + "')";
cmd.ExecuteNonQuery();
cmd.Clone();
// MessageBox.Show("record inserted in table days");
cn.Close();
int month_end = index_days;// int.Parse(hour);//original place before moving it up.
//cheking if the month has come to an end
if (month_end == 30)//should be 30
//accessing the daily table to sum up the the month's count.
cn.Open();
cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
month_sum = 0;
while (dr.Read())
month_sum += int.Parse(dr[2].ToString());
cn.Close();
//updating the monthly table.
cn.Open();
cmd.CommandText = "insert into tblmonths (ID,MONTH,PEOPLE) values ('"
+ index_months + "','" + array_months[index_months] + "','" + month_sum + "')";
cmd.ExecuteNonQuery();
cmd.Clone();
// MessageBox.Show("record inserted in table days");
cn.Close();
int year_end = index_months;// int.Parse(hour);
//cheking if the year has come to an end
if (year_end == 12)
//accessing the monthly table to sum up the the year's count.
cn.Open();
cmd.CommandText = "select * from tblmonths";
dr = cmd.ExecuteReader();
if (dr.HasRows)
year_sum = 0;
while (dr.Read())
year_sum += int.Parse(dr[2].ToString());
cn.Close();
//updating the yearly table.
cn.Open();
cmd.CommandText = "insert into tblyears (ID,YEAR,PEOPLE) values ('"
+ index_years + "','" + array_years[index_years] + "','" + year_sum + "')";
cmd.ExecuteNonQuery();
![Page 64: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/64.jpg)
54
cmd.Clone();
// MessageBox.Show("record inserted in table days");
cn.Close();
//accessing the monthly table in preparation for clearing it up.
int max_row_month = 0;
cn.Open();
cmd.CommandText = "select * from tblmonths";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_month = 0;
while (dr.Read())
max_row_month++;
cn.Close();
//deleting all the data from the monthly table.
cn.Open();
while (max_row_month >= 1)
cmd.CommandText = "delete from tblmonths where ID= '" +
max_row_month + "'";
cmd.ExecuteNonQuery();
max_row_month--;
cn.Close();
index_months = 0;
index_months++;
//accessing the daily table in preparation for clearing it up.
int max_row_day = 0;
cn.Open();
cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_day = 0;
while (dr.Read())
max_row_day++;
cn.Close();
//deleting all the data from the daily table.
cn.Open();
while (max_row_day >= 1)
![Page 65: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/65.jpg)
55
cmd.CommandText = "delete from tbldays where ID= '" + max_row_day +
"'";
cmd.ExecuteNonQuery();
max_row_day--;
cn.Close();
index_days = 0;
index_days++;
//accessing the hourly table in preparation for clearing it up.
int max_row_hour = 0;
cn.Open();
cmd.CommandText = "select * from info";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_hour = 0;
while (dr.Read())
max_row_hour++;
cn.Close();
//deleting all the data from the hourly table.
cn.Open();
while (max_row_hour >= 0)
cmd.CommandText = "delete from info where ID= '" + max_row_hour + "'";
cmd.ExecuteNonQuery();
max_row_hour--;
cn.Close();
index = 0;
// MessageBox.Show("table info cleared");
index++;
private void btnnext_Click(object sender, EventArgs e)
number_of_rows();
if (radioButtonHours.Checked)
if (inc_hours != max_row_hours - 1)
![Page 66: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/66.jpg)
56
inc_hours++;
NavigateRecords();
else
MessageBox.Show("No More Rows");
else if (radioButtonDays.Checked)
if (inc_days != max_row_days - 1)
inc_days++;
NavigateRecords();
else
MessageBox.Show("No More Rows");
else if (radioButtonMonths.Checked)
if (inc_months != max_row_months - 1)
inc_months++;
NavigateRecords();
else
MessageBox.Show("No More Rows");
else if (radioButtonYears.Checked)
if (inc_years != max_row_years - 1)
inc_years++;
NavigateRecords();
else
MessageBox.Show("No More Rows");
private void btnprevious_Click(object sender, EventArgs e)
number_of_rows();
if (radioButtonHours.Checked)
![Page 67: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/67.jpg)
57
if (inc_hours > 0)
inc_hours--;
NavigateRecords();
else
MessageBox.Show("First Record");
else if (radioButtonDays.Checked)
if (inc_days > 0)
inc_days--;
NavigateRecords();
else
MessageBox.Show("First Record");
else if (radioButtonMonths.Checked)
if (inc_months > 0)
inc_months--;
NavigateRecords();
else
MessageBox.Show("First Record");
else if (radioButtonYears.Checked)
if (inc_years > 0)
inc_years--;
NavigateRecords();
else
MessageBox.Show("First Record");
private void btnfirst_Click(object sender, EventArgs e)
![Page 68: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/68.jpg)
58
number_of_rows();
if (radioButtonHours.Checked)
if (inc_hours != 0)
inc_hours = 0;
NavigateRecords();
else if (radioButtonDays.Checked)
if (inc_days != 0)
inc_days = 0;
NavigateRecords();
else if (radioButtonMonths.Checked)
if (inc_months != 0)
inc_months = 0;
NavigateRecords();
else if (radioButtonYears.Checked)
if (inc_years != 0)
inc_years = 0;
NavigateRecords();
private void btnlast_Click(object sender, EventArgs e)
number_of_rows();
if (radioButtonHours.Checked)
if (inc_hours != max_row_hours - 1)
inc_hours = max_row_hours - 1;
NavigateRecords();
else if (radioButtonDays.Checked)
if (inc_days != max_row_days - 1)
![Page 69: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/69.jpg)
59
inc_days = max_row_days - 1;
NavigateRecords();
else if (radioButtonMonths.Checked)
if (inc_months != max_row_months - 1)
inc_months = max_row_months - 1;
NavigateRecords();
else if (radioButtonYears.Checked)
if (inc_years != max_row_years - 1)
inc_years = max_row_years - 1;
NavigateRecords();
private void radioButtonHours_CheckedChanged(object sender, EventArgs e)
label2.Text = "TIME (HOURS)";
label5.Text = "TIME (HOURS)";
inc_hours = 0;
number_of_rows();
NavigateRecords();
loadlist();
private void radioButtonDays_CheckedChanged(object sender, EventArgs e)
label2.Text = "DAY";
label5.Text = "DAY";
inc_days = 0;
number_of_rows();
NavigateRecords();
loadlist();
private void radioButtonMonths_CheckedChanged(object sender, EventArgs e)
label2.Text = "MONTH";
label5.Text = "MONTH";
inc_months = 0;
number_of_rows();
NavigateRecords();
loadlist();
![Page 70: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/70.jpg)
60
private void radioButtonYears_CheckedChanged(object sender, EventArgs e)
label2.Text = "YEAR";
label5.Text = "YEAR";
inc_years = 0;
number_of_rows();
NavigateRecords();
loadlist();
private void table_index()
cn.Open();
cmd.CommandText = "select * from info";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_hours = 0;
while (dr.Read())
max_row_hours++;
index = max_row_hours + 1;
cn.Close();
cn.Close();
cn.Open();
cmd.CommandText = "select * from tbldays";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_days = 0;
while (dr.Read())
max_row_days++;
index_days = max_row_days + 1;
cn.Close();
cn.Close();
cn.Open();
cmd.CommandText = "select * from tblmonths";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_months = 0;
while (dr.Read())
![Page 71: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/71.jpg)
61
max_row_months++;
index_months = max_row_months + 1;
cn.Close();
cn.Close();
cn.Open();
cmd.CommandText = "select * from tblyears";
dr = cmd.ExecuteReader();
if (dr.HasRows)
max_row_years = 0;
while (dr.Read())
max_row_years++;
index_years = max_row_years + 1;
cn.Close();
cn.Close();
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
![Page 72: UNIVERSITY OF NAIROBI DEPARTMENT OF …eie.uonbi.ac.ke/sites/default/files/cae/engineering/eie/CUSTOMER... · DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING ... A final year](https://reader031.fdocuments.in/reader031/viewer/2022022502/5aad2f257f8b9a2b4c8e26bf/html5/thumbnails/72.jpg)
62
APPENDIX C: PROJECT TIMELINE
Owing to the time that I got my final year project, Customer Volume Monitoring System, and the
comprehensive nature of it, the following is an estimate of the time schedule within which the
project was successfully designed and implemented. The project was implemented in the
following phases;
TIME DURATION TASKS CARRIED OUT
14th
November, 2013 – 13th
January, 2014: Intensive Research and Brainstorming phase
14th
January, 2014 – 31st January, 2014: Introduction and Literature Review
1st February, 2014 – 15
th March, 2014: Hardware/Software System Design and
Implementation
16th
March, 2014 – 28th
March, 2014: Hardware/Software System Testing and
Debugging
28th
March, 2014 – 4th
April, 2014: Fine tuning of the Project Documentation,
PCB Design and Fabrication
9th
April, 2014 – 11th
April, 2014: Project Presentation and Demonstration