Design and implementation of network monitoring system based on AT89C52

Publisher:DreamyEclipseLatest update time:2012-12-06 Source: 现代电子技术 Keywords:AT89C52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Introduction
Taking the intelligent system of electronic equipment fault inspection and repair skill assessment and training as an example, this paper introduces a master-slave network communication system composed of a PC and multiple single-chip microcomputers. The single-chip microcomputer control is the lower computer, responsible for data collection and control of the fault point of the electronic equipment, and transmits the results to the PC through the interface; the PC is the upper computer, which analyzes and processes the data and controls the operation of the single-chip microcomputer according to the results of analysis and processing. At present, there are usually four communication methods for using Visual C++ to develop serial communication to realize intelligent assessment and training systems:
(1) Calling API (Application Program Interface) function to implement;
(2) Using Visual C++ standard communication functions such as inp and inpw to directly operate the serial port;
(3) Using Visual C++ communication controls (MSComm);
(4) Using communication classes written by third parties (Cserial).
Among the above methods, the first method is widely used, but it requires many low-level settings, is relatively complex, requires a high degree of specialization, and is difficult to use; the second method requires understanding the principles of hardware circuit structure and is difficult to master; the third method seems simpler and only requires simple configuration of the serial port, but uses the confusing WARIANT class and cannot meet the needs of using multiple serial ports for complex processing; the fourth method is to use a CSerial class specifically for serial communication. This method is powerful and can be used conveniently as long as you understand several member functions of this class. The RS 485 bus is widely used in network microcontroller systems for its advantages of good flexibility, low cost, strong anti-interference ability, multiple supported nodes, long transmission distance, and simple connection. In this system, the host computer uses the Cserial class communication method of Visual C++; the lower computer uses the AT89C52 microcontroller of ATMEL, and the bus uses the RS 485 standard networking.


l System structure
The whole system is a master-slave bus monitoring system based on RS 485 field bus, custom communication protocol, connecting each lower computer and upper computer on the bus, and managed by the upper computer. The system includes monitoring layer, communication layer, and field equipment layer. Among them, the monitoring layer is undertaken by the upper computer (PC), which is responsible for receiving data uploaded by the underlying field equipment, analyzing and storing data, setting and modifying the parameters of the lower computer, and querying real-time and historical data to realize the monitoring and management of field equipment; the communication layer communicates with the field lower computer equipment in real time through a self-defined communication protocol to complete the packaging, unpacking, inspection and other processing of data communication packages; the field equipment layer is a monitoring system composed of multiple electronic devices, single-chip microcomputers, relays, keyboards, LCD displays, etc.
The system structure block diagram is shown in Figure 1.

The upper computer is a teaching control management system operated by teachers, and its functions are realized by programming with Visual C++ on a microcomputer. The main functions of the teaching control management system are:
(1) technical preparation for the examination;
(2) invigilation of the examination;
(3) assisting in completing other examination information management tasks.
According to the functional requirements, the teaching control management system consists of a communication module, a code compilation module, a code execution module, a system management module, and a historical data query module. These modules and the user interface together constitute the entire system software.
The lower computer, as the student client of this distributed control system, is an application system based on the AT89C52 single-chip microcomputer. This system uses a monitoring system composed of computers, AT89C52 single-chip microcomputers, optocouplers, drive circuits, relays, color TVs, etc., through a local area network to form an intelligent training and identification system. The AT89C52 single-chip microcomputer control system is shown in Figure 2. [page]

The AT89C52 single-chip microcomputer control system adopts a master-slave system composed of a variety of microprocessor chips composed of computers and AT89C52 single-chip microcomputers. The teacher computer is the upper computer of the system, which realizes human-computer interaction and data exchange, retrieval, storage, processing, updating of graphic display, control and communication of the lower computer (i.e., student computer). The student computer completes data collection and signal processing. The teacher computer is the host computer and the student computer is the slave computer. The communication method between the master and the slave computer adopts the serial port method. Each training or identification station has an independent student computer and color TV, and each student computer is interconnected by a network cable. The student computer controls the state of the color TV fault point through a relay.
The AT89C52 single-chip microcomputer control system requires software and hardware development. Unlike a single independent single-chip microcomputer system, the single-chip microcomputer in the network not only needs to work according to the pre-designed program, but more often needs to adjust the working program in time according to the control instructions from the upper computer. The main functions of the lower computer during practical training or examinations are as follows:
(1) Serving as a terminal for the upper computer;
(2) Serving as an electronic equipment controller;
(3) Providing an interactive interface for candidates;
(4) Other invigilation services.


2 Communication interface design
The communication interface is an important part of the single-chip control system. The single-chip computer and the computer are constantly exchanging and transmitting information, and this information exchange and transmission must be realized through the communication interface and data bus. The reasonable selection of communication interface devices and buses is the premise and guarantee for the smooth data exchange and transmission in the single-chip control system.
The system adopts RS 485 bus networking. The host computer converts the RS 232 standard level to the RS 485 standard level through the serial interface via the standard RS 232 bus and RS 232/RS 485 converter to communicate with the candidate's lower computer end; on the lower computer end, SN75176 converts the RS 485 standard level to the TTL level to access the asynchronous serial communication port (UART) of the processor, realizing half-duplex communication of the RS 485 network.
The RS 232/RS 485 converter uses plug-and-play products on the market, which has realized intelligent control of transceiver enablement, without changing any host computer hardware. The upper computer can connect to up to 32 lower computers. If SN75184 is used on the lower computer side, the upper computer can connect to up to 64 lower computers.
The design of the RS 485 interface circuit should fully consider various interferences on the line and the matching of the line characteristic impedance. During the transmission process, electromagnetic interference and terminal reflection will be generated, causing the useful signal and the interference signal to be superimposed on the transmission line. When the interference is too large, communication cannot be carried out. The system uses the SN75176 RS 485 interface chip. The communication medium of the RS 485 bus network uses a twisted pair with a shielded layer, and a 120Ω matching resistor is installed at each end of the transmission line to eliminate the reflection of the signal on the transmission line. The communication distance can reach 1200 m.


3 Communication protocol
The software design of RS 485 interface has a great influence on the reliability of system networking. Since RS 485 bus is an asynchronous half-duplex communication bus, the bus can only present one state at a certain moment, so this method is used for query communication between the upper computer and the lower computer. In order to coordinate the time-sharing multiplexing of the bus, a reasonable communication protocol must be formulated to ensure the normal data communication. The communication protocol of this system is: the baud rate is agreed to be 9600 b/s, Tl works in mode 2, the initial value is FDH, SMOD=0. The serial port is initialized to mode 3. The communication format requirements are as follows: The
communication data format is a total of 24 bits (binary), 8 bits of identification code, 8 bits of control instruction code, and 8 bits of fault point code. The format is as follows:

The regulations are as follows:
The identification code is the lower computer address code, and the address range is 70H to 88H. The control instruction code is: the character "1" indicates that the fault point is short-circuited, and the ASCII code is "31H"; the character "O" indicates that the fault point is disconnected, and the ASCII code is "30H".
(1) Upper computer status word:

bo: Paper issuing instruction flag 1, no paper issuing instruction flag 0;
b1: Test start instruction flag 1, no test start instruction flag O;
b2: Answer query instruction flag 1, no answer query instruction flag 0;
b3: Forced question termination instruction flag 1, no forced question termination instruction flag O;
b4: Resume question execution instruction flag 1, no resume question execution instruction flag 0.

[page]

(2) Status word of the lower computer:

b0: Login request 1, no login request 0;
b1: Logged in status flag 1, not logged in status flag 0;
b2: Paper collected status flag 1, not collected status flag 0;
b3: Start answering status flag 1, not started answering status flag O;
b4: Paper submission request flag 1, no paper submission request flag 0;
b5: Paper submitted flag 1, not submitted flag O;
b6: Question answering suspension flag 1, question answering resumption flag O.


4 Communication process
The upper computer starts the program and enters the polling process. At this time, the lower computer starts and logs in. When it is polled, it sends a login message. After the upper computer receives it, it performs the necessary login processing. After all the lower computers have logged in or the invigilator believes that the login information of all candidates has been received, the paper distribution button is pressed to distribute the papers to each logged-in lower computer in turn. After the papers are distributed, the invigilator presses the start button and broadcasts the start command of the exam. The lower computer displays the exam questions and the system starts timing. During the exam, the invigilator can query the status of any lower computer (including the exam status of the candidates); even the automatic inspection command can be started to automatically inspect the answering status of each candidate. During the exam, the candidate can hand in the paper after answering the questions. After the candidate presses the paper submission button, the paper submission information is sent, and the upper computer receives it and sends a reply message of correct reception. During the exam, if the invigilator finds that a student is cheating, he can press the stop exam button at any time to stop the operation of this lower computer and record zero points for the exam. When the exam time is up, the system automatically determines whether there are still candidates who have not handed in their papers, stops the candidates from answering the papers, and retrieves the answer information from the corresponding lower computer. The basic polling and communication action diagram between the upper and lower computers is shown in Figure 3.

The communication process between the upper and lower computers is as follows:
① The upper computer, as the network master, polls at a certain time interval dtl. The polling process is as follows: First, the upper computer queries the upper computer status word to determine whether there is a communication request. If not, it will issue a communication authorization mark to the polled lower computer. If the lower computer does not respond after a short delay, the lower computer at this address is not online, and the polling is terminated; if there is a response, the channel mark for communicating with this lower computer is set.
② The lower computer issues a command: indicating that the lower computer replies to the query command and determines the status of the lower computer according to the status word. ③ The upper computer issues a command: indicating that
the upper computer sends the upper computer to receive information according to the status word of the lower computer and the status word of the upper computer, according to the principle that the upper computer has priority.
④ The lower computer issues a command: The upper computer parses the data according to the functional command, completes the corresponding display and confirms the reply.
⑤ The upper computer issues a command: When an error occurs during the information transmission process from the lower computer to the upper computer, the upper computer will issue a retransmission function command to the lower computer. The number of retransmissions is determined according to the debugging process.
When designing RS 485 communication software, attention should be paid to the software programming of the RS 485 control end. In order to ensure reliable data transmission and reception, an appropriate delay needs to be added when the RS 485 bus state switches. The delay is generally controlled at about 1 ms before data transmission and reception. After this treatment, the bus has a stable working process when the state switches.

5 Design of host computer communication software
Host computer communication is designed using a CSerial class specifically for serial communication. This method is powerful and can be easily used as long as you understand several member functions of this class. The following are several commonly used member functions:

[page]

6 Conclusion
A software and hardware design based on the AT89C52 single-chip microcomputer network communication system is proposed. The solution has been successfully applied to the intelligent assessment system of electronic product fault repair skills and has been commercialized. After more than a year of use, it has been running reliably. In addition, since the system adopts a modular design and has strong flexibility, it can control terminal devices of different models, brands and functions according to the actual needs of users. Therefore, it has high application value and promotion value.

Keywords:AT89C52 Reference address:Design and implementation of network monitoring system based on AT89C52

Previous article:Design of SD card reading and writing system based on single chip microcomputer and FAT16
Next article:Design and implementation of a simple infrared remote control password lock based on single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 15:28

Practical USB interface design based on CH371
Universal Serial Bus (USB) is a new generation bus interface standard jointly launched by seven world-renowned computer and communication companies, including Intel, Compaq, Digital, IBM, Microsoft, NEC, and Nerthern Telecom. As a high-speed communication interface between PCs and peripherals, USB has the advantages
[Microcontroller]
Practical USB interface design based on CH371
Design of interface between 51 single chip microcomputer and ARINC429 aviation bus
1 Main functions of DEI1016 DEI1016 is a serial receiving and transmitting device produced by Device Engineering Instrumented that supports the ARINC429 aviation bus protocol. The main functions of this device are as follows: ●Serial data word length is 32 or 25 bits; ●Serial data rate is 100k
[Microcontroller]
Design of interface between 51 single chip microcomputer and ARINC429 aviation bus
Schematic diagram of infrared remote control transmitter circuit of remote control fan system
    As shown in the figure, this is the infrared remote control transmitter circuit diagram.     In the figure, the single-chip microcomputer uses AT89C52, which is the main chip of the remote control circuit. The AT89C52 single-chip microcomputer produced by ATMEL uses a high-performance static 80C51 design and is ma
[Microcontroller]
Schematic diagram of infrared remote control transmitter circuit of remote control fan system
Knob-type keyboard and its interface technology with AT89C52
Introduction Nowadays, single-chip microcomputer technology is developing rapidly, and single-chip microcomputer systems have been widely used in various fields of the national economy. Many single-chip microcomputer application systems require input devices, and the typical input device is the key
[Microcontroller]
Knob-type keyboard and its interface technology with AT89C52
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号