Text Based NI-DAQmx Data Acquisition Examples

Publish Date: Dec 20, 2012 | 18 Ratings | 2.89 out of 5 |  PDF

Table of Contents

Introduction

National Instruments high-performance data acquisition products include our premier NI-DAQmx driver, delivering increased performance and productivity in a variety of programming languages, including C#/Visual Basic .NET (VB .NET), Visual Basic 6.0 (VB 6), LabWindows/CVI and ANSI C/C++. The following text-based NI-DAQmx examples include both shipping and additional examples to help shorten your development time. These examples are divided by programming language and measurement type. Examples without links are shipping examples, and their locations are indicated under each section. Shipping examples may not be installed by default; support for C/C++ and/or .NET must be checked at the beginning of the NI-DAQmx driver installation process.

Choose Your Text Based Language

C#/Visual Basic.NET Visual Basic 6 CVI ANSI C
       

C#.NET and Visual Basic.NET (VB.NET)

We offer a number NI-DAQmx examples in C# and Visual Basic .NET (VB .NET).  In the following table, examples that are not linked are shipping examples.  Shipping examples are installed when you install NI-DAQmx and their default location is: 

  • Windows XP and Prior: C:\Documents and Settings\All Users\Shared Documents\National Instruments\NI-DAQ\Examples\ 
  • Windows Vista: C:\Users\Public\Public Documents\National Instruments\NI-DAQ\Examples. 
Analog Input Analog Output Counters Digital I/O Switches Control Synchronization Misc
Analog Input Measure Voltage Acquire One Voltage Sample
Acquire Voltage Samples - External Clock
Acquire Voltage Samples - Internal Clock
Acquire Voltage Samples - Internal Clock - Analog Start Trigger
Acquire Voltage Samples - Internal Clock - Digital Reference Trigger
Acquire Voltage Samples - Internal Clock - Analog Reference Trigger
Acquire Voltage Samples - Internal Clock - Digital Start and Reference Triggers
Acquire Multiple Voltage Samples - Software Timed
Continuously Acquire Voltage Samples - Internal Clock
Continuously Acquire Voltage Samples - Internal Clock - Software Trigger
Continuously Acquire Voltage Samples - Internal Clock - Save to File
Continuously Acquire Voltage Samples - Internal Clock - Pause Trigger
Continuously Acquire Voltage Samples - Internal Clock - Analog Start
Continuously Acquire Voltage Samples - External Clock
Continuously Acquire Voltage Samples - External Clock - Digital Start
Continuously Acquire Voltage Samples - Software Timed
Continuously Acquire Voltage Samples - Configure Filter - SCXI 114x
Measure Temperature Continuously Acquire RTD Samples - Internal Clock
Continuously Acquire Thermocouple Samples - Internal Clock
Continuously Acquire Thermocouple Samples - Software Timed
Measure Strain Acquire Strain Samples
Acquire Wheatstone Bridge Samples
Measure Sound Pressure Continuously Acquire Sound Pressure Samples
Rotary Position Continuously Acquire RVDT Samples - Internal Clock
Linear Position Continuously Acquire LVDT Samples - Internal Clock
Frequency Continuously Acquire Frequency - Internal Clock - SCXI 1126
Current Continuously Acquire 20mA Current Samples - Internal Clock
Acceleration Continuously Acquire Acceleration Sample - Internal Clock - Analog Start
Analog Output Generate Voltage Continuously Generate Voltage Waveform - Internal Clock
Continuously Generate Voltage Waveform - Internal Clock - Analog Start
Continuously Generate Voltage Waveform - External Clock
Continuously Generate Voltage Waveform - External Clock - Digital Start
Generate Multiple Voltage Updates - Internal Clock
Generate Multiple Voltage Updates - Internal Clock - Digital Clock
Generate Multiple Voltage Updates - Software Timed
Generate Voltage Update
Counters Count Digital Events Count Digital Events
Count Digital Events - Pause Trigger
Count Digital Events - Finite Buffered - External Clock
Count Digital Events - Continuous Buffered - External Clock
Measure Period or Pulse Width Measure Semi Period - Buffered Finite
Measure Single Semi-Period
Measure Single Period - Low Frequency - 1 Counter
Measure Digital Periods - Buffered Continuous - High Frequency - 2 Counters
Measure Pulse Width
Measure Pulse Width - Buffered Continuous - Sample Clock
Measure GPS Timestamp Measure GPS Timestamp
Measure Position Measure Angular Position - Buffered Continuous - External Clock
Measure Digital Frequency Measure Digital Frequency - Buffered Continuous - Large Range - 2 Counters
Measure Digital Frequency - Low Frequency - 1 Counter
Measure Two Edge Separation Measure Two Edge Separation
Measure Two Edge Separation - Buffered Continuous
Generate Pulse Generate Digital Pulse
Generate Single Pulse - Retriggerable
Generate Single Pulse - Digital Start Trigger
Generate Digital Pulse Train - Finite
Generate Digital Pulse Train - Finite - Retriggerable
Generate Digital Pulse Train - Finite - Digital Start Trigger
Generate Digital Pulse Train - Continuous
Generate Digital Pulse Train - Continuous - Digital Start
Generate Digital Pulse Train - Continuous - Pause Trigger
Digital I/O Generate Values Write Digital Port
Write Digital Channel
Write Digital Channel - External Clock
Write Digital Channel - Watchdog Timer
Continuously Write Digital Channel - Burst
Continuously Write Digital Channel - Pipe Sample Clock
Continuously Write Digital Channel - Pipe Sample Clock with Handshake
Read Values Read Digital Port
Read Digital Port - External Clock
Read Digital Channel
Read Digital Channel - Change Detection
Read Digital Channel - Change Detection - Digital Filter
Read Digital Channel - Change Detection - Events
Read Digital Channel - Internal Clock - Pattern Match Start
Continuously Read Digital Channel - External Clock
Continuously Read Digital Channel - Pipe Sample Clock with Handshake
Switches   Switch Connect - 2 Channels
Switch Connect - Multiple Channels
Sequence Connections On Switch
Switch Controlling Individual Relay
Switch Scanning - Software Trigger
Control General PWM Counter Output
Synchronization Multi-Function Synchronize Analog Input and Read Digital Channel
Synchronize Analog Input and Analog Output - Digital Start
Multi-Device Analog Input Finite Acquisition
Analog Input Continuous Acquisition
Analog Input and Analog Output Shared Timebase and Trigger - DSA
Other Advanced Topics Properties List DAQmx Devices Present in System

