Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
20 ratings:
 2.10 out of 5     Rate this Document

Programming NI-DAQ in Microsoft Visual Studio .NET

Primary Software: Measurement Studio>>Visual C++ Support
Primary Software Version: 7.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Multifunction DAQ (MIO)

Problem:
What options do I have when programming NI-DAQ in Visual Basic .NET?

Solution:
Refer to the following table when you are using Visual Studio .NET and the NI-DAQ Driver (Traditional or NI-DAQmx) to determine if you can create a NI-DAQ application, whether you have Measurement Studio installed or not. You can follow the links on the table itself or use the links at the bottom of the page for more information about options with other languages and environments.
  • Measurement Studio For Visual Studio.NET provides native .NET Framework and MFC Visual C++ libraries for advanced analysis, scientific user interface controls, and measurement data networking. Measurement Studio for Visual Studio .NET also provides code generation and integration tools, all for use with Microsoft Visual Studio 2005. Refer to this column if you are developing an NI-DAQ application using Visual Studio .NET 2005 and you have Measurement Studio 7.0 or later.
  • Measurement Studio Support for Visual Studio 6.0 provides ActiveX controls, MFC Visual C++ libraries and integration tools for use with Visual C++ 6.0 and Visual Basic 6.0. This support is available as a part of Measurement Studio 7.0 or later in the Professional or Enterprise package. Refer to this column if you are developing an NI-DAQ application using Visual Basic 6.0 or Visual C++ 6.0 and you have Measurement Studio Support for Visual Studio 6.0 installed. This was previously available as Measurement Studio 6.0.
  • Visual Studio only (without Measurement Studio) refers to the development options available to you if you have Visual Studio installed, but not Measurement Studio. In other words, you use Visual Studio .NET 2003 or higher for developing DAQ applications using Visual Basic .NET.


Measurement Studio for Visual Studio .NET Measurement Studio Support for Visual Studio 6.0 Visual Studio only
(without Measurement Studio)
Visual Basic .NET Traditional NI-DAQ Possible N/A Possible
NI-DAQmx Optimal N/A Yes
OPTIMAL: Project wizards, code generation, and configuration tools are provided to accelerate DAQ application development.
YES: Native components are provided for this purpose and shipping examples are included.
NO: The component is not designed for this environment and its use in that environment is not supported by National Instruments. Refer to the link for more information.
POSSIBLE: The component was not designed to work natively in that environment, but it is possible to use these components in the required environment by using wrappers or manual configuration. For example, you can access ActiveX controls in Visual C# or Visual Basic .NETby using Runtime Callable Wrappers, or you can manually set up a Visual C++ project to use C import libraries. Refer to the link for more information.
N/A: The particular Measurement Studio package does not provide support for the particular language. Refer to the link for more information.


Visual Basic .NET with Measurement Studio for Visual Studio .NET 2003

  1. Traditional NI-DAQ
    • National Instruments does not include native .NET libraries for Traditional NI-DAQ. Measurement Studio Support for Visual Studio .NET 2003 will not provide you any additional functionality for developing Traditional NI-DAQ applications in Visual Studio .NET 2003.
    • You can use the Traditional NI-DAQ ActiveX controls to perform data acquisition. The ActiveX controls are provided with the Traditional NI-DAQ Driver and do not require Measurement Studio. The CWDAQ control is installed as a part of the Traditional NI-DAQ Driver. Refer to the Visual Basic .NET without Measurement Studio section for information on how to use the Traditional NI-DAQ ActiveX controls with Visual C#.

  2. NI-DAQmx
    • Measurement Studio support for Visual Studio .NET provides native .NET class libraries, integration tools, and code generation tools for NI-DAQmx and Visual Studio .NET 2003. For example, Measurement Studio adds the DAQ Assistant for code generation, integrated Visual Studio help, and project wizards. You can also add native .NET graphs, tanks, and other Measurement Studio user interface controls to these projects for added functionality.
    • You can find examples in the following default directory location:

      1. Example programs are located according to the Operating System and version of NI-DAQmx used:
           

        • For NI-DAQmx versions prior to NI-DAQmx 8.5 examples are stored in C:\Program Files\National Instruments\DotNET\Examples\DAQmx. Sub-folders named VB contain Visual Basic.NET examples, and sub-folders named CS contain C# examples. If the example directory path does not exist, make sure you have .NET support installed for NI-DAQmx.
        • Starting with NI-DAQ version 8.5, the .NET example paths have changed. In the following paths, x is the letter of the hard drive. The .NET example paths for Windows Vista are x:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1 and x:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0.
        • The .NET example paths for Windows XP and Windows 2000 are x:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1 and x:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0.
      2. Double-click the .vbproj file to open the project.

