Measurement Studio Enhances C# .NET in Academics

Publish Date: Jan 23, 2007 | 83 Ratings | 1.89 out of 5 |  PDF

Table of Contents

  1. Introduction
  2. Teach Concepts, Not Theory
  3. Acquisition
  4. Analysis
  5. Presentation
  6. Conclusion

1. Introduction

Every day, engineering professors are challenged by two major tasks: (1) to teach theoretical concepts to students and (2) demonstrate the real-world implementation of these concepts. Each task, exclusive of the other, is a challenge requiring months of preparation by educators. Yet, creating a learning environment that integrates these two tasks only compounds the difficulty. The solution to this predicament is typically solved by teaching theory in the classroom and implementation in the laboratory. When teaching filter design for an electrical circuits course, a professor must explain concepts such as the characteristics of a theoretical filter, transfer functions, and analog filter design using capacitors and resistors to name a few. Then, students use a design software to make theoretical bode plots of the frequency response. From the theory to implementation, professors have to cross a gap – a gap from software design to hardware implementation. For implementation, professors must provide a laboratory for students to create their filter in hardware, then use an oscilloscope and function generator to measure the frequency response. These implementation tools are separate from the theory and design tools. Students are charged with bridging this gap between theory taught in software and implementation in hardware.

As an alternative, you need software and hardware that have the ability to plot data based on pure theory and compare it to real world acquisition data. LabVIEW is the ideal solution to combine design and hardware implementation into a graphical programming language. Yet, if you are already using Visual Studio .NET, National Instruments provides a text-based solution called Measurement Studio. These add-on tools for Visual Studio .NET allow you to quickly acquire laboratory data, perform robust analysis related to concepts taught in the classroom, and present data with powerful graphs and web services. All of these tools are fully integrated in the Visual Studio .NET environment and are provided in a language, C# , standardized by the ECMA and ISO. Many of today’s leading engineering schools already have full access to Measurement Studio through the NI Academic Site License – now is your chance to learn how you too can enhance the learning of engineering concepts.

This white paper discusses the enhancement of engineering curricula, especially Electrical, Mechanical, and Biomedical, through the combination of Measurement Studio and C#. It highlights the tools Measurement Studio provides and explains how National Instruments seamlessly integrates the teaching of engineering concepts from theory and design to implementation in hardware.

C# (pronounced C sharp) is a modern programming language that has evolved from C and C++. C# includes intuitive syntax as well as object-oriented and type safe approaches to programming. C# is managed by a Common Language Runtime, similar to the Java Virtual Machine, providing language interoperability with other .NET languages such as Visual Basic.NET and C++.NET. For more information on C# and .NET, please visit www.microsoft.com/net.

Back to Top

2. Teach Concepts, Not Theory


When studying analog filter design, electrical engineering students measure frequency response using equipment that often takes hours to configure and program. This distracts students from actually creating lowpass filters and manipulating the resistor and capacitor values. Ideally, software and hardware should be invisible to the user, thus keeping the focus on theory without distracting students with code debugging and hardware configuration. Measurement Studio delivers software and hardware integration – wizards and intuitive functions perform many tasks with a single line of code. For example, the DAQ Assistant configures and acquires real laboratory data by simply calling the Read( ) method (Figure 1). Next, students filter their data with a lowpass Butterworth filter with a call to FilterData(data) where data is an array of doubles. Finally, they plot this data to the Measurement Studio native graph by calling the PlotY(data) method. These wizards and methods encourage exploration of engineering concepts without spending hours on syntax and programming. All of this is provided in the rich, object-oriented environment of Visual Studio .NET.


private  void Plot_Click(object sender, System.EventArgs e)
{
//Acquire data from a 16-bit DAQ card such as the PCI-6036E
DAQControl userControl = new DAQControl(false);
double[,] myData = userControl.Read();

//Analyze the acquired data with a second order Butterworth lowpass filter
double[] myFilteredData = new  double[myData.GetLength(1)];
//Extract 1 channel from acquired data
for(int i=0; i < myData.GetLength(1); i++)
myFilteredData[i] = myData[0, i];
ButterworthLowpassFilter LowPass = new ButterworthLowpassFilter(2,10000,500);
myFilteredData = LowPass.FilterData(myFilteredData);

//Present the data on a 2-dimensional graph
waveformGraph1.PlotY(myFilteredData);
}
Figure 1: Acquire, analyze, and present data from a circuit

Back to Top

3. Acquisition

To acquire real data in laboratories today, students typically use bench top instruments and manually transfer this data into a computer to analyze it. Alternatively, students make function calls into a DLL to control a plug-in data acquisition card. In contrast, Measurement Studio includes built-in wizards like the DAQ and Instrument I/O Assistants to acquire data from plug-in data acquisition boards and GPIB based instruments such as oscilloscopes. These powerful assistants allow students to interactively configure and test acquisition processes from within Visual Studio .NET, in addition to generating C# or Visual Basic .NET code. With the low-level details of the acquisition handled by Measurement Studio, students can devote more time to learning the key engineering concepts including:


Aliasing Phase Shift
Noise Multiplexing
Amplification Gain
Settling Time Grounding
Impedance Resolution
Timing Analog-To-Digital Converters (ADC)
Isolation Digital-To-Analog Converters (DAC)
Range Counter Operation
Switching Digital Input/Output
Hardware Filtering (i.e. Butterworth) Sensor Fundamentals (i.e. bridge completion)


DAQ Assistant for Data Acquisition

The DAQ Assistant allows students to interactively modify parameters such as sampling rate, triggering, and clock source (Figure 2). With one click of the Test button from within the Visual Studio environment, students quickly see the acquired data from a DAQ board; they can also decrease the sampling rate to see a sine wave to alias a signal. Fundamentals such as phase shift are made clearer when students can quickly visualize how adding a resistor and capacitor to their circuit eliminates 60Hz noise. Measurement Studio also allows students to modify the signals input range, thus adjusting the DAQ card gain to provide better resolution for their signal. All of these features are provided interactively, before any code is needed. After students have configured and tested their acquisition using the DAQ Assistant, integration is seamless because the code is automatically generated:

//Here is the code generated by the DAQ Assistant.  A voltage task is created with a sample rate of 10000 that will acquire 500 samples in differential mode.  The voltage range is between -5 and 5 volts.
public  class DAQmxTask1 : Task
{
public DAQmxTask1() : base("DAQmxTask1")
{
this.Configure();
}
public  virtual  void Configure()
{
this.AIChannels.CreateVoltageChannel("Dev1/ai1", "Voltage", AITerminalConfiguration.Differential, -5, 5, AIVoltageUnits.Volts);

this.Timing.ConfigureSampleClock("", 10000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 500);
}
} 

Figure 2: DAQ Assistant integrated into Visual Studio .NET


With Measurement Studio, hundreds of hardware options are available. Educational Laboratory Virtual Instrumentation Suite (ELVIS) is one option designed specifically for academics. Combined with an E-Series data acquisition card, ELVIS allows students to build circuits on the prototyping board and utilize analog input and output terminals. Building an RC circuit on the prototyping board is shown below (Figure 3). A resistor and capacitor wired in series create this circuit. The analog output of the DAQ board creates a frequency sweep for the circuit input. The analog input channels can measure the response of the circuit. In addition, students can control the digital I/O lines and counters.


Figure 3: NI ELVIS and prototyping board wired with a RC circuit


Instrument I/O Assistant for Instrument Control

Many engineering laboratories have thousands of dollars of instruments not being used to their full potential. Students tediously modify control settings and record measurements on laboratory instruments. However, with a general purpose interface bus (GPIB) connected between a student's instruments and computer, Measurement Studio controls and synchronizes the instruments, in addition to saving the data. If students build a RC circuit, they might alternate between using a scope and function generator to measure the frequency response. With Measurement Studio, students control this process with instrumentation powered by their computer. The instrument I/O Assistant allows students to send commands to their instrument with a graphical user interface (Figure 4). They can then create a sequence of commands such as select instrument, query, and parse to configure the desired response from the instrument. After students have visualized this process, they use the code generation feature of the wizard to integrate their laboratory instruments into their program. After the data has been acquired, students perform further analysis such as a Fast Fourier Transform (FFT) to identify frequency components.


Figure 4: Students use the Instrument I/O Assistant to send, receive, and automatically parse data for laboratory instruments.

Back to Top

4. Analysis

After acquiring data from sensors, filters, and other circuits, most engineering curricula require students to analyze this data. This data could originate from an RC circuit and requires frequency-domain analysis. Other common analysis includes software filtering, windowing, curve-fitting, and network response. Measurement Studio includes built-in analysis libraries ideal for demonstrating concepts learned in the classroom:
  • Measurements such as Scaled Time Domain Window, Impulse Response, and Power Spectrum
  • Signal Generation such as Sine, Pulse, and White Noise
  • Windowing such as Blackman, Flat Top, Hamming, and Hanning
  • Digital Filters such as Bessel, Butterworth, IIR, FIR and Chebyshev
  • Signal Processing such as FFT, Deconvolution, Fast Hilbert, Integral, and Peak Detection
  • Linear Algebra such as Cholseky Factorization, Dot Product, Matrix Multiplication, and Linear Equations
  • Curve Fitting such as Linear, Exponential, and Polynomial fit
  • Statistics such Chi-Square, RMS, and Normal Distribution
  • Math such as Differential Equations, Calculus, and Scientific Conversions.

