예제 #1
0
    def do_get_output(self, channel, output_range=0):
        raw_data = comedi_lib.data_read(self._id, 1, channel, output_range, 0)
        data = comedi_lib.convert_to_phys(
                                    self._id, 1, channel,
                                    raw_data,
#                                    self._default_output_range,
                                    output_range,
                                    self._output_maxdata)
        return float(data)
예제 #2
0
 def do_get_output(self, channel, output_range=0):
     raw_data = comedi_lib.data_read(self._id, 1, channel, output_range, 0)
     data = comedi_lib.convert_to_phys(
         self._id,
         1,
         channel,
         raw_data,
         #                                    self._default_output_range,
         output_range,
         self._output_maxdata)
     return float(data)
예제 #3
0
    def do_get_input(self, channel, samples=1, averaged=False,
                        sample_rate=8e3,
                        input_range=0):
        '''Get the value of the analog input

            Input:
                channel
                samples     :   number of samples
                averaged    :   True or False
                sample_rate :   Samples / second
                input_range :   0  [-4.096 V, 4.096 V]
                                1  [-2.048 V, 2.048 V]
                                2  [ 0.0   V, 4.096 V]
                                3  [ 0.0   V, 2.048 V]
            Output:
                data (numpy float32 array)
        '''
        if samples == 1:
            raw_data = comedi_lib.data_read(self._id, 
                                            0, channel, 
                                            input_range, 
                                            0)
            data = comedi_lib.convert_to_phys(raw_data,
                                    self._default_input_range,
                                    self._default_input_maxdata)
            return data
        elif samples > 1:
#            data =  comedi_lib.data_read_n(self._id,
#                                                0, channel, 0, 0, 
#                                                samples)
            if sample_rate > 2e3:
                # The daq needs 0.5 ms to set up, which messes up the first
                # samples in fast measurements.
                offset = 2
            else:
                offset = 0
            data = comedi_lib.data_read_n_async(self._id,
                                                0,
                                                channel,
                                                input_range,
                                                0,
                                                samples + offset,
                                                sample_rate)
            if averaged:
                return average(data[offset:])
            else:
                return data[offset:]
        else:
            logging.warning('Invalid number of samples requested')
            return False
예제 #4
0
    def do_get_input(self, channel, samples=1, averaged=False,
                        sample_rate=8e3,
                        input_range=0):
        '''Get the value of the analog input

            Input:
                channel
                samples     :   number of samples
                averaged    :   True or False
                sample_rate :   Samples / second
                input_range :  
            Output:
                data (numpy float32 array)
        '''
        input_maxdata = comedi_lib.get_max_data(self._id,
                                            0,
                                            channel)
        if samples == 1:
            raw_data = comedi_lib.data_read(self._id, 
                                            0, channel, 
                                            input_range, 
                                            0)
            data = comedi_lib.convert_to_phys(
                                    self._id, 0, channel,
                                    raw_data,
#                                    self._default_input_range,
                                    input_range,
                                    input_maxdata)
            return data
        elif samples > 1:
            data = comedi_lib.data_read_n_async(self._id,
                                                0,
                                                channel,
                                                input_range,
                                                0,
                                                samples,
                                                sample_rate)
            if averaged:
                return average(data)
            else:
                return data
        else:
            logging.warning('Invalid number of samples requested')
            return False
예제 #5
0
    def do_get_input(self,
                     channel,
                     samples=1,
                     averaged=False,
                     sample_rate=8e3,
                     input_range=0):
        '''Get the value of the analog input

            Input:
                channel
                samples     :   number of samples
                averaged    :   True or False
                sample_rate :   Samples / second
                input_range :  
            Output:
                data (numpy float32 array)
        '''
        input_maxdata = comedi_lib.get_max_data(self._id, 0, channel)
        if samples == 1:
            raw_data = comedi_lib.data_read(self._id, 0, channel, input_range,
                                            0)
            data = comedi_lib.convert_to_phys(
                self._id,
                0,
                channel,
                raw_data,
                #                                    self._default_input_range,
                input_range,
                input_maxdata)
            return data
        elif samples > 1:
            data = comedi_lib.data_read_n_async(self._id, 0, channel,
                                                input_range, 0, samples,
                                                sample_rate)
            if averaged:
                return average(data)
            else:
                return data
        else:
            logging.warning('Invalid number of samples requested')
            return False
예제 #6
0
 def do_get_output_unipolar(self, channel):
     raw_data = comedi_lib.data_read(self._id, 1, channel, 1, 0)
     data = comedi_lib.convert_to_phys(raw_data,
                                 self._unipolar_output_range,
                                 self._default_output_maxdata)
     return float(data)