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; }
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; }
motorControl::~motorControl() { DAQmxClearTask(motorEnableHandle); DAQmxClearTask(motorTaskHandle); DAQmxClearTask(loadCelltaskHandle); live = FALSE; }
// 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; }
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; }
int motorControl::motorControllerEnd() { live = FALSE; motorControl::motorDisable(); isControlling = FALSE; DAQmxStopTask(motorTaskHandle); DAQmxClearTask(motorTaskHandle); DAQmxStopTask(loadCelltaskHandle); DAQmxClearTask(loadCelltaskHandle); DAQmxStopTask(encodertaskHandle); DAQmxClearTask(encodertaskHandle); return 0; }
void ScanThreadLinear::StopTasks(void) { DAQmxStopTask(taskAnalog); DAQmxStopTask(taskTrig); DAQmxStopTask(taskTrA); DAQmxStopTask(taskClock); //CLEAR TASKS DAQmxClearTask(taskAnalog); DAQmxClearTask(taskTrig); DAQmxClearTask(taskTrA); DAQmxClearTask(taskClock); }
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", µStep); 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", µStep); 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; }
// destructor Tweezers::~Tweezers() { cerr<<"reset..."; Reset(); DAQmxClearTask(AItaskHandle); DAQmxClearTask(AOtaskHandle); DAQmxClearTask(DOtaskHandle); DAQmxClearTask(TRtaskHandle); DAQmxResetDevice("Dev1"); DAQmxGetExtendedErrorInfo(errBuff,2048); cerr<<errBuff; cerr<<"delete.\n"; }
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 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; }
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; }
double QxrdNIDAQPlugin::count(int /* chan */, double /* time */) { QMutexLocker lock(&m_Mutex); static TaskHandle counterTask = 0; int error; float64 res = 0; if (counterTask == 0) { DAQmxErrChk(DAQmxCreateTask("counter", &counterTask)); DAQmxErrChk(DAQmxCreateCICountEdgesChan(counterTask,"Dev1/ctr2", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp)); DAQmxErrChk(DAQmxSetCICountEdgesTerm(counterTask, "/Dev1/ctr2", "/Dev1/100MHzTimebase")); DAQmxErrChk(DAQmxStartTask(counterTask)); } if (counterTask) { DAQmxErrChk(DAQmxReadCounterScalarF64(counterTask, 0, &res, NULL)); } return res; Error: DAQmxClearTask(counterTask); return res; }
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; }
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; }
ATIDAQHardwareInterface::~ATIDAQHardwareInterface() { /*stop and clear tasks, without regard to error*/ DAQmxClearTask( *m_thDAQTask ); /*delete unmanaged pointers*/ delete m_thDAQTask; }
//************************************ // Method: setupCLK // FullName: fetch::device::NationalInstrumentsDAQ::setupCLK // Access: public // Returns: void // Qualifier: // // set up counter for sample clock // - A finite pulse sequence is generated by a pair of on-board counters. // In testing, it appears that after the device is reset, initializing // the counter task doesn't work quite right. First, I have to start the // task with the paired counter once. Then, I can set things up normally. // After initializing with the paired counter once, things work fine until // the device (or computer) is reset. My guess is this is a fault of the // board or driver software. // - below, we just cycle the counters when config gets called. This ensures // everything configures correctly the first time, even after a device // reset or cold start. //************************************ void NationalInstrumentsDAQ::setupCLK(float64 nrecords, float64 record_frequency_Hz) { TaskHandle clk = 0; int32 N = _config->ao_samples_per_waveform(); float64 hz = computeSampleFrequency(nrecords, record_frequency_Hz); const char *dev =_config->name().c_str(), *ctr =_config->ctr().c_str(), *armstart_in =_config->armstart().c_str(), *gate_out =_config->frame_trigger_out().c_str(), *trig =_config->trigger().c_str(); float64 lvl =_config->level_volts(); char term_ctr[1024]={0}, term_gate[1024]={0}, term_arm_out[1024]={0}; make_terminal_name(term_ctr ,sizeof(term_ctr) ,dev,ctr); make_terminal_name(term_gate ,sizeof(term_gate) ,dev,ctr); strcat(term_gate,"Gate"); make_terminal_name(term_arm_out,sizeof(term_arm_out),dev,gate_out); DAQERR( DAQmxClearTask(_clk.daqtask) ); // Once a DAQ task is started, it needs to be cleared before restarting DAQERR( DAQmxCreateTask("fetch_CLK",&_clk.daqtask)); clk = _clk.daqtask; DAQERR(DAQmxCreateCOPulseChanFreq (clk,term_ctr,NULL,DAQmx_Val_Hz,DAQmx_Val_Low,0.0,hz,0.5)); DAQERR(DAQmxCfgImplicitTiming (clk,DAQmx_Val_FiniteSamps,N)); DAQERR(DAQmxCfgDigEdgeStartTrig (clk,"AnalogComparisonEvent",DAQmx_Val_Rising)); DAQERR(DAQmxSetArmStartTrigType (clk,DAQmx_Val_DigEdge)); // Arm trigger has to be through clk DAQERR(DAQmxSetDigEdgeArmStartTrigSrc (clk,armstart_in)); DAQERR(DAQmxSetDigEdgeArmStartTrigEdge(clk,DAQmx_Val_Rising)); DAQERR(DAQmxSetStartTrigRetriggerable (clk,1)); DAQERR(DAQmxConnectTerms(term_gate,term_arm_out,DAQmx_Val_DoNotInvertPolarity)); }
void NationalInstrumentsDAQ::setupAO( float64 nrecords, float64 record_frequency_Hz ) { float64 freq = computeSampleFrequency(nrecords, record_frequency_Hz); DAQERR( DAQmxClearTask(_ao.daqtask) ); DAQERR( DAQmxCreateTask( "fetch_AO", &_ao.daqtask)); registerDoneEvent(); }
/****************************************************************************** ** ** 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; }
int DllExport _nidaq_close (int id) { sTask *pTask; pTask = tasks.item + id; DAQmxClearTask (pTask->handle); pTask->handle = 0; return 1; }
void QxrdNIDAQPlugin::closeTaskHandles() { QMutexLocker lock(&m_Mutex); if (m_AOTaskHandle) { DAQmxClearTask(m_AOTaskHandle); m_AOTaskHandle = 0; } if (m_AITaskHandle) { DAQmxClearTask(m_AITaskHandle); m_AITaskHandle = 0; } if (m_TrigAOTask) { DAQmxClearTask(m_TrigAOTask); m_TrigAOTask = 0; } }
/****************************************************************************** ** ** 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 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 ** ******************************************************************************/ bool NI6211::stopAcquisition() { bool error=0; /*------ DAQmx Stop Code ------*/ error+=DAQmxStopTask(*taskRead); error+=DAQmxClearTask(*taskRead); delete taskRead; taskRead=NULL; return error; }
void Cleanup(void) { if (taskHandle != 0) { /*********************************************/ // DAQmx Stop Code /*********************************************/ DAQmxStopTask(taskHandle); DAQmxClearTask(taskHandle); taskHandle = 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); } }
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); }
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; }