Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Use 80mhzTimetable for counting and how can i set a trigger level for a counter

Hello

 

i work with this example and a ni USB 6152.

 

#include <stdio.h>
#include <NIDAQmx.h>

#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

int main(void)
{
	int         error=0;
	int			i=0;
	TaskHandle  taskHandle=0;
	int32       read;
	uInt32      data[1000000];
	char        errBuff[2048]={'\0'};

	/*********************************************/
	// DAQmx Configure Code
	/*********************************************/
	DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
	DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle,"Dev1/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp));
	DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/80MHzTimebase",80000000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000000));

	/*********************************************/
	// DAQmx Start Code
	/*********************************************/
	DAQmxErrChk (DAQmxStartTask(taskHandle));

	printf("Continuously reading. Press Ctrl+C to interrupt\n");
	while( 1 ) {
		/*********************************************/
		// DAQmx Read Code
		/*********************************************/
		DAQmxErrChk (DAQmxReadCounterU32(taskHandle,1000000,10.0,data,1000000,&read,NULL));

		printf("\rAcquired %d samples\n",read);
		
		for(i=0;i<1000000; i++)
		{
			printf("%d\r\n", data[i]);
		}
	
		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;
}

 

 

 But how can i work with the 80Mhz Timebase and set the trigger point to 0Volt?? I measure that the triggerpint is round 1,7 Volt.

 

I have a sinus signal who is varius between 0hz and 6khz. And need exact cointing and the default 100khz Timetabel ist not exact enouh. With my 1MHZ test signalhe doesn't count all .

 

How can i route the 80Mhz timetable to the counter as external clock for solving my problem..

 

Thanks for helping me.

0 Kudos
Message 1 of 3
(7,036 Views)

Hi,

 

there is a function called vielen "DAQmxSetCICtrTimebaseSrc" which should do what you want. You can find it in the reference help on the following link:

 

http://zone.ni.com/reference/en-XX/help/370471W-01/mxcprop/attr0143/

 

Do you really have an USB-6152? I was looking after it on ni.com, but could not find the device anywhere...

 

Have a nice day,

 

Janina

0 Kudos
Message 2 of 3
(6,985 Views)

Sorry I have a 6259.

 

i will try to use "DAQmxSetCICtrTimebaseSrc".

 

thank you.

0 Kudos
Message 3 of 3
(6,982 Views)