Design of Universal Data Acquisition and Communication Instrument Based on Single Chip Microcomputer

Publisher:见贤思奇异果Latest update time:2010-02-02 Source: 电子技术Keywords:W77E58 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Introduction

The single-chip microcomputer data acquisition system refers to a system that uses a single-chip microcomputer to collect, store, display and transmit various signals on site, including: non-electrical signals (such as temperature, pressure, flow, etc.), electrical signals (voltage, current), and switch quantity, frequency quantity signals, etc. At present, 8-bit single-chip microcomputers are widely used in various fields due to their powerful control functions, wide variety and low price. They are especially used in data acquisition, equipment control and other aspects. They are the mainstream models in single-chip microcomputer applications. This paper adopts the high-performance Turbo-51 series single-chip microcomputer W77E58 produced by Taiwan Winbond Company to realize the development of a general data acquisition and communication instrument based on single-chip microcomputer, which has high practical value. In order to make the designed data acquisition instrument convenient to use, the system uses the PTR2000 wireless data transmission module to communicate with the host computer, so that it can respond to the data upload command of the PC in the control center at any time and upload the collected data to the control center in real time.

1 System Hardware Design

The universal data acquisition and communication instrument designed in this paper can collect standard output signals of various field equipment, including 0-5V/4-20mA analog signals output by sensors; switch signals; frequency signals; in addition, the system also has an RS-485 interface so that it can be connected to intelligent instruments with 485 interfaces on site. In order to achieve good human-computer interaction, the system has expanded modules such as keyboard input, LCD display, real-time clock, and field fault alarm indication circuit. The overall block diagram of the system is shown in Figure 1.

1.1 Power module circuit design

In the single-chip data acquisition system, the design of the power supply is very critical. This instrument design uses dual power supplies from the power grid and rechargeable batteries. The power supply design is shown in Figure 2.

When the grid voltage is normal, the 220V AC passes through the 24V voltage stabilizer, and the voltage after filtering by the electrolytic capacitor C1 is divided into two paths after passing through the diode D1. One path passes through the transistor Q1 to the 7805 three-terminal voltage stabilizer chip to complete the voltage stabilized output +5V voltage, which is the power supply required by the single-chip microcomputer W77E58 and other chips; the other path charges the nickel-cadmium battery 9V through the resistor R1, and the charging current is selected to be about 40mA. If the grid fails, C1 discharges to 0V. At this time, the battery supplies power to the circuit through D2, Q1 to 7805, so that the output end still has a +5V voltage, thereby completing the function of the single-chip microcomputer backup power supply when the grid fails for a short time.

Diode D1 acts as an isolation device, so that when the grid fails occasionally, it can prevent the battery current from flowing to the 24V regulated power supply. The function of the voltage regulator D3 (5.6V) is to prevent the battery (+9V) from over-discharging. That is, when the battery discharge drops to about 6V, due to the action of D3, the transistor Q1 is cut off, the battery discharge stops, and the microcontroller will be powered off.

1.2 Real-time clock chip DS12887

In order to display the system time in real time and save the collected data according to the time and date, the system has expanded a parallel real-time clock calendar chip DS12887. DS12887 is a real-time clock chip launched by DALLAS Semiconductor. It is made of CMOS technology and integrates the crystal oscillator and external lithium battery related circuits required by the clock chip into the chip. The DS12887 chip has the advantages of low power consumption, simple peripheral interface, high precision, stable and reliable operation, etc. It has a wide range of uses in modern industrial control and intelligent instruments.

1.3 Keyboard interface circuit

To facilitate human-computer interaction, a special keyboard interface chip 8279 is used, and in combination with a 74LS138 decoder, the system expands a keyboard of 3×8=24 keys. The keyboard is equipped with 0~9 numeric keys to input various information. There are also various control keys. The keyboard can control the collection of various types of data. To improve the efficiency of the CPU, the keyboard uses an interrupt mode.

1.4 LCD display module

In order to facilitate real-time display of collected data and human-computer interaction, the system has expanded the graphic LCD display module MGLS-12032. MGLS-12032 is an LCD module with built-in SED1520 control driver produced by Hong Kong Varitronix. It is simple and convenient to use. Hardware interface between LCD display module MGLS-12032 and W77E58

Among them, D0~D7 are connected to the data bus of the microcontroller, A0 and A1 are the lower two address lines generated by the P0 port of the microcontroller after passing through the 74LS373 address latch, and the system uses Y5 and Y6 generated by the 74LS138 decoder as the selection signals for the two control drivers of MGLS12032.

1.5 Analog signal acquisition circuit

The system uses 12-bit parallel A/D converter MAX197 to collect the 0-5v/4-20mA analog electrical signal output by the sensor. MAX197 is a multi-range (this system uses 0-5V range), 8-channel, 12-bit fast A/D converter launched by Maxim Corporation of the United States. It adopts successive approximation working mode. It contains high-precision reference voltage source and clock circuit on the chip, so that it can complete all A/D conversion functions without any external circuit and clock, and it is very convenient to use. In addition, MAX197 has an input tracking/sample-and-hold circuit inside, and its parallel output port is easy to connect to the microcontroller, and only a few capacitors are needed.

The typical interface circuit between MAX197 and MCU is shown in Figure 4. The design uses MAX197's CH0-CH6 channels to collect 7 0-5V voltage signals. The 4-20mA current signal is selected in turn by the 8-to-1 analog switch CD4051, and then converted into a 0-5V voltage signal by the sensitive resistor and amplifier, and then enters the CH7 channel of MAX197 for analog-to-digital conversion, so that the system can collect 8 current signals.

