Measurement Studio Measurement Computing Edition TM TM User Manual Measurement Studio for MCC User Manual March 2006 374318A-01
Worldwide Technical Support and Product Information ni.
Important Information Warranty The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives notice of such defects during the warranty period.
WARNING REGARDING USE OF MEASUREMENT COMPUTING CORPORATION PRODUCTS MEASUREMENT COMPUTING CORPORATION DOES NOT AUTHORIZE ANY MEASUREMENT COMPUTING CORPORATION PRODUCT FOR USE IN LIFE SUPPORT SYSTEMS AND/OR DEVICES WITHOUT WRITTEN APPROVAL OF THE CEO OF MEASUREMENT COMPUTING CORPORATION. LIFE SUPPORT DEVICES/SYSTEMS ARE DEVICES OR SYSTEMS WHICH, A)ARE INTENDED FOR SURGICAL IMPLANTATION INTO THE BODY, OR B)SUPPORT OR SUSTAIN LIFE AND WHOSE FAILURE TO PERFORM CAN BE REASONABLY EXPECTED TO RESULT IN INJURY.
Contents About This Manual How To Use this Manual ...............................................................................................ix Conventions ...................................................................................................................x Chapter 1 Introduction to Measurement Studio Measurement Computing Edition Installation Requirements ..............................................................................................1-1 Deployment Requirements ...........
Contents Numeric Edit Control...................................................................................... 2-17 Switch and LED Controls ............................................................................... 2-18 Property Editor Control................................................................................... 2-19 Measurement Studio Support for Visual Studio 2005 Class Library Overview ........... 2-20 Windows Forms Array Controls ..................................................
Contents Appendix A Contacting Measurement Computing Corp.
About This Manual The Measurement Studio Measurement Computing Edition User Manual introduces the concepts associated with the Measurement Studio class libraries and development tools. This manual assumes that you have a general working knowledge of Microsoft Visual Studio, including .NET Windows and ASP.NET. How To Use this Manual Measurement Studio 8.0.1 includes one CD with support for both Visual Studio .NET 2003 and Visual Studio 2005.
About This Manual Conventions The following conventions appear in this manual: <> Text enclosed in angle brackets represents directory names and parts of paths that may vary on different computers, such as . » The » symbol leads you through nested menu items and dialog box options to a final action. The sequence File»Page Setup»Options directs you to pull down the File menu, select the Page Setup item, and select Options from the last dialog box.
Introduction to Measurement Studio Measurement Computing Edition 1 Measurement Studio Measurement Computing Edition is an integrated suite of tools and class libraries that are designed for developers using .NET Windows and ASP.NET to develop measurement and automation applications.
Chapter 1 Introduction to Measurement Studio Measurement Computing Edition integrated tools) or Visual C#, Visual Basic, or Visual C++ Express Editions of Microsoft Visual Studio 2005 Measurement Studio integration tools are not supported in the Visual Studio 2005 Express Editions.
Chapter 1 Introduction to Measurement Studio Measurement Computing Edition 2. Click Install NI Measurement Studio for Visual Studio .NET 2003 or click Install NI Measurement Studio for Visual Studio 2005. 3. Click Next to install all NI software to the default installation directory, or click Browse to select a different installation directory. You must install Measurement Studio to a local drive. Click Next.
Chapter 1 Introduction to Measurement Studio Measurement Computing Edition Measurement Studio Features The following list contains features included in Measurement Studio. Refer to mccdaq.com/mstudio for more information about the features and functionality included in Measurement Studio.
Chapter 1 Introduction to Measurement Studio Measurement Computing Edition The following resources also are available to provide you with information about Measurement Studio. • Examples—Measurement Studio installs examples to the following paths: – Visual Basic .NET or Visual C#—Program Files\National Instruments\\DotNET\Examples • Measurement Computing Technical Support—Refer to Appendix A, Contacting Measurement Computing Corp., for more information.
Measurement Studio Measurement Computing Edition .NET Class Libraries 2 This chapter provides overview information about the .NET class libraries included with Measurement Studio Measurement Computing Edition support for Visual Studio .NET 2003 and Visual Studio 2005. Refer to the Using the Measurement Studio .NET Class Libraries section of the NI Measurement Studio Help for detailed information about these libraries.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Analysis The Measurement Studio Analysis .NET class library is in the NationalInstruments.Analysis namespace. The Analysis class library includes a set of classes that provides various digital signal processing, signal filtering, signal generation, peak detection, and other general mathematical functionality. Use this library to analyze acquired data or to generate data.
Chapter 2 Measurement Studio Measurement Computing Edition .
Chapter 2 Measurement Studio Measurement Computing Edition .
Chapter 2 Measurement Studio Measurement Computing Edition .
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Statistics • Histogram • Mean • Median and Mode • Moment about Mean For more information about analyzing or generating data with the Analysis class library, refer to the Using the Measurement Studio Analysis .NET Library topic in the NI Measurement Studio Help. For more information about the functionality included in the Analysis class library, visit ni.com/analysis and select Analysis in Measurement Studio.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries MCC-488.2 The Measurement Studio MCC-488.2 .NET class library is in the MccDaq.Mcc4882 namespace. This class library is included when you install the MCC-488.2 driver. The MCC-488.2 class library includes a set of classes for communicating with GPIB instruments, controlling GPIB devices, and acquiring GPIB status information. Use this library to design code that communicates with and controls instruments on a GPIB interface.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries User Interface The Measurement Studio user interface controls are in the Windows Forms and Web Forms .NET class libraries. Refer to Table 2-1 for the UI controls provided by Measurement Studio. Table 2-1. Measurement Studio User Interface Controls User Interface Controls Visual Studio .
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Windows Forms Controls The Measurement Studio user interface controls are in the Windows Forms .NET class library. The Windows Forms .NET class library is in the NationalInstruments.UI.WindowsForms namespace.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Waveform Graph and Scatter Graph Controls Use the Measurement Studio waveform graph and scatter graph controls, as shown in Figure 2-1, to display two-dimensional data on a Windows Forms user interface. Use the waveform graph to display two-dimensional linear data. You explicitly specify each value in one dimension and provide an initial value and interval to implicitly specify the values in the other dimension.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries • Specify plots in the scatter graph control as X and Y data. Specify plots in the waveform graph control as X or Y data and optionally with date and time scaling. • Use the extensible plot and plot area drawing capabilities and events to customize the graph appearance. • Use plot data tooltips to display X and Y coordinates when a user hovers the mouse over a data point. • Create custom point and line styles for plots.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries • Copy the graph as a BMP, GIF, JPEG, or PNG image to the clipboard or a file. For more information about using the waveform and scatter graph controls, refer to the Using the Measurement Studio Windows Forms Scatter and Waveform Graph .NET Controls section in the NI Measurement Studio Help.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries • Specify anti-aliased digital plots. • Expand and collapse signal plots interactively. Waveform Sample and Signal State Operations • Simultaneously display waveforms and signals or display signals only. • Create custom waveform sample and signal state styles. • Configure sample and state labels. • Create custom waveform sample and signal state labels.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Figure 2-3. Windows Forms Complex Graph Control With the complex graph control and the classes that interface with the control, you can perform the following operations: Plot Operations • Plot and chart ComplexDouble data. • Configure a graph to contain multiple plots to show separate but related data on the same graph. • Draw lines or fills from a plot to an X value, Y value, or another plot.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Additional Operations • Pan and zoom interactively. • Configure major, minor, and custom divisions and origin lines. • Copy the graph as a BMP, GIF, JPEG, or PNG image to the clipboard or a file. For more information about using the complex graph control, refer to the Using the Measurement Studio Windows Forms Complex Graph .NET Control section in the NI Measurement Studio Help.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries • Customize the appearance of the control using 3D lab styles or classic 2D styles and change the color and length of ticks and labels. • Configure the format of value labels to engineering or date/time. Use the Measurement Studio knob, gauge, and meter controls, as shown in Figure 2-4, to input and display numeric data on your user interface. Figure 2-4.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries With the slide, tank, and thermometer controls and the classes that interface with them, you can perform the following operations: • Fill to the minimum or maximum value of the scale. • Position the scale horizontally with left, right, or both and position the scale vertically with top, bottom, or both.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries For more information about using the Windows Forms numeric edit control, refer to the NumericEdit Class section in the NI Measurement Studio Help. Tip Switch and LED Controls Use the Measurement Studio switch and LED controls as Boolean controls on a Windows Forms user interface. You typically use a switch control, as shown in Figure 2-7, to receive and control Boolean input on an application user interface. Figure 2-7.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Property Editor Control Use the Measurement Studio property editor control, as shown in Figure 2-9, to configure properties for Windows Forms controls at run time. Figure 2-9. Windows Forms Property Editor Control for the Windows Forms Knob Control Scale Arc Property With the property editor control and the classes that interface with the control, you can perform the following operations: • Edit any .
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries For more information about using the property editor control, refer to the Using the Measurement Studio Windows Forms Property Editor Control topic in the NI Measurement Studio Help. Tip Measurement Studio Support for Visual Studio 2005 Class Library Overview Measurement Studio support for Visual Studio 2005 includes all of the features and functionality described in the Measurement Studio Support for Visual Studio .
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Switch and LED Array Controls Use the Measurement Studio switch and LED array controls as an array of Boolean controls on a Windows Forms user interface. You typically use a switch array control, as shown in Figure 2-10, to control ports of a digital line or values of an array. You typically use an LED array control, also shown in Figure 2-10, to visualize ports of a digital line or values of an array. Figure 2-10.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Numeric Edit Array Control Use the Measurement Studio numeric edit array control, as shown in Figure 2-11, to control and visualize values of an array of double values. Figure 2-11. Numeric Edit Array control With the numeric edit array control and the classes that interface with the control you can perform the following operations: • Set values by passing an array of data.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries ASP.NET Web Forms Controls The Measurement Studio ASP.NET user interface controls are in the Web Forms .NET class library. The Web Forms .NET class library is in the NationalInstruments.UI.WebForms namespace.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Waveform Graph and Scatter Graph Controls Use the Measurement Studio waveform graph and scatter graph controls, as shown in Figure 2-12, to display two-dimensional data on a Web-based user interface. Use the waveform graph to display two-dimensional linear data. You explicitly specify each value in one dimension and provide an initial value and interval to implicitly specify the values in the other dimension.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries • Specify plots in the scatter graph control as X and Y data. Specify plots in the waveform graph control as X or Y data and optionally with date and time scaling. • Use the extensible plot and plot area drawing capabilities and events to customize the graph appearance. • Create custom point and line styles for plots. • Specify anti-aliased plots for plot lines.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries For more information about using the waveform and scatter graph controls, refer to the Using the Measurement Studio Web Forms Scatter and Waveform Graph .NET Controls section in the NI Measurement Studio Help. Tip Digital Waveform Graph Control Use the Measurement Studio digital waveform graph control, as shown in Figure 2-13, to display DigitalWaveform data in an ASP.NET Web application. Figure 2-13.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries With the digital waveform graph control and the classes that interface with the control, you can perform the following operations: Plot Operations • Plot digital waveform data, including digital signal state data and timing information. • Configure plot labels on the y-axis. • Configure plot templates to customize plots that are implicitly created from plotted data. • Specify anti-aliased digital plots.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Complex Graph Control Use the Measurement Studio complex graph control, as shown in Figure 2-14, to display ComplexDouble data on a ASP.NET Web application. A ComplexDouble consists of a real part and an imaginary part. Figure 2-14.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Axis Operations • Configure a graph to include multiple axes or independent ranges so that plot data fits the graph plot area. • Configure the axis modes to fixed, exact autoscaling, loose autoscaling, strip chart, or scope chart. • Interactively change the range of an axis and invert the axis at run time by clicking on the axis end labels. Additional Operations • Zoom interactively.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries With all of the numeric controls and the classes that interface with them, you can perform the following operations: • Configure the scale to be linear or logarithmic and toggle the visibility of the scale. • Fill the scale and configure the range, color, dimensions, and style of the fill. • Connect to a Measurement Studio .
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries With the knob, gauge, and meter controls and the classes that interface with the controls, you can perform the following operations: • Specify the start and sweep angle of the arc programmatically or from the Properties window. • Use automatic division spacing, custom divisions, and invert the scale.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Numeric Edit Control Use the Measurement Studio numeric edit control, as shown in Figure 2-17, to display numeric values and to provide a way by which end users can edit numeric values. Typically, you use a numeric edit control to input or display double numerical data instead of using a Web Forms TextBox control. Figure 2-17.
Chapter 2 Measurement Studio Measurement Computing Edition .NET Class Libraries Switch and LED Controls Use the Measurement Studio switch and LED controls as Boolean controls in an ASP.NET Web application. You typically use a switch control to receive and control Boolean input in an ASP.NET Web application. You typically use an LED control to indicate a Boolean value in an ASP.NET Web application. The switch and LED controls are shown in Figure 2-18. Figure 2-18.
Measurement Studio Integrated Tools and Features 3 When you use Measurement Studio in the Visual Studio environment, you have access to measurement and automation tools and features for.NET Windows and ASP.NET. These integrated tools and features are designed to help you quickly and easily build measurement and automation applications. These integrated tools are included in support for both Visual Studio .NET 2003 and Visual Studio 2005.
Chapter 3 Measurement Studio Integrated Tools and Features • Instrument Driver Network—Use the NI Instrument Driver Network at ni.com/idnet as a central resource for downloading, developing, and submitting instrument drivers. Select Measurement Studio Online Resources»Instrument Driver Network to access this menu item in Visual Studio 2005.
Chapter 3 Measurement Studio Integrated Tools and Features Figure 3-1. New Project dialog box in Visual Studio 2005 For more information about using project templates to create a new Measurement Studio project, refer to the Creating a New Measurement Studio Project section in the NI Measurement Studio Help.
Chapter 3 Measurement Studio Integrated Tools and Features Figure 3-2. Measurement Studio Add/Remove Class Libraries Wizard for Visual Studio 2005 For more information about using the Add/Remove Class Libraries wizard to add or remove Measurement Studio class libraries, refer to the Adding or Removing Measurement Studio Class Libraries section in the NI Measurement Studio Help. Tip Measurement Studio for MCC User Manual 3-4 ni.
Getting Started with Measurement Studio 4 The following sections include overview information and step-by-step instructions on developing applications with Measurement Studio tools and features. Refer to the Developing with Measurement Studio section and the Getting Started with the Measurement Studio Class Libraries section of the NI Measurement Studio Help for more information about the functionality of these tools and features. Measurement Studio Walkthroughs for Visual Studio .
Chapter 4 Getting Started with Measurement Studio Walkthrough: Creating a Measurement Studio Application with Windows Forms Controls and Analysis in Visual Studio .NET 2003 Measurement Studio includes user interface controls, such as a waveform graph control and a gauge control, and analysis functionality such as signal generation and mathematical functions.
Chapter 4 4. Getting Started with Measurement Studio In the Templates pane, select Windows Application. Specify MyMeasurementStudioProject for Name and specify a Location of your choice. 5. Click OK. The Measurement Studio Application Wizard launches. 6. Select Analysis and Windows Forms User Interface Controls. If you are working with an existing project, you can access the Add Class Libraries dialog box by selecting Measurement Studio»Add/Remove Class Libraries Wizard. Tip 7.
Chapter 4 Getting Started with Measurement Studio Adding user interface controls to the project In this section, you will build a user interface that looks like Form1 in the following screenshot. 1. Select View»Toolbox to display the Toolbox. The Toolbox contains components and controls that you can add to your project. 2. Select the Windows Forms tab. The Windows Forms tab contains controls and components included in the System.Windows.Forms namespace. 3.
Chapter 4 9. Getting Started with Measurement Studio Type Plot for the Name. Click OK. 10. Before you add the legend and gauge controls, you need to resize the form to accommodate them. Select the form and use the double-sided arrow to resize it. 11. Select the Legend control and drag and drop it onto the form. 12. Select the NumericEdit control and drag and drop it onto the form. 13. Select the Gauge control and drag and drop it onto the form. 14.
Chapter 4 Getting Started with Measurement Studio The following screenshot shows Form1 with the user controls. Generating, plotting, and analyzing the data 1. Double-click the button control to display the Form1 code, with the cursor inside the click event handler of the button control. 2. Add the following code to generate random data, plot the data, calculate the mean of the data, and display the mean on the gauge. [VB.NET] ' Declare and initialize an instance of WhiteNoiseSignal.
Chapter 4 Getting Started with Measurement Studio // Use the PlotY method to plot the data. Plot.PlotY(data); // Use the Mean method to calculate the mean of the data. double mean = Statistics.Mean(data); // Display the mean on the gauge. gauge.Value = mean; Customizing your user interface 1. Right-click the legend and select Edit Items to display the LegendItem Collection Editor dialog box. You use the LegendItem Collection Editor to add or remove legend items and to configure legend item properties.
Chapter 4 Getting Started with Measurement Studio the Auto Format feature configures the appropriate control properties to reflect the style you chose. 4. Select Points Only. Click OK. Notice that the legend changed automatically to match the formatting of the graph. 5. Right-click the gauge and select Auto Format to display the Auto Format dialog box. 6. Select Dark and click OK. 7. Right-click the gauge and select Properties to display the Properties Window. 8.
Chapter 4 Getting Started with Measurement Studio 12. Select the Format Mode property and in the Numeric Edit Format Mode Editor dialog box, change the Precision to 4. 13. Select File»Save Form1.cs to save your application. 14. Select Debug»Start Without Debugging to run the application. 15. After your program builds and runs, click Start. Notice the graph shows the data plot, and the gauge and the numeric edit display the mean of the data. 16. The following screenshot shows Form1 with customization.
Chapter 4 Getting Started with Measurement Studio functionality to a Windows Forms application by taking you through the following steps: • Setting up the project—Using the Visual Studio New Project dialog box, you will create a new project that references the Measurement Studio Measurement Computing DAQ class library and Windows Forms controls.
Chapter 4 Getting Started with Measurement Studio Application Wizard automatically adds references to the appropriate class libraries. If you are working with an existing project, you can access the Add Class Libraries dialog box by selecting Measurement Studio»Add/Remove Class Libraries Wizard. Tip 7. Click Finish to display Form1 in the Windows Forms Designer. Adding user interface controls to the project 1. Select View»Toolbox to display the Toolbox.
Chapter 4 Getting Started with Measurement Studio 7. Select the Meter control and drag and drop it onto the form. 8. Right-click the meter and select Properties to display the Properties window. 9. Set the CoercionIntervalBase property for the meter to –10. 10. Set the Range property for the meter with the drop-down Range type editor. Type –10 for the minimum value. Leave the default of 10 for the maximum value. The following screenshot shows Form1 with the user controls.
Chapter 4 Getting Started with Measurement Studio private System.ComponentModel.Container components = null; public Form1() { // Required for Windows Form Designer support InitializeComponent(); daqBoard =new MccDaq.MccBoard(0); 3. Scroll down to move the cursor inside the click event handler of the button control. 4. Add the following code to read a raw data point from a specified channel on the Measurement Computing device, convert the data to volts, and display the value on the meter. [VB.
Chapter 4 Getting Started with Measurement Studio The following screenshot shows Form1 with the meter displaying the acquired value. Walkthrough: Creating a Measurement Studio MCCDaq Scan Components Application in Visual Studio .NET 2003 Measurement Studio includes a component library and application templates that you can use to quickly create MccDaq Components applications with Visual Basic .NET and Visual C#.
Chapter 4 • Getting Started with Measurement Studio Generating and displaying the data—Using the MccDaq.Scan components, you will read data from a channel on an Measurement Computing device, convert the data object to an array, and show the value on a waveform graph. Before You Begin The following components are required to complete this walkthrough: • Microsoft Visual Studio .
Chapter 4 Getting Started with Measurement Studio 3. 4. In the Project Types pane, expand the Measurement Studio Projects folder. Select Visual Basic Projects or Visual C# Projects, depending on which language you want to create the project in. In the Templates pane, select Windows Application. Specify MyMCCScanProject for Name and specify a Location of your choice. 5. Click OK. The Measurement Studio Application Wizard launches. 6. Select Windows Forms User Interface Controls.
Chapter 4 Getting Started with Measurement Studio Adding user interface controls to the project 1. Select View»Toolbox to display the Toolbox. The Toolbox contains components and controls that you can add to your project. 2. Select the Windows Forms tab. The Windows Forms tab contains controls and components included in the System.Windows.Forms namespace. 3. Select the Button control and drag and drop it onto the form. 4.
Chapter 4 Getting Started with Measurement Studio The following screenshot shows Form1 with the user controls. The AIScan component is shown in the component tray. Generating and displaying the data 1. Double-click the Start button to display the Form1 code. 2. Add the following line of code to start an analog in scan. [VB.NET] ' This starts the scan AIScan1.Start() [C#] // This starts the scan private void button1_Click(object sender, System.EventArgs e) { aiScan1.Start(); } 3.
Chapter 4 Getting Started with Measurement Studio [C#] // This stops the scan private void button2_Click(object sender, System.EventArgs e) { aiScan1.Stop(); } 5. Double-click the AIScan component to open the code window. 6. Add the following lines of code to the DataReady event of the aiScan1 component to copy the analog data to an array. [VB.NET] Private Sub AiScan1_DataReady(ByVal sender As Object, ByVal e As System.EventArgs) Handles AiScan1.DataReady WaveformGraph1.PlotY(AiScan.
Chapter 4 Getting Started with Measurement Studio 8. Select File»Save Form1.cs to save your application. 9. Select Debug»Start Without Debugging to run the application. 10. After your program builds and runs, click Start Scan. The following screenshot shows Form1 with the waveform graph displaying the acquired values. Walkthrough: Creating a Measurement Studio MCC-488.2 Application in Visual Studio .
Chapter 4 Getting Started with Measurement Studio • MCC-488.2 Library • Measurement Computing GPIB Device Setting up the project 1. Open Visual Studio .NET from Start»All Programs»Microsoft Visual Studio .NET 2003»Microsoft Visual Studio .NET 2003. 2. Select File»New»Project. The New Project dialog box launches. 3. In the Project Types pane, expand the Measurement Studio Projects folder.
Chapter 4 Getting Started with Measurement Studio 7. Click Finish to display Form1 in the Windows Forms Designer. Adding user interface controls to the project 1. Select View»Toolbox to display the Toolbox. The Toolbox contains components and controls that you can add to your project. 2. Select the Windows Forms tab. The Windows Forms tab contains controls and components included in the System.Windows.Forms namespace. 3. Select the Button control and drag and drop it onto the form. 4.
Chapter 4 Getting Started with Measurement Studio Generating and displaying the data 1. Double-click the button control to display the Form1 code, with the cursor inside the click event handler of the button control. 2. Add the following code to read a raw data point from a specified channel on the Measurement Computing device, convert the data to volts, and display the value on the graph. [VB.
Chapter 4 Getting Started with Measurement Studio ' convert the string to a double Dim D As Double = Convert.ToDouble(S.Replace(NlChar, NullChar)) 'Plot the point WaveformGraph1.PlotYAppend(D, 1) Next System.Runtime.InteropServices.Marshal.
Chapter 4 Getting Started with Measurement Studio The following screenshot shows Form1 with the graph displaying the acquired value.
Chapter 4 Getting Started with Measurement Studio Walkthrough: Creating a Measurement Studio Application with Windows Forms Controls and Analysis in Visual Studio 2005 Measurement Studio includes user interface controls, such as a waveform graph control and a gauge control, and analysis functionality such as signal generation and mathematical functions.
Chapter 4 3. 4. Getting Started with Measurement Studio In the Project types pane, select Measurement Studio under Visual C# or Visual Basic, depending on which language you want to create the project in. In the Templates pane, select NI Windows Application. Specify MyMeasurementStudioProject for Name and specify a Location of your choice. 5. Click OK. The Measurement Studio Application Wizard launches. 6. Select Analysis and Windows Forms User Interface Controls.
Chapter 4 Getting Started with Measurement Studio IIf you are working with an existing project, you can access the Add/Remove Class Libraries dialog box by selecting Measurement Studio»View .NET Class Library Wizard. Tip 7. Click Finish to display Form1 in the Windows Forms Designer. Measurement Studio for MCC User Manual 4-28 ni.
Chapter 4 Getting Started with Measurement Studio Adding user interface controls to the project In this section, you will build a user interface that looks like Form1 in the following screenshot. 1. Select View»Toolbox to display the Toolbox. The Toolbox contains components and controls that you can add to your project. 2. Expand the All Windows Forms group. The All Windows Forms group contains controls and components included in the System.Windows.Forms namespace. 3.
Chapter 4 Getting Started with Measurement Studio 7. Select the WaveformGraph control and drag and drop it onto the form. 8. Right-click the waveform graph and select Edit Plots to display the WaveformPlot Collection Editor dialog box. You use the WaveformPlot Collection Editor to add or remove plots and to configure plot properties. Measurement Studio for MCC User Manual 4-30 ni.
Chapter 4 Getting Started with Measurement Studio You can also access the WaveformPlot Collection Editor dialog box by clicking the waveform graph smart tag. You access the smart tag by right-clicking the arrow button in the upper right corner of the control. Note 9. Type Plot for the Name. Click OK. 10. Before you add the Measurement Studio legend, numeric edit, and gauge controls, you need to resize the form to accommodate them. Select the form and use the double-sided arrow to resize it. 11.
Chapter 4 Getting Started with Measurement Studio The following screenshot shows Form1 with the user controls. Measurement Studio for MCC User Manual 4-32 ni.
Chapter 4 Getting Started with Measurement Studio Generating, plotting, and analyzing the data 1. Double-click the button control to display the Form1 code, with the cursor inside the click event handler of the button control. 2. Add the following code to generate random data, plot the data, calculate the mean of the data, and display the mean on the gauge. [VB.NET] ' Declare and initialize an instance of WhiteNoiseSignal.
Chapter 4 Getting Started with Measurement Studio Customizing your user interface 1. Right-click the legend and select Edit Items to display the LegendItem Collection Editor dialog box. You use the LegendItem Collection Editor to add or remove legend items and to configure legend item properties. 2. Select Plot in the Source drop-down list and enter Signal in the Text box. Click OK. Now that you have specified a legend item for the plot, changes you make to the plot are reflected on the legend. 3.
Chapter 4 Getting Started with Measurement Studio 5. Click the gauge smart tag to display the Gauge Tasks. 6. Select Auto Format to display the Auto Format dialog box. 7. Select Dark and click OK. 8. Right-click the gauge and select Properties to display the Properties window. 9. Set the Range property for the gauge with the drop-down Range type editor. Type -0.2 for the minimum value and type 0.2 for the maximum value. 10. Click the numeric edit smart tag to display the Numeric Edit Tasks. 11.
Chapter 4 Getting Started with Measurement Studio 16. After your program builds and runs, click Start. Notice the graph shows the data plot, and the gauge and the numeric edit display the mean of the data. 17. The following screenshot shows Form1 with customization.
Chapter 4 • Getting Started with Measurement Studio Customizing the user interface—Using the Collection Editor and Auto Format dialog boxes, you will display the mean value on the gauge and the numeric edit, as well as customize your user interface. Before You Begin The following components are required to complete this walkthrough: • Microsoft Visual Studio 2005 • Measurement Studio Measurement Computing Edition Setting up the project 1.
Chapter 4 Getting Started with Measurement Studio 5. Click OK. The Measurement Studio ASP.NET Web Site Wizard launches. 6. Select Analysis and Web Forms User Interface Controls. If you are working with an existing project, you can access the Measurement Studio ASP.NET Web Site Wizard dialog box by selecting Measurement Studio»View .NET Class Library Wizard. Tip 7. Click Finish to display Default.aspx in the Web Forms Designer. Measurement Studio for MCC User Manual 4-38 ni.
Chapter 4 Getting Started with Measurement Studio Adding user interface controls to the project In this section, you will build a Web page that looks like the following screenshot. 1. Select View»Toolbox to display the Toolbox. The toolbox contains components and controls that you can add to your project. 2. Click Design to switch from Source View to Design View. 3. Select View»Toolbox to display the Toolbox. The toolbox contains components and controls that you can add to your project. 4.
Chapter 4 Getting Started with Measurement Studio 8. Scroll to the Text property in the Properties window. Type Start for the button text. 9. Select the Measurement Studio tab on the Toolbox. 10. Select the WaveformGraph control and drag and drop it into a table cell. 11. On the waveform graph smart tag, type graph for the name of the waveform graph ID. You access the smart tag by right-clicking the arrow button in the upper right corner of the control. Tip 12.
Chapter 4 Getting Started with Measurement Studio 14. On the numeric edit smart tag, type numericedit for the Name of the numeric edit ID. 15. Select the Gauge control and drag and drop it into a table cell. 16. On the gauge smart tag, type gauge for the Name of the gauge ID. The following screenshot shows the Web page with the user controls.
Chapter 4 Getting Started with Measurement Studio Generating, plotting, and analyzing the data 1. Double-click the button control to display the Default.aspx.cs code, with the cursor inside the click event handler of the button control. 2. Add the following code to generate random data, plot the data, calculate the mean of the data, and display the mean on the gauge. [VB.NET] ' Declare and initialize an instance of WhiteNoiseSignal.
Chapter 4 Getting Started with Measurement Studio [C#] // Declare and initialize an instance of WhiteNoiseSignal. WhiteNoiseSignal whiteNoise = new WhiteNoiseSignal(); // Store the generated data in a double array named data. double[] data = whiteNoise.Generate(1000.0, 256); // Use the PlotY method to plot the data. Plot.PlotY(data); // Use the Mean method to calculate the mean of the data. double mean = Statistics.Mean(data); // Display the mean on the gauge. gauge.
Chapter 4 Getting Started with Measurement Studio 3. Select graph, Plots[0] in the Source drop-down list and enter Signal in the Text box. Click OK. Now that you have specified a legend item for the plot, changes you make to the plot are reflected on the legend. 4. Right-click the graph and select Auto Format to display the Auto Format dialog box. The Auto Format dialog box provides a set of pre-configured control styles.
Chapter 4 Getting Started with Measurement Studio 7. Select Dark and click OK. 8. Right-click the gauge and select Properties to display the Properties window. 9. Set the Range property for the gauge with the drop-down Range type editor. Type -0.2 for the minimum value and type 0.2 for the maximum value. 10. Right-click the numeric edit and select Properties to display the Properties window. 11. Select Gauge in the Source drop-down list.
Chapter 4 Getting Started with Measurement Studio The following screenshot shows the Web page with customization. Measurement Studio for MCC User Manual 4-46 ni.
A Contacting Measurement Computing Corp. You can reach Measurement Computing Corp. through the following ways: Mail Measurement Computing Corp. 16 Commerce Blvd. Middleboro, MA 02346 Telephone 508-946-5100 FAX 508-946-9500 Technical Support techsupport@MeasurementComputing.com Sales sales@measurementcomputing.com Other correspondence info@measurementcomputing.com Visit our Web site at www.measurementcomputing.com.
Glossary A analog I/O Reading or writing data in continuously variable physical quantities, such as voltage or current. annotate Adding text, arrows, or shapes to describe or highlight a point or region on a graph. API Application Programming Interface. A specification of software functions and their input and return parameters. array control An array of Measurement Studio user interface controls that behave as a single unit.
Glossary coercion Automatic conversion that Measurement Studio controls perform to change the numeric representation of a data element. complex graph A control that displays a ComplexDouble data type; the ComplexDouble data type represents a complex number of type Double that is composed of a real part and an imaginary part.
Glossary distribution Ability to install programs you develop with Measurement Studio to others working on different computers. DLL Dynamic Link Library. A library of functions that link to a program and load at run time rather than being compiled into the program. Loading libraries only when they are needed saves memory in software applications. DMM Digital Multimeter. A common measurement instrument that measures resistance, current, and voltage in a wide variety of applications.
Glossary G gauge A control used to input or display numerical data. GPIB General Purpose Interface Bus. The standard bus used for controlling electronic instruments with a computer. Also called IEEE 488 bus because it is defined by ANSI/IEEE Standards 488-1978, 488.1-1987, and 488.2-1987. graph A 2D or 3D display of one or more plots. H HTTP HyperText Transfer Protocol. Protocol based on TCP/IP, which is used to download Web pages from an HTTP server to a Web browser.
Glossary L LED Light-Emitting Diode. An indicator that emits a light when current passes through it. For example, an LED shows if your computer or printer is turned on. legend A control that displays symbols and descriptions for a specific set of elements of another object, such as the plots or cursors of a graph. M matrix A rectangular array of numbers or mathematical elements that represent the coefficients in a system of linear equations. MB Megabytes of memory. MCC-488.
Glossary P PCI Peripheral Component Interconnect. High-performance expansion bus architecture commonly found in PCs. plot 1. Trace (data line) on a graph representing the data in one row or column of an array. 2. To display a new set of data while deleting any previous data on the graph. point Structure that contains two 16-bit integers that represent horizontal and vertical coordinates. postback The process in which a Web page sends data back to the same page on the server.
Glossary scatter graph A control that displays two-dimensional data on a Windows Forms or Web Forms user interface; displays a graph of X and Y data pairs. scope See oscilloscope. serial Standard serial bus on a computer used to communicate with instruments. Also known as RS-232. slide A control used to input or display numerical data. slider Moveable part of a slide control. smart tag A glyph attached to a Measurement Studio control or component that exposes commonly performed tasks.
Glossary V vector 1D array. VXI VME eXtension for Instrumentation. Instrumentation architecture and bus based on the VME standard. Used in high-end test applications. W waveform graph A control that displays two-dimensional data on a Windows Forms or Web Forms user interface; displays data that is uniformly spaced in one dimension. Measurement Studio for MCC User Manual G-8 ni.
Index A Measurement Studio MCC DAQ Application (walkthrough), 4-10 Measurement Studio MCC Scan Components Application (walkthrough), 4-16 new Measurement Studio project, 3-2 Add/Remove Class Libraries wizard, 3-3 adding or removing Measurement Studio class libraries, 3-3 Analysis .
Index I .NET class libraries Scan Components, 2-7 Universal Library, 2-7 NI Instrument Driver Network, 3-2 numeric controls, 2-15, 2-29 numeric edit .NET control, 2-17, 2-32 InstaCal, 3-1 installation optional, 1-2 requirements, 1-1 K knob .NET control, 2-16 .NET Web Forms control, 2-30 O overview Measurement Studio, 1-1 .NET class libraries, 2-1, 2-20 L LED array control, 2-21 LED control, 2-18, 2-33 legend control, 2-15, 2-29 P project templates, 3-2 property editor control, 2-19 M R MCC-488.2 .
Index U Creating a Measurement Studio Application with Windows Forms Controls and Analysis, 4-2 Creating a Measurement Studio Application with Windows Forms Controls and Analysis in Visual Studio 2005, 4-29 Creating a Measurement Studio MCC 488.