Design of RS232 serial data interceptor

Publisher:breakthrough3Latest update time:2013-09-09 Keywords:RS232 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Many devices and their control computers use RS 232 standard serial interface for communication. This paper designs and implements RS 232 serial communication data interceptor, which can effectively intercept the communication data between the device and its control computer.

  1 Interceptor Hardware Design

  1.1 Overall block diagram and principle

  The system principle block diagram is shown in Figure 1.

  

  Principle analysis: The communication line between the specific device and its control computer is divided into two paths through level conversion. One path is directly connected to ensure that the normal communication between them will not be affected after the interceptor is added. The other path is connected to the microcontroller through the extended serial ports 1 and 2, ensuring that the communication data between them can be captured by the microcontroller. After being processed by the microcontroller, these data are transmitted to the host computer through another extended serial port to realize the interception of communication data.

  1.2 Device Selection

  The system uses the commonly used AT89C51 microcontroller as the processing core. The GM8123 chip produced by Chengdu Guoteng Company is selected to expand the one full-duplex asynchronous serial communication interface of the AT89C51 microcontroller into three full-duplex asynchronous serial communication interfaces. The MAX232 chip is used to realize the mutual conversion between RS 232 level and TTL level.

  1.3 Hardware Circuit

  The complete circuit diagram of the system is shown in Figure 2. The system circuit consists of three parts: the single-chip minimum system, the serial port expansion circuit and the level conversion circuit.

  

  The minimum system of the single-chip microcomputer includes power supply circuit, clock circuit and reset circuit. S1 and S2 are used as baud rate control switches to control the values ​​of P0.0 and P0.1 from 00 to 11 respectively, corresponding to the baud rate of 1200 to 9600 b/s.

  The serial port expansion circuit is composed of GM8123, and its clock circuit uses a 12 MHz quartz crystal oscillator to form an internal clock mode. The GM8123's mother serial port receiving pin RXD0 and sending pin TXD0 are connected to the microcontroller's serial port sending pin TXD and receiving pin RXD respectively. The GM8123's reset pin is connected to the microcontroller's P3.6 pin, and P3.6 controls the GM8123 system reset. Its mode control pin MS is connected to P3.7, and P3.7 selects the mode. The GM8123's sending address line pins STADD0, STADD1, and the receiving address pins SRADD0, SRADD1 are connected to the microcontroller's P1 port P1.0~P1.3 in sequence, and the microcontroller P1 port determines which sub-serial port receives data and selects a sub-serial port to send data.

  The level conversion circuit is completed by two MAX232 chips, which realizes the mutual conversion between RS 232 level and TTL level of J1, J2, and J3.

  2 Software Design

  The system software has two working modes. The software design of mode 1 is to realize the real-time transmission of intercepted data, and the interceptor cannot be separated from the host computer when working. The software design of mode 2 is to realize the storage and forwarding of intercepted data, and the interceptor can work without the host computer.

  2.1 Main program flow design

  The main programs of Mode 1 and Mode 2 are basically the same. Their main functions include: configuration of the microcontroller serial interrupt related registers, setting of the serial port data transmission and reception baud rate and configuration of related timers, and configuration of the reset operation and working mode of the GM8123 chip. The main program flow chart is shown in Figure 3.

  

  The program flow chart of the baud rate setting controlled by S1 and S2 is shown in Figure 4.

2.2 Interrupt Service Routine

  The function of the interrupt service program of mode 1 is to receive the data sent by the specific device (J1) and its control computer (J2), and send the data to the host computer (J3) for display in real time. The flow chart of the interrupt service program of mode 1 is shown in Figure 5.

  The main function of the mode 2 interrupt service program is to receive the data sent by the specific device (J1) and its control computer (J2), and store the received data in the RAM of the microcontroller. When receiving the send data command from the host computer (J3), the stored data is sent to the host computer. Its flow chart is shown in Figure 6.

  3 Functional Testing

  With the help of the serial port debugging assistant software, the interceptor is tested at different baud rates. Figure 7 shows the test results at a baud rate of 9600 b/s and mode 2. COM1, COM2 and COM4 correspond to specific devices, control computers and host computers respectively. The data after the "s:" label in the host computer received data is sent by the device, and the data after the "k:" label is sent by the control computer. These data are intercepted by the interceptor in chronological order. When the interceptor is used to intercept the actual communication data between a specific device and its control computer, the corresponding relationship between the communication data between them can be found by analyzing the intercepted data, thereby analyzing its communication protocol.

  

  4 Conclusion

  This paper discusses the design of RS 232 serial data interceptor, makes a product and conducts experiments. The system is stable and reliable and can effectively intercept serial communication data. The system can provide help for people with related needs.

Keywords:RS232 Reference address:Design of RS232 serial data interceptor

Previous article:New SIM card monitors your child's every move
Next article:Hardware debugging skills during MCU development

Latest Analog Electronics Articles
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号