Exemple #1
0
int motorControl::motorDisable()
{
	int32       error=0;
	char        errBuff[2048] = {'\0'};
    uInt32      dataDisable=0x00000000;
    int32		written;
    float64 zeroVoltages[3]={0.0,0.0,0.0};
    while(isControlling){
    }
    DAQmxErrChk (DAQmxStartTask(motorEnableHandle));
    DAQmxErrChk (DAQmxStartTask(motorTaskHandle));
    DAQmxErrChk (DAQmxWriteDigitalU32(motorEnableHandle,1,1,10.0,DAQmx_Val_GroupByChannel,&dataDisable,NULL,NULL));
    DAQmxErrChk (DAQmxWriteAnalogF64(motorTaskHandle,1,FALSE,10,DAQmx_Val_GroupByChannel,zeroVoltages,NULL,NULL));
    Sleep(500);
    DAQmxStopTask(motorTaskHandle);
    DAQmxStopTask(motorEnableHandle);
    isControlling = FALSE;
    isWindUp = FALSE;
    live = FALSE;
    isEnable = FALSE;

Error:
	if( DAQmxFailed(error) ){
		printf("DisableMotor Error: %s\n",errBuff);
        DAQmxGetExtendedErrorInfo(errBuff,2048);
        printf("DAQmx Error: %s\n",errBuff);
		DAQmxStopTask(motorEnableHandle);
        DAQmxStopTask(motorTaskHandle);
        DAQmxClearTask(motorEnableHandle);
        DAQmxClearTask(motorTaskHandle);
    }
	return 0;
}
Exemple #2
0
int SetDaqAbort()
{
    int32 error = 0;
    char errBuff[2048];

    epicsPrintf("**** DAQmx Task Abort****\n");

    DAQmxErrChk(DAQmxStopTask(daq6220pvt.taskHandle));
    DAQmxErrChk(DAQmxClearTask(daq6220pvt.taskHandle));

    daq6220pvt.status = DAQ_STATUS_STOP;

    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;
}
Exemple #3
0
int motorControl::motorEnable()
{
    uInt32      dataEnable=0x00000001;
    char        errBuff[2048]={'\0'};
    int32       error=0;
    float64 zeroVoltages[3]={0.0,0.0,0.0},zeroVoltage={0.0};
    DAQmxErrChk (DAQmxStartTask(motorEnableHandle));
    DAQmxErrChk (DAQmxStartTask(motorTaskHandle));
    DAQmxErrChk (DAQmxWriteDigitalU32(motorEnableHandle,1,1,10.0,DAQmx_Val_GroupByChannel,&dataEnable,NULL,NULL));
    DAQmxErrChk (DAQmxWriteAnalogF64(motorTaskHandle,1,FALSE,10,DAQmx_Val_GroupByChannel,zeroVoltages,NULL,NULL));
    Sleep(500);
    DAQmxStopTask(motorTaskHandle);
    DAQmxStopTask(motorEnableHandle);
    isEnable = TRUE;
Error:
	if( DAQmxFailed(error) ) {
		DAQmxGetExtendedErrorInfo(errBuff,2048);
        DAQmxStopTask(motorTaskHandle);
		DAQmxClearTask(motorTaskHandle);
        DAQmxStopTask(motorEnableHandle);
		DAQmxClearTask(motorEnableHandle);

		printf("DAQmx Error: %s\n",errBuff);
        printf("Motor enable Error\n");
	}
    return 0;
}
// from StopTasks();
int LifetimeAcq::stopTasks()
{
	
	//Stop Task;
	if( aoTaskHandle!=0 ) 
	{
		DAQmxStopTask(aoTaskHandle);
		DAQmxClearTask(aoTaskHandle);
		aoTaskHandle = 0; 
	}

	if( acqTaskHandle!=0 ) 
	{
		DAQmxStopTask(acqTaskHandle);
		DAQmxClearTask(acqTaskHandle);
		acqTaskHandle = 0; 
	}

	if( ctrTaskHandle!=0 ) 
	{
		DAQmxStopTask(ctrTaskHandle);
		DAQmxClearTask(ctrTaskHandle);
		ctrTaskHandle = 0; 
	}
	return 1;
}
Exemple #5
0
int motorControl::motorWindUp()
{
    char        errBuff[2048]={'\0'};
    int32       error=0;
    float64 windingUpCmnd[3]={0.5,0.5,0};
    if (isEnable){
        DAQmxErrChk (DAQmxStartTask(motorTaskHandle));
        DAQmxErrChk (DAQmxWriteAnalogF64(motorTaskHandle,1,FALSE,10,DAQmx_Val_GroupByChannel,windingUpCmnd,NULL,NULL));
        Sleep(500);
        isWindUp = TRUE;

        DAQmxStopTask(motorTaskHandle);
        
        printf("Windup Pass.\n");
    }else  printf("Motors must be first enabled prior to winding up.\n");
Error:
	if( DAQmxFailed(error) ) {
		DAQmxGetExtendedErrorInfo(errBuff,2048);
        DAQmxStopTask(motorTaskHandle);
        DAQmxClearTask(motorTaskHandle);
		printf("DAQmx Error: %s\n",errBuff);
        printf("winding up Error\n");
	}
     return 0;
}
DAQManager::~DAQManager()
{
#ifdef _WIN32
	DAQmxStopTask(adcTaskHandle);
	DAQmxStopTask(motorTaskHandle);
	DAQmxStopTask(triggerTaskHandle);
#elif __APPLE__
    DAQmxBaseStopTask(adcTaskHandle);
    DAQmxBaseStopTask(motorTaskHandle);
#endif
}
void ScanThreadLinear::StopTasks(void)
{
	DAQmxStopTask(taskAnalog);
	DAQmxStopTask(taskTrig);
	DAQmxStopTask(taskTrA);
	DAQmxStopTask(taskClock);
	
	//CLEAR TASKS
	DAQmxClearTask(taskAnalog);
	DAQmxClearTask(taskTrig);
	DAQmxClearTask(taskTrA);
	DAQmxClearTask(taskClock);
}
Exemple #8
0
int motorControl::motorControllerEnd()
{
    live = FALSE;
    motorControl::motorDisable();
    isControlling = FALSE;
    DAQmxStopTask(motorTaskHandle);
	DAQmxClearTask(motorTaskHandle);
    DAQmxStopTask(loadCelltaskHandle);
	DAQmxClearTask(loadCelltaskHandle);
    DAQmxStopTask(encodertaskHandle);
	DAQmxClearTask(encodertaskHandle);
    return 0;
}
Exemple #9
0
int microStep(int in)
{
	uInt8 MS1Sig[2];
	uInt8 MS2Sig[2];

	// Pull to zero for active in current controller mode
	switch (in){
	case 1 : // no mirostep
		MS1Sig[0] = 0;	MS1Sig[1] = 0;
		MS2Sig[0] = 0;	MS2Sig[1] = 0;
		break;
	case 2 : // half step
		MS1Sig[0] = 1;	MS1Sig[1] = 1;
		MS2Sig[0] = 0;	MS2Sig[1] = 0;
		break;
	case 4: // quarter step
		MS1Sig[0] = 0;	MS1Sig[1] = 0;
		MS2Sig[0] = 1;	MS2Sig[1] = 1;
		break;
	case 8: // eighth step
		MS1Sig[0] = 1;	MS1Sig[1] = 1;
		MS2Sig[0] = 1;	MS2Sig[1] = 1;
		break;
	default :
		return -1;
	}

	TaskHandle microStep = 0;

	DAQmxCreateTask("MS1", &microStep);
	DAQmxCreateDOChan(microStep, "Dev1/port0/line6", "MS1", DAQmx_Val_ChanForAllLines); // MS1
	DAQmxCfgSampClkTiming(microStep, NULL, 3000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2); // Ext. Trig
	DAQmxWriteDigitalLines(microStep, 2, 0, 1000.0, DAQmx_Val_GroupByChannel, MS1Sig, NULL, NULL); // MS1 out 
	DAQmxStartTask(microStep);
	DAQmxWaitUntilTaskDone(microStep, 1.0); // Wait for action to be completed
	DAQmxStopTask(microStep);
	DAQmxClearTask(microStep);

	microStep = 0;

	DAQmxCreateTask("MS2", &microStep);
	DAQmxCreateDOChan(microStep, "Dev1/port0/line7", "MS2", DAQmx_Val_ChanForAllLines); // MS1
	DAQmxCfgSampClkTiming(microStep, NULL, 3000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2); // Ext. Trig
	DAQmxWriteDigitalLines(microStep, 2, 0, 1000.0, DAQmx_Val_GroupByChannel, MS2Sig, NULL, NULL); // MS1 out 
	DAQmxStartTask(microStep);
	DAQmxWaitUntilTaskDone(microStep, 1.0); // Wait for action to be completed
	DAQmxStopTask(microStep);
	DAQmxClearTask(microStep);
	
	return 0;
}
Exemple #10
0
int32 Tweezers::CurrentRun(float64* curr, float64* indata, void* lpParam)
{
	threadinfo* t = (threadinfo*)lpParam;

	// config and start analog tast
	DAQmxErrRtn(DAQmxCfgSampClkTiming(AOtaskHandle,"",10*float64(1/(*t->delta*1E-3)),DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,(*t->cycles*10*t->nofFrames)));
	DAQmxErrRtn(DAQmxCfgOutputBuffer(AOtaskHandle, t->nofFrames*10));
	DAQmxErrRtn(DAQmxCfgDigEdgeStartTrig(AOtaskHandle, "PFI0", DAQmx_Val_Rising));
	DAQmxErrRtn(DAQmxWriteAnalogF64(AOtaskHandle,t->nofFrames*10,0,10.0,DAQmx_Val_GroupByChannel,curr,&written,NULL));
	DAQmxErrRtn(DAQmxStartTask(AOtaskHandle));

	cerr << "\nTrying to allocate buffer for " << (*t->cycles * t->nofFrames) << " frames\n";
	// config and start pulse channel with parameters set by user
	//DAQmxErrRtn(DAQmxCfgImplicitTiming(DOtaskHandle, DAQmx_Val_FiniteSamps,*t->cycles * t->nofFrames));
	DAQmxErrRtn(DAQmxCfgImplicitTiming(DOtaskHandle, DAQmx_Val_ContSamps,1));
	DAQmxErrRtn(DAQmxCfgDigEdgeStartTrig(DOtaskHandle, "PFI0", DAQmx_Val_Rising));
	DAQmxErrRtn(DAQmxStartTask(DOtaskHandle));

	// config analog in task
	DAQmxErrRtn(DAQmxCfgSampClkTiming(AItaskHandle,"Ctr0Out",100,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,*t->cycles * t->nofFrames));
	DAQmxErrRtn(DAQmxStartTask(AItaskHandle));

	// set trigger line to 1 - GO!
	DAQmxWriteDigitalLines(TRtaskHandle,1,1,10,DAQmx_Val_GroupByChannel,trigdata[1],&written,NULL);
	
	// wait until cam trigger task is done
	DAQmxWaitUntilTaskDone(AOtaskHandle,-1);
	
	// reset trigger line
	DAQmxWriteDigitalLines(TRtaskHandle,1,1,10,DAQmx_Val_GroupByChannel,trigdata[0],&written,NULL);

    // read protocol samples
	DAQmxReadAnalogF64(AItaskHandle,*t->cycles * t->nofFrames,5.0,DAQmx_Val_GroupByChannel,indata,*t->cycles * t->nofFrames*2,&read,NULL);

	//read indeed current
	ofstream strom;
	strom.open("newcurrent.txt", ofstream::app);
	for(int i=0;i<t->nofFrames;i++)
		strom<<i*(*t->delta*1E-3)<<"\t"<<indata[i]<<endl;
		strom.close();
	
	// stop tasks, disable trigger
	DAQmxStopTask(AOtaskHandle);
	DAQmxStopTask(DOtaskHandle);
	DAQmxStopTask(AItaskHandle);
	DAQmxDisableStartTrig(AOtaskHandle);
	DAQmxDisableStartTrig(DOtaskHandle);
}
Exemple #11
0
double QxrdNIDAQPlugin::getAnalogInput(int chan)
{
  QMutexLocker lock(&m_Mutex);

  int error;
  float64 res = 0;

  if (m_AITaskHandle) {
    DAQmxStopTask(m_AITaskHandle);
    DAQmxClearTask(m_AITaskHandle);
    m_AITaskHandle = 0;
  }

  if (chan >= 0) {
    DAQmxErrChk(DAQmxCreateTask("qxrd-input", &m_AITaskHandle));
    DAQmxErrChk(DAQmxCreateAIVoltageChan (m_AITaskHandle,
                                          qPrintable(tr("Dev1/ai%1").arg(chan)), NULL, DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, NULL));

    if (m_AITaskHandle) {
      DAQmxErrChk(DAQmxReadAnalogScalarF64(m_AITaskHandle, 10.0, &res, NULL));
    }
  }

Error:
  return res;
}
Exemple #12
0
void   QxrdNIDAQPlugin::setAnalogOutput(int chan, double value)
{
  QMutexLocker lock(&m_Mutex);

  int error;

  if (m_AOTaskHandle) {
    DAQmxStopTask(m_AOTaskHandle);
    DAQmxClearTask(m_AOTaskHandle);
    m_AOTaskHandle = 0;
  }

  if (chan >= 0) {
    DAQmxErrChk(DAQmxCreateTask("qxrd-output", &m_AOTaskHandle));
    DAQmxErrChk(DAQmxCreateAOVoltageChan (m_AOTaskHandle,
                                          qPrintable(tr("Dev1/ao%1").arg(chan)), NULL, -10.0, 10.0, DAQmx_Val_Volts, NULL));

    if (m_AOTaskHandle) {
      DAQmxErrChk(DAQmxWriteAnalogScalarF64(m_AOTaskHandle, true, 10.0, value, NULL));
    }
  }

Error:
  return;
}
Exemple #13
0
void   QxrdNIDAQPlugin::setAnalogWaveform(QString chan, double rate, double wfm[], int size)
{
  QMutexLocker lock(&m_Mutex);
//  printf("setAnalogWaveform(%g,%g...,%d)\n", rate, wfm[0], size);

  int error;
  int32 nsampwrt;

  if (m_AOTaskHandle) {
    DAQmxStopTask(m_AOTaskHandle);
    DAQmxClearTask(m_AOTaskHandle);
    m_AOTaskHandle = 0;
  }

  if (chan >= 0) {
    DAQmxErrChk(DAQmxCreateTask("qxrd-output", &m_AOTaskHandle));
    DAQmxErrChk(DAQmxCreateAOVoltageChan (m_AOTaskHandle,
                                          qPrintable(chan), NULL, -10.0, 10.0, DAQmx_Val_Volts, NULL));

    if (m_AOTaskHandle) {
      DAQmxErrChk(
            DAQmxCfgSampClkTiming(m_AOTaskHandle, NULL, rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, size)
            );

      DAQmxErrChk(
            DAQmxWriteAnalogF64(m_AOTaskHandle, size, false, -1, DAQmx_Val_GroupByChannel, wfm, &nsampwrt, NULL)
            );
    }
  }

//  printf("%d samples written\n", nsampwrt);

Error:
  return;
}
Exemple #14
0
	int EXPORT_API EOGStopTask(TaskHandle taskHandle)
	{
		int32       error = 0;
		char		errBuff[2048] = { '\0' };

		if (taskHandle != 0)
		{
			DAQmxErrChk(DAQmxStopTask(taskHandle));
			DAQmxClearTask(taskHandle);
			return 1;
		}
		else
		{
			return 2;
		}
		

	Error:

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

		return 0;
	}
void daq_err_check(int32 error, TaskHandle *task_handle_array, int n_tasks){
  for (int n = 0; n < n_tasks; n++){
    std::cout << "Checking for errors while stopping task " << n << std::endl;
    daq_err_check( DAQmxStopTask(task_handle_array[n]) );
  }
  std::cout << "The original error check:" << std::endl;
  daq_err_check(error);
}
Exemple #16
0
int32 Tweezers::RecoverFromError()
{
	// stop running tasks
	DAQmxErrRtn(DAQmxStopTask(DOtaskHandle));
	DAQmxErrRtn(DAQmxStopTask(AOtaskHandle));
	DAQmxErrRtn(DAQmxStopTask(AItaskHandle));

	// disable start triggers
	DAQmxErrRtn(DAQmxDisableStartTrig(DOtaskHandle));
	DAQmxErrRtn(DAQmxDisableStartTrig(AOtaskHandle));
	
	// reset trigger line
	DAQmxErrRtn(DAQmxWriteDigitalLines(TRtaskHandle,1,1,10,DAQmx_Val_GroupByChannel,trigdata[0],&written,NULL));

	// reset to zero
	DAQmxErrRtn(SetCurrent(AV));
}
Exemple #17
0
int32 Tweezers::TriggerFrames(unsigned int nr)
{
	//DAQmxErrRtn(DAQmxStopTask(DOtaskHandle));
	DAQmxErrRtn(DAQmxCfgImplicitTiming(DOtaskHandle, DAQmx_Val_FiniteSamps, 1));
	DAQmxErrRtn(DAQmxStartTask(DOtaskHandle));
	DAQmxErrRtn(DAQmxWaitUntilTaskDone(DOtaskHandle,-1));
	DAQmxErrRtn(DAQmxStopTask(DOtaskHandle));
}
/******************************************************************************
**
** Fonction d'arret et de suppresion de tache d'acquisition de la vitesse
**
******************************************************************************/
bool NI6211::stopSpeed()
{
    bool error=0;
    /*------ DAQmx Stop Code ------*/
    error+=DAQmxStopTask(*taskFreq);
    error+=DAQmxClearTask(*taskFreq);
    delete taskFreq;
    taskFreq = NULL;
    return error;
}
/******************************************************************************
**
** Fonction d'arret et de suppresion de tache du compteur
**
******************************************************************************/
bool NI6211::stopCounter()
{
    bool error=0;
    /*------ DAQmx Stop Code ------*/
    error+=DAQmxStopTask(*taskCounter);
    error+=DAQmxClearTask(*taskCounter);
    delete taskCounter;
    taskCounter = NULL;
    return error;
}
/******************************************************************************
**
** Fonction d'arret et de suppresion de tache d'acquisition de la vitesse
**
******************************************************************************/
bool NI6211::stopCapot()
{
    bool error=0;
    /*------ DAQmx Stop Code ------*/
    error+=DAQmxStopTask(*taskCapot);
    error+=DAQmxClearTask(*taskCapot);
    delete taskCapot;
    taskCapot = NULL;
    return error;
}
/******************************************************************************
**
** Fonction d'arret et de suppresion de tache d'acquisition
**
******************************************************************************/
bool NI6211::stopAcquisition()
{
    bool error=0;
    /*------ DAQmx Stop Code ------*/
    error+=DAQmxStopTask(*taskRead);
    error+=DAQmxClearTask(*taskRead);
    delete taskRead;
    taskRead=NULL;
    return error;
}
Exemple #22
0
	void Cleanup(void)
	{
		if (taskHandle != 0)
		{
			/*********************************************/
			// DAQmx Stop Code
			/*********************************************/
			DAQmxStopTask(taskHandle);
			DAQmxClearTask(taskHandle);
			taskHandle = 0;
		}
	}
Exemple #23
0
void DaqMagControl::set_volts(double this_volts)
{
    DAQmxCreateTask("",&taskHandle);
    DAQmxCreateAOVoltageChan (taskHandle, chan_char, "", -10.0, 10.0, DAQmx_Val_Volts , NULL);
    DAQmxStartTask(taskHandle);
    double volts=this_volts;
    DAQmxWriteAnalogF64(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,&volts,NULL,NULL);
    if( taskHandle!=0 )
    {
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
    }
}
Exemple #24
0
void YON(int in)
{
	TaskHandle YOn = 0;	
	uInt8 onSig[2] = { in, in };

	DAQmxCreateTask("YON", &YOn);
	DAQmxCreateDOChan(YOn, "Dev1/port0/line5", "YON", DAQmx_Val_ChanForAllLines); // Yon	
	DAQmxCfgSampClkTiming(YOn, NULL, 3000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2); // Ext. Trig
	DAQmxWriteDigitalLines(YOn, 2, 0, 1000.0, DAQmx_Val_GroupByChannel, onSig, NULL, NULL); // turn Off 
	DAQmxStartTask(YOn);
	DAQmxWaitUntilTaskDone(YOn, 1.0); // Wait for action to be completed
	DAQmxStopTask(YOn);
	DAQmxClearTask(YOn);
}
Exemple #25
0
void YDIR(int in)
{
	TaskHandle YDir = 0;
	uInt8 dirSig[2] = { in, in };

	DAQmxCreateTask("YDir", &YDir);
	DAQmxCreateDOChan(YDir, "Dev1/port0/line3", "YDir", DAQmx_Val_ChanForAllLines); // Ydirection
	DAQmxCfgSampClkTiming(YDir, NULL, 3000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2); // Int. Trig
	DAQmxWriteDigitalLines(YDir, 2, 0, 1000.0, DAQmx_Val_GroupByChannel, dirSig, NULL, NULL); // turn Off 
	DAQmxStartTask(YDir);
	DAQmxWaitUntilTaskDone(YDir, 1.0); // Wait for action to be completed
	DAQmxStopTask(YDir);
	DAQmxClearTask(YDir);
}
/******************************************************************************
**
** Fonction d'arret et de suppresion de tache d'alimentation du moteur
** La vitesse du moteur est préalablement fixé à 0% par sécurité
**
******************************************************************************/
bool NI6211::stopMotor()
{
    int error=1;
    if(!DAQmxWriteAnalogF64(*taskVOut,1,1,10.0,DAQmx_Val_GroupByChannel,0,NULL,NULL))
    {
        /*------ DAQmx Stop Code ------*/
        DAQmxStopTask(*taskVOut);
        DAQmxClearTask(*taskVOut);
        delete taskVOut;
        taskVOut = NULL;
        error=0;
    }
    return error;
}
int
DoneStartle(void)
{
	if( startleDaqHandle!=0 ) {
		/*********************************************/
		// DAQmx Stop Code
		/*********************************************/
		DAQmxStopTask(startleDaqHandle);
		DAQmxClearTask(startleDaqHandle);
	}
	if( DAQmxFailed(error) )
		printf("DAQmx Error: %s\n",errBuff);
Error:
    return 0;
}
Exemple #28
0
int main(void)
{
	int32       error=0;
	TaskHandle  taskHandle=0;
	int32       read;
	float64     data[1000];
	char        errBuff[2048]={'\0'};
	int	i;

	/*********************************************/
	// DAQmx Configure Code
	/*********************************************/
	DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
	DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
	DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));

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

	/*********************************************/
	// DAQmx Read Code
	/*********************************************/
	DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));

	printf("Acquired %d points\n",read);

	for (i = 0; i < 1000; i++) {
		printf ("data[%d] = %f\n", i, data[i]);
	}

Error:
	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;
}
void DexNiDaqTargets::Quit( void ) {

	int32 error_code;
	if( taskHandle!=0 )  {
		// I think that the task stops itself after the read, but I'm not sure.
		// In any case, it doesn't seem to hurt to do this.
		error_code = DAQmxStopTask(taskHandle);
		if( DAQmxFailed( error_code )) ReportNiDaqError();
		// I don't know what happens if you don't clear a task before leaving,
		// but the NI examples says to do it, so I do it.
		error_code = DAQmxClearTask(taskHandle);
		if( DAQmxFailed( error_code ) ) ReportNiDaqError();
	}
	screen_targets->Quit();

}
BOOL CForceChartDlg::DAQ(CString changeDeviceName, short changeFirstChannel)
{
	TaskHandle  taskHandle = 0;
	int32       read;
	CString cstrChannelList;
	cstrChannelList.Format( _T("/ai%d"), changeFirstChannel );
	DAQmxCreateTask("AAencoderTask", &taskHandle);
	DAQmxCreateAIVoltageChan(taskHandle, changeDeviceName+cstrChannelList, "AAencoderChannel", DAQmx_Val_RSE, 0, 5, DAQmx_Val_Volts, NULL);
	//UpdateData(TRUE);
	DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", 100, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 20);
	//UpdateData(TRUE);
	DAQmxStartTask(taskHandle);
	DAQmxReadAnalogF64(taskHandle, 10, 0.2, DAQmx_Val_GroupByChannel, G0, 10, &read, NULL);
	DAQmxStopTask(taskHandle);
	DAQmxClearTask(taskHandle);
	return TRUE;
}