Hello,
this may be trivial, but I can not find a hint or figure out the issue. I am using PXI-6133 with the BNC-2110 connector and NIDAQmx. I have a TTL signal on TRIGGER/COUNTER PFI0/P1.0 BNC connector of the BNC-2110. I can count the signals using DAQmxTestPannels ![dtp.png dtp.png]()
I can not figure out how to write a code to do the counting. The example provided with the NIDAQmx base does not count and shows 0. Here is the code I am using
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int error=0;
TaskHandle taskHandle=0;
uInt32 data;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle,"/Dev2/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp));
// DAQmxGetCICountEdgesTerm(taskHandle,"/Dev2/pfi0",data,1);
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf("Continuously polling. Press Ctrl+C to interrupt\n");
while( 1 ) {
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadCounterScalarU32(taskHandle,10.0,&data,NULL));
printf("\rCount: %d",data);
fflush(stdout);
}
Error:
puts("");
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
The output is
.[nidaq@nidaq CntDigEvents]$ ./CntDigEv
Continuously polling. Press Ctrl+C to interrupt
Count: 0
Count: 0^C
[nidaq@nidaq CntDigEvents]$
If I change /Dev2/ctr0 to /Dev2/pfi0 I am getting
[nidaq@nidaq CntDigEvents]$ ./CntDigEv
DAQmx Error: Physical channel specified does not exist on this device.
Refer to the documentation for channels available on this device.
Device: Dev2
Physical Channel Name: pfi0
Task Name: _unnamedTask<0>
Status Code: -200170
End of program, press Enter key to quit
Any help will be higly appreciated. Best regards,
KS