This paper introduces a practical and simple design method of RS-232 optoelectronic isolation communication interface, which filters the signal through the optoelectronic coupler to realize the anti-interference ability, and designs a hardware connection circuit, complete communication protocol and software design flow for communication between AT89C2051 single chip computer and PC computer. Finally, it realizes on the controller of Yuntai.
Examples of applications. RS-232 is a serial communication interface standard designed by EIA in the 1960s. It has been widely used in the field of communication. However, in the face of complex and changeable electrical environment, RS-232 communication is extremely unstable and greatly disturbed by the environment, and RS-232 communication distance is not very long. In order to improve the anti-jamming ability of communication, this design adds photoelectric isolation technology to RS-232 communication module to realize electrical isolation and filter signal. In this paper, RS-232 serial communication interface is applied to the Yuntai controller for practical detection and application. How to use MAX232 serial communication interface chip to carry out photoelectric isolation RS-232 serial interface communication for AT89C2051 microcontroller is introduced in detail. The goal of this paper is to design an open and universal system for current practical communication applications. Therefore, a general communication standard is adopted to design the system. The purpose of this design is to realize the system of data communication and control based on RS-232 bus, which uses single chip computer to collect data and then process and control it. It can collect voltage, current, pulse and other signals, that is to say, thermostatic element collect all kinds of data signals that will be input into the platform, send them to the optocoupler to screen the signals, and then supply the signals to the single chip computer. The single chip computer sends corresponding instructions to the external device according to the signal filtered by the optocoupler (which is programmed by the single chip computer), so as to realize the control of the device. Technical specifications: (1) Working power supply, input voltage 5V DC ( 10%) and current not more than 300mA. (2) The communication interface meets the standard of RS232, and the baud rate is as high as 250KB.
(3) Two independent RS-232 communications, the input and output circuits are separated from each other, the two input terminals are separated from each other, the two output terminals are separated from each other, the communication and the working power supply are separated from each other, and the isolation resistance is more than 1000 M. (4) The peak anti-jamming voltage at the input of communication port can reach 15KV. (5) The switching load voltage/current of K1, K2, K3, K4 and K 5 is 300V/300mA, and the switching time is adjustable from 0 to 24 hours (default is 1 second). The signal processing and control of the circuit are carried out by AT89C2051 single chip computer. Meanwhile, the conversion between TTL level (5v of computer output signal level) and RS232 level (12v of circuit transmission level) is realized by MAX232 chip, so as to transmit information with RS232 level, realize the effect of anti-interference and long-distance transmission of signals.
The input and output electrical signals are isolated and filtered. DS1232 (watchdog chip) is also used in the circuit to self-check and protect the circuit. Finally, the control of equipment by computer is realized. Through the design of RS-232 communication module, the data communication and control based on RS-232 bus are realized; then relay control module circuit is added to realize the data communication between the master and slave computers of the single chip computer, so as to achieve the control of the device at the PC terminal; then, the module of data acquisition and control at the PC terminal and the device terminal is designed, and the single chip computer is self-contained.
The task is to collect or control related data. After the hardware has been designed and debugged, a certain communication protocol should be compiled according to the whole system, and the optimal scheme should be selected to realize the data communication between PC and equipment [3]. These are realized in the program design. The software is programmed by Keil software. After realizing data communication, PC terminal and equipment terminal extract useful data information according to the proposed communication protocol, and then carry out relevant operations according to this information, so as to achieve the purpose of data communication and control based on RS-232 bus. The hardware circuit of this design mainly includes MAX232 level conversion, minimum system of single chip computer, five-way photoelectric conversion circuit, RS-232 communication circuit, five-way information transmission circuit, etc. The software part mainly includes system initialization, RS-232 communication protocol, AD/DA driver, etc. [4]. RS232 serial communication mode under crystal 11.0592M, baud rate 9600, check bit PNONE. Indicator lights POW1 and POW2 respectively indicate the working status of two internal isolation power sources; lighting indicates that the work is normal. Indicator lights K1, K2, K3, K4 and K5 indicate the corresponding switching state, and when lit, they indicate that the switch is on. Test presses twist S1, press K1, K2, K3, K4 to turn on, the corresponding indicator lights on. Channel 1 and channel 2 input instruction 33A6 simultaneously controls the turn-on time of K1, K2, K3 and K4 for one second, and the corresponding indicator lights are on. Channel 1 and Channel 2 input instructions 33A1, 33A2, 33A3, 33A4 and 33A5 respectively, and control K1, K2, K3 and K4 to turn on respectively. The turn-on time is one second, and the corresponding indicator light is on.
When the microcontroller is powered on or hot started, the feedback information is 66 D9 20 13 0615 through RS232 channel 1. The S1 keyboard is released immediately after pressing, and the performance of K1, K2, K3 and K4 switches is tested. The switching-on time is one second, and the corresponding indicator lights are on. At the same time, 66 DA A1 A2 A3 A4 is fed back through RS232 channel 1. When the holding time of S1 keyboard is more than 2 seconds, the performance of K1, K2, K3, K4 and K5 switches is tested.
The switch-on time is one second, and the corresponding indicator lights are on. At the same time, the feedback information 66 DA A1 A2 A3 A4A5 is provided through RS232 channel 1. Channel 1 and 2 will be shut down and reset after more than 24 hours without any communication. When the system is frequently disturbed, shutdown and reset.
After receiving the command “30H” about the host at the same time, shut down and reset. Connect to 5V power supply, observe the status of indicator lamp, POW 1, POW 2 are always on, RUN is scintillating. The observed current consumption should be less than 200 mA.
Set the baud rate to 9600 bit/S, check bit: PNone, data bit 8, stop bit 1, hexadecimal transceiver and display, do the following operations: after input instruction 33, the system reset, the receiving window should be able to receive characters 66 D9 20 13 0615. Sending hexadecimal arbitrary characters (beyond 33), the receiving window should be able to receive the same characters. After inputting instruction 33A6, K1, K2, K3 and K4 light up for 1 second and then extinguish. After inputting instruction 33A5, K5 lights up for 1 second and then extinguishes. When the holding time of S1 keyboard is more than 2 seconds, the corresponding indicator lights of K1, K2, K3, K4 and K5 will be turned off after one second. The receiving window should be able to receive and display 66 DA A1 A2 A3 A4 A5.
Through the above test, the product is qualified. According to the theoretical analysis and experimental results of this design, the principle and method adopted in this paper are correct and meet the design requirements of the subject from the application of the controller of the platform. The design of information communication can only complete the basic functions of one-way data transmission and control, and the system design is relatively simple. Therefore, the design can be enriched and improved in many ways.