简体   繁体   中英

NI DAQmx — How to configure software trigger?

I can't for the life of me figure out how to enable a software trigger using National Instruments DAQ mx. Documentation vaguely mentions properties, or that it can only be used with a switch device, but it's very incomplete. The one example page on the NI website is completely blank, of course. I don't have or want LabView.

I'm just trying to set it up so it acquires and generates 1000 samples simultaneously. There is lots of documentation for analog or digital hardware trigger, but I just want to be able to start the generation/acquisition on the same software instruction.

If I issue two sequential instructions (one for generate samples, one for acquire samples) it's probably good enough, but I'd really like to do it properly, as I don't know the timing skew between starting two tasks.

So how do I generate a software trigger to start 2 tasks simultaneously?

BTW I'm using PyDAQmx with a USB6363 device on Windows 7 x64.

Thanks

Measurement Synchronization

In order to have a single event start two tasks simultaneously, the two subsystems must be electrically synchronized. There are two ways to synchronize subsystems, and both require sharing a different electric signal:

  1. Synchronized start
  2. Synchronized sampling

With just the first, the two tasks will start at the same moment, but their individual clocks may skew or drift as time passes. When on the same device, like in your situation, drift is impossible since there is only one oscillator on the device. A single device is always self-coherent in time; in other words, a single device already has synchronized sampling. When synchronizing different devices, both the start trigger and the sample clock signals must be shared.

Synchronized Start

In order to electrically synchronize the start of two tasks, they must use the same start trigger signal, which can be programmed from the DAQmx API using the device's internal signal names [1] .

In your example, you want to start the analog input and analog output tasks on a software event. The AI and AO subsystems must first be electrically coupled, and then the software event can trigger both to start.

I realize you're using PyDAQmx, but here is the pseudocode in C (the official API):

TaskHandle analogInputHandle;
TaskHandle analogOutputHandle;

// Other configuration...

// Connect AO start to AI start
DAQmxCfgDigEdgeStartTrig(analogOutputHandle, "ai/StartTrigger", DAQmx_Val_Rising);

// Arm the AO task
// It won't start until the start trigger signal arrives from the AI task
DAQmxStartTask(analogOutputHandle);

// Start the AI task
// This generates the AI start trigger signal and triggers the AO task
DAQmxStartTask(analogInputHandle);    

In this way, the AI and AO subsystems have been configured to use the ai/StartTrigger signal to begin their tasks, and when the program starts the AI task, the device generates a pulse on-demand and the two measurements begin together.

[1] NI-DAQmx Help :: Terminal Names
http://zone.ni.com/reference/en-XX/help/370466V-01/TOC22.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM