You are on page 1of 7

Stopwatch using microcontroller

Prepared by : TAN BENG HIN (HK2006-3620)


Date : 25 MARCH 2009

Executive Summary
This paper is to design and implement a stopwatch. A stopwatch is a handheld
timepiece designed to measure the amount of time elapsed from a particular time when
activated to when the piece is deactivated. The program of stopwatch was used the
assembly language and implement to the hardware.

Introduction
In this project, the stopwatch is controlled by three buttons. Pressing the first button
start the timer running, the second button is stop the timer running and the third is
reset the timer running. This stopwatch is available which due to their crystal oscillator
because it is more accurate than mechanical timepieces. The result is shown on LCD
when push then button.

Objective
In this application notes, it gives people to learn and develop knowledge in designing
the application by using the microcontroller. Besides that, it give way how to write an
assembly language and combining with the hardware and also how the microprocessor
can be embed with LCD display.

Issues
The most important in this project is creating delay part. The microcontroller executed
each instruction very fast.

Hardware System Description


Voltage regulator is used to produce limited voltage supplied to PIC. This is important
because PIC will burn out if the supply voltage more than 5.5 volt. Resistor of 1kΩ is
used to bias the switch in order to have voltage drop as input signals to PIC. Switch is

1
used to control the connectivity of input whether to produce 0 or 5 volt. This switch is
turned ON when pressed and OFF when not pushed. PIC16F84A is used to burn into the
assembled program, which will process the whole system of stopwatch. LCD of 8 bit
input is used to show the process of stopwatch done by PIC such as start, running and
stop. Crystal oscillator is an electronic circuit that uses the mechanical resonance of a
vibrating crystal of piezoelectric material to create an electrical signal with a very precise
frequency. In this project, the frequency is used to keep track of time and provide a
stable clock signal.

Software System Description


There is two language can be use in order to program the PIC, that is either low level
language that is assembly or high level language such as C programming and PIC Basic
Pro. Both of the method has an advantage and disadvantages. In this project is using
the low level language because the size of program cannot exceed 1K (PIC16F84A).

Step
In this project, programming is the most important part to achieve a stopwatch. Before
write a program, it is necessary to have a flow chart of the program stopwatch. The
figure 1 shows the flow chart of the program stopwatch. After get the flowchart, the
program code can be written now. The full program is shown in appendix A. The
software that needed to write the assembly language is MPLAB Integrated Development
environment (IDE), provided by Microchip. The advantage by using this method is the
measurement of the time can be calculated. This PIC uses the external clock from the
ceramic resonator 4MHz. each instruction line will be executed in 1µs. By using MPLAB
IDE, we can observe the time executed by microcontroller by using stopwatch function
in MPLAB. This can be obtain by choose Debugger Stopwatch in MPLAAB
software. The figure 2 show the time elapsed and total instruction by microcontroller.

2
3
Figure 1: The flowchart of the stopwatch program

Figure 2: Time executed by microcontroller

After build successful at MPLAB software, then now is the turn to build the circuit. Figure
3 show the example of full circuit. The software used to build and simulate the circuit is
Proteus software. It is necessary to put the code that builds from the MPLAB inside the
PIC that we use. Double click the PIC then at the program file there inside the program,
which is in HEX file. Then we can start to debugging and execute the stopwatch circuit.

4
Figure 3: The example of full circuit of stopwatch

Result

5
Figure 4: The LCD show the time is running when the start button is press

Figure 5: The LCD show that the time is stop running when stop button is press

Figure 6: The LCD show the start again when reset button is press

Conclusion
After this project, you are able to learn and developed knowledge in designing by used a
microcontroller. You also learn how to developed skills and knowledge in systematic

6
design approach. Besides that we are know how the microprocessorcan be embed with
LCD display.

Recommendation
Stopwatch normally use at lab when doing experimental or sport usage. The concept of
stopwatch can be apply to do digital clock, countdown or timer function, or calendar
because the concept are almost same.

Reference
1. http://en.wikipedia.org/wik
2. http://www.scribd.com
3. http://www.microchip.com
4. http://www.cytron.com.my

You might also like