Serial communication design based on AT89C51 application system

Publisher:SereneHeartLatest 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:Partition jump processing of multiple banks in C8051 F12X
Next article:Serial communication design based on AT89C51 application system

Recommended ReadingLatest update time:2024-11-16 23:48

Research on the Reliability of RS485 Serial Bus
        When developing embedded systems, microprocessors need to be interconnected with different devices, which requires the establishment of a unified communication bus standard. Communication buses can be divided into parallel buses and serial buses. Parallel communication is fast and has good real-time performanc
[Power Management]
Research on the Reliability of RS485 Serial Bus
51 MCU RS485 program source code and proteus simulation diagram
MCU-485-PC serial communication.jpg (106.21 KB, Downloads: 21) Download attachments    and save them to the photo album Uploaded on 2018-3-26 01:45 The microcontroller source program is as follows: #include reg51.h #include intrins.h #define uchar unsigned char #define uint unsigned int sbit P12=P1^2; char co
[Microcontroller]
51 MCU RS485 program source code and proteus simulation diagram
Panasonic considers supplying electric vehicle technology to US manufacturer Tropos Motors
On September 10, according to foreign media reports, Panasonic will cooperate with Tropos Motors, a US pure electric vehicle startup, in the commercial vehicle field. Panasonic is considering providing on-board batteries and pure electric vehicle related technologies. Matsushita Panasonic will cooperate with Trop
[Automotive Electronics]
Panasonic considers supplying electric vehicle technology to US manufacturer Tropos Motors
RS485 communication based on Modbus + STM32 + IAR
I have been reading Modbus related content recently and searching the Internet for a long time. I found that most of the content is based on written explanations of the protocol, and there are few successful examples for reference. Here I would like to share with you the example I recently modified and debugged. I wou
[Microcontroller]
RS485 communication based on Modbus + STM32 + IAR
Design of RS485 interface long-distance data communication circuit with 3.3V power supply
  In the fields of industrial control, power communication, intelligent instruments, etc., serial communication is usually used for data exchange. The original RS232 interface often causes signal transmission errors due to electrical interference due to factors such as the external application environment. In addition
[Power Management]
Design of RS485 interface long-distance data communication circuit with 3.3V power supply
Molex Launches Rugged Brad HarshIO M8 Ethernet Module
Compact 30mm digital HarshIO modules provide IP67-rated on-machine Ethernet connectivity between I/O and control systems using PROFINET fieldbus    (Singapore – September 25, 2013)   Molex, a leading global supplier of a full range of interconnect products, has introduced the new Ethernet version of the Brad® Harsh
[Analog Electronics]
Molex Launches Rugged Brad HarshIO M8 Ethernet Module
PLC and multi-machine communication based on RS485 interface Modbus protocol
  1 Introduction   In the field of automatic control, both PLC and single-chip microcomputer are widely used. PLC is stable and reliable, has strong anti-interference ability, is powerful and easy to use . Single-chip microcomputer has the characteristics of low cost, flexible use and diverse functions. The combinat
[Microcontroller]
PLC and multi-machine communication based on RS485 interface Modbus protocol
PLC and multi-machine communication based on RS485 interface Modbus protocol
1 Introduction In the field of automatic control, both PLC and single-chip microcomputer are widely used. PLC has the characteristics of stability, reliability, strong anti-interference ability, powerful functions and easy use . Single-chip microcomputer has the characteristics of low cost, flexible use and
[Industrial Control]
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号