def stop_measure(self): #A ameliorer en recuperant dirrectement les tasks depuis system.truc try: self.timer.stop() except: pass try: self.apd.close() except: pass try: self.voltage_out.close() except: pass try: self.tension.close() except: pass try: with nidaqmx.Task() as task: task.ao_channels.add_ao_voltage_chan('Dev1/ao0') task.write(0) task.start() except: pass self.stop.setEnabled(False) self.start.setEnabled(True)
def apply_voltage(self): self.V = float(self.textV.text()) with nidaqmx.Task() as task: source = self.source_menu.currentIndex() task.ao_channels.add_ao_voltage_chan('Dev1/ao' + str(source)) task.write(self.V) task.start()
def servo(): with nidaqmx.Task() as task: task.ao_channels.add_ao_voltage_chan('Dev1/ao1') angle = 20 tension = angle * 5. / 180. task.write(tension) time.sleep(0.5)
def do2(): with nidaqmx.Task() as task: task.do_channels.add_do_chan('Dev1/port0/line1') out_stream = nidaqmx._task_modules.out_stream.OutStream(task) task.timing.cfg_samp_clk_timing( 10000, sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS) signal = np.zeros(100) for i in range(len(signal)): if i % 2 == 0: signal[i] = 1 signal = np.float64(signal) #print (signal[0].dtype) task.write([False, True], auto_start=True)
def digital_out(): with nidaqmx.Task() as task: task.do_channels.add_do_chan('Dev1/port0/line0') task.timing.cfg_samp_clk_timing( 100, sample_mode=nidaqmx.constants.AcquisitionType.FINITE, samps_per_chan=200) signal = [True, False] * 5 task.write(signal) task.start() while not task.is_task_done(): pass
def trigger(): with nidaqmx.Task() as trig: with nidaqmx.Task() as task: trig.co_channels.add_co_pulse_chan_freq('Dev1/ctr2', freq=0.2) trig.timing.cfg_implicit_timing( sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS) trig.start() task.do_channels.add_do_chan('Dev1/port0/line0') task.timing.cfg_samp_clk_timing( 1, sample_mode=nidaqmx.constants.AcquisitionType.FINITE, samps_per_chan=2) task.triggers.start_trigger.cfg_dig_edge_start_trig( '/Dev1/Ctr2InternalOutput') task.write([True, False]) task.start() while not task.is_task_done(): pass
def zero_hyst(self): dt = 1E-3 N = 2000 f_oscill = 50 f_acq = 1 / dt tmax = N * dt omega = f_oscill * 2 * np.pi t = np.linspace(0, tmax, N) Vlist = np.cos(t * omega) * (tmax - t) / tmax * 5 with nidaqmx.Task() as task: source = self.source_menu.currentIndex() task.ao_channels.add_ao_voltage_chan('Dev1/ao' + str(source)) task.timing.cfg_samp_clk_timing( f_acq, sample_mode=nidaqmx.constants.AcquisitionType.FINITE, samps_per_chan=N) task.write(Vlist) task.start() while not task.is_task_done(): pass
def close_shutter(self): with nidaqmx.Task() as task: task.do_channels.add_do_chan('Dev1/port0/line0') task.write(False) while not task.is_task_done(): pass
def moveServo(self): with nidaqmx.Task() as task: task.ao_channels.add_ao_voltage_chan('Dev1/ao1') tension=self.target*5./180. task.write(tension) time.sleep(0.5)
def test_sample_clock(): with nidaqmx.Task() as task: task.do_channels.add_do_chan('Dev1/port2/line4') task.write(True) task.start()