1.6 Switching quantity acquisition circuit design

The system uses an 8255 chip to expand the parallel port. The programming makes the A port of 8255 the input, which is used to collect 8-way switch signals. The B port is the output, which is used to output 8-way switch quantities. In order to enhance the anti-interference ability of the system, the switch quantity input/output channels are all photoelectrically isolated. The switch quantity acquisition circuit diagram is omitted.

1.7 Frequency signal measurement circuit design

This system uses the timer/counter 1 and 2 of the 8253 chip to count the number of pulses to be measured in two channels. The timer/counter 0 of the 8253 is used for timing. By utilizing the characteristic of W77E58 having multiple interrupt sources, an interrupt is generated when the timing ends. In the interrupt service program, the current count values ​​of the 8253 timer/counter 1 and 2 are read, and the frequency to be measured can be obtained by calculation.

The frequency signal measurement circuit is shown in Figure 5. D0-D7 is connected to the W77E58 data bus, the upper three bits of the MCU P2 port are decoded by the 138 decoder, and the Y0 is connected to the CS pin of 8253 to select the 8253 chip. The A0 and A1 of 8253 are directly connected to the lower two address lines, so the port address of 8253 is 1FFCH~1FFFH.

1.8 Serial Communication Design

Using the MAX485 chip, the enhanced serial port of the W77E58 microcontroller is used to expand the 485 interface so that it can be connected to the intelligent instrument with a 485 interface in the industrial field. The connection between the microcontroller and the MAX485 chip only requires a few external resistors, which is very simple and will not be described in detail here.

In order to make the designed data acquisition instrument easy to use, the system uses the PTR2000 wireless data transmission module to communicate with the host computer, so that it can respond to the data upload command of the PC in the control center at any time and upload the collected data to the control center in real time. PTR2000 is an ultra-small, low-power, high-speed wireless transceiver data transmission module. Its communication rate can reach up to 20Mbit/s, and it can also work at other rates, such as 4800bit/s and 9600bit/s. The schematic diagram of the system wireless data transmission is shown in Figure 6.

PTR2000 can be directly connected to the TXD and RXD of the microcontroller's serial port. The DO and DI pins of the PTR2000 wireless MODEM are connected to the RXD and TXD of the microcontroller's serial port respectively, so that the microcontroller can communicate serially with the wireless data transmission module. The PWR pin of PTR2000 is connected to the P1.0 pin of the microcontroller to manage the power supply of the wireless data transmission module, and TXEN is connected to the P1.1 pin of the microcontroller to control the transceiver state conversion of the PTR2000 wireless transceiver module. The host computer communicates with the microcontroller in real time through PTR2000. Since the host computer serial port usually uses RS-232 level, and the microcontroller serial port uses TTL level, the TTL level must be converted to RS-232 level when PTR2000 is connected to the host computer. The system uses MAXM's MAX232 chip for conversion. The host computer uses the RTS of the serial port to connect with the TXEN of PTR2000 to control the transceiver state conversion of the PTR2000 wireless transceiver module.

2 System Software Design

The system software adopts modular design. The main program first initializes each interface chip, then calls each subroutine module to enter each data acquisition subsystem, and stores the collected data in the 32K-byte serial E2PROM AT24C256 for query by the control center, and displays the corresponding data on the LCD. If the system receives a data upload command from the host computer, the data stored in the E2PROM will be sent to the PC through PTR2000. The main program flow of the system is shown in Figure 7.

The communication protocol between the two parties in the serial communication program is crucial, which is related to the reliability of wireless data transmission. The communication protocol format agreed by this system is as follows: the serial communication uses the internal timer/counter 1 of the microcontroller as the baud rate generator, and the baud rate of this system is set to 4800 bit/s; the frame format is 1 start bit, 8 data bits, 1 stop bit, and no parity check; the communication adopts interrupt mode; the host computer uses COM 1 communication. In the design, the data transmission channel also uses photoelectric isolation to improve the anti-interference ability of the system, and CRC check is used to ensure the accuracy of data transmission. When the microcontroller system is initialized, the P1.1 pin of the microcontroller is set to a low level, which makes the PTR2000 in the receiving state by default, so as to monitor the data upload command of the host computer at all times. After receiving the command from the host computer, the interrupt service program takes the data from the microcontroller data buffer and switches the module's receiving state to the transmitting state. The conversion process takes about 5ms, and then transmits the data in the form of FSK modulation. The PTR2000 module then returns to the receiving state. The data transmitted from the MCU system is received by PTR2000 in the host computer system, converted by the RS232 interface, and sent to the host computer. After the host computer analyzes and processes the data, it sends a confirmation data packet to the MCU system to confirm the correctness of the MCU system data packet. After the host computer receives the data, its PTR2000 module returns to the normal transmission state. If data is lost during the transmission process, the host computer will require the MCU system to resend the data until all the data is correct. The serial interrupt service program is shown in Figure 8.

3 Conclusion

This article uses an 8-bit single-chip microcomputer to design a universal data acquisition system, which can be used as a remote monitoring terminal for industrial sites, and can also be conveniently designed into a portable intelligent data acquisition and communication instrument. Since the data transmission adopts wireless method, it can be widely used in industrial occasions where data acquisition is required, and has a relatively high practical application value.

Keywords:W77E58 Reference address:Design of Universal Data Acquisition and Communication Instrument Based on Single Chip Microcomputer

Previous article:Three-phase power transmission and distribution power factor measurement and control system based on LPC2138
Next article:Design of brushless DC motor control system based on LPC2141

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号