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:
- Synchronized start
- 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