On the basis of the USB interface data acquisition system design of ADuC841
Summary: This text propose one Fu set up leaf USB simple and easy to realize in data collecting system in the spectrometer. Keyword: USB; Microcontroller; Multiple channel; Data acquisition
The foreword will often meet the situation needing to input various analog signals in the computer observes and controls the system, must need to change A/D at this moment. In some actual projects sometimes, choose some dedicated data collecting cards in order to gather some analog quantity, not only make the system more complicated,but also not apt to realize the function is expanded, increases the systematic design cost yet. On the other hand, the USB interface is easy to operate more and more widely used, so the USB interface of the Apparatus is a development trend. XFT-1 type open Fu set up leaf, vary spectrometer, adopt classical the intersection of Michael and modest interferometer, the light intensity after interfering changes with movement of the index glass, the electro-optic recipient target transforms the mere strong signal of secular change that is received for the corresponding voltage signal. In order to remove because not even errors caused of the migration velocity of the index glass, adopt the double channel in the module, measure the reference light (He-Ne laser) at the same time And after examining the light source, utilize and consult photic information to correct the position error of optical measurement examined. In XFT-1 type open Fu sets up the leaf and varies the spectrometer, have adopted such simple and easy USB data collecting system that this text put forward. In view of the economic, practical factor, have adopted one-chip computer and common USB interface chip in the system, will both combine the data acquisition system design which will realize the USB interface. The epistasis PC has adopted C # language programming, the data real-time display that gets gathering, handling the analysis, data to keep and print.
The hardware, circuit design this, system regards ADuC841 of ADI Company as the core to realize data acquisition and control. This one-chip computer lasts single instruction cycle 20MIPS 8052 kernels and 8 passways of 420Ksps at a high speed, 12bit A/D converter, support online download. Control device and ADC have integrated and shortened development time, has improved the stability of the system. This text regards oozing the permanent USB interface chip CH375 in Nanjing as the core and realizes USB data transmission. The following characteristic: Compatible USB2.0; Shield the associated USB agreement under the built-in firmware mode, finish canonial USB and enumerate the configuration procedure automatically, do not need local end control device to do any treatment at all, has simplified the firmware programming of the one-chip computer; One grade of interface of provision of equipment of common Windows driver program, offer API to employ the layer interface through DLL. The interface circuit diagram of ADuC841 and CH375 is shown as in Fig. 1. Two kinds of data link connecting means that and run side by side that ADuC841 and CH375 are serial. Adopt the way of running side by side in the module in order to improve the speed, link P0 mouth of ADuC841 with parallel bus of CH375. Besides reading and writing signal connection, adopt A14 as the address bit. A14 =0,Show it is the data on the data bus; A14 =1,Order on representing the data bus. In USB transmission course, ADuC841 and CH375 touch off through external interruption, adopts INT0 external interruption pin of ADuC841 to connect with INT # pin of CH372 directly. CH375 exports as the low level in normal working hour ACT # pin, so add a luminescent diode and point out whether the USB interface chip is the normal operation between power and this pin. The luminescent diode one has killed and offered important information for debugging of the lower-position unit procedure bright.
The system software of systematic software design is by the lower-position unit procedure (firmware procedure) , USB systematic driver program and three parts of utility program form. Utilize USB agreement to transmit the machine format model and is shown as in Fig. 2. Data acquisition and data transmission subroutine that the software program of this system mainly includes language C wrote the one-chip computer, and the data real-time display which the epistasis PC written with C # gathers, handling analysis, data keeping and procedure of sealing. The firmware procedure of the program device of the lower-position unit is a core of the data collecting system, the lower-position unit procedure mainly utilizes KeilC51 to be written. In order to reduce the complexity and increase the maintainability of the procedure, the lower-position unit programming adopts and inquires about the way carried out again in order that the PC spreads over through the USB interface first. Presume the agreement in upper computer and lower-position unit communication, presume corresponding command word and check field in the agreement. The master command word has systems that finds whether it is normal and presuming sampling frequency, presuming that samples the point size, samples the enabling signal etc. or not. The intersection of lower-position unit and for scan the intersection of command word and variable constantly, see it effective main program. It is original to be monitored the command word and set invalid, after the upper computer sends out the new command word, the lower-position unit enters the interrupt subroutine to receive the command word, the command word sets effective. After the content that the lower-position unit scans the new command word, carry out corresponding operation, then will wait to monitor the command word to set invalid and continue waiting for the new command word. The function of the task of refinement of this kind of design, help to develop, debug and safeguard. The data acquisition subroutine runs after the main program receive and start the course command word of data acquisition. After the one-chip computer receives the command word that the upper computer sends through USB over, start the course of data acquisition. It utilize slices of inner timer set for, gather time interval, pay data acquisition with slices of inner ADC. In the interrupt subroutine while booking, the one-chip computer will gather the data of two passways, deposite them in the buffer in certain order, then check whether the buffer is full, if the buffer is discontented, the sub end of program of timer interrupt, otherwise send the data in the buffer to the upper computer through CH375, clear out the buffer, the sub end of program of timer interrupt. It is easy to develop a great advantage of USB driver program, this system. Nanjing oozed the permanent company to already offer the general USB driver program to user. Only need installation Off-The-Shelf USB to drive the erection procedure, it has offered a lot of interface functions for development of the utility program. Because mainly adopt and upload in batches and download the way in batches, mainly use CH375ReadData, functions such as CH375WriteData,etc.. This part does not need writer. The procedure upper computer procedure of the upper computer can adopt many kinds of software development tools, this system has written the utility program with C # language under Visual Studio2005 development environment. Mainly finish reading, revealing, keeping, opening and printing the work of data,etc.. It is the key part of the upper computer procedure that the data read the course. For in from under location machine-readable data fetch at influence by interface smoothness that be responded to, make use of multithread to realize the data to read in the programming. Data acquisition work finish in single sub thread, but main the intersection of thread and piece responsible for, finish mouse, keyboard response in user. In the sub thread of data acquisition, offer API to employ the layer interface to visit the buffer in USB driver program directly through DLL. After succeeding in turning on the apparatus, utilize CH375WriteData interface function to write the command word in the buffer, send the order to the one-chip computer; Utilize CH375ReadData interface function to read the data in the buffer, the data gathered. Under Visual Studio2005 development environment, it is relatively lower to write the difficulty of program development of the upper computer. It is ocular that the real-time display of data has increased course of data acquisition. The data gathered set up a software timer through GDI + drawing on PictureBox controlling part, paint the figure once through regular hour again while being every, because the time interval is less than 0.1s, it is a curve of continuous change visually. Machine format save and it opens functions to be to utilize StreamWriters and StreamReader completion of C in the # mainly. Print data and figure and mainly use PrintDocuments, after transferring Print method, characters and graphic output that will need printing in PrintDocument_PrintPage incident or painting again and can be printed.
The simple connection which utilizes one-chip computer and USB interface chip is the getting extendible data acquisition module of a USB interface to conclude the speech, need, expand data storage outside, meanwhile, still very abundant acquisition system this peripheral hardware and the intersection of I/O and resource carry on expansion functionally on the abundant slice with ADuC841. In XFT-1 type open Fu sets up the leaf and varies the spectrometer system, have utilized ADuC841 to pass the synchronous electric machine control Michael modest interferometer index glass seat. Through testing, the precision great of sampled data of this system, the transmission rate is very fast, the characteristic is steady, after through linking with PC, not merely make the memory capacity of the data great, and apt to carry on data processing, economy simple, set up leaf vary spectrometer characteristic steady in the system in XFT-1 open Fu.
Bibliographical reference: 1. http://www.analog.com/UploadedFiles/Data_Sheets/ 247905996157419352262670829ADuC841_2_3_0.pdf2. Universal Serial Bus Specification Reversion 1.1. www.usb.org, 19983. http://winchiphead.com/download/CH372/CH372DS1.PDF4. http://winchiphead.com/download/CH372/CH372DS2.PDF