I'm currently attempting to have a NI-DAQ read an external trigger in the digital input PFI1, but I get an error -200982 when I run the line:
(DAQmxRegisterSignalEvent(taskHandle, DAQmx_Val_SampleClock, 0, SaveViconData, NULL));
The error states
DAQmx Signal Events are not supported by your device. DAQmx Signal events include the Counter Output event, the Sample Complete Event, the Sample Clock Event, and the Digital Change Detection event.>
but I have created this function using MATLAB fine so I don't think there's an issue with the hardware so I believe I must be making a mistake somewhere as I am quite new to using C++.
The code used is:
int32 error = 0;
static TaskHandle taskHandle;
int32 read;
float64 data[1000];
char errBuff[2048] = { '\0' };
using namespace std;
int32 CVICALLBACK SaveViconData(TaskHandle taskHandle, int32 signalID, void* callbackData)
{
using namespace std;
cout << "Function triggered\n";
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
cout<< "taskHandle\n" << flush;
chrono::seconds dura(1);
DAQmxStartTask(taskHandle);
return 0;
}
int main(void)
{
DAQmxErrChk(DAQmxCreateTask("", &taskHandle));
DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", "Voltage", DAQmx_Val_RSE, -10.0, 10.0, DAQmx_Val_Volts, NULL));
DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(taskHandle, "PFI1", DAQmx_Val_Falling));
DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle, NULL, 500.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000));
DAQmxErrChk(DAQmxRegisterSignalEvent(taskHandle, DAQmx_Val_SampleClock, 0, SaveViconData, NULL));
DAQmxStartTask(taskHandle);
DAQmxWaitUntilTaskDone(taskHandle, 10);
Error:
if (DAQmxFailed(error))
DAQmxGetExtendedErrorInfo(errBuff, 2048);
if (taskHandle != 0) {
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if (DAQmxFailed(error))
printf("DAQmx Error: %s\n", errBuff);
return 0;
}
and I'm using a USB-6003 NI-DAQ. Any help would be appreciated