Why not challenge students to explore Butterworth filters and a Fast Fourier Transforms (FFT) with intuitive function calls included with Measurement Studio? The analysis libraries included with Measurement Studio allows students to experiment with concepts learned directly in the classroom. Each of the methods included the Measurement Studio analysis class library are directly relevant to your engineering curriculum. We will cover the different analysis libraries below.

Measurements

The Measurements library includes functions familiar to many popular courses including Signals and Systems for electrical engineering.

Measurements Functions
EE
ME
BME
AC and DC Estimator
Amplitude and Phase Spectrum
Auto Power Spectrum
Cross Power Spectrum
Harmonic Analyzer
Impulse Response Function
Network Functions (avg)
Power and Frequency Estimate
Scaled Time Domain Window
Spectrum Unit Conversion
Transfer Function
Signals and Systems
Communication
Senior Design
Control Systems I
Control Systems II
Communication
and Control
Network Theory
Mixed Signals
Signal Measurements and Analysis
Mechatronics
Senior Design
Engineering Laboratory
Biomedical Instrumentation
Senior Design
Devices and Systems




Table 1: Measurements helpful for EE, ME, and BME

The Network Function is a good example of a popular application in academics. The Network Function computes the coherence, averaged cross power spectrum magnitude, cross power spectrum phase, averaged transfer function, frequency response magnitude and frequency response phase, and averaged impulse response. The input signals are typically the stimulus and response data of a unit under test. As with many analysis methods included with Measurement Studio, multiple measurements can be found through a single function call, allowing students to focus on theory and not implementation. Figure 5 shows how the network function displays the frequency response magnitude of an impulse signal passed through a second order Elliptical lowpass filter with a cutoff frequency of 250 Hz. Notice that frequency components greater than 250 Hz are drastically attenuated.



// The code needed to perform a network function on the stimulus and response signals in Measurement Studio
Transforms.NetworkFunctions(stimulusSignal, responseSignal, dt, out crossPowerSpectrumMagnitude, out crossPowerSpectrumPhase, out frequencyResponseMagnitude, out frequencyResponsePhase, out coherence, out impulseResponse, out df);
Figure 5: Students calculate the network transfer functions from stimulus and response data with one method call. Then, they plot this data with the PlotXY( ) method

Signal Generation

Again, in courses such as Signals and Systems, accurate signal generation is crucial to the success of the laboratory experiment. With the analysis libraries included with Measurement Studio, common functions such as sine waves, Gaussian White Noise, and Uniform White Noise are precisely generated.

Signal Generation Functions
EE
ME
BME
Arbitrary Wave
Chirp Pattern
Gaussian White Noise
Impulse Pattern
Pulse Pattern
Ramp Pattern
Sawtooth Wave
Sinc Pattern
Sine Pattern
Sine Wave
Square Wave
Triangle Wave
Uniform White Noise
Signals and Systems
Senior Design
Probability, Statistics, and Random Processes






Senior Design









Senior Design
Biotechnology Laboratory





Table 2: Signal Generation in EE, ME, and BME

A simple sine wave can be generated, as shown in Figure 8, by using the BasicFunctionGenerator:
// Generate a basic sine wave
BasicFunctionGenerator myData = new BasicFunctionGenerator(BasicFunctionGeneratorSignal.Sine);
myData.Generate();
The above C# code creates a default sine wave of 1000 points with an amplitude of 1. Of course, BasicFunctionGenerator has a polymorphic constructor, enabling you and your students to customize this function with a specific frequency, amplitude, phase, offset, sampling rate, and number of samples, as shown here:
// Generate a customized sine wave
new BasicFunctionGenerator(BasicFunctionGeneratorSignal.Sine, Freq, Amp, Phase, Offset, SamplingRate, numSamples);
Signal generation can be combined with DAQ Assistant discussed above to output specific signals from a DAQ card such as the E-Series PCI-6036E. Outputting sine waves with known frequencies provides a configurable input for the RC filter shown in Figure 3. In addition, signal generation can be used as a theoretical reference for comparison with measured data.

Digital Filters