Browse NI Developer Zone for More Examples...

Visual Basic 6.0 (VB 6)

The following is a list of our NI-DAQmx examples for Visual Basic 6.0.  The default install directory is for shipping examples is C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0.

Analog Input Measure Voltage
Measure Slow Varying Signal
Analog Output Generate Voltage
Counter Count Digital Events
Generate Pulse
Digital I/O Generate Values
Read Values

Browse NI Developer Zone For More Examples...

LabWindows/CVI

The default installation directory for LabWindows/CVI examples is C:\Documents and Settings\All Users\Documents\National Instruments\CVI\samples\DAQmx.

Analog Input Analog Output Counters Digital I/O Switches Control Synchronization
Analog Input Measure Voltage Acquire One Voltage Sample
Acquire Voltage Samples - External Clock
Acquire Voltage Samples - Internal Clock
Acquire Voltage Samples - Internal Clock - Analog Start Trigger
Acquire Voltage Samples - Internal Clock - Digital Reference Trigger
Acquire Voltage Samples - Internal Clock - Digital Start and Reference Triggers
Acquire Multiple Voltage Samples - Software Timed
Continuously Acquire Voltage Samples - Internal Clock
Continuously Acquire Voltage Samples - Internal Clock - Digital Pause Trigger
Continuously Acquire Voltage Samples - Internal Clock - Analog Start
Continuously Acquire Voltage Samples - External Clock - Digital Start
Continuously Acquire Voltage Samples - Software Timed
Measure Temperature Continuously Acquire RTD Samples - Internal Clock
Continuously Acquire Thermocouple Samples - Internal Clock
Measure Strain Continuously Acquire Strain Samples
Measure Sound Pressure Continuously Acquire Sound Pressure Samples - Internal Clock
Rotary Position Continuously Acquire RVDT Samples - Internal Clock - SCXI 1540
Linear Position Continuously Acquire LVDT Samples - Internal Clock - SCXI 1540
Frequency Continuously Acquire Frequency - Internal Clock - SCXI 1126
Current Continuously Acquire 20mA Current Samples - Internal Clock
Acceleration Continuously Acquire Acceleration Sample - Internal Clock - Analog Start
Analog Output Voltage Generate Single Sample
Multiple Voltage Updates - Internal Clock
Multiple Voltage Updates - Internal Clock - Digital Start
Multiple Voltage Updates - Internal Clock - Done Event
Multiple Voltage Updates - Software Timed
Continuously Generate Voltage - Internal Clock
Continuously Generate Voltage - Internal Clock - Analog Start
Continuously Generate Voltage - External Clock
Continuously Generate Voltage - External Clock - Digital Start
Current Multiple Current Updates - Internal Clock
Continuously Generate Current - Internal Clock
Generate 20mA Current
Counters Count Digital Events Count Digital Events
Continuously Count Digital Events - Buffered - External Clock
Digital Frequency Measure Digital Frequency - Low Frequency - 1 Counter
Measure Digital Frequency - Buffered - Continuous - Large Range - 2 Counters
GPS Time Stamp GPS Timestamp
GPS Timestamp - Finite - Buffered
Period of Pulse Width Measure Pulse Width
Measure Pulse Width - Buffered - Sample Clock
Measure Digital Periods - Buffered - Continuous - High Frequency - 2 Counters
Measure Semi Period - Buffered - Finite
Position Measure Angular Position - Buffered - Continuous
Two-Signal Edge-Separation Measure Two Edge Separation - Buffered - Continuous
Measure Two Edge Separation
Generate Digital Pulses Generate Digital Pulse
Generate Digital Pulse Train - Continuous
Generate Digital Pulse Train - Continuous - Digital Start
Generate Digital Pulse Train - Continuous - Pause Trigger
Digital I/O Generate Values Write Digital Port
Write Digital Channel
Write Digital Channel - Watchdog Timer
Write Digital Channel - External Clock
Continuously Write Digital Port - External Clock
Continuously Write Digital Channel - Burst
Continuously Write Digital Channel - Pipe Sample Clock with Handshaking
Digital Measurements Read Digital Port
Read Digital Port - External Clock
Read Digital Channel
Read Digital Channel - Internal Clock - Digital Reference Trigger
Read Digital Channel - Change Detection
Read Digital Channel - Change Detection Event
Read Digital Channel - Change Detection - Digital Filter
Continuously Read Digital Channel - External Clock
Continuously Read Digital Channel - Pipe Sample Clock with Handshake
Switches   Connect Multiple Channels
Connect Two Channels
Control Individual Relay
Sequence Connections On Switch
Switch Scan - Software Trigger
Control General PID Control - Single Channel
PWM - Counter Output
Synchronization Multi-Device Continuous Analog Input
DSA Shared Timebase and Triggered Analog Input and Analog Output
Finite Analog Input
Multi-Function Continuous Analog Input and Read Digital Channel

Browse NI Developer Zone For More Examples...

ANSI C

The default installation directory for ANSI C examples is:

  • Windows XP and Prior: C:\Documents and Settings\All Users\Shared Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C 
  • Windows Vista: C:\Users\Public\Public Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.
Analog Input Analog Output Counters Digital I/O Switches Synchronization
Analog Input Measure Voltage Acquire One Voltage Sample
Acquire Voltage Samples - External Clock
Acquire Voltage Samples - Internal Clock
Acquire Voltage Samples - Internal Clock - Analog Start Trigger
Acquire Voltage Samples - Internal Clock - Digital Reference Trigger
Acquire Voltage Samples - Internal Clock - Digital Start and Reference Triggers
Acquire Multiple Voltage Samples - Software Timed
Continuously Acquire Voltage Samples - Internal Clock
Continuously Acquire Voltage Samples - Internal Clock - Digital Pause Trigger
Continuously Acquire Voltage Samples - Internal Clock - Analog Start
Continuously Acquire Voltage Samples - External Clock - Digital Start
Continuously Acquire Voltage Samples - Software Timed
Measure Temperature Continuously Acquire RTD Samples - Internal Clock
Continuously Acquire Thermocouple Samples - Internal Clock
Measure Strain Continuously Acquire Strain Samples
Measure Sound Pressure Continuously Acquire Sound Pressure Samples - Internal Clock
Rotary Position Continuously Acquire RVDT Samples - Internal Clock - SCXI 1540
Linear Position Continuously Acquire LVDT Samples - Internal Clock - SCXI 1540
Frequency Continuously Acquire Frequency - Internal Clock - SCXI 1126
Current Continuously Acquire 20mA Current Samples - Internal Clock
Acceleration Continuously Acquire Acceleration Sample - Internal Clock - Analog Start
Analog Output Voltage Generate Single Sample
Multiple Voltage Updates - Internal Clock
Multiple Voltage Updates - Internal Clock - Digital Start
Multiple Voltage Updates - Software Timed
Continuously Generate Voltage - Internal Clock
Continuously Generate Voltage - Internal Clock - Analog Start
Continuously Generate Voltage - External Clock
Continuously Generate Voltage - External Clock - Digital Start
Current Multiple Current Updates - Internal Clock
Continuously Generate Current - Internal Clock
Generate 20mA Current
Counters Count Digital Events Count Digital Events
Continuously Count Digital Events - Buffered - External Clock
Digital Frequency Measure Digital Frequency - Low Frequency - 1 Counter
Measure Digital Frequency - Buffered - Continuous - Large Range - 2 Counters
GPS Time Stamp GPS Timestamp
GPS Timestamp - Finite - Buffered
Period of Pulse Width Measure Pulse Width
Measure Pulse Width - Buffered - Sample Clock
Measure Digital Periods - Buffered - Continuous - High Frequency - 2 Counters
Measure Semi Period - Buffered - Finite
Position Measure Angular Position - Buffered - Continuous
Two-Signal Edge-Separation Measure Two Edge Separation - Buffered - Continuous
Measure Two Edge Separation
Generate Digital Pulses Generate Digital Pulse
Generate Digital Pulse Train - Continuous
Generate Digital Pulse Train - Continuous - Digital Start
Generate Digital Pulse Train - Continuous - Pause Trigger
Digital I/O Generate Values Write Digital Port
Write Digital Channel
Write Digital Channel - Watchdog Timer
Write Digital Channel - External Clock
Continuously Write Digital Port - External Clock
Continuously Write Digital Channel - Burst
Continuously Write Digital Channel - Pipe Sample Clock with Handshaking
Digital Measurements Read Digital Port
Read Digital Port - External Clock
Read Digital Channel
Read Digital Channel - Internal Clock - Digital Reference Trigger
Read Digital Channel - Change Detection
Read Digital Channel - Change Detection - Digital Filter
Continuously Read Digital Channel - External Clock
Continuously Read Digital Channel - Pipe Sample Clock with Handshake
Switches   Connect Multiple Channels
Connect Two Channels
Control Individual Relay
Sequence Connections On Switch
Switch Scan - Software Trigger
Synchronization Multi-Device Continuous Analog Input
DSA Shared Timebase and Triggered Analog Input and Analog Output
Finite Analog Input
Multi-Function Continuous Analog Input and Read Digital Channel

Browse NI Developer Zone For More Examples...

Code Generation DAQ Assistant with LabWindows/CVI and Measurement Studio 

The DAQ Assistant is provided when using Measurement Studio or LabWindows/CVI with NI-DAQmx. The DAQ Assistant is a graphical, interactive guide for configuring, testing, and acquiring measurement data. With a single click, you can generate code based on your configuration, making it easier and faster to develop complex operations. Because the DAQ Assistant is completely menu-driven, the time from setup to first measurement can be drastically reduced.

 

Additional Resources

Try LabWindows/CVI

Try Measurement Studio

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit