Design of Asynchronous Serial Interface Keyboard Based on 51 Single Chip Microcomputer

Publisher:婉如ChanelLatest update time:2011-10-13 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In the information processing system, the display subsystem is the human-machine interface of the entire system. The situation graphics and data presented on the display screen are important bases for people to make decisions. Human intervention means are an indispensable tool to turn people's decisions into information that the system can receive. Therefore, the amount and effectiveness of human intervention means directly affect the effectiveness of the entire system. Especially in systems that process large amounts of information and have frequent human-computer interactions, the requirements for human intervention means are higher.

Based on the actual work, the author designed a universal asynchronous serial interface keyboard around the single-chip microcomputer 89C51 as an extended keyboard for the display subsystem. The purpose is to add an intervention method for the display subsystem. Practice shows that this keyboard improves the human-machine interface of the system and improves the processing efficiency of the system.

1 Design requirements and working principles

1.1 Design requirements

(1) The key coding of the extended keyboard complies with the conventions of the display subsystem.
(2) The communication between the extended keyboard and the display processor is completed through its asynchronous serial interface, and the baud rate is 9600 b/s.
(3) The interface level of the communication between the extended keyboard and the display processor is RS232C standard.
(4) The relative error of the baud rate should be less than 2.5%.
(5) The power supply requirement of the extended keyboard: DC +5 V.
(6) The ambient temperature requirement of the extended keyboard: -100 to +500°C.

1.2 Working Principle

The working principle of the extended keyboard is shown in Figure 1. The extended keyboard is connected to the display processor through an asynchronous serial interface. Together with the standard keyboard, the display processor has two keyboards. The two keyboards can send intervention commands to the display processor at the same time. Therefore, the display subsystem adds a new way to input intervention commands, shortens the input time of intervention commands, and improves the efficiency of manual intervention.

2 Circuit Design

The extended keyboard consists of the following parts:

① Single chip microcomputer 89C51 and clock and reset circuit.
② TTL level to RS232C level conversion chip ICL232CPE, this chip only needs DC +5 V power supply.
③ Working indication circuit.
④ Key array part (8×13).

The electrical schematic diagram of the extended keyboard is shown in Figure 2.

3 Structure and performance characteristics of 89C51

89C51 is one of the typical products of MCS-51 series microcontrollers. Its internal hardware resources are shown in Figure 3.

①4 kB programmable E2PROM.
②8 b CPU for control.
③128 b internal RAM data memory.
④32 b bidirectional input/output lines.
⑤1 full-duplex serial port.
⑥2 16 b timers/counters.
⑦5 interrupt sources, 2 interrupt priorities.
⑧Clock generator.
⑨64 kB program memory and 64 kB external data memory can be addressed.

The keyboard uses the E2PROM on the chip of 89C51 as program storage to avoid the external storage occupying the input/output port resources of the single-chip microcomputer; uses the second function of the P3 port to complete the asynchronous serial communication function; uses an ICL232CPE as an interface level conversion chip to realize the entire hardware logic of the keyboard. Less hardware and high reliability. The entire keyboard uses a +5 V DC power supply; the circuit and the key array are separated. This keyboard also overcomes the shortcomings of the previous keyboard design, such as fewer keys and non-universality.

4 Software Function Flowchart

The software implements functions such as key position scanning, jitter elimination, key code conversion, and key code sending. In addition, the software also implements the functions of shifting and key bursting. The software function flow chart is shown in Figure 4.

5. Issues that should be noted in application

In the serial communication of heterogeneous machines, after the transmission rate is specified, it is very important to select the appropriate crystal oscillator frequency in the MCS-51 microcontroller system. It, together with the working mode of the serial interface, the SMOD bit of the power control register PCON, and the timer T1, determine the success or failure of the communication. When the serial interface of the MCS-51 microcontroller works in mode 0, its baud rate is fixed and its size is: crystal frequency/12. This mode is synchronous; when working in mode 2, it is asynchronous, and its baud rate is Crystal frequency : ① When SMOD=0, the baud rate is: crystal frequency/64; ② When SMOD=1, the baud rate is: crystal frequency/32; When the serial interface works in modes 1 and 3, it is asynchronous and its baud rate is variable. In addition to being related to the value of the SMOD bit, it mainly depends on the overflow rate of timer 1. The baud rate can be determined by the following formula:

The overflow rate of timer 1 is determined by the counting rate and the timing preset number X, that is:

At this time, T1 works in mode 2, that is, 8-bit automatic loading mode. This mode can avoid reloading the initial value through the interrupt service program, and the baud rate is more accurate. In the formula, X is the initial count value loaded in TH1 and TL1. The counting rate of timer 1 is related to the selection of the timer working mode. When T1 is selected as the timing working mode, its counting input pulse is the internal clock signal, that is, the register value is increased by 1 in each machine cycle. And each machine cycle is 12 oscillation cycles, so the counting rate is 1/12 of the crystal frequency. Therefore

Since the serial communication between this extended keyboard and the display processor is asynchronous, the working mode of its serial interface is set to mode 1, and the working mode of timer 1 is set to mode 2. Then calculate its preset value according to the baud rate requirement (9 600 b/s). If the oscillation frequency of the system crystal is 12 MHz, when SMOD is selected as 1, the initial values ​​of TH1 and TL1 are calculated as follows:

Solving the above equation, we can get: X1 = 250 (FAH) or X2 = 249 (F9H)

When X is placed in TH1, TL1, the actual transmission rate generated by the baud rate generator is:

Or baud rate 2 = 8 928.57 b/s, baud rate error 2 = 7%

No matter which number is set, the PC and the MCU cannot communicate normally. If a 11.059 2 MHz crystal is used, X = 250 FAH is calculated according to the above formula, and the actual transmission rate is 9 599.83 b/s, the error is 0.001 77%, and the communication between the PC and the MCU can be carried out normally. In addition, the selection of the SMOD bit can sometimes affect the baud rate error. Therefore, when setting the baud rate, the selection of the SMOD bit should also be carefully considered.

When designing a key array, the conductive rubber membrane key array of a standard keyboard should be used to avoid old-style keys that have a short service life and often have poor contact.

6 Conclusion

The function design of this keyboard can be further refined, such as realizing caps lock, keypad lock, etc. Since the amount of data communicated between the keyboard and the host is not large, the USB port is not used to communicate with the host. With a little modification, the USB port can be used to communicate with the host. If this keyboard is used in some systems that do not use serial communication, it can be directly connected with TTL level, eliminating the ICL232CPE chip, making the circuit simpler, and the P3 port can use parallel output.

Reference address:Design of Asynchronous Serial Interface Keyboard Based on 51 Single Chip Microcomputer

Previous article:Method of Producing Sound of Single Chip Microcomputer Alarm
Next article:Design and implementation of the interface between 51 single-chip microcomputer and CF card

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号