In some special industrial occasions, it is sometimes necessary to continuously collect and store sensor signals in real time, and then play the data back to the PC for analysis and processing after a certain period of time. In the case of harsh working environment, the solution of using high-performance microcontrollers and industrial-grade large-capacity FLASH memory is probably the most appropriate choice. CYGNAL's C8051F320 SOC is a high-performance microcontroller with an 8051 core, and its operating speed is 12 times that of ordinary 8051.
This article presents a data acquisition and storage circuit for monitoring the operation status of a large photovoltaic system . Since it is made using surface mount technology, the width of the entire circuit board is only 18 mm, which is as convenient as using a USB flash drive.
Acquisition circuit hardware part
Circuit hardware structure
This system uses CYGNAL's C8051F320 chip and ATMEL's AT45DB321C memory chip as the main control and storage chips. Figure 1 is the acquisition and storage system block diagram of the signal acquisition system.
Figure 1 Block diagram of USB-based data acquisition and storage system
As can be seen from Figure 1, during the acquisition process, the sensor's input analog signal is amplified by a variable gain amplifier and sent to the C8051F320, where it is converted into a digital signal by the ADC. There are eight 45DB321C chips outside the microcontroller to form a 32MB Data flash memory. The collected data is continuously transmitted to the 45DB321C chip through the SPI interface for storage.
Compared with other chip models, C8051F320 has a USB interface. The USB function control module in the chip complies with the USB2.0 specification, can run at full speed or low speed, and has a 1KB USB cache, integrated transceiver, and no external resistors are required. It can be plug-and-play with a PC. When data is needed, the acquisition storage circuit can be retrieved from the site and played back to the PC through the USB interface, and waveform display and data analysis and processing can be performed on the LabVEIW platform.
Hardware interface between 8051F320 and 45DB321C
In the system, C8051F320 and 45DB321CI use SPI single master and multiple slaves to communicate. Pin NSS is used as the slave select line to select the memory chip, and low level is effective; SCK is used as the synchronous clock signal for the serial peripheral interface to send and receive data; RDY/BUZ is used as the signal line to determine whether the device is not busy or ready to receive new instructions; SO and SI are used as data transmission lines.
This system design considers using 8 45DB321C chips, with a maximum capacity of 32MB, and connects to the CS end of each 45DB321C through chip selects CS1~CS8. The clock SCK is only valid for the selected 45DB321. In addition to providing sufficient storage space, the design of this system using multiple Flash chips also solves a key problem, that is, drawing on the idea of RAID technology in the hard disk field, a basic parallel acceleration is achieved by sequentially operating a group of 4 Flash chips, solving the problem of slow Flash write speed and greatly improving storage performance.
The specific circuit is shown in Figure 2, where the SPI of the eight memories is cascaded and only one is drawn, and their respective CS chip select signals are decoded by 74HC138.
Figure 2 Interface circuit between MCU and FLASH memory
Acquisition circuit program software
The program of the acquisition circuit refers to the program solidified in C8051F320, which is written in C language and consists of four parts: main program module, ADC data acquisition, Flash data storage and USB communication.
Main program and ADC data acquisition
The main program mainly completes system initialization status indication operation control and parameter setting, starts A/D conversion, etc.
The ADC data acquisition program converts the analog signal from the sensor into a digital signal. In this system, the ADC conversion is triggered by the automatic overflow of Timer2, and the acquisition rate can be set in advance by the host computer. [page]
Flash Data Storage Program
The communication between the C8051F320 chip and the Flash memory uses the SPI interface, and the data transmission rate is 12MHz (bit/second). In this design, the C8051F320 works in the SPI master mode, and the data transmission of the SPI bus will be initiated by the C8051F320. First, configure the SPI-related SFR SPI0CFG register and SPI0CN register to make it work in the 3-wire master mode 12MHz. When communicating, first use the GPIO pin to select the corresponding Flash slave device, and then read the SPIDAT to perform read and write operations. When using the Flash chip for read and write operations, you must first determine the status of the Flash memory. You can write the D7H command and read the status register to determine whether the device is Ready or in Bus
After the status is determined, the relevant read, write and erase operations can be performed according to the command format in the data sheet.
USB Communication Program
Firmware programming is the main work in the USB device development process. The main task of the firmware is to initialize the microcontroller and peripherals, send USB requests, and respond to the host's standard device requests. Complete various data exchange requests according to the functional classification of the device. Initialization programming mainly completes the initialization of the USB controller, endpoint initialization, cross switch and I/O port initialization, system clock setting, and controller enablement. After initialization, the USB device can be inserted into the host at any time, and the host will follow the USB protocol to identify and initialize the device. After the host recognizes the device, it configures the device, calls the corresponding driver, and performs related communication operations with the host computer software.
Silicon lab provides a USBXpress development kit. By using the USBXpress library, the development of USB firmware programs and PC-side drivers is greatly simplified. USBXpress implements the application program interface (API) on the microcontroller side through a series of functions. These functions encapsulate the details of the USB protocol, so that program developers do not need to understand too many details of USB to use USB for data communication (see Figure 3).
Figure 3 USB communication between MCU and PC
This system mainly uses the four functions of initialization, reading, writing and interruption:
Initialization function USB_Init(0,0xEA61,NULL,NULL,Serial,250,0x80,0x100); block write function Block_Write(); block read function Block_Read(); USB interrupt enable function.
All USB processing procedures are completed through the USB interrupt service program. After entering the USB interrupt, the program calls the Get_Interrupt_Source() function to obtain the entry reason of the USB interrupt. Then, according to different entry conditions, corresponding processing is performed. For example, after receiving data, the corresponding buffer content is read into the memory; when receiving the initialization command, the various state parameters in the microcontroller are reset. The USB communication flow chart is shown in Figure 4.
Figure 4 USB communication flow chart
PC software program
The computer-side software program consists of two parts: USB driver and user application.
USB Drivers
A USB driver is a software component that encapsulates the functions of an application program to access a hardware device. Some devices have the same properties, and by grouping them into a set of standard categories, a device class specification can be defined as the host driver framework for this type of device. Device class drivers use similar functions to handle communications between different devices, so that the development of device class drivers can be independent of device manufacturers.
The USB driver model is generally divided into five layers (see Figure 5).
Figure 5 USB driver model
If the client wants to read data from the device, it will call an application program interface API, such as OpenFile, which is implemented by SiUSBXp.dll. The bus driver controls access to all devices on the bus.
In this system, the tool used to develop the USB device driver is USBXpress Development Kit. The main functions are as follows:
S
I_Open() function; SI_Close() function; SI_Read function; SI_Write() function; SI_GetNumDevices() function; SI_CheckRXQueue() function. [page]
User Application
In this system, the application is written in NI's LabVIEW software, and the graphical C language is used for software development to achieve data display, analysis functions that meet different needs, and parameter settings for data acquisition hardware (see Figure 6).
Figure 6 Playback data waveform display interface
Conclusion
The acquisition and storage circuit based on the C8051F320 USB interface closely combines computer technology with traditional signal acquisition technology, giving full play to the advantages of PC and single-chip microcomputer to realize the acquisition, storage, display and processing of sensor signals. With the communication function of the USB interface, the complexity of the data transmission system is reduced.
Previous article:Design of Oscilloscope Monitoring Program Based on C8051F020
Next article:Design of portable multifunctional medical examination meter based on MXT8051
Recommended ReadingLatest update time:2024-11-16 16:00
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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