def createCOPulseTask2(chan, totTime, delay, pulseWidth, numPulses=4, edge=DAQmx_Val_Rising, triggerSource="PFI0"): th = Task() #th.CreateCOPulseChanFreq ( chan, "", DAQmx_Val_Hz, DAQmx_Val_Low, delay, freq, th.CreateCOPulseChanTime(chan, "", DAQmx_Val_Seconds, DAQmx_Val_Low, delay, totTime - pulseWidth, pulseWidth) th.CfgDigEdgeStartTrig(triggerSource, edge) th.CfgImplicitTiming(DAQmx_Val_FiniteSamps, numPulses) th.SetTrigAttribute(DAQmx_StartTrig_Retriggerable, True) return th
from PyDAQmx import Task import PyDAQmx import numpy as np from ctypes import byref pulse = Task() pulse.CreateCOPulseChanTime("/Dev2/ctr0", "LED pulse", PyDAQmx.DAQmx_Val_Seconds, PyDAQmx.DAQmx_Val_Low, 1.00, 10, 10) pulse.StartTask() voltage = Task() voltage.CreateAOVoltageChan("/Dev2/ao1", "LED", 0, 5, PyDAQmx.DAQmx_Val_Volts, None) voltage.CfgImplicitTiming(PyDAQmx.DAQmx_Val_ContSamps, 1000) voltage.CfgDigEdgeStartTrig("/Dev2/pfi0", PyDAQmx.DAQmx_Val_Rising) voltage.WriteAnalogScalarF64(1, 0, 3, None) # voltage.CfgSampClkTiming(None,1000,PyDAQmx.DAQmx_Val_Rising,PyDAQmx.DAQmx_Val_ContSamps,4000) # voltage.CfgDigEdgeStartTrig("/Dev2/pfi0",PyDAQmx.DAQmx_Val_Rising) # voltage.StartTask() # voltage.WriteAnalogF64(1,0,voltage_out,None) # taskHandle,4000,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL) # class LED(Task): # def __init__(self): # Task.__init__(self) # self.CreateAOVoltageChan("/Dev2/ao1","LED",0,5,PyDAQmx.DAQmx_Val_Volts,None) # self.CfgSampClkTiming(None,1000,PyDAQmx.DAQmx_Val_Rising,PyDAQmx.DAQmx_Val_ContSamps,1000) # self.CfgDigEdgeStartTrig("/Dev2/pfi0",PyDAQmx.DAQmx_Val_Rising) # self.AutoRegisterDoneEvent(0)
print(a.message) pmt1_gain_val = float(input("Enter voltage gain between 0.1 and 1.25 V: ")) if first_pass == True: # Generate gating pulses # gate = Task() # gate.CreateCOPulseChanTime(b"/%s/ctr0"%device,"",PyDAQmx.DAQmx_Val_Seconds,PyDAQmx.DAQmx_Val_Low,10,5,5) #initial delay, low time, high time # gate.CfgImplicitTiming(PyDAQmx.DAQmx_Val_ContSamps,buffer_size) # gate.StartTask() # Generate pulse pulse = Task() pulse.CreateCOPulseChanTime(b"/%s/ctr0"%device,"",PyDAQmx.DAQmx_Val_Seconds,PyDAQmx.DAQmx_Val_Low,30,15,15) #initial delay, low time, high time pulse.CfgImplicitTiming(PyDAQmx.DAQmx_Val_ContSamps,buffer_size) #last is the number of pulses to generate in Finite mode pulse.StartTask() #PyDAQmx.DAQmxConnectTerms(b"/%s/PFI4"%device, b"/%s/PFI3"%device, PyDAQmx.DAQmx_Val_InvertPolarity) # gate.StartTask() # pulse.StartTask() # Write out voltage # led_data = np.ones(1)*4 #np.concatenate((np.ones(95)*4, np.zeros(5))) # led = Task() # led.CreateAOVoltageChan(b"/%s/ao0"%device,"LED",0,5,PyDAQmx.DAQmx_Val_Volts,None) # led.CfgSampClkTiming(b"/%s/Ctr0Source"%device,sampling_freq,PyDAQmx.DAQmx_Val_Rising, PyDAQmx.DAQmx_Val_ContSamps,buffer_size) # led.StartTask() # led.WriteAnalogF64(100,1,10.0,PyDAQmx.DAQmx_Val_GroupByChannel,led_data,None,None)