Exemple #1
0
    def __init__(self, ai_device, ai_channels, do_device, samp_rate, secs,
                 write, sync_clock, trigger_source):
        self.ai_handle = TaskHandle(0)
        self.do_handle = TaskHandle(1)

        DAQmxCreateTask('', byref(self.ai_handle))
        DAQmxCreateTask('', byref(self.do_handle))

        DAQmxCreateAIVoltageChan(self.ai_handle, ai_device, '', DAQmx_Val_Diff,
                                 -10.0, 10.0, DAQmx_Val_Volts, None)
        DAQmxCreateDOChan(self.do_handle, do_device, '',
                          DAQmx_Val_ChanForAllLines)
        # DAQmxCfgAnlgEdgeStartTrig(self.ai_handle, trigger_source, DAQmx_Val_RisingSlope, 4.0)
        DAQmxCfgDigEdgeStartTrig(self.ai_handle, trigger_source,
                                 DAQmx_Val_Rising)

        self.ai_read = int32()
        self.ai_channels = ai_channels
        self.sampsPerChanWritten = int32()

        self.write = Util.binary_to_digital_map(write)
        self.sampsPerChan = self.write.shape[1]
        self.write = numpy.sum(self.write, axis=0)

        self.totalLength = numpy.uint64(samp_rate * secs)
        self.analogData = numpy.zeros((self.ai_channels, self.totalLength),
                                      dtype=numpy.float64)

        DAQmxCfgSampClkTiming(self.ai_handle, '', samp_rate, DAQmx_Val_Rising,
                              DAQmx_Val_FiniteSamps,
                              numpy.uint64(self.totalLength))
        DAQmxCfgSampClkTiming(self.do_handle, sync_clock, samp_rate,
                              DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                              numpy.uint64(self.totalLength))
Exemple #2
0
    def __init__(self, device, samprate, secs, write, clock=''):
        Task.__init__(self)
        self.CreateDOChan(device, "", DAQmx_Val_ChanPerLine)

        self.sampsPerChanWritten = int32()
        self.totalLength = samprate * secs
        self.CfgSampClkTiming(clock, samprate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, np.uint64(self.totalLength))

        self.AutoRegisterDoneEvent(0)

        self.write = Util.binary_to_digital_map(write)
Exemple #3
0
    def __init__(self, device, samprate, secs, write, clock=''):
        self.do_handle = TaskHandle(0)

        DAQmxCreateTask("", byref(self.do_handle))

        DAQmxCreateDOChan(self.do_handle, device, '', DAQmx_Val_ChanPerLine)

        self.sampsPerChanWritten = int32()
        self.write = Util.binary_to_digital_map(write)

        self.totalLength = numpy.uint64(samprate * secs)

        DAQmxCfgSampClkTiming(self.do_handle, clock, samprate,
                              DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                              numpy.uint64(self.totalLength))
Exemple #4
0
    def __init__(self, ai_device, ai_channels, do_device, samp_rate, secs, write, sync_clock):
        self.ai_handle = TaskHandle(0)
        self.do_handle = TaskHandle(1)

        DAQmxCreateTask("", byref(self.ai_handle))
        DAQmxCreateTask("", byref(self.do_handle))

        DAQmxCreateAIVoltageChan(self.ai_handle, ai_device, "", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, None)
        DAQmxCreateDOChan(self.do_handle, do_device, "", DAQmx_Val_ChanPerLine)

        self.ai_read = int32()
        self.ai_channels = ai_channels
        self.sampsPerChanWritten = int32()
        self.write = Util.binary_to_digital_map(write)

        self.totalLength = np.uint64(samp_rate * secs)
        self.analogData = np.zeros((self.ai_channels, self.totalLength), dtype=np.float64)

        DAQmxCfgSampClkTiming(self.ai_handle, '', samp_rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                              np.uint64(self.totalLength))
        DAQmxCfgSampClkTiming(self.do_handle, sync_clock, samp_rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                              np.uint64(self.totalLength))
Exemple #5
0
    def __init__(self,
                 do_device,
                 co_device,
                 samp_rate,
                 secs,
                 write,
                 trigger_source,
                 controlled_carrier=False):
        self.do_handle = TaskHandle(0)
        self.co_handle = TaskHandle(1)
        self.do_device = do_device

        DAQmxCreateTask('', byref(self.do_handle))
        DAQmxCreateTask('', byref(self.co_handle))

        DAQmxCreateCOPulseChanFreq(self.co_handle, '/cDAQ1/Ctr0', '',
                                   DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, samp_rate,
                                   0.5)
        DAQmxCreateDOChan(self.do_handle, do_device, '',
                          DAQmx_Val_ChanForAllLines)

        DAQmxCfgDigEdgeStartTrig(self.co_handle, trigger_source,
                                 DAQmx_Val_Rising)
        self.totalLength = numpy.uint64(samp_rate * secs)
        self.secs = secs
        self.sampsPerChanWritten = int32()
        self.write = Util.binary_to_digital_map(write)
        self.sampsPerChan = self.write.shape[1]
        self.chans = self.write.shape[0]
        self.write = numpy.sum(self.write, axis=0)
        if controlled_carrier:
            self.write += 2**(self.chans + 1)
        DAQmxCfgImplicitTiming(self.co_handle, DAQmx_Val_FiniteSamps,
                               self.totalLength)
        DAQmxCfgSampClkTiming(self.do_handle, '/cDAQ1/Ctr0InternalOutput',
                              samp_rate, DAQmx_Val_Rising,
                              DAQmx_Val_FiniteSamps,
                              numpy.uint64(self.totalLength))