Design and application of data acquisition system based on μC/OS-Ⅱ

Publisher:心灵清澈Latest update time:2011-08-10 Keywords:μCOS-Ⅱ Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

With the continuous development of science and technology, people have higher and higher requirements for the performance indicators of data acquisition, and traditional data acquisition methods can no longer meet the needs. Universal Serial Bus (USB) has the advantages of fast transmission speed, plug and play, easy expansion, and less system resource occupation; ?C/OS-Ⅱ in embedded real-time operating system (RTOS) has the characteristics of high code efficiency, small space occupation, good real-time performance and reliability. This paper combines the two with traditional data acquisition technology, and designs and implements a data acquisition system based on USB communication and ?C/OS-Ⅱ that integrates data acquisition, analysis, and display.

2 System Architecture

The architecture of the data acquisition system based on USB communication is shown in Figure 1. The working process of the system is a data acquisition process, and each step requires the support of different groups. First, the temperature and pressure parameters are converted into analog signals by the sensor, and the analog signals are converted into digital signals that can be recognized by the microcontroller through A/D conversion. After the microcontroller processes the digital signal, it can be sent to the LED display or to the USB interface chip. When the host needs it, the USB interface chip sends the received data to the host through the USB for processing and display. The communication between the host and the USB interface requires the support of the device firmware program, the USB device driver and the USB host application.

3 Hardware Circuit Design of USB Data Acquisition System

The hardware circuit structure of the USB data acquisition system mainly includes the following parts: USB communication circuit part, data acquisition circuit part, digital display circuit part and firmware program download circuit part. The functions of these modules are all realized on the hardware platform with ATmega16 as the core.

3.1 Design of USB communication circuit

The function of the USB communication circuit is to realize the communication between the device side and the host side of the data acquisition system. This function is mainly realized by the core microcontroller ATmega16 and the USB control device PDIUSBD12. Among them, PDIUSBD12 is a chip that complies with the USB1.1 protocol and plays the role of a bridge between the device and the host in the USB communication circuit. The microcontroller ATmegal6 and the USB controller PDIUSBD12 communicate through an 8-bit parallel bus. The 8-bit parallel bus needs to connect 8 I/O ports at the ATmegal6 end. The PDIUSBD12 chip integrates a clock multiplication PLL, and the crystal oscillator circuit uses a 6MHZ crystal oscillator and two 2pF to 68pF capacitors. The signal output terminals D+/D-1 of the PDIUSBD12 should each be connected in series with an 18-ohm matching resistor. The communication circuit is shown in Figure 2.

3.2 Design of data acquisition circuit The function of data acquisition circuit is to convert the temperature, pressure and stress data in the field into appropriate analog signals, and then transmit the analog signals to A/D conversion circuit. This module includes temperature acquisition module and pressure acquisition module. [page]

Since the ATmegal6 chip integrates an adjustable gain differential amplifier circuit and an A/D conversion channel, the temperature acquisition circuit consists of only one bridge for temperature measurement. The specific method is to use the copper thermal resistor as one arm of the bridge according to the characteristic that the resistance value of the thermal resistor changes with temperature. When the temperature changes, the output voltage of the bridge also changes accordingly. The output voltage of the bridge is sent to the sampling and holding circuit inside the ATmegal6, and then amplified and A/D converted, and then the measured temperature can be obtained after conversion by the firmware program.
In this system, the device used to measure pressure is a pressure transmitter produced by Guangzhou Senax Instrument Co., Ltd., with a range of 0.0lMPa and an output signal of 4~20mA current. When the pressure changes, the output current also changes accordingly, so a precision resistor is connected to the signal output end, and then the voltage across the resistor is sampled and converted, and then the measured pressure can be obtained after conversion by the firmware program.

3.3 Firmware download circuit

The function of the firmware program download circuit is to download the compiled program code to the Flash of the ATmegal6 microcontroller. ATmega16 supports multiple programming modes, among which the simpler and more convenient one is the ISP (In-system-programming) mode, which is to download the compiled program code debugged in Windows to the memory of ATmegal6 through the serial SPI (serial peripheral interface) bus. Flash program memory, EEPROM data memory, fuse bits and encryption lock bits can all be programmed in this mode. The firmware program download circuit is shown in Figure 3.

3.4 LED display design

As shown in Figure 4, the system display is an 8-bit stable static display implemented by MAX7219. MAX7219 is a serial common cathode digital tube dynamic scanning display driver chip. It only uses a 3-wire serial interface to transmit data and can be directly interfaced with the microcontroller. Users can also easily modify its internal parameters to achieve multi-digit LED display. Therefore, the serial port of the microcontroller can be used to send display data conveniently. It takes less time and is convenient for programming and signal detection.

4 Software Development of USB Data Acquisition System

The USB data acquisition system is a multi-tasking system, and the program structure is relatively complex. In order to improve the development rate, enhance the stability of the system, and reduce the development and maintenance costs, an embedded operating system is needed as a platform for system development and operation. ?C/OS-Ⅱ is a free embedded real-time operating system with open source code. It has good stability and high reliability. ?C/OS-Ⅱ also has the characteristics of good portability, curability, and tailorability, making it very suitable as a development platform for USB data acquisition systems.

[page]

The software of the USB data acquisition system consists of three parts: the USB device firmware program, the USB device driver on the host PC, and the client application on the host. The composition of the system software and the relationship between the parts are shown in Figure 5.

The firmware program can be divided into USB communication program, A/D conversion program and LED display program according to its function. The USB communication program is the main part of the entire firmware program, and its function is to realize USB device enumeration and data transmission. USB device enumeration is the process of exchanging information and automatically configuring the host and device after the USB device is plugged in. After the enumeration is successful, the USB interface can communicate with the host.

The device driver is the link between the device and the host application. It provides the application access interface (API) upward and implements the access and management functions of specific devices downward. The driver is closely related to the device hardware and the upper user program, and plays the role of an intermediary for information conversion and transmission in the middle of the USB system. When developing USB devices, the design of the device driver is a very important link, which directly affects the performance of the entire device system.

This system uses Driverworks to develop a WDM USB device driver. The main functions of the application are to find the device in the device driver, exchange data with the device, and process and display the data sent by the device. The communication between the application and the driver is achieved by accessing the application program interface (API) function, so the application must be developed on a platform that can access the API function. Visual C++ 6.0 provided by Microsoft is a powerful programming tool that supports API functions. The host application of this design is developed based on VC. Its main functions include finding USB devices, exchanging data with USB devices, and dynamically displaying data curves.

5 Conclusion

The innovation of this paper lies in the data acquisition system based on USB interface and ?C/OS-Ⅱ, with a sampling frequency of up to 15KSPS (samples per second), a data transmission error recovery rate of more than 99%, plug-and-play, easy to use and with very low development cost, which can provide an effective solution and a convenient and efficient transmission device form for data acquisition, especially battery-powered mobile or handheld acquisition devices; secondly, Microsoft's recent WDM driver model is introduced on the PC side, and a device driver for the data acquisition system is developed on its basis, which can successfully identify and configure the device, and provides an application interface for exchanging data with the device. Based on these interfaces, a PC-side application with functions such as querying the device, exchanging data with the device and drawing the data into dynamic curves is compiled.

Keywords:μCOS-Ⅱ Reference address:Design and application of data acquisition system based on μC/OS-Ⅱ

Previous article:Research and design of automatic detection device for ground potential in substation
Next article:High-performance test system architecture for aerospace measurement and control based on ATCA

Latest Test Measurement 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号