Serial communication design based on AT89C51 application system

Publisher:转眼人老Latest update time:2006-10-08 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

In the power equipment status detection system using infrared imaging technology, the application system is based on the AT89C51 microcontroller and uses the non-contact infrared thermometer model 3iLRL3 from the American Raytheon Company. This thermometer uses the RS232C serial communication standard interface, which is commonly used in many communication devices. The current direct serial communication with a PC is also the RS 232C interface. Although the performance indicators of RS232C are not very good, it still has widespread market support. Serial communication technology plays an important role in measurement and control systems, using only three wires. You can easily exchange information between two digital devices, achieve full-duplex data transmission, and have low hardware costs. And it has good versatility.

2 The hardware design of serial communication

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

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

Therefore, the system uses the MAX232 produced by MAXIM Company 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 achieve bidirectional conversion of 2 channels and 2 levels. In this system, it can replace 2 pieces of MCl488 and 2 pieces of MCl489, and connect an external 5 V power supply. It does not need to connect an 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 the 89C51 has only one serial port. The programmable universal serial interface chip 8251A is used to communicate with the host PC. Since the chip select terminal CS interface of the 8251A serial port chip To Y2 of the 74LS138 decoder. Therefore, the port address of 8251A is OA000H, the RXCLK and TXCLK receiving and transmitting 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 the 89C15 through MAX232, so the infrared scanning sensor head scans the power equipment according to the given scanning strategy, reads in the temperature scanning signal, and performs maximum, minimum, average and abnormal elimination Processing, the microcontroller records the scanning time and temperature value, and waits for PC commands. Send data to the PC. The data sending process is shown in Figure 2. The infrared sensor detects the status of the power equipment through the online work configuration control downloaded from the PC. The process of receiving data is shown in Figure 3. The serial communication between the microcontroller and the PC passes through 825lA, so in the communication program, first perform initialization programming on 825lA, set the serial communication mode, and determine the communication protocol. These are key points in communications programming.


(1) The working mode setting of the serial port is

completed by setting the serial port control register (SCON) of the microcontroller. Since a frame of 11-bit data format is used, the working mode of the 89C51 serial port can only be set to mode 2 and mode 3. The baud rate of data transmission is controlled by a timer. This system adopts mode 3. In the l frame of data received serially by the microcontroller, the parity bit is completed by TB8 and RB8 (9th bit data) of SCON to complete the check function.

(2)Serial port baud rate setting


Through the calculation of this formula, it can be further verified that there is no error in the initial value of T1 calculated when the frequency of the crystal oscillator selected for the design system is 11.0592 MHz.

(3) The stipulations of handshake signals are

that the request signal is FFH, the response signal is FEH, the error signal is FDH, and the end signal is FCH.

(4) Data transmission method

uses 2 transmission lines of RS 232C to achieve full-duplex sending and receiving data.

(5) Communication method

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

(6) Format of data frame

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

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

The PC uses Visual basic programming. VB supports object-oriented programming, has a structured event-driven programming model and can use infinitely expanded controls, and can easily create a good human-computer interface. In terms of standard serial communication, VB provides a powerful communication control MSCOMM, the file name is MSCOMM. VBX. This control can set the data sending and receiving of serial communication, and set 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, and the CommEvent property is accessed programmatically to understand the type of communication event and handle them respectively. 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. RS 232C in this system is only used for short-distance communication. Using RS 485 in an improved system can expand transmission distance and system stability is enhanced.
Reference address:Serial communication design based on AT89C51 application system

Previous article:Research on WDT in MSP430 microcontroller
Next article:Research and application examples of rapid printing method of electrocardiogram based on thermal printer

Recommended ReadingLatest update time:2024-11-16 17:27

A water meter system based on ultrasonic measurement and GPRS data transmission
Contents The invention belongs to the field of water meters, and in particular relates to a water meter system based on ultrasonic measurement and GPRS data transmission. Background of the Invention The water consumption of large users such as large residential areas, factories, hotels, schools, hospitals, and the t
[Test Measurement]
A water meter system based on ultrasonic measurement and GPRS data transmission
iQOO officially becomes BMW M Motorsport's top global partner
Today, the official Weibo account of iQOO mobile phone announced that iQOO has become the world's top partner of BMW M Motorsport. Regarding this cooperation, iQOO Brand President Feng Yufei said that BMW M Motorsport is the embodiment of BMW's sports spirit and BMW's pursuit of the ultimate in performance and contr
[Mobile phone portable]
If you don't know how to use RS 485 to realize serial communication, you are too out of date. Here is a tutorial to help you easily replace RS 232
  ARM (Advanced RISC Machines) is a general term for a class of microprocessors. ARM is a well-known company in the microprocessor industry. It has designed a large number of high-performance, low-cost, low-energy RISC processors, related technologies and software. ARM microprocessor is a high-performance, low-power 3
[Microcontroller]
If you don't know how to use RS 485 to realize serial communication, you are too out of date. Here is a tutorial to help you easily replace RS 232
Renesas Electronics joins hands with CG Power and Stars Micro to build packaging and testing factory in India
Renesas Electronics, India's CG Power and Industrial Solutions, and Thailand's Stars Microelectronics officially announced that they will cooperate to build an outsourced semiconductor packaging and test (OSAT) factory in India. This joint venture plan has been approved by the Indian government, marking a new stage of
[Semiconductor design/manufacturing]
Design of GPRS System Based on Embedded System
An embedded system is a combination of computer hardware and software with specific functions or purposes, or a special computer system that is installed in another device and controls the device. The biggest feature of an embedded system is that it is purposeful and targeted, that is, the development of each embedd
[Industrial Control]
Design of GPRS System Based on Embedded System
Community Wireless Meter Reading System Based on GPRS Module
Electricity metering is an important part of the modern power marketing system. Traditional electricity settlement relies on manual on-site data reading at regular intervals, which has many shortcomings in terms of real-time, accuracy and applicability. Combining modern communication technology, computer technology
[Analog Electronics]
Based on RS60E series robot dedicated servo drive
Reporter: Wang Hong. Harbin University (Shenzhen) The 60E series dedicated servo is a high-performance 6-in-1 servo drive developed by the robot team specifically for the urgent needs of servo drives in the robot industry, through in-depth basic theoretical research and continuous technological innovation. It s
[robot]
Interface circuit between AT89S52 and RS-232
Interface circuit between AT89S52 and RS -232 Figure 5 Interface circuit between AT89S52 and RS-232 The microcontroller uses AT89S52, and the RS232 chip uses MAX232.
[Microcontroller]
Interface circuit between AT89S52 and RS-232
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号