Design and development of LCD calculator control board
A large-scale device with specific functions is integrated on the single-chip microcomputer chip. The most important component is the central processing CPU, which is the brain of the single-chip microcomputer. The single-chip microcomputer also integrates some devices with storage functions, such as: read-only memory ROM and random access memory RAM; timer/timer is also a commonly used unit; in order to transmit information with other devices, the single-chip microcomputer also needs to have a variety of I/O mouth. This article studies the common application of single-chip microcomputer in daily life - simple calculator. Because it is easy to operate, it is widely used. The device usually uses LCD liquid crystals to display the data, so that the calculation results can be more intuitive without wasting too much power. In order to facilitate learning, this article simplifies its functions, which can perform integer and floating-point operations, and the number of operations can also be extended to 15.
1. Significance Analysis of Electronic Calculator
Electronic calculator is a kind of electronic product, and it is an indispensable tool in people's life and work. With the rapid development of electronic technology, people's requirements for electronic products are also constantly improving. In view of the above situation, this paper designs a more convenient calculator, which uses a new method to realize the function. Because the use of traditional technology requires a very complex analog circuit design to achieve relatively complete functions, it will not only make the device look cumbersome, but also not conducive to operation. And a chip with higher integration and small size can solve the above problems. The calculator designed in this paper uses a single-chip microcomputer to control the system, the display module uses a 1602LCD display, and the data input uses matrix keys. The advantages of this device are very obvious, not only small size, high precision but also easy to use. At present, the calculation of data is not only limited to the simple four arithmetic operations, but also often requires calculations such as power, square root, exponent, logarithm, and trigonometric functions. Therefore, the research and improvement of calculators have strong practical significance and value.
2. Overall Design of LCD Calculator System
2.1 Design requirements
In this paper, STC89C52 series single-chip microcomputer is used as the main controller, and the peripheral circuit is expanded to a certain extent to complete the design of the calculator. The design requirements mainly include the following six aspects:
(1) Master the design method of single-chip microcomputer and peripheral expansion circuit; (2) Can perform four arithmetic operations, and use LCD to display data and results; (3) Can complete some addition, subtraction, multiplication and division operations between floating-point numbers; (4) Support parenthesis operations , allowing multiple layers to be nested correctly; (5) has a relatively complete error reporting system; (6) has a friendly display interface and can display input data in real time;
2.2 Design scheme
The specific design scheme of the system is mainly divided into the following four steps: (1) The input module part uses a 4*4 matrix keyboard and 4 independent keys; the power supply uses the LM7805 voltage regulator circuit;
(2) Executing the program: using the LCD display module part, there is no digital display when starting up, and it enters the state of waiting for the input value; when there is a number input, the value is displayed on the LCD display; when the input operator +, -, * , /, the inside of the calculator will enter the state of conversion and storage of numerical values, and then wait for the next numerical value to be entered, and then the entered numerical value will be displayed; finally, the calculation result will be displayed on the LCD by pressing the equal sign key screen;
(3) AC clearing function: After the calculation result is output, press the key to press the AC key to clear the data, and then wait for the next calculation.
(4) Error prompt: If an error occurs during the execution of the program by the MCU, the corresponding error message will be displayed on the LCD.
3. Electronic calculator hardware system design
3.1 Main control chip STC89C52 microcontroller
Considering the power consumption and performance of the system, the selected STC89C52 control chip has 32 I/0 ports, 8KB of internal FLASH program memory, 12 bytes of internal RAM, 2KB of internal EEPROM, double DPTR pointers, 3 timers/counters, automatic With a watchdog WatchDog.
3.2 Auxiliary module design
LCD liquid crystal display is used to display the output and input of numerical value. Its data end is connected with the P0 port of the single-chip microcomputer, and the control end part is connected with P24~P26. When the number of keyboards required is large, in order to avoid occupying more I/O ports, the most effective method is to arrange the keys in a matrix. It should be noted that the intersection of rows and columns cannot be directly connected, but a key is used to connect the two. Through the above processing, one I/O port can control multiple buttons. The buzzer acts as a prompt, and it will sound when a key is pressed. In this article, the triode is used to drive the buzzer. Because the driving capability of the I/O of the single-chip microcomputer is insufficient, the I/O port of the single-chip microcomputer can be used to realize the switching function. If you want to open the buzzer channel, the display will show '0', so the buzzer will make a sound.
The power supply module of the calculator system designed in this paper uses LM7805 as the voltage regulator chip. Since both STC89C52 and LCD1602 are powered by 5V voltage, after primary and secondary capacitor filtering, 5V voltage can be obtained for use.
4. LCB Electronic Calculator Software System Design
The software programming platform selects the most commonly used keil software, and the simulation platform selects the common Proteus software. Because these programs do not involve the underlying driver issues, they choose the convenient and simple C language programming. Usually, the programming process is divided into four modules: the main function module, the delay module, the 1602 display module, and the battle module for processing calculation expressions. Modular design is adopted to facilitate system debugging and understanding. Focuses on the expression solver algorithm portion of the software core.
4.1 Overall Design
In the process of displaying data transmission, the real-time processing information controlled by the program should be used to display the input data information, error control information, and calculation result information, solve the custom control key function in real time, and realize the control function. The specific process design steps of the system are as follows:
(1) After the program starts, the parameters should be initialized first, and the 1602 has no digital display at this time.
(2) Then start scanning the keyboard to see if there is input, and read the code of the keyboard if there is input. If it is a number key, enter the value; if it is a reset key, the state will be cleared; if it is a function key, it will be judged whether the input is the '+' key'-'key'*'key'/'key or the'='key ; If it is the '=' key, then output the operation result and display the operation result on the LCD; if it is other keys, save the first address of its relative operation program and output and display it on the LCD.
4.2 Subroutine Design
The scanning procedure of the matrix keyboard is as follows. Firstly, the address parameters are initialized, and the lower four bits of data and the upper four bits are read in turn. Then confirm that the ASCII code value of the key is sent to the LCD display and the stack corresponding to the expression is processed. The key reading process uses the inversion method, regardless of the size of the matrix, it is divided into two times to complete the key reading. For the first time, all row lines output high level, and row information is read in; for the second time, all column lines output high level, and column information is read in.
According to the analysis of the requirements of the system and the characteristics of the hardware itself, the reset function of the system only needs to connect the AC button to the external interrupt 0 of the single-chip microcomputer, and then the data can be cleaned up by the interrupt of the single-chip microcomputer. The specific process is: during the running of the program, the flag bit is continuously inquired. If it is 0, the clearing function is started. After the clearing is completed, the flag bit is set to 1 and then returns to the main program.
After the 1602 is powered on, its internal chip should be initialized first when performing specific operations. And it is very necessary to refer to its timing diagram during specific operations. You must refer to its timing diagram, then write commands into its internal registers, and then set the working mode and working status.
5. Electronic calculator system debugging
This paper uses integer arithmetic as an example to test the feasibility of electronic calculators. First of all, you need to turn on the power, and you can see that the LCD is turned on and displayed, which means it can run normally. If we enter a relatively complete expression: 12*(34+56-78)/9, the correct result should be 16. After all the values are entered, press the "=" key again, and the operation result will be displayed on the second line. During use, the opening and closing of the key tone can also be controlled by the sound switch button, which can be displayed on the LCD to judge whether to turn on the key sound. There is a display. If the sound has not been turned on, then there is no display in the first position of the second row, and they can be turned on or off by the button.
Summarize
This design uses STC89C52 as the main control chip, and uses LCD1602 liquid crystal to display data. The software part is written in C language. It uses a keyboard and a simple calculator designed by LCD, which can realize simple four arithmetic operations of data, and display the calculation on the LCD screen. result. In addition, the program of the single-chip microcomputer can be operated and modified reliably, especially some unique functional characteristics can be realized. By using the single-chip microcomputer to write the program in order to achieve high intelligence, high efficiency and higher reliability.
The above is the development example of LCD electronic calculator introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. If you have bluetooth headset solution development needs, you can trust us. We represent a variety of single-chip microcomputers, voice chips, dual-mode Bluetooth ICs, and wifi chips. Brands include Songhan MCU, Yingguang MCU, Jerry Bluetooth, Ankai Bluetooth, Allwinner, and Realtek. Our technical services include: PCB design, microcontroller development, Bluetooth solutions, software and hardware custom development, APP development, small program development, WeChat official account development, etc. It can also undertake the design of intelligent electronic products, the development of living appliances, the research and development of beauty equipment, the application of Internet of things platform, the smart home control system, the development of TWS earphones, Bluetooth earphone speakers, the development of children's educational toys, the design of electronic education products, etc.
Proposal recommendation
- TOP