In some intelligent instruments, the human-machine interface is usually an LED digital tube display and a small keyboard. There are two common working methods: one is to directly use the CPU in the system to dynamically scan the display and detect the keyboard. In order to ensure the stability of the display and the timely response of the keyboard, the CPU needs to frequently execute the dynamic scanning program, which is obviously not suitable when the CPU is busy; the other is to use dedicated display and keyboard chips such as 8279, SAA1064, etc. These chips are always inconvenient in practical applications for various reasons, such as the number of bits that can be displayed is small and the price is high. Phlips' P87LPC76X series of microcontrollers belong to the 51 series. They are small in size, powerful in function, low in price, and have a high cost performance. This article introduces a display and keyboard circuit with certain versatility composed of this series of microcontrollers.
Figure 1 Hardware circuit diagram
Introduction to P87LPC76X MCU
The P87LPC76X microcontrollers include P87LPC760, P87LPC761, P87LPC762, P87LPC764, P87LPC767, P87LPC768, etc. The chip uses an accelerated 51 core. At the same clock frequency, its speed is twice that of the standard 51. Except for the number of pins, memory capacity and some special I/O functions, most of their functions are the same. The following takes 87LPC762 as an example. 87LPC762 is a 20-pin package with 2KB of program memory, 128B of data memory, two 16-bit timers/counters, a standard serial communication port, an I2C interface, and an internal oscillator, power-on reset and watchdog circuit. When using its internal oscillator and power-on reset circuit, there can be up to 18 I/O lines; it is particularly worth mentioning that its I/O ports can all have pull-ups, and the P0 port also has a special keyboard interrupt function. If these port lines are used as buttons, a corresponding interrupt will be generated when any key is pressed.
Hardware Design
Figure 2 Register address arrangement [page]
D7 D6 D5 D4 D3 D2 D1 D0
D3-D0, number of LED digits displayed
D4 Data format, 0-ASCII code, 1-BCD code
D6 Keyboard working mode, 0-simple key, 1-scan keyboard
D5, D7 Reserved
Figure 3 Control register format
This design uses 87LPC762 to form a minimum single-chip microcomputer system. In order to minimize the cost and the simplest structure, and considering that its reliability requirements are not too high, the oscillator, power-on reset and watchdog circuit inside the single-chip microcomputer are used, so that 18 I/O lines can be used. Considering the number of bits of the driven LED digital tube and the driving ability of the single-chip microcomputer port line, the serial interface of 87LPC762 is used to expand the shift register. In this application, since the total number of bits displayed is 8-bit LED, two shift registers 74HC595 are used, one of which is used as the position control of the display and the other is used as the segment control. According to the output driving characteristics of the 74HC series chip, the current limiting resistor can be used directly to drive the segments and bits of the digital tube with the output of 74HC595. The results show that under the conditions of a power supply voltage of 5V and a small number of digital tubes displayed, it has good brightness and can work stably for a long time. The key can be directly connected to the P0 port of 87LPC762, so that its circuit structure is the simplest. When working, the key interrupt mode of 87LPC762 can be used without adding any external components. However, when using 87LPC762 without scanning mode, there can be only 8 keys at most. Here, P0.0~P0.7 are used as input, and there can be 8 keys, which is enough in general; if the number of keys required is large, a scanning keyboard can be used. The data exchange between the display/keyboard part and the main CPU in the system uses the I2C interface, and 87LPC762 is used as a slave device; when working, the main CPU of the system only needs to send the data to be displayed to 87LPC762 in a standard format through the I2C interface. In addition, 87LPC762 uses an I/O line as a signal line to send an interrupt request to the main CPU of the system. When a key is pressed, 87LPC762 analyzes and identifies it and sends an interrupt request to the main CPU of the system. After the main CPU of the system responds to the interrupt, it reads the key value from 87LPC762 through the I2C interface. The hardware circuit of this design is shown in Figure 1.
Software Design
The software design mainly includes the design of display driver, keyboard recognition and analysis program and I2C interface program. The display program design is relatively simple. Let the serial interface of 87LPC762 work in mode 0, use a timer/counter to work in timing mode, determine the timing constant according to the number of displayed bits and scanning frequency, turn on the timing interrupt, and send the displayed segment control and bit control codes through the serial port after P87LPC762 enters the interrupt. The keyboard can use the key interrupt function of P87LPC762. When a key is pressed, it enters the interrupt service program to perform key anti-shake, recognition, etc., which will not be repeated here.
The following mainly introduces the interface design and considerations of the I2C interface and driver software. The 87LPC762 has a complete I2C interface component inside. It can work in master mode or slave mode. Here, it can work in slave mode, and its programming is relatively simple. In slave mode, the 87LPC762 needs a slave address. This address can be selected according to our needs, but be careful not to conflict with other I2C device addresses in the system. The software interface design is exactly the same as the standard I2C device. When accessing, the device address is written first, followed by the on-chip address; when accessing, it can be accessed to a specific unit or to several units continuously. In order to facilitate the main CPU in the system to access the keyboard and display circuit, the circuit provides a standard interface to the outside, that is, 10 registers that can be accessed by the main CPU through I2C. The address arrangement of these registers is shown in Figure 2. Note that this is only the address used when accessing through the I2C interface, not the real address in the internal RAM of the 87LPC762. When working, the main CPU only needs to write the data to be displayed through the I2C interface according to the address, and the 87LPC762 will display it. Similarly, when 87LPC762 recognizes that a key is pressed, it puts the key code of the key into the register, and then sends an interrupt request to the main CPU. The main CPU responds to the interrupt and reads the key code from the address specified in 87LPC762 through the I2C interface. It can be seen that we can use 87LPC762 as a dedicated keyboard and display chip. In order to make the circuit more convenient and flexible to use, a control register is also set to control the number and mode of display, the keyboard working mode, etc. as shown in Figure 3. On this basis, some other functions can be added, such as making the specified bit flash, turning off the display when no key is pressed for a long time, entering protection mode, etc. The control register is used to control the working mode of the display/keyboard circuit, and its format is shown in Figure 3.
The main CPU in the system can use a single-chip microcomputer with an I2C interface; it can also use a single-chip microcomputer without a dedicated I2C interface. In this case, the I2C interface can be simulated by software.
Conclusion
The display and keyboard circuit composed of P87LPC762 has the characteristics of simple structure, powerful function, simple interface with the system main CPU, convenient use and low cost, and has been successfully used in the intelligent instrument developed by us. In fact, we can integrate P87LPC762, 74HC595 and other chips together to make a dedicated display and keyboard module.
Reference
1 He Limin. I2C Application System Design. Beijing: University of Aeronautics and Astronautics Press
Previous article:The specific application of time-sharing operating system concept in single-chip microcomputer
Next article:Anti-interference measures in single chip microcomputer system application
Recommended ReadingLatest update time:2024-11-16 23:47
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- My Journey of MCU Development (Part 2)
- 【Development and application based on NUCLEO-F746ZG motor】13. Parameter configuration - USART3 configuration
- What is the sound-generating mechanism of a piezoelectric buzzer? How to choose the sound component?
- The mechanical and electrical parts of the intelligent car based on the DFRobot four-way motor driver board have been preliminarily completed.
- [Example] Easily implement wifi remote RS485 bus (multi-node bus)
- Forum friends give examples to explain these operators in C language
- Talk about the upper and lower tubes of the buck circuit_DC-DC BUCK bootstrap circuit
- Real-time solution to single chip microcomputer delay
- CB5654 Development Board Review 2
- [Raspberry Pi Pico Review] 3. My first project