Esempio n. 1
0
	TaskHandle EXPORT_API EOGSetCallback(UnityCallback uCallback)
	{
		int32       error = 0;
		char        errBuff[2048] = { '\0' };
		//int32       read;
		//float64		data[1];

		if (uCallback) 
		{
			DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle, "", 240.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, numSamples));
			DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, 1, 0, uCallback, NULL));
			// DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, 1000, 0, EveryNSamplesCallback, NULL));
			DAQmxErrChk(DAQmxRegisterDoneEvent(taskHandle, 0, DoneCallback, NULL));
			/*********************************************/
			// DAQmx Start Code
			/*********************************************/
			DAQmxErrChk(DAQmxStartTask(taskHandle));

			return taskHandle;
		}
	Error:
		if (DAQmxFailed(error))
		{
			DAQmxGetExtendedErrorInfo(errBuff, 2048);
			Cleanup();
			printf("DAQmx Error: %s\n", errBuff);
		}

		return 0;
	}
Esempio n. 2
0
 void NationalInstrumentsDAQ::registerDoneEvent( void )
 {
   DAQERR( DAQmxRegisterDoneEvent (
     _clk.daqtask,                      //task handle
     0,                                 //run the callback in a DAQmx thread
     &_daq_event_done_callback,         //callback
     (void*)this));                     //data passed to callback
 }
Esempio n. 3
0
int NiPci6220Config()
{
    int32 error = 0;
    char errBuff[2048];

    daq6220pvt.sampsPerChan = (uInt64)((daq6220pvt.t1 - daq6220pvt.t0) * daq6220pvt.rate);

    epicsPrintf("**** Initialize Task 6220 ****\n");
    epicsPrintf("**** 6220 : sampsPerChan = %d****\n", daq6220pvt.sampsPerChan);
    DAQmxErrChk(DAQmxCreateTask("", &daq6220pvt.taskHandle));
    DAQmxErrChk(DAQmxCreateAIVoltageChan(daq6220pvt.taskHandle, "Dev3/ai0:15","", daq6220pvt.terminalConfig, -10.0, 10.0, DAQmx_Val_Volts, NULL));

    if(daq6220pvt.extMode == 1) {
        DAQmxErrChk(DAQmxCfgSampClkTiming(daq6220pvt.taskHandle, "/Dev3/PFI7", daq6220pvt.rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, daq6220pvt.sampsPerChan));
    }
    else {
        DAQmxErrChk(DAQmxCfgSampClkTiming(daq6220pvt.taskHandle, "", daq6220pvt.rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, daq6220pvt.sampsPerChan));
    }

    if(daq6220pvt.trigMode == 1) {
        DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(daq6220pvt.taskHandle,"/Dev3/PFI0",DAQmx_Val_Rising));
        DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(daq6220pvt.taskHandle,DAQmx_Val_Acquired_Into_Buffer,daq6220pvt.sampsPerChan,0,EveryNCallback,NULL));
        DAQmxErrChk (DAQmxRegisterDoneEvent(daq6220pvt.taskHandle,0,DoneCallback,NULL));
    }

    return 0;

