//************************************ // 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)); }
/****************************************************************************** ** ** Fonction de démarage du comptage de la voie A du compteur incrémentale. ** ******************************************************************************/ bool NI6211::startCounter() { int32 error=0; taskCounter = new TaskHandle; /*------ DAQmx Configure Code Reading Task ------*/ DAQmxErrChk (DAQmxCreateTask("",taskCounter)); DAQmxErrChk (DAQmxCreateCIAngEncoderChan(*taskCounter,"Equilibreuse/ctr0","",DAQmx_Val_X1,TRUE,999,DAQmx_Val_AHighBLow,DAQmx_Val_Ticks,1000,0,NULL)); DAQmxErrChk (DAQmxSetArmStartTrigType(*taskCounter,DAQmx_Val_DigEdge)); DAQmxErrChk (DAQmxSetDigEdgeArmStartTrigSrc(*taskCounter,"/Equilibreuse/PFI2")); /*------ DAQmx Start Code ------*/ DAQmxErrChk (DAQmxStartTask(*taskCounter)); Erreur: checkError(error); return 0; }