A Basic Approach to Designing E Calculator and C Oach to Designing

A Basic Approach to Designing E Calculator and C Oach to Designing

Nigerian Journal of Technology (NIJOTECH) Vol. 33. No. 3, July 201 4, pp. 359 – 366 Copyright© Faculty of Engineering, University of Nigeria, Nsukka, ISSN: 1115 -8443 www.nijotech.com http://dx.doi.org/10.4314/njt.v33i3.14 A BASIC APPROACH TO DESIGNING EMBEDDED SYSTEMS USING A SIMPLE CALCULATOR AND C PROGRAPROGRAMMMMMING LANGUAGE FFF.F. TTTanshiTanshi 1,*1,*1,* and N. Bello 222 111DEPARTMENT OF ELECTRICAL /E LECTRONIC ENG , FEDERAL UNIVERSITY OF PETROLEUM RESOURCES , EFFURUN , NIGERIA 222DEPARTMENT OF ELECTRICAL /E LECTRONIC ENGINEERING , UNIVERSITY OF BENIN , BENIN CITY , NIGERIA EEE-E---mail addresses: 111 [email protected], 222 [email protected] ABSTRACT Embedded systems form the bedrock of most consumer appliances in today’s world. Products such as automatic transmission cars, fuel pump metres, washing machines, digital cameras, DVDs, mobile phones , vending machines eee.e...tttt....cccc depend on an embedded microcomputer to enable it perform its range of functions. For example a vending machine may have tthhhhree main functions (((namely(namely --- insert money, choose item to be purchased and send out item to buyebuyer/userr/userr/user)) that are controlled by an embedded chip through its peripherals which are linked to the appliance’s user interinterfacfacfacfaceeee.. This paper intends to be a complete introductory guide to embedded design considering a simple calculator that usususesus eseses a microcontroller for input, processing and output operations. KKKeywords:Keywords: Central Processing Unit (CPU), C Programming Language, Electronics, Embedded Systems, Integrated Circuit, Microprocessor and Microcontroller. 1.1.1. INTRODUCTION An embedded microc ontroller (also called a A calculator is a small hand held electronic device microcomputer and sometimes abbreviated µC , uC or used to perform mathematical and logical operations. MCU) contains a processor core, memory, and It often has a microprocessor or microcontroller chip programmable input/output peripherals in one embedded in it that enables it to perform these integrated circuit [3] [4].An integrated circuit is a functions. The microprocessor cam e about as a complete electronic circuit made with a small piece of programmable replacement for control circuits and semiconductor material (also called a Chip) and is calculator chips in the 1970s [1][2]. Up to this point, encapsulated in plastic and used as one component. most control systems using digital logic were The simple calculator realized in this design is capable implemented using individual logic integrated circuits of performing four arithmetic operations: addition to create the design and as more fun ctionality was (+), subtraction (-), m ultiplication (*) and division (/) required, the circuits became very bulky and and can perform computation on a maximum of 16 unreliable . Many hundreds of these discreet logic digits at a time. chips were needed just to create a simple four function calculator. But with the invention of the 2.2.2. DESIGN CONSIDERATIONS microprocessor which has a complete processing unit The first thing we considered in this design was the inside a microchip, the reliability of digital logic settings and additional peripherals that the circuits were greatly increased as a result of reduced microcontroller will require to perform as a functional size. Subsequently, there was need to include a calculator and how it would be made to interphase permanent memory in the microprocessor which with them. Some of these peripherals which include; ultimately gave birth to th e microcontroller which is resistors, an oscillator, capacitors, a keypad and LCD the processor component used in this design. Unlike could be connected to designated pins of the the microprocessor that doesn’t have a program or microcontroller as specified by the manufacturer in its data memory, [2] the microcontroller has a program datasheet and others to bidirectional general purpose and data memory in addition to a central processing data ports pins. Specifically, it is worthy to note here unit (CPU). that the 4˟4 keypad matrix used would require an 8- * Corresponding author, Tel: +234+234----703703703703----129129129 ---9216-921692169216 DDDESIGNESIGNESIGNINGESIGN INGINGING OF EEEMBEDDED SSSYSYSYSTEMSYS TEMS UUUSING AAA SSSIMPLE CCCALCULATOR AANDND CCC PPPROGRAMMING LLLANGUAGE F. Tanshi & N. Bello bit data port because it has four rows and four 4.3 Circuit Diagram aaandand Analysis columns. The LCD will require seven of the pins of an For convenience the circuit diagram is divided into 8-bit data port when connected in 4-bit mode and can marked segments in other to explain its functional only display information that is first converted to a parts as shown in Figure 2. string of characters. Therefore the source code should include a float conversion function. Table 1: List of hardware components Furthermore, the software settings that would Item Value Quantity prepare the microcontroller to interact via these ports Resistors: 10kohm 5 were also established. These software settings include Ceramic Capacitors 10pF 2 Hi -Watt Dry Cell 9v 1 the configuration bits, the direction of data flow across Button Switch No units 1 a port (whether input or output) and the type and Toggle Switch No units 1 frequency of the external oscillator which serves as a Voltage Regulator 5v (L7805CV) 1 timer for the microcontroller to schedule its activities. Jumper Wires No Units 1 yard Crystal Oscillator 4MHz 1 4*4 keypad Matrix No Units 1 333.3... DESIGN METHODOLOGY 16×2 LCD: RT1602C, No Units 1 The major components in this design include a v3.0 PIC16F876A, a 2×16 Monochrome Liquid Crystal PIC16F876A No Units 1 Display (LCD) and a 4×4 keypad matrix. The calculator circuit was designed and simulated in 4.3.1 Microcontroller Circuit Labcenter Electronics® Proteus®. The source code A button switch is connected through a 10Ω resistor in for the microcontroller was written in C and compiled parallel to the master clear pin (resets the with MikroC® Pro v6.00. microcontroller) [6]. One instruction cycle consists of The Common Object File (COF) generated after four oscillator periods; for an oscillator frequency of 4 compilation was downloaded to the microcontroller in MHz, this gives a normal instruction execution time of Proteus in order to test and debug the source code. A 1μs. [7]. COF file is a portable file format across many The PIC16F876A has an 8k program memory holding embedded programming platforms. The required the calculator source codes, 368byte of RAM which corrections were made to the source code in MikroC® stores inputted and computed data temporarily. Pro and then burnt into the microcontroller ROM with a Top 2005+ programmer. The circuit components including the microcontroller were then soldered on a Vero board and encased in Perspex, with the LCD and keypad placed at the top to make it accessible to the user. Finally, the entire circuit was tested after implementation. 4. DESIGN SPECIFICATION 4.1 Hardware Components The list of hardware components used in the design together with their specifications and quantity are listed in Table 1 4.2 Programming Usually before embarking on writing software for any purpose, an execution procedure of the program in view of the design considerations such as; described in section 2.0 should be spelt out and written down. This is called an Algorithm. And a pictorial representation of an algorithm is called a flowchart, shown in Figure 1. Figure.1: Flow Chart of Program Nigerian Journal of Technology, Vol. 33, No. 3, July 2014 360 DDDESIGNESIGNESIGNINGESIGN INGINGING OF EEEMBEDDED SSSYSYSYSTEMSYS TEMS UUUSING AAA SSSIMPLE CCCALCULATOR AANDND CCC PPPROGRAMMING LLLANGUAGE F. Tanshi & N. Bello Figure 2: Simple Calculator Circuit Diagram In order to burn code into a PIC microcontroller, its flowchart and it causes the microcontroller to configuration word has to be determined. The continuously scan the keypad in other to detect any configuration word is a group of 14-bits which make key press. As keys are pressed, it decodes their value up the configuration Register located at address by the ASCII standard and stores them temporarily in 2007h in program memory of the PIC16F876A. This its RAM pending when the operation to be performed memory location is beyond the user code program is provided. Key inputs are stored as a string of memory space and can be accessed only during characters which is sent to be displayed in the first programming of the chip [6]. These bits govern the row of the LCD. The first set of inputted characters are response of the microcontroller to certain power stored in a defined character string variable; states as well as configure its clock inputs to operate “leftsidestr” (see appendix) , the operation key (i.e within a certain oscillator type and frequency. addition, subtraction, multiplication, division) is There are 14-bits in the configuration register and bit- stored in a defined character variable; “ operation”(see 3 is the Power-up Timer Enable bit which allows a appendix), and the subsequent input keys are stored in 72ms delay when the power button is pressed. Then a defined character string variable; “rightsidestr”(see the Oscillator Start-up Timer (OST) provides a delay appendix) . of 1024 oscillator cycles (from OSC1 input) after the Power up Timer delay is over. This control bit ensures 444.4...3333.2.2.2.2 Liquid Crystal Display (Lcd) Circuit power supply to the circuit is steady and crystal To set up the LCD for operation, VDD is positive oscillator

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us