Visual Basic .NET with Measurement Studio Support for Visual Studio 6.0
Note: You must have Visual Studio 6.0 to install Measurement Studio Support for Visual Studio 6.0.

  1. Traditional NI-DAQ

    • National Instruments does not provide native .NET class libraries for Traditional NI-DAQ. Measurement Studio Support for Visual Studio 6.0 will not provide you any additional functionality for developing Traditional NI-DAQ applications using Visual C#.
    • You can find examples in the following default directory location: C:\Program Files\National Instruments\VB\Samples\DAQ. These examples are written for Visual Basic 6.0, but by using the Visual Basic .NET conversion wizard (a Visual Studio .NET 2003 tool), the projects in these folders can be upgraded to Visual Basic.NET. The following steps explain how to upgrade a project:

      1. Open Visual Studio .NET.
      2. Select File » Open » Project
      3. Browse to the example folder, then to the specific example you want to convert.
      4. The wizard will walk you through the steps needed to upgrade the project.
      5. Once the project has been successfully upgraded (you might have a few warnings, but the program should still compile and run), the program should run as if you were using Visual Basic 6.0.

    Note: You must have Visual Studio 6.0 installed in order to install Measurement Studio Support for Visual Studio 6.0; then you can use Measurement Studio 6.0 ActiveX controls designed for Visual Basic 6.0 to add graphs, sliders, etc., to your project in Visual Basic .NET. National Instruments recommends using Measurement Studio for Visual Studio .NET 2003 for Visual Basic .NET, which provides .NET native user interface controls you can add to the example.

  2. NI-DAQmx

    • Measurement Studio Support for Visual Studio 6.0 will not provide you any additional functionality for developing NI-DAQmx applications in Visual Basic.NET. If you would like to use NI-DAQmx, refer to the Visual Basic.NET without Measurement Studio section.

Visual Basic .NET without Measurement Studio

  1. Traditional NI-DAQ

    • National Instruments does not include native .NET components for Traditional NI-DAQ.
    • Use the Traditional NI-DAQ ActiveX control CWDAQ to create NI-DAQ applications. This is provided as a part of the Traditional NI-DAQ installer and does not require Measurement Studio.
    • To use the CWDAQ ActiveX control from Visual Basic .NET, you can create a new Visual Basic .NET project and add the CWDAQ ActiveX Controls to a .NET project using the following steps:

      1. With the .NET project open, select View » Toolbox. The toolbox will appear.
      2. Right-click the toolbox and select Add/Remove Items. The Customize Toolbox will appear.
      3. Select the COM Components tab.
      4. On this tab, you can select the specific CWDAQ control you wish to use, and click OK.
      5. The control you selected will now show up in the toolbox, where you can select it and drop it onto the form, the same as if you were in Visual Basic 6.0.

  2. NI-DAQmx

    • National Instruments provides a native .NET API for NI-DAQmx. This is available as a part of the NI-DAQmx driver and does not require Measurement Studio.
    • You can find examples in the following default directory location:

      1. Example programs are located according to the Operating System and version of NI-DAQmx used:

        • For NI-DAQmx versions prior to NI-DAQmx 8.5 examples are stored in C:\Program Files\National Instruments\DotNET\Examples\DAQmx. Sub-folders named VB contain Visual Basic.NET examples, and sub-folders named CS contain C# examples. If the example directory path does not exist, make sure you have .NET support installed for NI-DAQmx.
        • Starting with NI-DAQ version 8.5, the .NET example paths have changed. In the following paths, x is the letter of the hard drive. The .NET example paths for Windows Vista are x:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1 and x:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0.
        • The .NET example paths for Windows XP and Windows 2000 are x:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1 and x:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0.

      2. Double-click the .vbproj file to open the project.


Related Links:
KnowledgeBase 317742FQ: Programming NI-DAQ in Text-Based Languages
KnowledgeBase 3146J6FQ: Programming DAQ in Visual Basic 6.0
KnowledgeBase 317BPGW3: Programming DAQ in Visual C++ 6.0
KnowledgeBase 317CP7W3: Programming DAQ in Visual C++ .NET
KnowledgeBase 3186P9W3: Programming DAQ in Visual C# .NET

Attachments:





Report Date: 09/08/2003
Last Updated: 12/07/2007
Document ID: 3178NEFQ

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit