Development and implementation of virtual oscilloscope based on USB interface

Publisher:静心静气Latest update time:2016-11-23 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Overall system design  


The USB specification divides USB into five parts: controller, controller driver, USB chip driver, USB device, and client driver for different USB devices. According to the different requirements of the device for system resources, the USB specification stipulates four different data transmission methods: isochronous transmission method (isochronous), interrupt transmission method (interrupt), control transmission method (control) and batch (bulk) transmission method. These transmission methods have their own characteristics and are used in different places. USB requires support from three aspects: host hardware, operating system and peripherals to work. At present, motherboards generally use control chipsets that support USB functions, and also install USB interface sockets. According to the USB specification, the design of the entire virtual oscilloscope system is divided into the host software part and the external hardware part (see Figure 1). Click to browse the next page

The development of this virtual oscilloscope integrates the functions of three practical instruments.

(1) Dual-channel broadband oscilloscope functions: real-time waveform display and calculation, waveform storage and printing, spectrum analysis, etc.

(2) Digital/needle dual display high-precision multimeter functions: voltage measurement, current measurement, resistance measurement, etc.

(3) High-precision customizable signal generator function: triangle wave generation, sine wave generation, square wave generation, custom waveform generation, etc. 


2 System plug-in hardware design 


The system plug-in hardware design structure is shown in Figure 2.


The plug-in hardware of this system uses Philips' PDIUSBD12 full-speed USB interface chip to form the USB interface unit. For detailed information on the PDIUSBD12 chip, please visit Philips' website www.philips.com. The analog-to-digital conversion chip uses MAX's latest AD chip MAX108. The control unit uses the AT908515 microcontroller as a controller to control the coordinated work of the entire hardware part. The two channels of measured signals can enter the dual-channel AD unit at the same time. The digital signals after analog-to-digital conversion pass through the signal preprocessing unit, which performs preliminary processing on the signals and converts the signals into a data form that is easy to store. After that, the data is sent to the cache and waits for the USB interface unit to gradually input the host. The path of the system output signal is opposite, and finally it is converted by the DA unit into an analog signal defined by the user. The control unit controls the start and stop of AD and DA conversion, the processing actions of the signal preprocessing unit, the access of the cache, and assists the input and output of the USB interface unit. 


3 USB driver design  


This USB driver uses isochronous pipes to transfer data and control pipes to transfer instructions and information. Isochronous pipes can be used to achieve regular time-sensitive data exchange between the host and the device. The bus driver will use 90% of the bus bandwidth for isochronous and interrupt transmission.  


To open a USB pipe, you must first know the GUID and pipe name of the USB device. After obtaining the handle, you can use ReadFile/WriteFile to read and write.  


The USB driver complies with WDM (Windows Driver Model). This driver is developed using Microsoft's DDK2000 and uses Windows 2000 as the platform. Due to space limitations, only the design of the USB driver main entry routine is provided here. 

The main entry routine of a WDM driver is the DriverEntry routine, which is called by the I/O manager. For the DriverEntry routine of this WDM driver, its main task is to fill in various function pointers into the driver object. These pointers indicate the location of various subroutines in the driver library to the operating system. They include the following pointer members (in the driver object):  

(1) DriverUnload points to the driver's cleanup routine. The I/O manager calls this routine before unloading the driver.  

(2) DriverExtension→AddDevice points to the driver's AddDevice function. The PnP manager will call the AddDevice routine once for each hardware instance.  

(3) DriverStartIo The driver uses the standard IRP (interrupt request package) queue.  

(4) The MajorFunction driver may need to process several types of IRPs, so the pointer elements corresponding to those IRP types should be set to point to the corresponding dispatch functions. According to the actual requirements of the virtual instrument system, the main function IRPs to be processed by this driver are: IRP-MJ-CREATE; IRP-MJ-CLOSE; IRP-MJ-DEVICE-CONTR; IRP-MJ-WRITE; IRP-MJ-READ; IRP-MJ-SYSTEM-CONTROL; IRP-MJ-PNP; IRP-MJ-POWER.  


In the main entry routine, you must set the pointer elements corresponding to these IRP types so that they point to the corresponding dispatch functions. 


4 Customer Service Software Design 

The entire customer service software is written using VC++ and is designed into the following main modules.


4.1 Communication module between driver layer and application layer  


If the communication function block is implemented directly in the main thread of the application, then when the application communicates data with the driver, the main interface will freeze. To solve this problem, we directly create a child thread to complete the communication task with the driver alone, allowing the main interface to focus on responding to the messages of the window interface. In the child thread, the IO operation of the USB device is implemented by calling the Windows API function. Among them, the DeviceIoControl() function is used to transmit device configuration information; CreateFile() is used to create a device object; WriteFile() and ReadFile() are used to read and write data to the USB device.


4.2 Control Panel Module  


On the customer service interface, we created six main control function buttons: RUN, STOP, SINGLE, spectrum analysis, LOAD and SAVE to realize its main control functions. This part of the design system completes the control functions such as start, stop, single step, store and load data files.


4.3 Real-time waveform display module  


The display window is customized according to user habits, and the waveform is displayed, refreshed and certain operations are performed on the waveform according to the specified parameters of the control panel.


4.4 FFT module  


The spectrum analysis is performed using Fast Fourier Transform (FFT). The spectrum analysis in this software uses the time-decimated FFT algorithm, and then the amplitude spectrum analysis and phase spectrum analysis results are displayed in the form of coordinate curves on the user interface. 4.5 Other modules  


It includes waveform storage, printing, playback, digital/needle dual display high-precision multimeter and high-precision customizable signal generator function modules. 


5 Conclusion  


With the introduction of USB2.0 standard, the application scope of USB is getting wider and wider, and it has involved almost all computer peripherals. The characteristics of USB provide new ideas for solving some problems of current virtual instruments. This paper is an exploratory study on introducing USB interface into virtual instruments and instrument systems.

Reference address:Development and implementation of virtual oscilloscope based on USB interface

Previous article:Two ways to measure voltage with an oscilloscope
Next article:How an oscilloscope captures and reproduces transient signals

Latest Test Measurement Articles
Change More Related Popular Components
Guess you like

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号