Esempio n. 1
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;
}
Esempio n. 2
0
    int NationalInstrumentsDAQ::waitForDone(DWORD timeout_ms/*=INFINITE*/)
    {
#if 0
      HANDLE hs[] = {
        _notify_done,
        _agent->_notify_stop};
      DWORD  res;
      const char classname[] = "NationalInstrumentsDAQ";
      res = WaitForMultipleObjects(2,hs,FALSE,timeout_ms);
      if(res == WAIT_TIMEOUT)
        error("%s: Timed out waiting for DAQ to finish AO write.\r\n",classname);
      else if(res==WAIT_ABANDONED_0)
      {
        warning("%s: Abandoned wait on notify_daq_done.\r\n",classname);
        return 1;
      }
      else if(res==WAIT_ABANDONED_0+1)
      {
        warning("%s: Abandoned wait on notify_stop.\r\n",classname);
        return 1;
      }
      return 0;
#endif
      DAQJMP_SILENT(DAQmxWaitUntilTaskDone(_ao.daqtask,timeout_ms/1000));
      return 1;
    Error:
      return 0;
    }
Esempio n. 3
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));
}
Esempio n. 4
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);
}
Esempio n. 5
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);
}
Esempio n. 6
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);
}
Esempio n. 7
0
void TriggerFrames(unsigned int nr, double extime)
{

	char        errBuff[2048];
//	int32       error;

	TaskHandle DOtaskHandle;
	DAQmxCreateTask("DO",&DOtaskHandle);
	//cerr<<"sending trigger pulse: "<<extime*1E-3<<" secs!\n";
	DAQmxCreateCOPulseChanTime(DOtaskHandle,"Dev1/Ctr0","",DAQmx_Val_Seconds,DAQmx_Val_Low,0.0,extime*1E-3,extime*1E-3);
	//DAQmxCfgImplicitTiming(DOtaskHandle, DAQmx_Val_ContSamps, 1);
	DAQmxCfgImplicitTiming(DOtaskHandle, DAQmx_Val_FiniteSamps, 1);
	DAQmxStartTask(DOtaskHandle);
	DAQmxWaitUntilTaskDone(DOtaskHandle,-1);
	DAQmxStopTask(DOtaskHandle);
	DAQmxClearTask(DOtaskHandle);

	DAQmxGetExtendedErrorInfo(errBuff,2048);
	cerr<<errBuff;
}
Esempio n. 8
0
void moveXStage(int steps, uInt8 clockSig[])
{
	int bits = steps * 2;

	TaskHandle	XClockOut = 0;
	uInt8 *signal = new uInt8[bits];
	for (int i = 0; i < bits; i += 2) {
		signal[i] = clockSig[0];
		signal[i + 1] = clockSig[1];
	}

	DAQmxCreateTask("X", &XClockOut);
	DAQmxCreateDOChan(XClockOut, "Dev1/port0/line0", "X", DAQmx_Val_ChanForAllLines); // Xmotor
	DAQmxCfgSampClkTiming(XClockOut, NULL, motorSpeed, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, bits); // Ext. Trig
	DAQmxWriteDigitalLines(XClockOut, bits, 0, 1000.0, DAQmx_Val_GroupByChannel, signal, NULL, NULL); // X Motor signal	
	DAQmxStartTask(XClockOut); // Pulse motor
	DAQmxWaitUntilTaskDone(XClockOut, 1000.0); // Wait for action to be completed
	DAQmxStopTask(XClockOut);
	DAQmxClearTask(XClockOut);

	delete signal;
}