Exemplo n.º 1
0
def syncAIOTest():
    print "::::::::::::::::::  Sync Analog I/O Test  :::::::::::::::::::::"
    task1 = n.createTask()
    task1.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task1.CfgSampClkTiming("/Dev1/ao/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)

    task2 = n.createTask()
    task2.CreateAOVoltageChan("/Dev1/ao0", "", -10., 10., n.Val_Volts, None)
    #task2.CfgSampClkTiming(None, 10000.0, nidaq.Val_Rising, nidaq.Val_FiniteSamps, 1000)
    task2.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    #task2.CfgDigEdgeStartTrig("ai/StartTrigger", nidaq.Val_Rising)
    


    data1 = np.zeros((100,), dtype=np.float64)
    data1[20:40] = 7.0
    data1[60:80] = 5.0
    print "  Wrote ao samples:", task2.write(data1)
    task1.start()
    task2.start()
    
    data2 = task1.read()
    #time.sleep(1.0)
    task1.stop()
    task2.stop()
    
    print "  Data acquired:", data2[0].shape
    return data2
Exemplo n.º 2
0
Arquivo: test.py Projeto: ablot/acq4
def syncAIOTest():
    print "::::::::::::::::::  Sync Analog I/O Test  :::::::::::::::::::::"
    task1 = n.createTask()
    task1.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task1.CfgSampClkTiming("/Dev1/ao/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)

    task2 = n.createTask()
    task2.CreateAOVoltageChan("/Dev1/ao0", "", -10., 10., n.Val_Volts, None)
    #task2.CfgSampClkTiming(None, 10000.0, nidaq.Val_Rising, nidaq.Val_FiniteSamps, 1000)
    task2.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    #task2.CfgDigEdgeStartTrig("ai/StartTrigger", nidaq.Val_Rising)
    


    data1 = numpy.zeros((100,), dtype=numpy.float64)
    data1[20:40] = 7.0
    data1[60:80] = 5.0
    print "  Wrote ao samples:", task2.write(data1)
    task1.start()
    task2.start()
    
    data2 = task1.read()
    #time.sleep(1.0)
    task1.stop()
    task2.stop()
    
    print "  Data acquired:", data2[0].shape
    return data2
Exemplo n.º 3
0
Arquivo: test.py Projeto: ablot/acq4
def syncADTest():
    print "::::::::::::::::::  A/D  Test  :::::::::::::::::::::"
    task1 = n.createTask()
    task1.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task1.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    task2 = n.createTask()
    task2.CreateDIChan("/Dev1/port0", "", n.Val_ChanForAllLines)
    task2.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    
    print task2.GetTaskChannels()
    #data1 = numpy.zeros((1000,), dtype=numpy.uint32)
    #data1[200:400] = 5
    #data1[600:800] = 5
    task2.start()
    #print "Wrote samples:", task2.write(data1)
    task1.start()
    data1 = task1.read()
    data2 = task2.read()
    task2.stop()
    task1.stop()
    
    print data1[0].shape, data1[0].dtype
    print data1
    print data2[0].shape, data2[0].dtype
    print data2
Exemplo n.º 4
0
def syncIOTest():
    print "::::::::::::::::::  Sync I/O Test  :::::::::::::::::::::"
    task1 = n.createTask()
    task1.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task1.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)

    task2 = n.createTask()
    task2.CreateAOVoltageChan("/Dev1/ao0", "", -10., 10., n.Val_Volts, None)
    #task2.CfgSampClkTiming(None, 10000.0, nidaq.Val_Rising, nidaq.Val_FiniteSamps, 1000)
    task2.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    #task2.CfgDigEdgeStartTrig("ai/StartTrigger", nidaq.Val_Rising)
    
    task3 = n.createTask()
    task3.CreateDIChan("/Dev1/port0/line0", "", n.Val_ChanForAllLines)
    task3.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    
    task4 = n.createTask()
    task4.CreateDOChan("/Dev1/port0/line4", "", n.Val_ChanForAllLines)
    task4.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    
    
    
    #task1.SetRefClkSrc("PXI_Clk10")
    #task2.SetRefClkSrc("PXI_Clk10")
    #print task1.GetSampClkTimebaseSrc()
    #print task2.GetSampClkTimebaseSrc()
    #task2.SetSampClkTimebaseSrc("SampleClockTimebase")
    #task2.SetSyncPulseSrc("/Dev1/SyncPulse")


    data1 = np.zeros((100,), dtype=np.float64)
    data1[20:40] = 7.0
    data1[60:80] = 5.0
    print "Wrote ao samples:", task2.write(data1)
    print "Wrote do samples:", task4.write(data1.astype(uint32))
    task2.start()
    task3.start()
    task1.start()
    data2 = task1.read()
    data3 = task3.read()
    #time.sleep(1.0)
    task1.stop()
    task2.stop()
    task3.stop()
    
    print "Data acquired:"
    print data2[0].shape
    print data3[0].shape
    return data2
Exemplo n.º 5
0
Arquivo: test.py Projeto: ablot/acq4
def syncIOTest():
    print "::::::::::::::::::  Sync I/O Test  :::::::::::::::::::::"
    task1 = n.createTask()
    task1.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task1.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)

    task2 = n.createTask()
    task2.CreateAOVoltageChan("/Dev1/ao0", "", -10., 10., n.Val_Volts, None)
    #task2.CfgSampClkTiming(None, 10000.0, nidaq.Val_Rising, nidaq.Val_FiniteSamps, 1000)
    task2.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    #task2.CfgDigEdgeStartTrig("ai/StartTrigger", nidaq.Val_Rising)
    
    task3 = n.createTask()
    task3.CreateDIChan("/Dev1/port0/line0", "", n.Val_ChanForAllLines)
    task3.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    
    task4 = n.createTask()
    task4.CreateDOChan("/Dev1/port0/line4", "", n.Val_ChanForAllLines)
    task4.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    
    
    
    #task1.SetRefClkSrc("PXI_Clk10")
    #task2.SetRefClkSrc("PXI_Clk10")
    #print task1.GetSampClkTimebaseSrc()
    #print task2.GetSampClkTimebaseSrc()
    #task2.SetSampClkTimebaseSrc("SampleClockTimebase")
    #task2.SetSyncPulseSrc("/Dev1/SyncPulse")


    data1 = numpy.zeros((100,), dtype=numpy.float64)
    data1[20:40] = 7.0
    data1[60:80] = 5.0
    print "Wrote ao samples:", task2.write(data1)
    print "Wrote do samples:", task4.write(data1.astype(uint32))
    task2.start()
    task3.start()
    task1.start()
    data2 = task1.read()
    data3 = task3.read()
    #time.sleep(1.0)
    task1.stop()
    task2.stop()
    task3.stop()
    
    print "Data acquired:"
    print data2[0].shape
    print data3[0].shape
    return data2