Popular in many electrical engineering and biomedical engineering courses, digital filters are studied extensively. Measurement Studio provides highpass, lowpass, bandpass, and bandstop software filters for many IIR and FIR digital filter designs. When designing a filter, these tools can be used to provide students with theoretical filtered data given a known signal such as a sine wave. Combining these filter functions with signals from the Signal Generation libraries and real-world circuits (Figure 3), students can design and test their circuit with a digital signal processor (DSP) chip.



Filter Functions
EE
ME
BME
Bessel
Butterworth
Cascade
Chebyshev
Elliptic
Equiripple
FIR
FIR Windowed
IIR Cascade
IIR
Inverse Chebyshev
Parks-McClellan Coefficients
Electronic Circuits
Digital Signal Processing
Communications
Senior Design
DSP Hardware
Active RC Networks
Network Theory
Communication
and Control
Linear Systems
and Signals
Automatic Control
Electronic Circuits
Senior Design






Electronic Circuits
Instrumentation
Senior Design
Devices and Systems





Table 3: Digital Filtering in EE, ME, and BME


After the theory of digital filters has been taught in the classroom, students can experiment with changing order and cutoff frequency to learn about phenomena like phase shift (Figure 6). It is one thing to look at a graph in a textbook, but learning is brought to a new level when students can use software to generate theoretical data and apply a software filter, then actually build the filter in hardware and compare the results. Alternatively, they can acquire noisy real-world data and filter this in software and then compare it to a filter designed in hardware.



// Invoke a lowpass Butterworth filter
ButterworthLowpassFilter butterworthLowpass = new ButterworthLowpassFilter(Order, SamplingRate, CutOffFrequency);
double[] filteredData = butterworthLowpass.FilterData(data);
Figure 6: Lowpass Butterworth filter attenuating 60Hz noise


Signal Processing

Crucial for every electrical engineering student is thorough comprehension of signal processing techniques such as Fast Fourier Transforms (FFT) and peak detection. As shown in Table 4, nearly all EE and many BME courses will use various forms of signal processing.

Signal Processing Functions
EE
ME
BME
Autocorrelation
Convolution
Cross Power
Cross Correlation
Decimate
Deconvolution
Derivative x(t)
Fast Hilbert Transform
Fast Hartley Transform
Integral x(t)
Inverse Real
and Complex Fast Fourier Transform (FFT)
Inverse Fast Hilbert Transform
Inverse Fast Hartley Transform
Peak Detection
Power Spectrum
Pulse Parameters
Real and Complex FFT
Threshold Peak Detector
Unwrap Phase
Electronic Circuits
Digital Signal Processing
Communications
Control Systems I
Control Systems II
Systems and Signals
Senior Design
Computer Vision
Signal Measurements
and Analysis
Digital Control Systems
Network Theory
DSP Hardware
Statistical Signal Processing
Signal Processing
and Communications
Image Processing
Nonlinear Automatic Control Theory
Senior Design
Dynamics
and Vibrations











Instrumentation
Senior Design
Image Processing
Thermodynamics
Physiological Transport Phenomena
Devices and Systems







Table 4: Signal Processing in EE, ME, and BME


In a Signal Processing course, professors spend time teaching students about Fast Fourier Transforms as an algorithm for computing magnitude of energy versus frequency for a given signal. This is accomplished by assuming that every signal is a sum of sinusoids of various frequencies. After the theory has been explained, Measurement Studio is a great tool to use because it provides intuitive functions to calculate a FFT. For example, Figure 7 demonstrates the Measurement Studio ComplexDouble data type used to store both imaginary and real numbers. The RealFft method only returns the real components of dataArray, but other methods such as Fft return both real and imaginary components. In the laboratory, especially when learning filter design, students can experiment with the FFT functions to visualize attenuated frequency components for various filters. When combined with hardware, a 2-hour laboratory can cover everything from filter theory and design to implementation and testing.


// Perform a FFT
ComplexDouble[]FFTValue = NationalInstruments.Analysis.Dsp.Transforms.RealFft(dataArray);
Figure 7: Performing a FFT on sampled data to identify component frequencies

Back to Top

5. Presentation

What better way to encourage learning than to actually visualize engineering topics such as a filter attenuating frequencies or an FFT breaking down a signal into its frequency components? Visual Studio .NET includes the System.Windows.Forms library to provide basic visualization objects such buttons, text boxes, and image controls to create a familiar Windows forms. Measurement Studio adds enhanced visualization tools for creating a rich graphical user interface (GUI) specific to engineering and scientific data including a waveform graph, a scatter graph, Boolean LED, and 3D switch. One common visualizing tool seen every day in academics is a graph. A graph can display everything from acquired raw data to filtered data to analyzed data. Unfortunately, a graph is missing from all of the most popular IDEs. Fortunately, a powerful extensible graph is included with Measurement Studio. In addition to displaying the data on a graph, these graphical tools give Virtual Instruments the look and feel of laboratory bench top instruments and can even take a laboratory into cyberspace with the power of ASP.NET and web services. These web features allow publication of experiments online allowing students to interact from their dorms.

