1 Introduction
The stability of the operating state of electronic equipment directly affects the production of modern enterprises. The high maintenance costs after equipment failure and the losses caused to enterprise production after equipment downtime have led various enterprises to take measures to reduce the failure rate of equipment. Through the data acquisition system, the equipment operation characteristic data is accurately obtained, and the data is analyzed to determine whether the equipment is in good condition, so as to prevent failures in advance and reduce downtime for maintenance. In practical applications, the reliability, accuracy and portability of the data acquisition system are very high. Currently, the commonly used data transmission networks (such as RS232/RS485, CAN, etc.) can no longer meet the requirements of large-scale data collection and high-speed real-time data transmission. USB transmission has the advantages of high-speed and reliable transmission, low cost, high reliability and easy maintenance. This paper takes C8051F340 with on-chip USB and high-speed AD converter as the core control device, and uses the high-speed transmission characteristics of the USB bus to design a high-speed and low-cost data acquisition system. The acquisition signals include 14 parameters such as the temperature, pressure and flow rate of the output gas of the equipment, which is suitable for data acquisition of the operating state of specific equipment.
2 System Design
The system design diagram is shown in Figure 1. The system is mainly composed of the C8051F340 data acquisition module and the host PC. The data to be monitored is converted by the sensor at the front end of the system and sent to the preprocessing circuit. The data output from the preprocessing circuit is sent to the AD conversion port through the I/O port. After AD conversion, the data is saved to the C8051F340 microcontroller, and finally the data is sent to the host PC through USB for storage and processing.
Figure 1 System Design Block Diagram
3 Hardware Design
In the entire hardware design, the C8051F340 microcontroller is an important part of the system. The C8051F340 microcontroller is a fully integrated mixed-signal system-on-chip MCU launched by Silicon Laboratories. 8051 compatible microcontroller core with high speed and pipeline structure (up to 48M IPS); Universal Serial Bus (USB) function controller with 8 flexible endpoint pipelines, integrated transceiver and 1K FIFO RAM; true 10-bit 200ksps single-ended/differential ADC with analog multiplexer; on-chip voltage reference and temperature sensor; accurately calibrated 12MHz internal oscillator and 4 times clock multiplier; up to 64KB on-chip FLASH memory; up to 4352 bytes on-chip RAM (256+4KB); up to 40 port I/O (5V input allowed) circuit design of acquisition system.
Due to the characteristics of C8051F340 itself integrating many hardware circuits, the hardware interface design becomes very simple, and no additional electronic components are needed to realize USB data transmission and AD conversion, etc., making the system hardware structure simple, highly integrated and reliable. As shown in Figure 2, the MCU is connected to the host PC through the on-chip USB interface for data transmission. The P2.0~P2.6 pins on the C8051F340 are used as the input port of data acquisition, receiving data from the preprocessing circuit, and finally determining the channel for AD conversion through the analog multiplexer (AMUX) of the MCU.
Figure 2 Data acquisition hardware schematic.
4 Software Design
The software part of the system includes the MCU firmware and the host PC client program. The MCU firmware is mainly responsible for the initialization of the MCU and the communication preparation with the host computer, while the client program is responsible for calling the corresponding control in the firmware to realize data transmission control, data storage and fault warning.
4.1 MCU firmware (firmware)
The MCU firmware is written using Keil uVision3 software and consists of three modules: main program, AD data conversion, and USB communication.
The main program is responsible for initializing the ports and functional modules of the microcontroller, setting the corresponding IO ports as data input ports, and entering the USB interrupt service through the void USB_API_TEST_ISR (void) function after completing the initialization. In the interrupt service, the USB interrupt source is obtained by calling the Get_Interrupt_Source() function. Then, according to different entry conditions, corresponding processing is performed. For example, when receiving the initialization command, the various state parameters in the microcontroller are reset.
The AD data conversion module is mainly responsible for the setting of the conversion time interval and sampling accuracy during AD conversion. The AD conversion start of the C8051F340 microcontroller has 6 triggering modes, and the state of the ADC0 conversion start mode bit (AD0CM2..0) in ADC0CN determines which mode is used. This system triggers AD conversion through each timer overflow of timer 2 in the microcontroller. In order to ensure that the previous data conversion is completely completed when the timer triggers AD conversion each time, the time interval (Tcont) from the overflow of timer 2 to the next timer overflow must be greater than the AD conversion time to ensure the completeness of each AD conversion. The AD conversion time consists of the settling time (Tsettle) and the sampling time (Tsample). Figure 3 shows the input circuit of the equivalent AD conversion in differential mode. For a system with a given settling accuracy (SA), the required ADC settling time (Tsettle) can be determined by equation 1. The sampling time (Tsample) requires 10 SAR clocks by consulting the technical manual. Tcont must satisfy equations (2) and (3) to meet the design requirements.
Figure 3 AD conversion equivalent input circuit.
Where: SA is the settling accuracy, expressed as a fraction of an LSB (for example, a settling accuracy of 0.25 corresponds to 1/4LSB); t is the required settling time (Tsettle), in seconds; n is the resolution of the ADC, expressed in bits. Rtotal is the sum of the AMUX resistance and the external signal source resistance; Csample is the ADC sampling capacitor:
Where: K is the count value reloaded after timer 2 overflows; clk is the system clock frequency.
The USB communication module sets the data transmission mode between the microcontroller and the host. According to the USB communication protocol requirements, the corresponding registers are set to configure endpoints 0 and 2 in the USB to communicate with the host. Endpoint 0 is responsible for receiving and responding to the control commands of the host, and endpoint 2 is responsible for transmitting the collected data to the host. At the same time, the 256-byte space used by endpoint 2 in the FIFO allocation of USB SB0 is configured for data output. Since C8051F340 integrates a 10-bit ADC controller, the collected data is filled with 16-bit data, and the data is saved in the system RAM with the lower 8 bits first and the higher 8 bits later. One AD conversion can get 2 bytes of data. Therefore, in order to make full use of the space used by endpoint 2 each time data is uploaded, a variable i is added to the ADC interrupt response function to detect the number of conversions. After 128 AD conversions, the Block_Write() function is called to send data to the host. Part of the code is as follows:
4.2 Host PC client program
The host PC client program includes two parts: USB driver and user application.
The USB driver is a software component that encapsulates the functions of the application to access the hardware device. Some devices have the same properties. By grouping them into a set of standard categories, the device class specification can be defined as the host driver framework for this type of device. The device class driver uses similar functions to handle the communication between different devices, so that the development of the device class driver can be independent of the device manufacturer. The driver of this system uses the USB Xpress development kit provided by Silicon Laboratories, developed in the Visual C++ 6.0 environment, and encapsulated in the form of a dynamic link library DLL for user application calls.
The user application is written in C++ and consists of four modules: customer interaction interface, USB data communication, data storage and display, and device fault warning. In the design of USB data communication module, the API functions such as SI_GetNumDevices, SI_GetProductString (), SI_Open (), SI_Close (), SI_Read (), SI_Write () provided by Silicon Laboratories are used to shield the complex USB communication protocol in the underlying hardware operation, simplify the USB communication development, and make it easier to develop USB communication programs. The
program flow chart is shown in Figure 4.
Figure 4 Client application flow chart.
There are many reasons for equipment failure. In order to ensure the normal operation of the equipment, it is necessary to detect multiple data. This system mainly detects the temperature and pressure data of the equipment. Once the data obtained exceeds a certain limit, it means that the equipment may fail. Therefore, in order to ensure the long-term stable operation of the equipment, it is necessary to compare the real-time data obtained with the pre-set critical value. Once the critical value is exceeded, the system will issue an alarm to remind the staff to troubleshoot the equipment, which has the effect of fault warning.
5 Conclusion
There are many options for USB data acquisition systems. This design considers portability and high-speed transmission, and writes firmware and client data transmission protocols, making the data acquisition system easy to carry, with high-speed and accurate data transmission, a good human-computer interaction interface, and the ability to warn of certain equipment failures, which has great use value. Moreover, the microcontroller port resources have not been used up, and there is still room for development and expansion.
Previous article:RL512G signal amplifier circuit
Next article:BF51x sets a new benchmark for cost-effectiveness of digital signal processors
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Technical applications of crystal oscillators and intelligent robots during the epidemic
- EEWORLD University ---- Gizwits ECE Getting Started Tutorial
- Regarding the problem of operating a single bit in a register
- Field effect tube constant current source heat
- How to choose and use 2.4G antenna applications?
- Automotive Power Electronics and Motor Drives Handbook
- [NXP Rapid IoT Review] + Finally climbed out of the pit (Second week review summary)
- National Undergraduate Electronic Design Competition Module Design Series (II)
- allegro16.6 Questions about via opening and via cover oil?
- MSP430 interrupt mechanism