Exemplo n.º 6
0
def syncADTest():
    print "::::::::::::::::::  A/D  Test  :::::::::::::::::::::"
    task1 = n.createTask()
    task1.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task1.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    task2 = n.createTask()
    task2.CreateDIChan("/Dev1/port0", "", n.Val_ChanForAllLines)
    task2.CfgSampClkTiming("/Dev1/ai/SampleClock", 10000.0, n.Val_Rising, n.Val_FiniteSamps, 100)
    
    print task2.GetTaskChannels()
    task2.start()
    task1.start()
    data1 = task1.read()
    data2 = task2.read()
    task2.stop()
    task1.stop()
    
    print data1[0].shape, data1[0].dtype
    print data1
    print data2[0].shape, data2[0].dtype
    print data2
Exemplo n.º 7
0
def contReadTest():
    print "::::::::::::::::::  Continuous Read Test  :::::::::::::::::::::"
    task = n.createTask()
    task.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_ContSamps, 4000)
    task.start()
    t = ptime.time()
    for i in range(0, 10):
        data, size = task.read(1000)
        print "Cont read %d - %d samples, %fsec" % (i, size, ptime.time() - t)
        t = ptime.time()
    task.stop()
Exemplo n.º 8
0
def finiteReadTest():
    print "::::::::::::::::::  Analog Input Test  :::::::::::::::::::::"
    task = n.createTask()
    task.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -1., 1., n.Val_Volts, None)
    task.CreateAIVoltageChan("/Dev1/ai1", "", n.Val_Cfg_Default, -10., 10., n.Val_Volts, None)
    
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 1000)
    task.start()
    data = task.read()
    task.stop()
    
    return data
Exemplo n.º 9
0
Arquivo: test.py Projeto: ablot/acq4
def contReadTest():
    print "::::::::::::::::::  Continuous Read Test  :::::::::::::::::::::"
    task = n.createTask()
    task.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -10., 10., n.Val_Volts, None)
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_ContSamps, 4000)
    task.start()
    t = ptime.time()
    for i in range(0, 10):
        data, size = task.read(1000)
        print "Cont read %d - %d samples, %fsec" % (i, size, ptime.time() - t)
        t = ptime.time()
    task.stop()