Waveform and Scatter Graphs
Use a waveform graph to display data acquired from a DAQ card or bench top instrument. A waveform is defined as a set of y data against equally spaced x increments or a set of x data against equally spaced y increments. Add greater flexibility with a scatter graph to plot by both X and Y data sets. This is useful when designing a filter and graphing the zero-polls.

Both graphs provide a highly-customizable interface that includes user-defined plot and point colors, plot and point styles, X and Y axes, plot legend, and zooming. Both graphs offer the option to either plot or chart data. Plotting only displays a specific data set. This is useful for visualizing a static measurement such as an FFT. Charting, on the other hand, appends new data to the end of previous data. This is ideal for displaying slow moving data like temperature values.



Figure 8: Waveform (left) and Scatter (right) graphs


Take your Laboratory to Cyberspace

Leading engineering schools such as Massachusetts Institute of Technology (MIT) are taking their laboratory experiments mobile with the ASP.NET. In a project called I-Lab, MIT professors have given students web access and control of experiments such as:
· Microelectronics WebLab
· Chemical reactor
· Mechanical structures
· Heat exchanger
· Instrumentalized Flagpole 
· Shaker table
· Polymer recrystallization
· Photo voltaic weather station

ASP.NET
Using ASP.NET, students can learn in their dormitories, while engineering departments can reuse experiments online (Figure 9). ASP.NET allows easy change of teaching venue from the laboratory to the web. With the ASP.NET framework managing the HTML, JavaScript, and security of the laboratory, professors can focus on concepts, not code.


Figure 9: MIT takes its ME laboratory online with ASP.NET


Use Measurement Studio to expand the power of .NET to make the lab go mobile. Visual Studio .NET provides a framework to present data on the web; combined with Measurement Studio analysis libraries, students can learn concepts anywhere. Figure 10 highlights the Temperature data type provided by Measurement Studio. It stores a temperature value which can be converted to Celsius, Fahrenheit, Kelvin, or Rankine with C# get and set properties. Professors can post interactive homework assignments and laboratories that students can complete from the dormitories. All of this web functionality is provided without any additional programming; professors use ASP.NET Web Application project type provided by Visual Studio .NET and program as they would a standard Windows application. Pressing Start (F5), publishes the application to the web.



// Converting a temperature from Fahrenheit to Celsius
Temperature myTemp;
myTemp = Temperature.FromFahrenheit(input);
output = myTemp.Celsius;
Figure 10: ASP.NET publishes analysis libraries to the web


Web Services
Online learning benefits from web service technology when integrated with Measurement Studio. Web services are a platform to create distributed applications upon standardized protocols such as Extensible Markup Language (XML). Using the same analysis libraries demonstrated earlier for Windows forms and ASP.NET, Measurement Studio enables users to incorporate analysis functions running on multiple computers into their program enabling a distributed computing application. This capability allows them to create a signal analysis program to perform computationally intensive FFTs calculations. Using the deployment wizard provided by Visual Studio .NET permits deployment of this application to multiple servers. Web Services and Measurement Studio allow students to calculate multiple FFTs simultaneously by invoking CalculateFFT( ) method on multiple servers. Each server would receive an array of data, perform an FFT, and return an array of transformed data. All this can be accomplished without additional lines of code because .NET completely handles the communication protocols. As a result, students can experience the benefits of distributed computing without spending time programming the communication. Figure 9 shows the architecture of a distributed computing model to calculate multiple FFTs using web services.
// Performing a FFT
WebService1.CalculateFFT(dataArray1);
WebService2.CalculateFFT(dataArray2);
WebService3.CalculateFFT(dataArray3);
Figure 11: Call remote methods without additional code

Back to Top

6. Conclusion

Measurement Studio combined with Visual Studio .NET facilitates the teaching of engineering concepts - from the theory taught in the classroom to implementation in the laboratory. These add-on tools enhance acquisition, analysis, and presentation in engineering curriculums with the DAQ and Instrument I/O assistants, robust analysis functions to perform FFTs and generate functions, and graphics such as the waveform and scatter graphs. To learn more about adding Measurement Studio to your academic curriculum, please see the links below.
Related Links:
Academic Site License
Learn more about Measurement Studio
NI Measurement Studio 8.0 – Extensible Architectures and .NET Measurement Designers Deliver Flexibility and Robust I/O Connectivity

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit