DIGITAL CLOCK AND VISITOR COUNTER USING A MICROPROCESSOR OR MICROCONTROLLER [Type the document subtitle] The objective of this assignment is to design and construct a prototype for a Digital Clock and Visitor Counter using a low cost microprocessor or microcontroller. Mohamad Muddassir Ghoorun 12/24/2012
PIC 16F877A use to design digital clock with visitor counter
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
DIGITAL CLOCK AND VISITOR COUNTER USING A MICROPROCESSOR OR MICROCONTROLLER [Type the document subtitle] The objective of this assignment is to design and construct a prototype for a Digital Clock and Visitor Counter using a low cost microprocessor or microcontroller. Mohamad Muddassir Ghoorun 12/24/2012
Mohamad Muddassir Ghoorun UC4F1110EEE APU
1. Introduction:
This project Digital Clock and Visitor Counter is a reliable circuit that takes over the task of
displaying the digital clock and visitors count. When somebody enters into the room then the
sensor at the entrance is triggered and the counter is incremented by one and when any one
leaves the room then the sensor at the exit is triggered and the counter is decremented by one.
Thus, the total number of persons inside the room can be calculated. The
microprocessor/microcontroller does the above job. It receives the signals from the sensors,
and this signal is operated under the control of software which is stored in RAM/ ROM.
2. Objectives:
The objective of this assignment is to design and construct a prototype for a Digital Clock and
Visitor Counter using a low cost microprocessor or microcontroller. The block diagram of such a
system is shown in Figure 1.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 1: Block diagram of digital clock and visitor counter
3. Explanation of proposed system:
In order to progressively solve this assignment, the proposed system first is going to be
divided in two parts: First one being the clock part and the second one, the visitor counter.
Furthermore, two new enhancements is going to be made to the system for further
improvement. The clock is not only going to display only time in hours, minutes and seconds
but also the date, month and year 1 information which could also be changed in case. Also,
there is going to be an alarm system 2 which would be activated as soon as the number of
persons inside the room exceeds 10; This will act as an indication that no on shall enter the
room whenever the alarm is on.
1 Enhancement 1
2 Enhancement 2
Mohamad Muddassir Ghoorun UC4F1110EEE APU
3.1. Investigation on material/component selection
A. Microcontroller
(i) 8051 microcontroller:
A microcontroller is an economical computer built on a chip to carry out a specific task. The
most commonly used set of microcontrollers belong to the 8051 family. The 8051 can be
programmed in either embedded C programming or assembly depending on the user. The
block diagram of the 8051 is shown in figure 2.
Figure 2: Block diagram of 8051
Mohamad Muddassir Ghoorun UC4F1110EEE APU
(ii) AT89S52
AT89S52 is one of the family MCS-51/52 equipped with an internal 8 Kbyte Flash EPROM
(Erasable and Programmable Read Only Memory), which allows memory to be reprogrammed.
It is a low-power, high-performance CMOS 8-bit microcontroller using Atmel high-density,
nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction
set and pin out. On-chip flash allows the program memory to be reprogrammed in-system or by a
conventional nonvolatile memory programmer. This powerful microcontroller is suitable for
many embedded control applications.
Figure 3: AT89S052 Block Diagram
Mohamad Muddassir Ghoorun UC4F1110EEE APU
(iii) PIC 16F877A
The PIC 16F877A is one of the most popular PIC in the industry and it is both very powerful and
easy to use at the same time. PIC16F877A has inbuilt analog to digital converters unlike the
8051, more ROM and RAM amongst others and thus more appropriate to use for the proposed
model. Though not going to be used, PIC16F877A has other inbuilt features such as
capture/compare/PWM peripherals, 3 timers, 2 comparators, and a universal synchronous
asynchronous receiver transmitter (USART). The PIC can be programmed on MPLAB IDE and
design can easily be simulated and viewed on Proteus software. The programmer kit can be
brought and the embedded c program downloaded into the microchip using the SK40C and the
USB ICSP PIC programmer namely UIC00B. Both the block diagram and pin diagram of PIC
16F877A are available in figure 4and 5 respectively.
Figure 4: PIC16F877A block diagram
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 5: Pin diagram of PIC16F877A
As seen above some pins have dual or more than 2 functions. In order to use these functions,
refer to the datasheet attached in the appendix. This is mainly done through programming the
pins and enabling the other functions of that specific pin.
B. Liquid crystal display screen
In the recent years LCD, is finding in daily use replacing LED‟s which may be single, Seven
Segment or Multi Segment LED‟s because of declining pricing of LCD and ability to display
numbers, characters and graphics. Another advantage of LCD is the incorporation of refreshing
controller in the LCD for relieving the CPU of the task of refreshing LCD. LM 016L is a 16 * 2
character LCD. This means that it can display 16 characters on one line and that it has the
capacity to display on two different lines.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
The LCD can be configured in two modes: parallel (8 bits) or nibble mode (4 bits). LCD
in 4 bits means that we are using only 4 lines of the data bus of a port of a microcontroller. We
can use it if the number of pins is limited to our application. However, in this project since we
have sufficient pins and are more towards speed of transmission of data to the LCD, we will
make use of the parallel mode. Each pin of the LCD screen is shown in the figure 6.
Figure 6: 16*2 LCD
Mohamad Muddassir Ghoorun UC4F1110EEE APU
The LCD command bits have been summarized in the table below:
Table 1: Command bit of LCD
C. Pushbutton:
The pushbutton has been used during simulation instead of infrared sensors to sense whether a
person comes in or goes out and is placed at the door. It works the same way as an infrared
sensor or an SPDT switch and the coding for all of them are similar. There are two ways of
connecting pushbuttons to a microcontroller/PIC. They are as shown in figure 7 and figure 8:
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 7: Pushbutton connected in pull down configuration
In the pull down configuration, microcontroller pin is connected to ground level through
a resistor (Logic 0). When the switch is pressed, microcontroller pin is connected to Vcc (logic
1). When switch is released, level goes back to level „0‟.
Figure 8: Pushbutton connected in pull up configuration
In the pull up configuration, microcontroller pin is connected to Vcc through a resistor
(Logic „1‟) before switch is pressed. When switch is pressed, it is connected to ground (logic
„0‟). When switch is released, level goes back to level „1‟.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
D. DS1307 Real time clock (RTC)
The DS1307 serial real-time clock (RTC) is a lowpower, full binary-coded decimal (BCD)
clock/calendar plus 56 bytes of NV SRAM chip as shown in figure 9. Address and data are
transferred serially through an I2C, bidirectional bus. The clock/calendar provides seconds,
minutes, hours, day, date, month, and year information. The end of the month date is
automatically adjusted for months with fewer than 31 days, including corrections for leap year.
The clock operates in either the 24-hour or 12-hour format with AM/PM indicator. The DS1307
has a built-in power-sense circuit that detects power failures and automatically switches to the
backup supply. Timekeeping operation continues while the part operates from the backup supply.
Figure 9: DS1307 RTC
Mohamad Muddassir Ghoorun UC4F1110EEE APU
4. Simulation of each block of the system
Figure 10: Simulation part for clock (hour, minutes, and seconds) and enhancement 1 (Date, month, and year)
The DS1307 clock as can be seen from the simulation results is said to be operating in the 24
hour format. It is connected to the microcontroller through pins RC3 and RC4. Three switches
connected in the pull up configurations are connected to pins RC0, RC1, and RC2 respectively.
The first one to the left is to move the pointer across the hour minutes, seconds, date, month, and
year as we normally do on normal clock in houses. The second or middle switch is to increment
the value at which the pointer is pointing. In this way, we can change all the parameters
displayed on the LCD. Switch 3 and the other two LEDs connected to port A are optional and
have been added only in case of any further enhancement or for future purposes if one wants to
improve the system.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 11: Welcoming message for visitor count part
Since putting all the design in one is going to be cumbersome due to the numerous amount of
wire lines and other components, the unused pins from the clock part has been noted down and
visitor count part has been thus designed using only the free pins as can be seen from figure 11.
The second LCD is connected to PORTD and the switches 1 and 2, act the same way as an
infrared sensor placed nect to the door to sense incoming or outgoing people. “Visitor count
part” starts with a welcoming message then starts to display the number of persons inside the
room furthermore, as said before for enhancement 2, an alarm circuit (simulated as LED) has
also been included in the design when the number of people inside the room is greater or equal to
10.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 12: Visitor part initial stage
As can be seen from figure 12, when the system starts, the number of visitors is 0 and the alarm
circuit (simulated as LED) is off.
Figure 13: Someone enter the room
Whenever anyone enters the room, they pass through the infrared sensors which causes input at
switch 1 to go to 0 which is then fed to the PIC through pin RA4. As such, the number of visitors
is immediately incremented as displayed on the LCD as shown in figure 13. Also note that alarm
circuit (simulated as LED) remains in an off state as number of visitors is less than 10 persons.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 14: Second person enters the room
If a second person enters the room, the previous count of the number of visitors is incremented to
2 and alarm circuit (simulated as LED) still remains in an off state.
Figure 14: Counting when someone leaves the room
When someone leaves the room, the infrared is again intercepted but this time at the exit door.
This causes pin RA5 to go low (0), and number of visitors count is immediately decremented and
displayed on the LCD as shown in figure 14.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 15: System at visitor count of 10
When the number of visitors or people inside the room is greater or equal to 10, this triggers the
alarm circuit to go to state 1. The alarm circuit has been simulated as a LED and as seen from
figure 15 goes to logic level 1 which therefore confirm the successful implementation of the
second enhancement. This will in turn inform any person that the room is full and that they will
have to wait until one or more people leave the room.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
5. System Flowchart
Figure 16: Flowchart for clock part
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Figure 17: Flowchart for visitor counter part
6. Discussion
In such this project to design and construct a prototype for an automatic clock with a visitor
counter system using low cost microcontroller. It needs to have the understanding the idea of the
project and then arrange this idea in the form of agenda and working on implementing it on
sequential stages. The beginning of this project was by collecting the necessary information from
different resources that could help in the accomplishment of this project.
Mohamad Muddassir Ghoorun UC4F1110EEE APU
Hardware and software that this project needs to be done was the focusing topic. For the hard
ware part selecting weather microcontroller or microprocessor was the main issue. PIC16F877A
microcontroller was the suitable option for implementing it in the executing this project. This
microcontroller need it some other hardware to be working with in order to does it task. For
software part C language was the suitable option to be dealing with. That it is considered a high
level language so that it is easy to be understood comparing to the assembly language, which
classified as low level language. For other hard ware part infrared sensor (simulated as
pushbutton for better convenience of simulation process), and DS1307 RTC clock were not
problem in the selection process.
As for the enhancement part, two extra features were added to the design and was successfully
simulated:
Date, Month and Year
Alarm circuitry to inform that number of visitors is greater or equal to 10
Thus, the main objectives of this assignment have been accomplished along with more than one
enhancement done to the system. Personally speaking, this project can be made more
professional by making use of RFID technology instead of infrared sensors at the sides of the
entrance and exit doors. By doing so, we may be able to come up with an actual system which
might be able to be marketed and implemented in the industry if not done yet.
7. Conclusion
For this project automatic clock with a visitor counter system, the final results were
satisfactory and effective. Proteus software is one of the important factors for accomplish this
project. To have a licensed version of this software will be helpful for providing the whole
software library tools in order to simulate such this project and get an accrue result. Having
knowledge about the technologies related to any project that could be making is very
Mohamad Muddassir Ghoorun UC4F1110EEE APU
important factor. That could be done by joining different work shop that many companies are
providing it. In addition to that, having a contact with lectures or senior students of the
particular engineering field could be helpful too in the achievement of such a project.
The advantages that could be found for this project are low cost and easy to be used in
different application high quality of performance. For the disadvantages, it can be noted that
the visitor counter can be used only when one single person cuts the rays of the sensor hence
it cannot be used when two person cross simultaneously.
By enhancing this circuit by adding the possibility option of many persons can be cut the
sensor‟s rays, it can be implemented in useful applications. By modifying this circuit and
using two relays it can be achieved a task of opening and closing the door This project is also
useful to be work in medicine industry, at patient‟s rooms and surgery sections especially in
the emergency situation it is necessary to be able to be manage the number of persons who