Example Code

Synchronize Two Counters using a Dummy AI and an Arm Start Trigger

Code and Documents

Attachment

Overview


This example shows you how to synchronize two counter inputs using a dummy analog input and an arm start trigger. This is useful for E and M series cards where you do not have a third counter to use for synchronization of the others.

I. Description:
This example shows you how to synchronize two counter inputs using a dummy analog input and an arm start trigger. This is useful for E and M Series cards where you do not have a third counter to use for synchronization of the others. The dummy analog input is basically an analog input task that is created but the data is not being read or used. This is done because you can use the aiSampleClock of this analog input to synchronize the two counter tasks.

II. Instructions for Running:
1. Select the Physical Channel for the First and Second Counters as well as for the Dummy AI that you will be using on your device.
2. Select the ai/SampleClock that you would like to use for synchronizing the counter tasks.
3. Select the Trigger Source and Software Trigger Line for your device. These two inputs should share a pin on the device and this can be verified by checking the Device Pinouts of the device. (The default for most E and M Series devices is Port1/Line0).

III. Block Diagram Steps:
1. Create a Counter Input channel.
2. Call the DAQmx Timing VI (Sample Clock) to configure the external sample clock timing parameters such as Sample Mode and Sample Clock Source. The Sample Clock Source determines when a sample will be inserted into the buffer. The 100kHz, 20MHz, and 80MHz timebases cannot be used as the Sample Clock Source. The Edge parameter can be used to determine when a sample is taken.
3. Use the DAQmx Trigger property node to configure a Digital Edge Arm Start Trigger. The Trigger Edge determines if a rising or falling edge will start the counter. The Trigger Source determines the location of the Arm Start Trigger.
4. Call the Start VI to arm the counter. The counter will begin counting edges when the Arm Start Trigger occurs.
5. Writes a signal to Port1/line0 which is routed to PFI0. PFI0 is being monitored by the ArmStart Trigger from Step 3. This begins the acquisition for the two counter tasks.
6. For continuous measurements, the counter will continually read all available data until the Stop button is pressed on the front panel.
7. Call the Clear Task VI to clear the Task.
8. Use the popup dialog box to display an error if any.

IV. Connections Overview:
Make sure the Pinouts for your particular device shows that PFI0 and Port1/line0 share a pin or the software trigger will not work. For further connection information, refer to your hardware reference manual.

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

Contributors