Developing a Labview and MATLAB-Based Test Bed for Data Acquisition, Analysis and Calibration of Frequency Generators Over GPIB
Total Page:16
File Type:pdf, Size:1020Kb
International Journal of Computer Applications (0975 – 8887) Volume 40– No.16, February 2012 Developing a LabVIEW and MATLAB-based Test Bed for Data Acquisition, Analysis and Calibration of Frequency Generators over GPIB Shehryar Humayun Maria Mehmood Faran Mahmood Institute of Space Technology, Institute of Space Technology, Institute of Space Technology, Islamabad Islamabad Islamabad ABSTRACT environment to be employed in the other. Such as, a code written in MATLAB can exploit inherit parallel execution of This paper focuses on methods of interfacingLabVIEW with Genvironment. This paper deals with one such case where the MATLAB package for applicationswhichneed extensive calibration of a signal generator is analyzed by combing the computation as well as automation and control. It aims to two packages via three different approaches. integrate MATLAB and LabVIEW together,and develop a calibration software for frequency generators supporting the IEEE-488 bus standard. Different approaches have been 2. LITERATURE SURVEY explored that can be used to combine the data acquisition In [2], [3], [4], the author has demonstrated the use of features of LabVIEWand computational power of Mathscript RT module to deploy MATLAB source files on NI MATLABin presenting the results. platforms. In [5], the author proposed solutions of using LabView for real-time control with MATLAB engine running General Terms at the back end. GPIB is discussed in detail in [6], where the GPIB bus protocol, calibration author advocates the use of GPIB interface as a preferred choice for instrumentation control. Keywords LabVIEW, MATLAB, GPIB 3. IMPLEMENTATION 1. INTRODUCTION A wide variety of protocols are availableto connect and LabVIEW (Laboratory Virtual Instrumentation Engineering communicate with different laboratory instruments present. Workbench) is based on a dataflow programming language These protocols range from simple serial communication to while MATLAB (Matrix Laboratory) isa fourth-generation GPIB, USB, and Ethernet etc. LabVIEW provides the programming language for performing numerical and simplest solutionfor communicating with any of these computational tasks. protocols. MATLAB has been traditionally used as anaccepted platform for mathematical manipulation of data. In LabVIEW‟s dataflow programming is graphical in nature and this paper we are discussing one of the possible options for is often referred as „G‟. The routines made with this G using LabVIEW for communication purposes. Data is language are called VIs (Virtual Instruments). The acquired through GPIB protocol. Once data is acquired, we programming interface is based on a “Front Panel”, the part will use the powerful mathematical features of MATLAB for which serves as user interface and “Block Diagram”, the part handling that data. where various components are joined in a graphical manner to The procedure followedin the paperis that first the data is form astructure. Front Panel takes input and gives output. acquired from the instrument under test and then it is There is also another important feature called as “Connector correlatedwith software generated waveforms to find offset Panel”. It is used for calling one VI in block diagram of errors. LabVIEW interface is used for acquisition of data from another VI. the Agilent Oscilloscope via GPIB interface. Due to the high The initial focus of LabVIEW was towards measurement, computation power available, the waveform is generated automation and control but with time it incorporated more internally with the help of MATLAB at a high sampling rate. features, transforming it into a full-fledged software This waveform is importedin LabVIEW with the help of three developing environment. The key advantage of using G is its different techniques. These techniques are implemented to be capability of parallel execution [1]. used for the same purpose and then compared to conclude MATLAB is often referred as 4GL (fourth generation which approach is the best. Language) as it was developed for a specific purpose, which was obviously matrix operations involving rigorous numerical tasks, which if performed by simple languages like C, C++ 4. THE SYSTEM etc. can be exhaustive for both the programmer and the 4.1 Signal Generator computer. The MATLAB was intended originally for complex Signal generator is used as input. We used a number of matrix computations. It also kept on integrating different different generators to ensure proper readings. For example: features toease various engineering disciplines. For example, addition of Simulink was a major step towards graphical 1.Aeroflex Signal GeneratorFrequency Range: 10 kHz-550 modeling in MATLAB. MHz, Resolution: 10 Hz; Digital Readout , Switching Time: Using LabVIEW or MATLAB for any specific function 200 ms. depends on the programmer‟s comfort with the software. But there are occasions when we require a routine written in one 11 International Journal of Computer Applications (0975 – 8887) Volume 40– No.16, February 2012 2. Instek GFG-8210 Function Generator: The Instek generator 4.4 Data Acquisition has a range of 0-10MHz. It can produce ramp, sine and square Once the GPIB connection was established through waveforms. LabVIEW, the data was acquired and stored in a text file. For acquisition and storage of data, a small code was developed in 4.2 Oscilloscope LabVIEW. The signal generated isthen retrievedbyan oscilloscope. The 4.5 Processing in MATLAB reason for using oscilloscope was the lack of any GPIB/serial After receivingthe sampled data, we processed them on port with the available signal generators. Otherwise the signal MATLAB. MATLAB was used for data processing because could have been directly acquired fromsignal generator. of its ease at mathematical and numerical operations. Infiniium 54855A oscilloscope by Agilent was used for this purpose. This particular model provided an added advantage 5. CATERING FOR OTHER FACTORS of selecting a variable sampling rate. To make sure that the error obtained was not due to any 4.3 Communication Interface source other than calibration difference, the sampling rate, Both serial and GPIB interfaces areavailable to use in the frequency and phase offset of both the oscilloscope and above mentioned oscilloscope. We, however, chose GPIB, MATLAB was kept same. This is also the main reason to also known as IEEE-488 standard. This standard provides apply correlation algorithm, i.e. to make sure that the error 1.8MB/s which well-suited for the data acquisition rate being obtained is not due to some other factor. The error needed. Also the amount of latency in GPIB is quite less as handling is also employed with the help of error handling VIs compared to serial. of LabVIEWwhich would have otherwise been difficult to develop in MATLAB. Signal Communication Processing in Oscilloscope Data Acquisition Generator Interface Matlab Figure 1 : The complete System 6. SOFTWARE GUIDE 6.1.2.2 Data Acquisition sub VI This section is focused on the description of the software that The subVI for data acquisition has been developed by mainly was developed. using the data acquisition VIs provided by Agilent technology. This sub VI initializes the oscilloscope, acquires 6.1 LabVIEW data and then closes it. LabVIEWwas basically used for data acquisition because it has been developed for the purpose of automation, control and 6.1.2.3 Data Storage acquisition. For data logging, the samples are saved to a file in standard text format. The code for this has also been developed in 6.1.1 The Front Panel LabVIEW. Saving the data allows the user to further analyze The front panel mainly consists of a display for the acquired and use it for other purposes. It also provides a backup for the waveform. The dial and gauge show the value of the data if the program crashes due to unforeseen reasons. calculated mean square error, whereas, the numeric display depicts the value of the correlation coefficient. 6.2 MATLAB The MATLAB processors have been used to carry out the Out of the many signal fidelity methods used for comparison extensive numerical computations required to compare the e.g. baseline electric noise comparison, SINAD (signal to noise and distortion) and ENOB (effective number of bits), two waveforms. the method of mean squared error was employed to compare the waveforms because of its simplicity, reliability, convexity 6.2.1 Mean Square Error and statistic nature. The code of mean square error takes the data of the two waveforms as arrays and applies the formula of mean square The correlation has been used to prove the similarity between the two waves i.e. the linear relationship between the two error upon them. It then displays the result back in LabVIEW. data. So, the script function allows easy implementation of the algorithm along with easy import/export of the data. 6.1.2 The block diagram The block diagram consists of three major parts: Mathematically it can be computed with the following 6.1.2.1 MATLAB Script formula This is discussed is section 7.2. (푦−푦 ∗)2 푀푆퐸 = : 푛 12 International Journal of Computer Applications (0975 – 8887) Volume 40– No.16, February 2012 Figure 2: The front panel 7.2 Second Method 6.2.2 Correlation Coefficient The second alternative is to use the LabVIEW softwarefor acquiring data only. The internal data is generated using The code of the correlation coefficient employs the command MATLAB script. The mean square error and correlation of coefficient are calculated in MATLAB script by using the internal data along with external one.The results were plotted R = corrcoef(X) in MATLAB to have a better comparison and analyses. This command correlates the two arrays obtained by the acquired data and the internally generated data to provide an output correlation coefficient. Statistically the correlation coefficient can be described by the following formula: 1 푥 − 푥 푦 − 푦 푟 = ( ) ∗ ( ) 푛 − 1 푠푥 푠푦 6.2.3 Generation of Reference Signal The reference signal which is used as abase for comparing he Figure 2. MATLAB Script acquired data is generated in MATLAB.