08-19-2010 03:17 AM
I need to synchronize changing an Analog output Dev1/ao0 on my PXI-6289 DAQmx with an acquisition on another instrument in the PXI. Unfortunately, most of the documentation and examples I've found give more details on how to acquire rather than generate a trigger. I have been experimenting with two methods.
1) Just specify the AO channel in setting up the task:
const char *outputTerminal = "PXI_Trig5";
TaskHandle H2LtaskHandle=0;
char ao_chan[256] = "Dev1/ao0";
char do_chan[256] = "Dev1/port0/line0";
.
.
.
error = DAQmxCreateTask("",&H2LtaskHandle);
error = DAQmxCreateAOVoltageChan (H2LtaskHandle, ao_chan, "", 0.0, 5.0, DAQmx_Val_Volts, NULL);
// error = DAQmxSetOnDemandSimultaneousAOEnable(H2LtaskHandle, 1); // I'm a little confused on this command
error = DAQmxWriteAnalogScalarF64 (H2LtaskHandle, 1, 1.0, 2.800, 0);
error = DAQmxExportSignal (H2LtaskHandle, DAQmx_Val_StartTrigger, outputTerminal);
error = DAQmxStartTask (H2LtaskHandle);
.
.
.
DAQmxStopTask(H2LtaskHandle);
DAQmxClearTask(H2LtaskHandle);
2) Add an unused DO channel to the task to generate the trigger on the backplane:
const char *outputTerminal = "PXI_Trig5";
TaskHandle H2LtaskHandle=0;
char ao_chan[256] = "Dev1/ao0";
char do_chan[256] = "Dev1/port0/line0";
.
.
.
error = DAQmxCreateTask("",&H2LtaskHandle);
error = DAQmxCreateDOChan (H2LtaskHandle, "DAQ/port0/line0", "", DAQmx_Val_ChanPerLine);
error = DAQmxCfgDigEdgeStartTrig (H2LtaskHandle, outputTerminal, DAQmx_Val_Rising);
error = DAQmxCreateAOVoltageChan (H2LtaskHandle, ao_chan, "", 0.0, 5.0, DAQmx_Val_Volts, NULL);
error = DAQmxWriteAnalogScalarF64 (H2LtaskHandle, 1, 1.0, 2.800, 0);
error = DAQmxStartTask (H2LtaskHandle);
.
.
.
DAQmxStopTask(H2LtaskHandle);
DAQmxClearTask(H2LtaskHandle);
The first method runs error free, but the other instrument does not see the trigger. The second method still has some errors.
Any advice is appreciated!
Thanks in advance,
Sam Broyles
08-19-2010 05:42 PM - edited 08-19-2010 05:42 PM
Hi sam.broyles,
This KB addresses this topic in LabVIEW.
You can use these functions in C just the same as the VIs from that KB. Basically call DAQmxConnectTerms before you start your task and DAQmxDisconnectTerms after you clear your task.
int32 DAQmxConnectTerms (const char sourceTerminal[], const char destinationTerminal[], int32 signalModifiers);
int32 DAQmxDisconnectTerms (const char sourceTerminal[], const char destinationTerminal[]);
Then open Measurment & Automation Explorer and open the Device Routes.
This will show you which routes can be made. You'll have to pick an output to send a pulse to your PXI_Trig line. This will most likely be a counter, or you could use a dummy task and re-route the start trigger from that task.
I hope this helps out!
Regards,