Ejemplo n.º 1
0
def setVoltage_2(val):
    try:
        taskHandle = tp.TaskHandle()
        daq.DAQmxCreateTask("",taskHandle)
#        print "taskHandle Value", taskHandle.value
        daq.DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao1","",0.0,10.0,cnst.DAQmx_Val_Volts,"")
        daq.DAQmxStartTask(taskHandle)
        daq.DAQmxWriteAnalogScalarF64(taskHandle,1,5.0,tp.float64(val),None)
        if not taskHandle == 0 :
#            print "Stopping Tasks\n"
            daq.DAQmxStopTask(taskHandle)
            daq.DAQmxClearTask(taskHandle)
        return 0
    except:
        errBuff=tp.create_string_buffer(b"",2048)
        daq.DAQmxGetExtendedErrorInfo(errBuff,2048)
        print(errBuff.value)
Ejemplo n.º 2
0
def getVoltage():
    try:
        taskHandle = tp.TaskHandle()
        daq.DAQmxCreateTask("",taskHandle)
#        print "taskHandle Value", taskHandle.value
        val = tp.float64()
        daq.DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",cnst.DAQmx_Val_RSE,0.0,10.0,cnst.DAQmx_Val_Volts,"")
        daq.DAQmxStartTask(taskHandle)
        daq.DAQmxReadAnalogScalarF64(taskHandle,5.0,daq.byref(val),None)
        if not taskHandle == 0 :
#            print "Stopping Tasks\n"
            daq.DAQmxStopTask(taskHandle)
            daq.DAQmxClearTask(taskHandle)
        return val.value
    except:
        errBuff=tp.create_string_buffer(b"",2048)
        daq.DAQmxGetExtendedErrorInfo(errBuff,2048)
        print(errBuff.value)