08-04-2011 02:37 PM
Hi,
I am trying to synchronize two M-series USB devices - NI USB 6211 and NI USB 6218. I want to use the PFI lines to share start trigger and sample clock.I am trying to export the start trigger for 6211 to PFI0 and then physically connect PFI0 of device 6211 to PFI0 of device 6218 and use PFI0 of device 6218 as it start trigger source.
The following code is trying to share just the trigger lines.
/*********************************************************************
*
* ANSI C Example program:
* ContinuousAI.c
*
* Example Category:
* Sync
*
*********************************************************************/
#include <string.h>
#include <stdio.h>
#include <NIDAQmx.h>
static TaskHandle masterTaskHandle=0,slaveTaskHandle=0;
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
static int32 GetTerminalNameWithDevPrefix(TaskHandle taskHandle, const char terminalName[], char triggerName[]);
int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
int main(void)
{
int32 error=0;
char errBuff[2048]={'\0'};
char str1[256],str2[256],trigName[256];
float64 clkRate;
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&masterTaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(masterTaskHandle,"Dev11/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(masterTaskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
DAQmxErrChk (DAQmxCreateTask("",&slaveTaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(slaveTaskHandle,"Dev12/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(slaveTaskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
DAQmxErrChk (DAQmxExportSignal(masterTaskHandle,DAQmx_Val_StartTrigger,"PFI0"));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(slaveTaskHandle,"PFI0",DAQmx_Val_Rising));
DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(masterTaskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
DAQmxErrChk (DAQmxRegisterDoneEvent(masterTaskHandle,0,DoneCallback,NULL));
/*********************************************/
// DAQmx Start Code
/*********************************************/
// The slave device is armed before the master so that the slave device does
// not miss the trigger.
DAQmxErrChk (DAQmxStartTask(slaveTaskHandle));
DAQmxErrChk (DAQmxStartTask(masterTaskHandle));
printf("Acquiring samples continuously. Press Enter to interrupt\n");
printf("\nRead:\tMaster\tSlave\tTotal:\tMaster\tSlave\n");
getchar();
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
/*********************************************/
// DAQmx Stop Code
/*********************************************/
if( masterTaskHandle ) {
DAQmxStopTask(masterTaskHandle);
DAQmxClearTask(masterTaskHandle);
masterTaskHandle = 0;
}
if( slaveTaskHandle ) {
DAQmxStopTask(slaveTaskHandle);
DAQmxClearTask(slaveTaskHandle);
slaveTaskHandle = 0;
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit");
getchar();
return 0;
}
I get the following error
NI Error -89136:
Specified route cannot be satisfied, because the hardware does not support it.
Property: DAQmx_Exported_StartTrig_OutputTerm
Destination Device: Dev5
Destination Terminal: PFI0
Task Name: _unnamedTask<12F4>
Status Code: -89136
when i start the task. How can I export the start trigger for my task to a PFI? I checked the Device routes and it seems that /Dev5/ai/StartTrigger has a direct connection to PFI0 and I should be able to export the task's start trigger ( which I think should be /Dev5/ai/StartTrigger , since the task contains ai channel). Is this analysis correct?
Thanks,
Regards,
Manisha Singh
The MathWorks
Solved! Go to Solution.
08-05-2011 09:22 AM
Manisha,
Thanks for posting. According to page 7 of the NI USB-621x Specifications, the PFI lines for the USB-6211 are divided such that PFI0-3 can function as inputs and PFI4-7 can function as outputs. Changing the pin from PFI0 on your USB-6211 to PFI4-7 should allow you to export the ai/Start Trigger and fix the issue. I hope this helps!
Regards,
Joe S.
08-08-2011 07:17 AM
Thanks Joe! That works ! However do you know if there is a DAQmx function that I can use to query if the terminal is a input or a output. I use DAQmxGetTerminals to get a list of all the terminals available on the device. Is there a method that would give me all the possible terminals that can be used as outputs, basically a programmatic way of finding the device routes available?
Thanks,
Regards,
Manisha
08-09-2011 10:50 AM
Manisha,
I do not believe there is a DAQmx function that will be able to give that information. Any device-specific information regarding terminals will be available in the User Manual and Specifications document for the device. When you use a PFI line in your code, you should just be able to keep track of which line it was and how it is configured. I hope this helps!
Regards,
Joe S.