Design of serial communication based on 51 single chip microcomputer application system

Publisher:疯狂小马Latest update time:2011-10-21 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In the power equipment status detection system of infrared imaging technology, the application system based on AT89C51 single chip microcomputer adopts the non-contact infrared thermometer model 3iLRL3 of American Ray State Company. The thermometer adopts the RS232C serial communication standard interface, which is commonly used in many communication devices. At present, the direct serial communication with PC is also RS 232C interface. Although the performance index of RS232C is not very good, it still has wide market support. Serial communication technology occupies a very important position in the measurement and control system. Only three wires are used. It is convenient to exchange information between two digital devices and realize full-duplex data transmission. The hardware cost is low and the versatility is good.

2 Hardware design of serial communication

In the developed system. The infrared thermometer will detect the working and ambient temperature of the power equipment and transmit it to the single-chip microcomputer through the RS 232C serial port. At the same time, the single-chip microcomputer controls the online working state of the detection device. The formulation and selection of the working state of the infrared detection device are completed by the host PC. In this way, the control circuit composed of the single-chip microcomputer as the core is the data transfer station. The host PC downloads the online working state of the infrared thermometer and uploads the online working temperature of the power equipment detected by the infrared thermometer to diagnose the working state of the power equipment. Here, the serial communication interface between the single-chip microcomputer and the PC is still the standard communication of RS 232C. The AT89C51 single-chip microcomputer has only one serial port, which requires solving another serial port expansion problem. The system uses the universal serial communication interface chip 8251A to expand. The hardware circuit of the serial communication of the system is shown in Figure 1.

RS-232 is an EIA (Electronics Industries Association) level. The signal level uses negative logic, logic "1" = -12V, logic "0" = +12V. This is incompatible with the TTL signal level of the microcontroller, so RS232C cannot be directly connected to the serial port RXD (serial receiving port) and TXD (serial transmitting port) of the 89C51 microcontroller. A converter is required to perform level conversion between RS232C and TTL circuits. There are many level conversion chips on the market, such as MCl488 and MCl489, which were widely used in the early days. MC1488 receives TTL level and outputs RS 232C level. MC1489 receives RS 232C level and outputs TTL level. The inconvenience of this level conversion interface is that it requires ±12V working voltage and consumes a lot of power. It is not suitable for low-power systems.

Therefore, the system uses MAX232 produced by MAXIM to achieve conversion between the two levels. Its main advantages are: there is a voltage converter inside the chip, which can convert the input +5 V working voltage into the ±12 V voltage required by the RS 232C interface; at the same time, it can realize two-way two-level bidirectional conversion. In this system, it can replace two MCl488 and two MCl489 chips, and connect an external 5 V power supply, instead of the external ±12 V power supply like MCl488 and MCl489, so the circuit is simple and the performance is improved.

In the system, the infrared thermometer and the PC have two serial ports, while 89C51 has only one serial port. The programmable universal serial interface chip 8251A is used to communicate with the upper PC. Since the chip select terminal CS of the 8251A serial port chip is connected to Y2 of the 74LS138 decoder, the port address of 8251A is OA000H, and the RXCLK and TXCLK receiving and sending clocks are connected to the T1 port of 51, and T1 is used as the baud rate generator [1].

3 Software Design

The serial port of the infrared thermometer is directly connected to 89C15 through MAX232, so the infrared scanning sensor head scans the power equipment according to the given scanning strategy, reads the temperature scanning signal, performs maximum, minimum, average and abnormal elimination processing, and the microcontroller records the scanning time and temperature value, waiting for the PC command. Send data to the PC, and the data sending process is shown in Figure 2. The infrared sensor detects the status of the power equipment through the online working state control transmitted by the PC, and its data receiving process is shown in Figure 3. The serial communication between the microcontroller and the PC is through 825lA, so in the communication program, the 825lA is first initialized and programmed, the serial port communication mode is set, and the communication protocol is determined. These are the key points of communication program design.


(1) Setting the working mode of the serial port

This is done by setting the serial port control register (SCON) of the microcontroller. Since the data format is 11 bits per frame, the working mode of the serial port of 89C51 can only be set to mode 2 and mode 3. The baud rate of data transmission is controlled by a timer. This system uses mode 3. In the serial data received by the microcontroller, the parity bit is checked by TB8 and RB8 (9th bit data) of SCON.

(2) Setting the serial port baud rate


The calculation of this formula can further verify that when the frequency of the crystal oscillator selected in the design system is 11.0592 MHz, the calculated initial value of T1 has no error.

(3) Provisions for handshake signals

The request signal is set to FFH, the response signal is set to FEH, the error signal is set to FDH, and the end signal is set to FCH.

(4) Data transmission method

The two transmission lines of RS 232C are used to realize full-duplex transmission and reception of data.

(5) Communication method

Asynchronous communication method transmits data in units of words. Since the sender and the receiver use their own clocks, the format of the data frame is strictly specified in asynchronous communication.

(6) Data frame format

A frame of data is 11 bits, including the start bit, data bit, parity bit, and stop bit. The data format is as follows [2]:

Therefore, the control word of the 8251A initialization method is 7DH.

The PC is programmed using Visual Basic. VB supports object-oriented programming, has a structured event-driven programming model, can use unlimited expansion controls, and can easily create a good human-computer interface. In terms of standard serial port communication, VB provides a powerful communication control MSCOMM, the file name is MSCOMM.VBX. This control can set the data transmission and reception of serial communication, the serial port status and the information format and protocol of serial communication. The onComm event is triggered during the process of sending or receiving data. The CommEvent property is accessed by programming to understand the type of communication event and handle them separately. The VB serial initialization communication software is as follows [3]:

4 Conclusion

Serial communication technology is currently widely used in many measurement and control systems, and long-distance communication is more prominent. The RS 232C of this system is only used for short-distance communication. Using RS 485 in the improved system can expand the transmission distance and enhance the system stability.
Reference address:Design of serial communication based on 51 single chip microcomputer application system

Previous article:Design of Interface between DS2450 Converter and 51 Single Chip Microcomputer
Next article:Design of serial communication based on 51 single chip microcomputer application system

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号