Exemplo n.º 10
0
Arquivo: test.py Projeto: ablot/acq4
def finiteReadTest():
    print "::::::::::::::::::  Analog Input Test  :::::::::::::::::::::"
    task = n.createTask()
    task.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -1., 1., n.Val_Volts, None)
    task.CreateAIVoltageChan("/Dev1/ai1", "", n.Val_Cfg_Default, -10., 10., n.Val_Volts, None)
    
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 1000)
    task.start()
    data = task.read()
    task.stop()
    
    return data
Exemplo n.º 11
0
def outputTest():
    print "::::::::::::::::::  Analog Output Test  :::::::::::::::::::::"
    task = n.createTask()
    task.CreateAOVoltageChan("/Dev1/ao0", "", -10., 10., n.Val_Volts, None)
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 1000)
    
    data = np.zeros((1000,), dtype=np.float64)
    data[200:400] = 5.0
    data[600:800] = 5.0
    task.write(data)
    task.start()
    time.sleep(0.2)
    task.stop()
Exemplo n.º 12
0
Arquivo: test.py Projeto: ablot/acq4
def outputTest():
    print "::::::::::::::::::  Analog Output Test  :::::::::::::::::::::"
    task = n.createTask()
    task.CreateAOVoltageChan("/Dev1/ao0", "", -10., 10., n.Val_Volts, None)
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 1000)
    
    data = numpy.zeros((1000,), dtype=numpy.float64)
    data[200:400] = 5.0
    data[600:800] = 5.0
    task.write(data)
    task.start()
    time.sleep(0.2)
    task.stop()
Exemplo n.º 13
0
def triggerTest():
    task = n.createTask()
    task.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -1., 1., n.Val_Volts, None)
    task.CreateAIVoltageChan("/Dev1/ai1", "", n.Val_Cfg_Default, -10., 10., n.Val_Volts, None)
    
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 1000)
    task.CfgDigEdgeStartTrig("/Dev1/PFI5", n.Val_Rising)
    print "Waiting for trigger.."
    
    task.start()
    data = task.read()
    task.stop()
    
    return data
Exemplo n.º 14
0
Arquivo: test.py Projeto: ablot/acq4
def triggerTest():
    task = n.createTask()
    task.CreateAIVoltageChan("/Dev1/ai0", "", n.Val_RSE, -1., 1., n.Val_Volts, None)
    task.CreateAIVoltageChan("/Dev1/ai1", "", n.Val_Cfg_Default, -10., 10., n.Val_Volts, None)
    
    task.CfgSampClkTiming(None, 10000.0, n.Val_Rising, n.Val_FiniteSamps, 1000)
    task.CfgDigEdgeStartTrig("/Dev1/PFI5", n.Val_Rising)
    print "Waiting for trigger.."
    
    task.start()
    data = task.read()
    task.stop()
    
    return data
Exemplo n.º 15
0
modPath = os.path.split(__file__)[0]
acq4Path = os.path.abspath(os.path.join(modPath, '..', '..', '..'))
utilPath = os.path.join(acq4Path, 'lib', 'util')
sys.path = [acq4Path, utilPath] + sys.path
from nidaq import LIB as lib
import acq4.util.ptime as ptime


if sys.argv[-1] == 'mock':
    from mock import NIDAQ as n
else:
    from nidaq import NIDAQ as n


print "Assert num devs > 0:"
assert(len(n.listDevices()) > 0)
print "  OK"
print "devices: %s" % n.listDevices()
dev = n.listDevices()[0]

print "\nAnalog Channels:"
print "  AI: ", n.listAIChannels(dev)
print "  AO: ", n.listAOChannels(dev)

print "\nDigital ports:"
print "  DI: ", n.listDIPorts(dev)
print "  DO: ", n.listDOPorts(dev)

print "\nDigital lines:"
print "  DI: ", n.listDILines(dev)
print "  DO: ", n.listDOLines(dev)
Exemplo n.º 16
0
Arquivo: test.py Projeto: ablot/acq4
if sys.argv[-1] == 'mock':
    from mock import NIDAQ as n
    #import mock as nidaq
else:
    from nidaq import NIDAQ as n
    #from nidaq import SuperTask
    #import nidaq
    
#from SuperTask import SuperTask
    
    


print "Assert num devs > 0:"
assert(len(n.listDevices()) > 0)
print "  OK"
print "devices: %s" % n.listDevices()
dev = n.listDevices()[0]

print "\nAnalog Channels:"
print "  AI: ", n.listAIChannels(dev)
print "  AO: ", n.listAOChannels(dev)

print "\nDigital ports:"
print "  DI: ", n.listDIPorts(dev)
print "  DO: ", n.listDOPorts(dev)

print "\nDigital lines:"
print "  DI: ", n.listDILines(dev)
print "  DO: ", n.listDOLines(dev)