PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI-6133 counting signals on PFI0

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

 

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

0 Kudos
Message 1 of 5
(5,424 Views)

Hi krisXX,

 

There are some things that I would like to know before:

 

* What programming environmet are you using to generate the task?

* What OS are you using?

* Which driver versions you have installed?

* Which pins you have connected to your connector block?

 

The error you get when you change the Dev2/ctr0 to Dev2/PFI0 is because that function will search for the phisical channel of the counter and when you set PFI0 (AI Start Trigger pin) you are assigning a counter channel that will not be available to be selected.

Regards,

Sil.VI
0 Kudos
Message 2 of 5
(5,389 Views)

Hello S.J.

 

Thank you very much for responding. Here are answers to your questions:

- I am using a gcc ver 4.4.7  on a linux kernel 2.6.32-358.18.1.el6.i686

- I am using Scientific Linux 5

-  I am using nidaqmx version 8.0.2

- I am connecting a TTL signal on the PFI0/P1.0  BNC connector at the TRIGGER/COUNTER part of the BNC-2110, the region labeled as 6 in Figure 2, page 3 of the BNC-2110 manual, below the DIGITAL AND TIMING I/O. I can use this signal as a trigger calling /Dev2/PFI0 , but I am not able to use it as a counter.

 

Best regards,

 

Kris

0 Kudos
Message 3 of 5
(5,383 Views)

I need to correct the SL version, I am using Scientific Linux 6, but I think the kernel version plays the more important role than the distribution

 

Best regards,

 

Kris

0 Kudos
Message 4 of 5
(5,381 Views)

Hi krisXX,

 

I was checking at the compatibility between the software you have installed on your computer, and in the following document you can find that the version of Linux Scientific 6 is supported by NI and the DAQmx Base version that you have installed, and it is listed as a previously supported software, which does not mean that it is not going to work but NI does not actively validate perviously supported Linux distributions. Additionally that version of DAQmx (8.0.2) was supported for Linux Red Hat Enterprise Linux Desktop + Workstation 5
Red Hat Enterprise WS 4 and OpenSUSE 11.1, 11.2, 11.3.

 

So my next recommendation since the counting was possible using the Test Panel, you may check if you have the correct NI-KAL version installed corresponding to your DAQmx driver. The following link on "Previous Support" section you can find a more detailed explanation and a link to the NI-KAL compatibility table

 

http://digital.ni.com/public.nsf/allkb/4857A755082E9E228625778900709661

Regards,

Sil.VI
0 Kudos
Message 5 of 5
(5,357 Views)