Researchgatedesign and Implementation of Microcontro

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/326493983

Design and Implementation of Microcontroller Based Calculator

Article · July 2018

CITATIONS READS
14 8,218

1 author:

Engr. Dr. Oluwagbemiga Omotayo Shoewu


Lagos State University
170 PUBLICATIONS 761 CITATIONS

SEE PROFILE

All content following this page was uploaded by Engr. Dr. Oluwagbemiga Omotayo Shoewu on 21 October 2018.

The user has requested enhancement of the downloaded file.


JOURNAL OF COMPUTATION IN BIOSCIENCES AND ENGINEERING
Journal homepage: http://scienceq.org/Journals/JCLS.php

Research Article Open Access

Design and Implementation of Microcontroller Based Calculator


Adedoyin M. A.1, Olopade o.I.2, Shoewu O. O.3 , Ogunlewe A.O.4

*Corresponding author: Shoewu O. O


Department of Electronic and Computer Engineering,
Lagos State University, Lagos Nigeria.
E-mail: [email protected]
Received: April 2, 2013, Accepted: April 23, 2014, Published: April 24, 2014.

ABSTRACT
This paper focused on design and implementation of a microcontroller based calculator which will perform simple arithmetic
using a calculator keypad and a 16x2 Liquid Crystal Display (LCD). The program is limited to single digit input and double-digit
results. This allows the program for the arithmetic operations to be simple, while the same principles can be extended to multi-digit
calculations.
Keywords: Microcontroller, Calculator, keypad, LCD display.

INTRODUCTION
Advancement in technology has led to building time it executes correctly. Analog to digital converter (ADC) is
electronic devices with simple circuit. Introduction of responsible for converting an information about some analog
microcontroller has made designing of electronic devices value to a binary number and follow it through to a CPU block
circuit simpler. A computer on a chip is known as so that CPU block can further process it. Finally, the
microcontroller. It is essential for the operation of devices such microcontroller is completed, and all need to be done is to
as mobile phones, video cameras, electrical appliances and assemble it into an electronic component where it will access.
most self-contained electronic systems. Microcontroller has the Theory of Design
following elements: memory, central processing unit, ports, The circuit for a calculator which will perform simple
bus, serial communication, etc. arithmetic operations in the PIC 16F887 Microcontroller, using
Memory: Program and data are stored in the memory. a calculator keypad and 16X2 LCD display, is shown in
Central Processing Unit (CPU) has capability to multiply, Figure1. The keypad has 16 keys: 10 numeric buttons, 4
divide, subtract, and move its contents from Memory locations arithmetic operations, equals and clear. The results obtained are
which are called registers. Registers are memory locations displayed on the LCD display.
whose role is to perform various mathematical operations or
any other operations with data wherever data can be found. Bus
is a connection between memory and CPU-the path through
which data goes from one block to another. Physically, it
represents a group of 8, 16, or more wires. There are two types
of buses: address and data buses. The first one has many lines
as the amount of memory to address, and the other one is as
wide as data. First one transmits address from CPU memory,
and the second connects all blocks inside the microcontroller.
Ports have several memory locations whose one end is
connected to the data bus, and the other has connection with the
output lines on the microcontroller which can be seen as pins on
the electronic component. There are several types of ports:
input, output or bidirectional ports. When working with ports,
first of all it is necessary to choose which port one needs to
work with, and then to send data to, or take it from the port.
When working with it the port acts like a memory location.
Something is being written into or read from it, and this could
be noticed on the pins of the microcontroller. Watchdog is a
free-run counter where a program needs to write a zero in every Figure 1: Calculator Circuit Diagram

J. of Computation In Biosciences And Engineering Volume 1/ Issue 2 ISSN: 2348 – 7321 1


The calculator operates as follows: Input Unit
• In order to perform a calculation, press a number key, The 4 x 4 keypad used in this design serves as an input unit
followed by an operation key, then another number and then through which the user communicates
equals. with the system.
• The calculation and result are displayed. For the divide Output Unit (LCD)
operation, the result is displayed as result and remainder. The output unit is the LCD the calculator is a 16 x 2 LCD. It has
• The clear key erases the current display, and a new calculation a back-ground light which enhances readability in low light
can be entered. If an invalid key sequence is entered, the conditions.
program should be restarted. Control Unit
The calculation routine uses the operation input code to select The microcontroller is CPU of the calculator. It gives
the required process: add, subtract, multiply or divide. The instructions, accepts inputs through the keypad, process it, and
binary result of the calculation is passed to a routine to convert displays the processed output through the LCD.
it into BCD, then ASCII, and send it to the display. The result of B. Software Design
the divide, being a single digit result and remainder, is sent In the software design, the program outline and flow diagram
direct to the display. The clear operation sends a command to show how the system works. It carefully illustrates the flow of
the display to clear the last set of characters. instructions from one step to the other during operation.
Design Overview Program outline for implementing the calcultor
The design overview is divided into two, hardware and The program outline used to implement the the calculator is
software. shown below:
A. Hardware design 1. Single digit calculator produces two digit results.
The Hardware Design is into the modules for easy design, 2. Hardware: x12 keypad, 2x16 LCD, P16F887 MCU
analysis and integration. 3. MAIN
• Power Supply unit 4. Initialise
• Control Unit 5. PortC = keypad
• Input Unit 6. RC0 – RC3 = output rows
• Output Unit 7. RC4 – RC7 = input columns
Each module was design individually and then joined together 8. PortD = LCD
to form a calculator. The different modules are controlled by a 9. RD1, RD2 = control bits
series of C-programs linked into the control unit. Figure 1. 10. RD4– RD7 = data bits
shows the system block diagram. 11. CALL Initialise display
Power Supply Unit 12. Scan Keypad
power supply unit provides the electronic circuit with necessary 13. REPEAT
direct voltages and current with low level of A.C ripples and 14. CALL Keypad input, Delay 50ms for debounce
good stability. The power supply comprises of a transformer, a 15. CALL Keypad input, Check key released
rectifier, a filter and a regulator. 16. IF first key, load Num1, Display character and restart loop

Control Unit Input 17. IF second key, load sign, Display character and restart loop
Power Supply Unit (keypad)
Unit 18. IF third key, load Num2 Display character and restart loop
9
19. IFfourth key, CALL Calculate result
Output Unit
(LCD) 20. IF fifth key, Clear display
Figure 2. Block Diagram of the calculator 21. ALWAYS

J. of Computation In Biosciences And Engineering Volume 1/ Issue 2 ISSN: 2348 – 7321 2


22. SUBROUTINES Construction of the Project
23. Included LCD driver routines The system is constructed on the board after the circuit has been
24. Initialise display analysed and simulated in proteus ISIS Professional 7.8
25. Display character portable simulation software.
26. Keypad Input
27. Check row A, IF key pressed, load ASCII code
28. Check row B, IF key pressed, load ASCII code
29. Check row C, IF key pressed, load ASCII code
30. Check row D, IF key pressed, load ASCII code
31. ELSE load zero code
32. Calculate result
33. IF key = ‘+’, Add
34. IF key = ‘-‘, Subtract
35. IF key = ‘x’, Multiply
36. IF key = ‘/’, Divide
37. Add Add Num1 + Num2
38. Load result, CALL Two digits Figure 4: The system construction
39. Subtract Subtract Num1 – Num2 Implementation and Testing
40. IF result negative, load minus sign, CALL
The system is successfully implemented based on the system
Display character
design, Microcontroller PIC 16F783A was programmed with
41. Load result, CALL Display character
C-language and compiled using CCS_PCWH_V3.203 PIC C
42. Multiply
Compiler Series of programs were written and simulated using
43. REPEAT
PIC simulator IDE and MPLAB before the working program
44. Add Num1 to Result
was finally achieved and then transferred to the microcontroller
45. Decrement Num2
chip using PICCALL software / hardware parallel port
46. UNTIL Num2= 0
interface PIC programmer. The actual prototype
47. Load result, CALL Two digits
implementation, simulations were carried out to test if the
48. Divide
codes were working correctly. A sampled result was obtained
49. REPEAT
and this was compared with that of other calculators and the
50. Subtract Num2 from Num1
results were the same.
51. Increment Result
CONCLUSION
52. UNTIL Num1 negative
There is need for a portable, reliable, low cost and faster means
53. Add Num2 back onto Num1 for Remainder
of calculation with simple design. This study designed and
54. Load Result, CALL Display character
implemented a Microcontroller based calculator for easy and
55. Load Remainder, CALL Display character
speedy calculation. The Microcontroller PIC 16F887 was
56. Two digits
programmed with C-language and compiled using
57. Divide result by 10, load MSD, CALL Display character
CCS_PCWH_V3.203 PIC C Compiler and proteus ISIS
58. Load LCD, CALL Display character
Professional 7.8 portable simulation software. Results of the
calculator were found to agree with the other calculators.

J. of Computation In Biosciences And Engineering Volume 1/ Issue 2 ISSN: 2348 – 7321 3


4. PIC16F887 Datasheet – http://ww1.microchip.com/
REFERENCES downloads/en/devicedoc/35007b.pdf
1. Martin Bates (2006). Interfacing PIC Microcontrollers,
5. Nebojsa Matic and Dragan Andric (2010) PIC
Embedded Design by Interactive Simulation.
Microcontroller for beginners
2. Electronics Projects with Microcontroller –
6. Programming PIC16F873A Micro-controllers -
www.jap.hu/electronics.html
www.ubasics.com.
3. Introduction to PIC Programming –
www.quasare/eletronics.com

Citation: Shoewu O. O, et al (2014). Design and Implementation of Microcontroller Based Calculator. J. of Computation in
Biosciences and Engineering. V1I2.

Copyright: © 2014 Shoewu O. O . This is an open-access article distributed under the terms of the Creative Commons Attribution
License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are
credited.

J. of Computation In Biosciences And Engineering Volume 1/ Issue 2 ISSN: 2348 – 7321 4

View publication stats

You might also like