Beispiel #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
Beispiel #2
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 = 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
Beispiel #3
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()
    #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
Beispiel #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
Beispiel #5
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 = 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
Beispiel #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
Beispiel #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()
Beispiel #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
Beispiel #9
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()
Beispiel #10
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
Beispiel #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()
Beispiel #12
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 = 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()
Beispiel #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
Beispiel #14
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