Example #1
0
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
Example #2
0
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
Example #3
0
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.'
Example #4
0
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 (repr(options.ao_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 as msg:
        print('Caught Ctrl-C.')
    task.stop()
    del task
Example #5
0
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:
        raise ValueError('Select argument to function ' +\
                'decelProg must be one of the strings "SF" or "S=1"')
Example #6
0
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
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")
Example #8
0
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
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