Design of serial communication based on single chip microcomputer application system

Publisher:SereneGardenerLatest update time:2011-08-25 Source: EEWORLD 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 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 common 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. It can easily exchange information between two digital devices and realize full-duplex data transmission, with low hardware cost and good versatility.

2 Hardware Design of Serial Communication

Serial communication refers to the use of a data line to transmit data one bit at a time, with each bit of data occupying a fixed length of time. It only requires a few lines to exchange information between systems, and is particularly used for long-distance communication between computers and computers, and between computers and peripherals.

In the developed system, the infrared thermometer detects the working and ambient temperature of the power equipment and transmits 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, and the host PC transmits the online working state of the infrared thermometer. 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 for expansion. The hardware circuit of the serial communication of this 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. Output RS 232C level. MC1489 receives RS 232C level and outputs TTL level. The inconvenience of this level conversion interface is that it requires ±12V operating voltage and consumes a lot of power. It is not suitable for low-power systems.

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 of the 8251A serial port chip is connected to Y2 of the 74LS138 decoder, the port address of the 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

AT89C51 is a low-voltage, high-performance CMOS 8-bit microprocessor with 4K bytes of FLASH memory (FPEROM—Flash Programmable and Erasable Read Only Memory), commonly known as a single-chip microcomputer. AT89C2051 is a single-chip microcomputer with 2K bytes of flash programmable and erasable read-only memory. The erasable read-only memory of the single-chip microcomputer can be erased repeatedly 1000 times. The device is manufactured using ATMEL's high-density non-volatile memory manufacturing technology and is compatible with the industry-standard MCS-51 instruction set and output pins. Due to the combination of a multi-function 8-bit CPU and flash memory in a single chip, ATMEL's AT89C51 is an efficient microcontroller, and AT89C2051 is a streamlined version of it. The AT89C single-chip microcomputer provides a highly flexible and inexpensive solution for many embedded control systems.

Key Features:

Compatible with MCS-51

128×8 bits internal RAM

32 programmable I/O lines

Two 16-bit timer/counters

5 interrupt sources

Programmable serial channel

Low power idle and power-down modes

On-chip oscillator and clock circuit

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 accomplished by setting the microcontroller's serial port control register (SCON). Since an 11-bit data frame is used, 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 uses mode 3. In the microcontroller's serial received frame data, 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) Regulations on 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

Utilize the two transmission lines of RS 232C to realize full-duplex sending and receiving data.

(5) Communication method

In asynchronous communication, data is transmitted in units of words. Since the sender and 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 consists of 11 bits, including a start bit, data bits, parity bit, and stop bit. The data format is as follows [2]:

Therefore, the 8251A initialization mode control word 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-machine interface. In terms of standard serial port communication, the onComm event is triggered during the process of sending or receiving data. The CommEvent property is accessed through programming to understand the type of communication event and handle it 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 single chip microcomputer application system

Previous article:Programmable Active Filter Circuit Based on Single Chip Microcomputer Control
Next article:Design of serial communication based on single chip microcomputer application system

Latest Industrial Control 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号