コード例 #1
0
    def do_scan(self):
        """Does a scan of an analog output while recording an analog input. It doesn't take any arguments,
        it relies on having the proper properties set in the dictionary properties['Scan']
        """
        self.running_scan = True
        start = Q_(self.properties['Scan']['start'])
        stop = Q_(self.properties['Scan']['stop'])
        step = Q_(self.properties['Scan']['step'])
        port_in = self.properties['Scan']['port_in']
        port_out = self.properties['Scan']['port_out']
        delay = Q_(self.properties['Scan']['delay'])
        self.stop_scan = False

        units = start.u
        stop = stop.to(units)
        num_points = (stop - start) / step
        num_points = int(num_points.m_as(''))
        scan = np.linspace(start, stop, num_points + 1)
        self.xdata_scan = scan
        self.ydata_scan = np.zeros((num_points + 1))
        i = 0
        for value in scan:
            if self.stop_scan:
                break
            value = value * units
            self.daq.set_analog_value(port_out, value)
            sleep(delay.m_as('s'))
            data = self.read_analog(port_in).m_as('V')
            self.ydata_scan[i] = data
            i += 1
        self.running_scan = False
コード例 #2
0
    def do_scan(self):
        """Does a scan of an analog output while recording an analog input. It doesn't take any arguments,
        it relies on having the proper properties set in the dictionary properties['Scan']
        """
        if self.running_scan:
            raise Warning('Trying to start a second scan')

        start = Q_(self.properties['Scan']['start'])
        stop = Q_(self.properties['Scan']['stop'])
        step = Q_(self.properties['Scan']['step'])
        channel_in = self.properties['Scan']['channel_in']
        channel_out = self.properties['Scan']['channel_out']
        delay = Q_(self.properties['Scan']['delay'])
        units = start.u
        stop = stop.to(units)
        num_points = (stop - start) / step
        num_points = round(num_points.m_as('')) + 1
        scan = np.linspace(start, stop, num_points) * units
        self.xdata_scan = scan
        self.ydata_scan = np.zeros(num_points) * units
        i = 0
        self.running_scan = True
        for value in scan:
            self.daq.set_analog_value(int(channel_out), value)
            sleep(delay.m_as('s'))
            self.ydata_scan[i] = self.daq.get_analog_value(int(channel_in))
            i += 1
        self.running_scan = False