def test(driver):

            with driver.open_unit() as device:
                five_milliseconds = 0.005
                config = TimebaseOptions(
                    max_time_interval=five_milliseconds,
                    no_of_samples=None,
                    min_collection_time=five_milliseconds * 30,
                    oversample=1)
                timebase_info = device.find_timebase(config)

            self.assertValidTimebases(config, timebase_info)
    def test_invalid_config(self):
        request = TimebaseOptions(max_time_interval=0.005,
                                  no_of_samples=None,
                                  min_collection_time=1.)
        actual_timebase = 0.004
        required_max_samples = int(
            math.ceil(request.min_collection_time / actual_timebase))
        response = TimebaseInfo(timebase_id=7,
                                time_interval=0.004,
                                time_units=None,
                                max_samples=required_max_samples - 5,
                                segment_id=0)

        self.assertFalse(Device._validate_timebase(request, response))
 def test(driver):
     with driver.open_unit() as device:
         threw = False
         try:
             # we ask for a config which requires 1TS (one terra-sample) of memory on device.
             smallest_timebase = 1.e-8
             one_terra_sample = 1.e12
             duration = smallest_timebase * one_terra_sample
             config = TimebaseOptions(
                 max_time_interval=smallest_timebase,
                 no_of_samples=one_terra_sample,
                 min_collection_time=duration)
             timebase_info = device.find_timebase(config)
         except NoValidTimebaseForOptionsError:
             threw = True
         if not threw:
             return "didn't throw an NoValidTimebaseForOptionsError."
 def test(driver):
     with driver.open_unit() as device:
         threw = False
         try:
             # we ask for a config which cannot be achieved (specifying all 3 variables can lead to invalid
             # configs.)
             no_of_samples = 150
             duration = 0.4
             computed_timebase = duration / no_of_samples
             max_timebase_requested = computed_timebase / 4
             config = TimebaseOptions(
                 max_time_interval=max_timebase_requested,
                 no_of_samples=no_of_samples,
                 min_collection_time=duration)
             timebase_info = device.find_timebase(config)
         except NoValidTimebaseForOptionsError:
             threw = True
         if not threw:
             return "didn't throw an NoValidTimebaseForOptionsError."
Exemple #5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-b', '--bits', type=float, default=8)
    args = parser.parse_args()

    if args.bits < 8:
        raise ValueError("you need to specify bits to be at least 8.")

    with find_unit() as device:

        print("found PicoScope: %s" % (device.info, ))

        channel_configs = [
            ChannelConfig(name='A', enabled=True, coupling='DC', range_peak=5.)
        ]
        actual_interval = 1.e-6
        oversample = int(round(4**(args.bits - 8)))

        print("using oversample of", oversample)

        min_total_capture_time = 2.e-3

        # using oversample, we can pump up the effective resolution of the scope (while reducing the total available
        # sample memory).
        timebase_options = TimebaseOptions(
            max_time_interval=actual_interval,
            no_of_samples=None,
            min_collection_time=min_total_capture_time,
            oversample=oversample)

        times, voltages, overflow_warnings = device.capture_block(
            timebase_options, channel_configs)

        for channel, data in voltages.items():
            label = "Channel %s" % channel
            if channel in overflow_warnings:
                label += " (over range)"
            plt.plot(times, data, label=label)

        plt.xlabel('Time / s')
        plt.ylabel('Amplitude / V')
        plt.legend()
        plt.show()
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#
from __future__ import print_function
from picosdk.discover import find_unit
from picosdk.device import ChannelConfig, TimebaseOptions
import matplotlib.pyplot as plt

with find_unit() as device:

    print("found PicoScope: %s" % (device.info, ))

    channel_configs = [ChannelConfig('A', True, 'DC', 5.)]
    microsecond = 1.e-6
    # the entry-level scopes only have about 8k-samples of memory onboard for block mode, so only ask for 6k samples.
    timebase_options = TimebaseOptions(microsecond, None, 6000 * microsecond)

    times, voltages, overflow_warnings = device.capture_block(
        timebase_options, channel_configs)

    for channel, data in voltages.items():
        label = "Channel %s" % channel
        if channel in overflow_warnings:
            label += " (over range)"
        plt.plot(times, data, label=label)

    plt.xlabel('Time / s')
    plt.ylabel('Amplitude / V')
    plt.legend()
    plt.show()