class dac: def connect_nidaqmx(self): '''look at nidaqmx''' system = System() '''search for the card that we want to use''' card = None for dev in system.devices: if dev.get_product_type() == CARD_NAME: card = dev assert (card != None) '''create the 8-channel task''' self.task = AnalogOutputTask() channels = card.get_analog_output_channels()[:8] for channel in channels: self.task.create_voltage_channel(channel, min_val=0, max_val=7) '''zero everything''' self.zero() def write_voltages(self, voltages): av = np.array(voltages) if max(av) > 7.0: print 'CANNOT WRITE VOLTAGES GREATER THAN 7.0V' voltages = [0, 0, 0, 0, 0, 0, 0, 0] av = voltages self.task.write(voltages) print 'wrote', av.round(2) def zero(self): self.write_voltages([0, 0, 0, 0, 0, 0, 0, 0]) def __init__(self): print 'CNOT-MZ heater server\n' self.connect_nidaqmx()
class dac: def connect_nidaqmx(self): '''look at nidaqmx''' system=System() '''search for the card that we want to use''' card=None for dev in system.devices: if dev.get_product_type() == CARD_NAME: card=dev assert(card!=None) '''create the 8-channel task''' self.task = AnalogOutputTask() channels=card.get_analog_output_channels()[:8] for channel in channels: self.task.create_voltage_channel(channel, min_val=0, max_val=7) '''zero everything''' self.zero() def write_voltages(self, voltages): av=np.array(voltages) if max(av)>7.0: print 'CANNOT WRITE VOLTAGES GREATER THAN 7.0V' voltages=[0,0,0,0,0,0,0,0] av=voltages self.task.write(voltages) print 'wrote', av.round(2) def zero(self): self.write_voltages([0,0,0,0,0,0,0,0]) def __init__(self): print 'CNOT-MZ heater server\n' self.connect_nidaqmx()
def configure_daq(mode,daq_config): try: from nidaqmx import AnalogOutputTask except Exception: print "nidaqmx missing, continuing anyway" daq = AnalogOutputTask() daq.create_voltage_channel(**daq_config['X']) daq.create_voltage_channel(**daq_config['Y']) daq.configure_timing_sample_clock(**daq_config[mode]) return daq
def move_daq(signal,daq_config): try: from nidaqmx import AnalogOutputTask except Exception: print "nidaqmx missing, continuing anyway" daq = AnalogOutputTask() daq.create_voltage_channel(**daq_config['X']) daq.create_voltage_channel(**daq_config['Y']) daq.write(signal) del daq
def connect_nidaqmx(self): '''look at nidaqmx''' system = System() '''search for the card that we want to use''' card = None for dev in system.devices: if dev.get_product_type() == CARD_NAME: card = dev assert (card != None) '''create the 8-channel task''' self.task = AnalogOutputTask() channels = card.get_analog_output_channels()[:8] for channel in channels: self.task.create_voltage_channel(channel, min_val=0, max_val=7) '''zero everything''' self.zero()
def set_voltage_to_channel(channel, voltage): from nidaqmx import AnalogOutputTask tolerance = 1 laserTask = AnalogOutputTask("pointer") laserTask.create_voltage_channel(channel, min_val=voltage - tolerance, max_val=voltage + tolerance) laserTask.write(voltage) laserTask.clear()
def write(self, context): task = AnalogOutputTask(_task_name(context)) minimum = context.minimum if context.minimum is not None else -10 maximum = context.maximum if context.maximum is not None else 10 task.create_voltage_channel(_phys_channel(context), terminal="rse", min_val=minimum, max_val=maximum) task.write(self, context.value, auto_start=False) task.start()
def set_voltage_to_channel(channel,voltage): from nidaqmx import AnalogOutputTask tolerance = 1 laserTask = AnalogOutputTask("pointer") laserTask.create_voltage_channel(channel,min_val=voltage - tolerance, max_val=voltage + tolerance) laserTask.write(voltage) laserTask.clear()
def runner (parser, options, args): task = AnalogOutputTask() args, kws = get_method_arguments('create_voltage_channel', options) phys_channel = kws['phys_channel'] task.create_voltage_channel (**kws) channels = task.get_names_of_channels() if not channels: print 'No channels specified' return args, kws = get_method_arguments('configure_timing_sample_clock', options) clock_rate = kws.get('rate', 1000.0) if not task.configure_timing_sample_clock(**kws): return args, kws = get_method_arguments('ao_write', options) layout = kws.get('layout', 'group_by_scan_number') if options.ao_task=='sin': min_val = task.get_min(phys_channel) max_val = task.get_max(phys_channel) samples_per_channel = clock_rate / len(channels) x = np.arange(samples_per_channel, dtype=float)*2*np.pi/samples_per_channel data = [] for index, channel in enumerate(channels): data.append(0.5*(max_val+min_val) + 0.5*(max_val-min_val)*np.sin(x-0.5*index*np.pi/len(channels))) data = np.array(data) if layout=='group_by_scan_number': data = data.T else: raise NotImplementedError (`options.ai_task`) print 'samples available/written per channel= %s/%s ' % (data.size//len(channels), task.write(data.ravel(), **kws)) if not options.ao_write_auto_start: task.start() try: time.sleep(options.ao_task_duration) except KeyboardInterrupt, msg: print 'Caught Ctrl-C.'
def configure_daq(mode, daq_config): try: from nidaqmx import AnalogOutputTask except Exception: print "nidaqmx missing, continuing anyway" daq = AnalogOutputTask() daq.create_voltage_channel(**daq_config['X']) daq.create_voltage_channel(**daq_config['Y']) daq.configure_timing_sample_clock(**daq_config[mode]) return daq
def move_daq(signal, daq_config): try: from nidaqmx import AnalogOutputTask except Exception: print "nidaqmx missing, continuing anyway" daq = AnalogOutputTask() daq.create_voltage_channel(**daq_config['X']) daq.create_voltage_channel(**daq_config['Y']) daq.write(signal) del daq
def connect_nidaqmx(self): '''look at nidaqmx''' system=System() '''search for the card that we want to use''' card=None for dev in system.devices: if dev.get_product_type() == CARD_NAME: card=dev assert(card!=None) '''create the 8-channel task''' self.task = AnalogOutputTask() channels=card.get_analog_output_channels()[:8] for channel in channels: self.task.create_voltage_channel(channel, min_val=0, max_val=7) '''zero everything''' self.zero()
@author: Cold_OH """ from yepy import instruments, yeutil, output from time import sleep from nidaqmx import AnalogOutputTask from numpy import * import time, copy pb = instruments.PulseBlaster() scope = instruments.Tds7154() scope.single_mode() scope.average_mode(840) # 1400 records for 600/600 #scope.trigger() # Instantiate the Photon Counter task = AnalogOutputTask() task.create_voltage_channel('Dev1/ao0', min_val=0.0, max_val=8) # 5.3V corresponds to 8 kV task.configure_timing_sample_clock(rate=100000) task2 = AnalogOutputTask() task2.create_voltage_channel('Dev1/ao1', min_val=0.0, max_val=8.86) # 5.3V corresponds to 8 kV task2.configure_timing_sample_clock(rate=100000) counter = instruments.Sr430() counter.restoreSettings() counter.setRecords(20) counter2 = instruments.Sr400() counter2.setRecords(100)
It computes deceleration sequences for generalized charge configurations. - Dave Reens, 8/6/18 """ from yepy import instruments, yeutil, output, alternateDecelerator from time import sleep from nidaqmx import AnalogOutputTask import copy # Setup Timing Card pb = instruments.PulseBlaster() pb.add(5, [0], [22.6 * pb.us]) # start the valve # Setup the Analog Output Card for the PS voltage task = AnalogOutputTask() task.create_voltage_channel('Dev1/ao0', min_val=0.0, max_val=9) # 5.3V corresponds to 8 kV task.configure_timing_sample_clock(rate=100000) task.write(100000 * [12500 / 15000.0 * 10]) # Setup Decelerator decelSeq = alternateDecelerator.delayMode def decelProg(vi, vf, select): if select == 'SF': decelSeq = alternateDecelerator.delayMode elif select == 'S=1': decelSeq = alternateDecelerator.normalMode decelSeq.calcPhase(vi, vf, 57)
import niScope from nidaqmx import AnalogOutputTask import numpy as np scope = niScope.Scope("Dev4") task = AnalogOutputTask() task.create_voltage_channel("Dev3/ao3") task.configure_timing_sample_clock(source="RTSI0") data = np.sin(0.5*np.pi*np.arange(10000))**2 task.write(data) scope.ConfigureHorizontalTiming(sampleRate=30000,numPts=1000000) scope.ConfigureVertical() scope.ConfigureTrigger("Edge") scope.ExportSignal(signal=4, outputTerminal='VAL_RTSI_0') raw_input("signal exported") scope.Commit() raw_input("committed") scope.InitiateAcquisition() raw_input("Acquisition initiated")
from nidaqmx import AnalogOutputTask task = AnalogOutputTask() task.create_voltage_channel("Dev1/ao2",min_voltage=0,max_voltage=6)
def runner(parser, options, args): task = AnalogOutputTask() args, kws = get_method_arguments('create_voltage_channel', options) phys_channel = kws['phys_channel'] task.create_voltage_channel(**kws) channels = task.get_names_of_channels() if not channels: print 'No channels specified' return args, kws = get_method_arguments('configure_timing_sample_clock', options) clock_rate = kws.get('rate', 1000.0) if not task.configure_timing_sample_clock(**kws): return args, kws = get_method_arguments('ao_write', options) layout = kws.get('layout', 'group_by_scan_number') if options.ao_task == 'sin': min_val = task.get_min(phys_channel) max_val = task.get_max(phys_channel) samples_per_channel = clock_rate / len(channels) x = np.arange(samples_per_channel, dtype=float) * 2 * np.pi / samples_per_channel data = [] for index, channel in enumerate(channels): data.append(0.5 * (max_val + min_val) + 0.5 * (max_val - min_val) * np.sin(x - 0.5 * index * np.pi / len(channels))) data = np.array(data) if layout == 'group_by_scan_number': data = data.T else: raise NotImplementedError( ` options.ai_task `) print 'samples available/written per channel= %s/%s ' % ( data.size // len(channels), task.write(data.ravel(), **kws)) if not options.ao_write_auto_start: task.start() try: time.sleep(options.ao_task_duration) except KeyboardInterrupt, msg: print 'Caught Ctrl-C.'
from nidaqmx import AnalogOutputTask import numpy as np data = 9.95 * np.sin(np.arange(1000, dtype=np.float64) * 2 * np.pi / 1000) task = AnalogOutputTask() task.create_voltage_channel('Dev1/ao2', min_val=-10.0, max_val=10.0) task.configure_timing_sample_clock(rate=1000.0) task.write(data) task.start() raw_input('Generating voltage continuously. Press Enter to interrupt..') task.stop() del task
from nidaqmx import AnalogOutputTask import numpy as np task = AnalogOutputTask() task.create_voltage_channel('Dev1/ao0', max_val=10) task.configure_timing_sample_clock() task.write(np.ones(1000) * 3) data = [i * 0.001 for i in range(1000)] for n in range(1000): task = AnalogOutputTask() task.create_voltage_channel("Dev1/ao3") task.configure_timing_sample_clock() task.write(data, auto_start=False) # del task
from nidaqmx import AnalogOutputTask import numpy as np task = AnalogOutputTask() task.create_voltage_channel('Dev1/ao0', max_val = 10) task.configure_timing_sample_clock() task.write(np.ones(1000)*3) data = [i*0.001 for i in range(1000)] for n in range(1000): task = AnalogOutputTask() task.create_voltage_channel("Dev1/ao3") task.configure_timing_sample_clock() task.write(data,auto_start=False) # del task
from nidaqmx import AnalogOutputTask task = AnalogOutputTask() task.create_voltage_channel("Dev1/ao2", min_voltage=0, max_voltage=6)
from time import sleep from nidaqmx import AnalogOutputTask import copy # Setup Pulseblaster pb = instruments.PulseBlaster() pb.add(5,[0],[22.6*pb.us]) # Valve Fire Pulse # Setup the Analog Output Card # channel 0 sets the HV PS Voltage #task = AnalogOutputTask() #task.create_voltage_channel('Dev1/ao0', min_val=0.0, max_val=9) #task.configure_timing_sample_clock(rate=100000) #task.write(100000*[12500/15000.0*10]) # Channel 1 sets the amplitude for the valve driving pulse task2 = AnalogOutputTask() task2.create_voltage_channel('Dev1/ao1', min_val=0.0, max_val=8.75) task2.configure_timing_sample_clock(rate=100000) task2.write(100000*[8.75]) # Setup Decelerator offset = 0.186/810 def decelProg(num,select): n = num/4 if select == 'SF': decelSeq = alternateDecelerator.bunchFirstSF decelSeq.labelArray = 'xyzw'*n+'As'+'bjarbias'*(83-n) elif select == 'S=1': decelSeq = alternateDecelerator.bunchFirstS1 decelSeq.labelArray = 'xyzw'*n+'A' + 'baba'*(83-n) else:
from nidaqmx import AnalogOutputTask import numpy as np data = 9.95*np.sin(np.arange(1000, dtype=np.float64)*2*np.pi/1000) task = AnalogOutputTask() task.create_voltage_channel('Dev1/ao2', min_val=-10.0, max_val=10.0) task.configure_timing_sample_clock(rate = 1000.0) task.write(data) task.start() raw_input('Generating voltage continuously. Press Enter to interrupt..') task.stop() del task