Design of RS-232 Serial Port Data Analyzer Based on Stc12c5a60s2

introduction

With the rapid development and popularization of computer technology, and the rapid development of communication technology, the communication between computers and the exchange of data between computers and various industrial devices through serial ports [1] have become more and more widely used. The serial port data monitoring and analysis system is also rapidly applied in production and scientific research. Since the RS-232 serial port has a small number of lines and low cost in the serial communication mode, especially in remote transmission, it is widely used because it avoids inconsistencies in multiple line characteristics. RS-232 serial port is so widely used in serial communication. It is meaningful to study serial data analyzer to achieve intuitive observation of serial communication data. Nowadays, various serial data analyzers are widely used in wired networks, becoming a very useful test and maintenance tool.

1RS-232 serial port level shifting

Since the input and output levels of the MCU are TTL level, and the PC is configured with the RS-232 standard serial interface, the electrical specifications of the two are inconsistent. Therefore, to complete the data communication between the MCU and the PC, the TTL output of the MCU must be output. Conversion is performed flat. The MC1488 converts the TTL level to the RS-232 level with a supply voltage of ±12V. The MC1489 converts the RS-232 standard level to TTL and the supply voltage is +5V, so the circuit has the +5v power supply in addition to the system. In addition, a ±12v power supply is required. This is very troublesome for a microcontroller system that does not have a ±12v power supply. Therefore, this circuit uses a standard RS-232 chip MAX232 for level shifting between RS-232 and TTL.

2 serial data analyzer keyboard and LCD display design

The keyboard system of this design needs to complete the following functions: baud rate selection, data format output selection, increase/decrease, determination and other five buttons. There are two common keyboard design schemes, the first is matrix and the second is independent. Since the system involves a small number of buttons, it is easy to use a stand-alone type. Based on the above description, the system has designed the following buttons: start button, baud rate setting button, format output button, up/down button and OK button. Since the single-chip microcomputer Stc12c5a60s2[4] is an enhanced CPU, it is not necessary to connect the pull-up resistors to the keys. The interface between the button and the Stc12c5a60s2 chip is shown in Figure 1(a).

Design of RS-232 Serial Port Data Analyzer Based on Stc12c5a60s2

Design of RS-232 Serial Port Data Analyzer Based on Stc12c5a60s2

The function of each button is as follows:

(1) Baud rate selection button: When the baud rate setting button is pressed, the LCD screen will display as shown in Figure 2(a). At this time, the up/down button can be used to move the arrow when the arrow moves to the desired baud rate. Press the OK button to set the baud rate to take effect.

(2) Format selection button: When the format selection button is pressed, the LCD screen will display as shown in Fig. 2(b). At this time, the increase/decrease button can be used to move the arrow. When the arrow moves to the desired format output, press the OK button. The output format will take effect.

(3) Add/Subtract button: Set the relevant parameters together with the baud rate selection button or the format selection button. Once set, press the "OK button" to save the settings.

(4) OK button: Press this button, all the parameter settings will be saved and will return to monitor the serial port data status. This design adopts MPG240128 liquid crystal module as graphic dot matrix liquid crystal, which can not only display digital and character content, but also display Chinese characters and arbitrary graphics. Its interface with single chip microcomputer is shown in Figure 1(b).

3 software design and test results

Design Idea: Complete the tasks in the main program: LCD initialization, select the default baud rate, display the boot screen after clearing the screen, prepare to read the serial port data, key scan and control. The above initialization program can be placed in a function (system initialization function).

Initialization of the LCD: mainly to initialize the display mode, initialization of the display address of the text area and the graphics area, initialization of the selection of the font, and the like. Key scan and control: The buttons of this system are relatively complicated, and the program is also complicated. Many places involve one-key multi-meaning processing. The main function keys are baud rate selection button, format selection button, OK button, up/down button, etc. Figure 2 shows the test results of pressing the baud rate selection button (a), pressing the format output selection button (b), and selecting the decimal format output (c).

Design of RS-232 Serial Port Data Analyzer Based on Stc12c5a60s2

4 Conclusion

This paper mainly introduces the hardware working principle and hardware and software test results of each part of RS-232 serial port data analyzer. In the design of hardware, the design of level conversion circuit, the design of interface circuit of MPG240128 and Stc12c5a60s2 are introduced. Among them, the design of the LCD display and the conversion of the data format are the focus and difficulty of this design. The test results show that all parts of the software and hardware can perform their own functions, work together, and achieved good results, achieving the monitoring of serial data of one serial port and the target displayed in different formats.

Single Pole Distribution Box

UKK Power Distribution Box- 95% contact- Flame retardant:UL94 V0- Nickel-plated copper conductor:copper cable or aluminum cable- The maximum withstand short-circuitcurrent can reach 100KA- Comply with ROHS,CE- Flexible busbars can be directly ibserted into the connection(UKK 500A)- Flexible busbars can be inserted and connectedwith flat connectos(UKK 250A&UKK 400A)

Power Distribution Terminal Box , Brass busbar Distribution Terminal blocks with removable cover A Distribution block is an economical and convenient way of distributing an electrical circuit from a single input source, to several devices in the branch circuit. Thus reducing the total number of wires in your electrical panel and saving you time and money. The exclusive compact and modular design of our distribution blocks.

Distribution Box Metal Box,Distribution Metal Box,Distribution Box Panel ,Electrical Power Distribution Box

Wonke Electric CO.,Ltd. , https://www.wkdq-electric.com