Example Code

Triggering a Counter and Analog Input Simultaneously

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Driver

  • NI DAQmx
  • NI Vision Acquisition Software

Code and Documents

Attachment

Description

Overview
The example demonstrates how to trigger a counter and analog input simultaneously using DAQmx and Arm Start triggers.

Description:

This example utilises an Arm Start trigger on the Gate of a counter to trigger a counter and one or more analog inputs.

Steps to implement or execute code

To implement this example (Assuming that you use counter 0 and the analog input 0):

  1. Place a DAQmx Create Virtual Channel VI to create your counter and analog task.
  2. Use the DAQmx Timing VI to define your sampling mode, sample rate and clock source.
  3. On the counter task, place a DAQmx Trigger Property Node.
    1. Expand the Property Node to show ArmStart.DigEdge.Source, ArmStart.DigEdge.Edge and ArmStart.TrigType.
    2. Set their values as follows:
      • ArmStart.DigEdge.Source to the gate of ctr0.
      • ArmStart.DigEdge.Edge to Rising.
      • ArmStart.TrigType to Digital Edge.
  4. In parallel, place a DAQmx Trigger VI in the analog task.
    1. Configure it for a Start Digital Edge trigger type.
    2. Connect The Source input to ArmStart.DigEdge.Source.
    3. Connect the Edge input to ArmStart.DigEdge.Edge.
  5. Start both tasks with the DAQmx Start Task VI.
    1. use a Flat Sequence Structure to ensure that both tasks start at the same time.
  6. For each task, place a While Loop consisting of a DAQmx Read VI to acquire your data.
  7. After each While Loop, place a DAQmx Stop VI and DAQmx Clear VI to stop and clean up the tasks.

 

To execute this example:

  1. Install the required software.
  2. Connect the DAQ hardware that supports the counter and analog input features.
  3. Confirm the connection with the NI Measurement & Automation Explorer (MAX).
  4. Open the VI and run it.


Requirements
Software:
LabVIEW 2012 or compatible
NI-DAQmx 16.0 or compatible

Hardware:
cDAQ with C series Counter Input Module and analog input module or compatible DAQ devices.

 

2017-10-31_10-23-18.jpg2017-10-31_10-23-35.jpg

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.