Design of Decimal Calculator System Based on AT89C51 Single Chip Microcomputer

Publisher:以泉换泉Latest update time:2017-11-12 Source: eefocusKeywords:AT89C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This design is a decimal calculator system design based on the AT89C51 single-chip microcomputer. It can complete the keyboard input of the calculator, perform simple arithmetic operations of addition, subtraction, multiplication and division of 4-bit unsigned numbers, and display the results accordingly on the LED. In terms of hardware, from the functional considerations, the AT89C51 single-chip microcomputer with rich internal storage resources is first selected, and the input adopts a 4×4 matrix keyboard. The display adopts a 4-bit 7-segment common anode LED dynamic display. In terms of software, the system design is carried out from the analysis of calculator functions, flow chart design, to program writing. Here I recommend you to read the ten-day learning single-chip microcomputer.

  0 Preface

  This system uses AT89C51 single-chip microcomputer as the controller to realize the four-digit "+", "-", "*", "/" operation. The operation result is displayed through the digital tube and has a clearing function. AT89C51 has the following features: 40 pins, 4k BytesFlash on-chip program memory, 128 bytes of random access data memory (RAM), 32 external bidirectional input/output (I/O) ports, 5 interrupt priority levels, 2-level interrupt nesting interrupts, 2 16-bit programmable timer counters, 2 full-duplex serial communication ports, watchdog (WDT) circuit, and on-chip clock oscillator.

  1 Overall design plan

  1.1 System composition and working principle

  This system is based on the 51 single-chip microcomputer as the main control core, and is combined with a matrix keyboard, crystal oscillator, and LED display tube module. Its working process is: first, the storage unit is initialized, the initial value and keyboard scan are displayed, the key position is determined, and the key value is obtained. The single-chip microcomputer stores the data and processes and converts it accordingly, and then sends it to the digital tube for dynamic display. The calculation result is sent to the digital tube for dynamic display. This design can only perform calculations with a result of no more than four digits, and its functions are as follows:

  (1) The numeric keys "0" to "9" are displayed using digital tubes.

  (2) Addition operation: Both the addend and the augend cannot exceed 9999, and the final result of the addition cannot exceed 9999.

  (3) Subtraction operation: The normal logic of subtraction operation is to subtract a larger number from a smaller number. This calculator is also the same and can only perform normal logic operations. For example, if you want to subtract a larger number from a smaller number, add the resulting negative number to 535 to get the corresponding result. In other words, if you want to subtract a larger number from a smaller number, subtract 535 from the result to get the correct result for a negative number.

  (4) Multiplication operation: As with the above method, the calculation result cannot exceed 9999. If overflow occurs, only the last three digits of the result will be displayed.

  (5) Division operation: The divisor and dividend cannot exceed 9999, and only the integer part of the calculation result is displayed.

  (6) Equal key: The calculation result will be displayed only when the equal key is pressed; otherwise, the previous number will be displayed.

(7) Reset function: When the program is unstable or an error occurs, use the reset key to return to the initial state. You can also use the reset key to reset.

  2 System Hardware Design

  2.1 Overall design of system hardware

  This system consists of a keyboard matrix and an LED display tube. The keyboard inputs key values, and the LED display tube displays the current key presses and results. The overall hardware design diagram 1 is as follows:



  2.2 Matrix scan displays the current key module

  Use the P0 port P0.0 - P0.7 of the AT89S51 microcontroller to connect to the a - h segments of a seven-segment digital tube, and the common end of the digital tube is connected to the power supply. The matrix scan displays the current key module as shown in Figure 2. 



 2.3 Keyboard Layout Module

  Working principle of matrix keyboard: The keyboard layout of calculator is shown in Figure 3: It is generally composed of 16 keys. In the single-chip microcomputer, one P port can be used to realize the functions of 16 keys. This form is also the most commonly used in single-chip microcomputer systems.



 3 System Software Design

  3.1 System software overall design

  The software flow of this system is shown in Figure 4.

 

 3.2 Display program modules

  The display program calculates the thousands, hundreds, tens and units of the value to be displayed, outputs the value through the P0 segment selector, and realizes dynamic display through the bit selectors P3^3, P3^4, P3^5 and P3^6.

  LED digital tube, realize the display of four-digit decimal number by seven-segment digital tube. The value of key and calculation result is displayed by segment selection. Since this hardware design adopts common anode connection, the corresponding segment code table is as follows 3.3 Keyboard scanning module

  This keyboard scanning program uses the row-column flip method to scan the keyboard, that is, first set the row to 0, read the column value, and store it in variable 1, then set the column to 0, read the row value, and store it in variable 2. Adding variable 1 and variable 2 is the key value corresponding to the key. The following table shows the key values ​​corresponding to the corresponding keys.

  This calculator is a calculator system based on the 51 series single-chip microcomputer. It is designed to perform simple arithmetic operations. Under the existing hardware conditions, it can only perform operations with results not exceeding four digits. It can realize the calculation functions of addition, subtraction, multiplication and division, the function of clearing numbers, and the reset function of the system.


Keywords:AT89C51 Reference address:Design of Decimal Calculator System Based on AT89C51 Single Chip Microcomputer

Previous article:51 MCU-button part (1)
Next article:Six common problems with 51 single-chip microcomputers

Recommended ReadingLatest update time:2024-11-16 13:54

Design of electronic therapeutic instrument based on embedded device AT89C51SND1C
        1 Introduction    Currently, electronic therapeutic devices that use two electrodes to symmetrically cover the treatment part of the human body are used. The pulsating voltage on the electrode acts on the resistance of the treatment part of the human body to generate a pulsating current that the human body c
[Microcontroller]
Design of electronic therapeutic instrument based on embedded device AT89C51SND1C
Design and simulation of multi-channel temperature monitoring system based on DS18B20
0 Introduction     In real-time temperature monitoring systems, such as greenhouse temperature monitoring, cold storage temperature measurement, intelligent building temperature control and other systems, it is often necessary to collect and detect multiple temperatures. Rapid and reliable acquisition of high-precisi
[Microcontroller]
Design and simulation of multi-channel temperature monitoring system based on DS18B20
Design of remote control alarm system based on single chip microcomputer
1 Introduction Due to the rapid development of the economy, people's living standards have been greatly improved, and the pace of life has become faster and faster. Therefore, home appliance remote control and family safety are also needed and valued by people. The remote control and alarm device of electrical a
[Microcontroller]
Design of remote control alarm system based on single chip microcomputer
Interface Design Based on AT89C5131
Introduction AT89C5131 is a MCU based on 52 core. In terms of memory, it integrates 32 KB of FLASH memory for code storage; 1 KB of E2PROM memory for user data storage; users can use the on-chip Bootloader or FLASH API to perform ISP or IAP programming on the FLASH memory and E2PROM memory through the USB interf
[Microcontroller]
Interface Design Based on AT89C5131
Audio signal amplitude equalization control amplifier designed using SG270/LM4884 and AT89C51
Introduction Many schools today have adopted computer plus network multimedia systems for on-site teaching. In addition, construction workers making intercom calls at the construction site, and drivers making calls on moving tanks and other self-propelled artillery vehicles, etc., cannot avoid noisy background noise
[Microcontroller]
Audio signal amplitude equalization control amplifier designed using SG270/LM4884 and AT89C51
Design of temperature measurement and control system based on AT89C51 single chip microcomputer
0 Introduction Temperature measurement and control are widely used in daily life and industrial fields. With the substantial improvement of people's living standards, there are higher requirements for the accuracy and range of temperature measurement and control. In industrial enterprises, how to improve the operatin
[Microcontroller]
Design of temperature measurement and control system based on AT89C51 single chip microcomputer
Application of AT89C51 single chip microcomputer in cutting force measurement of CNC lathe
AT89C51 is a low voltage, high performance CMOS 8-bit microprocessor with 4K bytes of flash programmable and erasable read only memory (FPEROM), commonly known as a single chip microcomputer. The device is manufactured using ATMEL's high-density non-volatile memory manufacturing technology and is compatible with the
[Microcontroller]
Application of AT89C51 single chip microcomputer in cutting force measurement of CNC lathe
Design of traffic lights at crossroads based on AT89C51 single chip microcomputer
The actual picture is as follows:   This is a traffic light design simulation schematic diagram for a crossroads (the proteus simulation project file can be downloaded in the attachment of this post)   The keil microcontroller source program is as follows: #include include.h sbit NS_GRE = P2^5;       sbit NS_YEL
[Microcontroller]
Design of traffic lights at crossroads based on AT89C51 single chip microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号