예제 #1
0
파일: NI_DAQ_IV.py 프로젝트: zsurge/qkit
 def get_sense_value(self, sample_freq=None, channel=0):
     """
     Gets sense value of channel <channel>.
     
     Parameters
     ----------
     channel: int
         Number of channel of interest. Default is 0 (ai0).
     
     Returns
     -------
     val: float
         Sense value.
     """
     if sample_freq:
         self._sample_freq[channel] = sample_freq
     samples = int(self._sample_freq[channel] / self._plc *
                   self._sense_nplc[channel])
     if not samples:
         samples = 1
     data = list(
         map(
             lambda i: nidaq.read(devchan='{:s}/ai{:d}'.format(
                 self._dev, channel),
                                  samples=samples,
                                  freq=self._sample_freq[channel],
                                  config=self._chan_config[channel]),
             range(int(self._sense_average[channel]))))
     return np.mean(np.trapz(data, dx=1. / (samples - 1)))
예제 #2
0
파일: NI_DAQ_IV.py 프로젝트: zsurge/qkit
    def read(self,
             channel,
             samples=1,
             freq=1e4,
             minv=-10.0,
             maxv=10.0,
             timeout=10.0):
        """
        Reads analog input values <data> of input channel <channel> with sample frequency <freq>.

        Parameters
        ----------
        channel: int
            Number of input channel of interest.
        samples: int
            Number of samples to read up to max_samples.
        freq: float
            Sample frequency in Hertz.
        minv: float
            Minimum voltage in Volts.
        maxv: float
            Maximum voltage in Volts.
        timeout: float
            Time to wait for completion in seconds.

        Returns
        -------
        data: float/numpy.array/None
            Read voltage data in Volts on success or None on error.
        """
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxcreatetask/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaivoltagechan/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxcfgsampclktiming/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxstarttask/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxreadanalogf64/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxreadanalogscalarf64/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxstoptask/
        # Corresponding command: http://zone.ni.com/reference/en-XX/help/370471AM-01/daqmxcfunc/daqmxcleartask/
        return nidaq.read(devchan='{:s}/ai{:d}'.format(self._dev, channel),
                          samples=samples,
                          freq=freq,
                          minv=minv,
                          maxv=maxv,
                          timeout=timeout,
                          config=self._chan_config[channel])
예제 #3
0
 def read(self,devchan, samples=1, freq=10000.0, minv=-10.0, maxv=10.0, timeout=10.0):
     return nidaq.read(devchan, samples=samples, freq=freq, minv=minv, maxv=maxv, timeout=timeout,config=self._chan_config)
예제 #4
0
 def do_get_input(self, channel):
     devchan = '%s/%s' % (self._id, channel)
     return nidaq.read(devchan, config=self._chan_config)