Esempio n. 1
0
def main(period):
    taskHandle = daqmx.TaskHandle()
    daqmx.CreateTask("", taskHandle)

    physicalChannel = "Dev1/ao0"

    t = np.linspace(0, 2 * pi / period, 1000)
    data = 2 * np.sin(t)

    daqmx.CreateAOVoltageChan(taskHandle, physicalChannel, "", -10.0, 10.0,
                              daqmx.Val_Volts, None)

    daqmx.CfgSampClkTiming(taskHandle, "", 1000.0, daqmx.Val_Rising,
                           daqmx.Val_ContSamps, 1000)

    daqmx.WriteAnalogF64(taskHandle, 1000, 0, 10.0, daqmx.Val_GroupByChannel,
                         data)

    daqmx.StartTask(taskHandle)

    for n in range(100):
        time.sleep(0.3)

    daqmx.StopTask(taskHandle)
    daqmx.ClearTask(taskHandle)
Esempio n. 2
0
 def stop_DAQmx(self):
     daqmx.StopTask(self.AOtask)
     daqmx.StopTask(self.AItask)
     daqmx.ClearTask(self.AItask)
     daqmx.ClearTask(self.AOtask)
Esempio n. 3
0
 def stop(self):
     daqmx.StopTask(self.handle)
     if self.autolog:
         self.autolog_file_object.close()
Esempio n. 4
0
daqmx.CreateAOVoltageChan(AOtaskHandle, "Dev1/ao0", "", -10.0, 10.0,
                          daqmx.Val_Volts, None)

daqmx.CfgSampClkTiming(AOtaskHandle, "", sr, daqmx.Val_Rising,
                       daqmx.Val_ContSamps, 1000)

daqmx.CreateAIVoltageChan(AItaskHandle, "Dev1/ai1", "", daqmx.Val_Diff, -10.0,
                          10.0, daqmx.Val_Volts, None)

daqmx.CfgSampClkTiming(AItaskHandle, "", sr, daqmx.Val_Rising,
                       daqmx.Val_ContSamps, 1000)

written = daqmx.WriteAnalogF64(AOtaskHandle, 1000, 0, 10.0,
                               daqmx.Val_GroupByChannel, data)

dataread, nread = daqmx.ReadAnalogF64(AItaskHandle, 1000, 10.0,
                                      daqmx.Val_GroupByChannel, 1000, 1)

daqmx.StartTask(AOtaskHandle)
daqmx.StartTask(AItaskHandle)

print written, "samples written"
print nread, "samples read"

plt.plot(dataread)

daqmx.StopTask(AItaskHandle)
daqmx.ClearTask(AItaskHandle)
daqmx.StopTask(AOtaskHandle)
daqmx.ClearTask(AOtaskHandle)
Esempio n. 5
0
 def stopdaq(self):
     daqmx.StopTask(self.analogtask)
     daqmx.StopTask(self.carpostask)
     daqmx.StopTask(self.turbangtask)
Esempio n. 6
0
diTaskHandle = daqmx.TaskHandle()

daqmx.CreateTask("", aiTaskHandle)
daqmx.CreateAIVoltageChan(aiTaskHandle, "Dev1/ai0", "", daqmx.Val_Diff, 0.0,
                          10.0, daqmx.Val_Volts)

daqmx.CfgSampClkTiming(aiTaskHandle, "", 100.0, daqmx.Val_Rising,
                       daqmx.Val_ContSamps, 1000)

trigname = daqmx.GetTerminalNameWithDevPrefix(aiTaskHandle, "ai/SampleClock")

daqmx.CreateTask("", diTaskHandle)
daqmx.CreateDIChan(diTaskHandle, "Dev1/port0", "", daqmx.Val_ChanForAllLines)
daqmx.CfgSampClkTiming(diTaskHandle, trigname, 100.0, daqmx.Val_Rising,
                       daqmx.Val_ContSamps, 1000)

daqmx.StartTask(diTaskHandle)
daqmx.StartTask(aiTaskHandle)

adata = daqmx.ReadAnalogF64(aiTaskHandle, 1000, 10.0, daqmx.Val_GroupByChannel,
                            1000, 1)
ddata = daqmx.ReadDigitalU32(diTaskHandle, 1000, 10.0,
                             daqmx.Val_GroupByChannel, 1000, 1)

print adata
print ddata

daqmx.StopTask(diTaskHandle)
daqmx.StopTask(aiTaskHandle)
daqmx.ClearTask(diTaskHandle)
daqmx.ClearTask(aiTaskHandle)