Error:
    if( DAQmxFailed(error) )
        DAQmxGetExtendedErrorInfo(errBuff,2048);

    if( daq6220pvt.taskHandle!=0 ) {
        DAQmxStopTask(daq6220pvt.taskHandle);
        DAQmxClearTask(daq6220pvt.taskHandle);
    }
    if( DAQmxFailed(error) )
        epicsPrintf("DAQmx Error(6220): %s\n",errBuff);

    return -1;
}
Esempio n. 4
0
int start_daq (void)
{
	int32       error=0;
	char        errBuff[2048]={'\0'};
	char	    str1[256],str2[256],trigName[256];
	char		devName[256];
	float64     clkRate;
	int			i;

	for (i = 0; i < DEV_NUM; i++) {
		sprintf (devName, "Dev%d/ai0", i+1);
		DAQmxErrChk2 ("CreateTask", DAQmxCreateTask("",&gTaskHandle[i]));

		DAQmxErrChk2 ("CreateAIVoltageChan"  , DAQmxCreateAIVoltageChan(gTaskHandle[i],devName,"",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
		DAQmxErrChk2 ("CfgSampClkTiming", DAQmxCfgSampClkTiming(gTaskHandle[i],"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
		DAQmxErrChk2 ("CfgDigEdgeStartTrig", DAQmxCfgDigEdgeStartTrig(gTaskHandle[i],TRIG_NAME,DAQmx_Val_Rising));

		DAQmxErrChk2 ("RegisterEveryNSamplesEvent", DAQmxRegisterEveryNSamplesEvent(gTaskHandle[i],DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
		DAQmxErrChk2 ("RegisterDoneEvent", DAQmxRegisterDoneEvent(gTaskHandle[i],0,DoneCallback,NULL));

		printf ("Dev(%s) : Task(%u) was created \n", devName, gTaskHandle[i]);
	}

	for (i = 0; i < DEV_NUM; i++) {
		gReadTotal[i]	= 0;

		printf ("start task%d(%u) ...\n", i+1, gTaskHandle[i]);
		DAQmxErrChk2 ("StartTask", DAQmxStartTask(gTaskHandle[i]));
	}
	
	printf("Acquiring samples continuously. Press Enter to interrupt\n");
	printf("\nHandle:\tTotal:\tDev1\tDev2\tDev3\n");

	getchar();

Error:
	if( DAQmxFailed(error) ) {
		DAQmxGetExtendedErrorInfo(errBuff,2048);
		printf("DAQmx Error: %u(0x%x), %s\n", error, error, errBuff);
	}

	/*********************************************/
	// DAQmx Stop Code
	/*********************************************/
	for (i = 0; i < DEV_NUM; i++) {
		if( gTaskHandle[i] ) {
			printf ("stop task%d (%u) ...\n", i+1, gTaskHandle[i]);
			DAQmxStopTask(gTaskHandle[i]);
			DAQmxClearTask(gTaskHandle[i]);
			gTaskHandle[i] = 0;
		}
	}

	if( DAQmxFailed(error) ) {
		printf("DAQmx Error: %u(0x%x), %s\n", error, error, errBuff);
	}

	printf("End of program. Press enter to restart ... \n");
	getchar();
	return 0;
}
Esempio n. 5
0
int start_daq (void)
{
	int32       error=0;
	char        errBuff[2048]={'\0'};
	int			i;

	for (i = 0; i < getNumOfDev(); i++) {
		printf ("\n------------------------------------------------------------\n");
		printf ("Create Task for Dev(%s)\n", gTaskInfoList[i].devName);

		DAQmxErrChk2 ("CreateTask", DAQmxCreateTask("",&gTaskInfoList[i].nTaskHandle));

		DAQmxErrChk2 ("CreateAIVoltageChan"  , DAQmxCreateAIVoltageChan(gTaskInfoList[i].nTaskHandle,
					gTaskInfoList[i].chName,"",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));

		DAQmxErrChk2 ("CfgSampClkTiming", DAQmxCfgSampClkTiming(gTaskInfoList[i].nTaskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));

		//DAQmxErrChk2 ("SetRefClkSrc", DAQmxSetRefClkSrc(gTaskInfoList[i].nTaskHandle,"PXI_Clk1"));
		//DAQmxErrChk2 ("SetRefClkRate", DAQmxSetRefClkRate(gTaskInfoList[i].nTaskHandle,10000000.0));
		DAQmxErrChk2 ("CfgDigEdgeStartTrig", DAQmxCfgDigEdgeStartTrig(gTaskInfoList[i].nTaskHandle,gTaskInfoList[i].trigName,DAQmx_Val_Rising));

		DAQmxErrChk2 ("RegisterEveryNSamplesEvent", DAQmxRegisterEveryNSamplesEvent(gTaskInfoList[i].nTaskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
		DAQmxErrChk2 ("RegisterDoneEvent", DAQmxRegisterDoneEvent(gTaskInfoList[i].nTaskHandle,0,DoneCallback,NULL));

		printf ("Dev(%s) : Task(%u) was created \n", gTaskInfoList[i].devName, gTaskInfoList[i].nTaskHandle);
	}

	printf ("\n------------------------------------------------------------\n");

	for (i = 0; i < getNumOfDev(); i++) {
		gTaskInfoList[i].nReadTotal	= 0;

		DAQmxErrChk2 ("StartTask", DAQmxStartTask(gTaskInfoList[i].nTaskHandle));
	}
	
	printf ("\n------------------------------------------------------------\n");

	printf("Acquiring samples continuously. Press Enter to interrupt\n");
	printf("\nHandle:\tTotal:\tDev1\tDev2\tDev3\n");

	getchar();

Error:
	if( DAQmxFailed(error) ) {
		DAQmxGetExtendedErrorInfo(errBuff,2048);
		printf("DAQmx Error: %u(0x%x), %s\n", error, error, errBuff);
	}

	/*********************************************/
	// DAQmx Stop Code
	/*********************************************/
	for (i = 0; i < getNumOfDev(); i++) {
		if( gTaskInfoList[i].nTaskHandle ) {
			printf ("stop task%d (%u) ...\n", i+1, gTaskInfoList[i].nTaskHandle);

			DAQmxStopTask(gTaskInfoList[i].nTaskHandle);
			DAQmxClearTask(gTaskInfoList[i].nTaskHandle);

			gTaskInfoList[i].nTaskHandle = 0;
		}
	}

	if( DAQmxFailed(error) ) {
		printf("DAQmx Error: %u(0x%x), %s\n", error, error, errBuff);
	}

	printf("End of program. Press enter to restart ... \n");
	getchar();
	return 0;
}