[
  {
    "path": ".github/CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment include:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@picotech.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]\n\n[homepage]: http://contributor-covenant.org\n[version]: http://contributor-covenant.org/version/1/4/\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# Contributing\n\nWe welcome contributions to the picosdk-python-examples repository. By contributing to this repository, you agree to abide by our [code of conduct](CODE_OF_CONDUCT.md).\n\n## Steps to contribute\n\n1. Fork, then clone the repository:\n\n```\ngit clone https://github.com/YOUR-USERNAME/picosdk-python-wrappers.git\n```\n\n2. Create a new branch - specify a name in lowercase, using hyphens to link words e.g. `fft-example`\n\n3. Push to the new branch on your fork, and then submit a pull request.\n\nWe will then review the pull request.\n\n## Pull request guidelines\n\n* Follow the conventions in the other file headers if adding a new file, or changing an existing file\n* If contributing a new file, ensure that it is in the appropriate location in the repository directory structure\n* [Commit messages](https://chris.beams.io/posts/git-commit/#seven-rules) should clearly communicate the reason for the change"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "Fixes #.\n\nChanges proposed in this pull request:\n\n*\n*\n*\n"
  },
  {
    "path": ".github/issue_template.md",
    "content": "### Setup\n\n* Example filename:\n* Version of Python:\n* Pico Technology device model:\n* Driver name, version number and platform (32- or 64-bit):\n* Operating system:\n* USB port type\t(e.g. 2.0):\n\n### Description\n\n#### Steps to reproduce the issue\n\nUse one of two methods to describe the issue:\n\n1. A list of steps to reproduce the issue. \n1. A natural language description of what you were doing when the issue occurred if you are unable to work out what the steps are. \n\n#### Actual Result\n\n\n\n#### Expected Result\n\n\n\n### Notes\n\nInclude any other information here."
  },
  {
    "path": ".gitignore",
    "content": "# .gitignore file for picosdk-ps6000a-matlab-instrument-driver\r\n# Untracked files/folders to ignore.\r\n\r\n# Windows platforms\r\n\r\n**/*.obj\r\n**/*.lib\r\n**/*.exp\r\n**/*.bak\r\n\r\n# All platforms\r\n\r\n**/*.h\r\n\r\n# Byte-compiled / optimized / DLL files\r\n__pycache__/\r\n*.py[cod]\r\n\r\n# Distribution / packaging\r\nbuild/\r\ndist/\r\n*.egg-info/\r\n*.egg"
  },
  {
    "path": "LICENSE.md",
    "content": "Copyright © 2019 Pico Technology Ltd.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# picosdk-python-wrappers\n\nWelcome to the PicoSDK for Python. It allows you to control PicoScope devices in your own Python programs.\n\n## Getting started\n\nTo use this code you will need to install the PicoSDK C libraries.\n\n### Microsoft Windows\n\nPlease visit [our Downloads page](https://www.picotech.com/downloads) to download the 32-bit or 64-bit PicoSDK C Libraries for Windows. \nPlease take care to match the \"bitness\" of your python to the PicoSDK.\n\n### Linux\n\nFollow the instructions from our [Linux Software & Drivers for Oscilloscopes and Data Loggers page](https://www.picotech.com/downloads/linux) \nto install the required driver packages for your product.\n\n### macOS\n\nPlease visit [our Downloads page](https://www.picotech.com/downloads) to download the PicoSDK C Libraries for MacOS.\n\n## Installing the python driver bindings\n\nA `distutils` installer is provided. After you have installed the PicoSDK\ndriver package (see above), the Python package can be installed using the\nfollowing command in the top-level directory:\n\n    pip install .\n\nIf you are not using a virtualenv or are not elevated, use:\n\n    python setup.py install\n\t\n=======\nFor using the AS108 you will need to use the following as well:\n\n\tpython setupPicosynth.py install\n\t\n\nOn macOS and Linux you will either need to use `sudo` with this command, to\ninstall into the system folders, or to install for the current user only you\ncan use:\n\n    pip install . --user\n\nWithin python, the library for `import` is called `picosdk`.\n\n## Compatibility\n\nThis code is written to be compatible with both Python 2.7 and Python 3 (any version).\n\nIf you find a compatibility problem please raise an [Issue](https://www.picotech.com/tech-support), listing all the versions you can find (python, numpy, \npicosdk commit hash, etc.) and your error message(s).\n\n## C interface\n\nYou can access C driver functions directly (ctypes calls) by their original C name, following the [Programmer's\nGuides](https://github.com/picotech/picosdk-python-wrappers#programmers-guides) exactly. Examples are provided in the folders like `psX000[a]Examples/`.\n\n### Programmer's Guides\n\nYou can download Programmer's Guides providing a description of the API functions for the relevant PicoScope or \nPicoLog driver from our [Documentation page](https://www.picotech.com/library/documentation).\n\n## Python interface\n\nWe are in the process of adding Pythonic wrappers around the C functions. If we haven't got to your feature yet or your device is listed as one of the [unsupported models](https://github.com/picotech/picosdk-python-wrappers#unsupported-models),\nlet us know that you're waiting in an [Issue](https://www.picotech.com/tech-support)\n\n### Unsupported models\n\nThe following drivers and devices are not yet supported:\n\n* `plcm3` - PicoLog CM3 Current Data Logger\n* `ps3000` - PicoScope 3204, 3205, 3206, 3223, 3224, 3423 & 3423\n\n### Dependencies\n\nAs well as depending on the C libraries, the Python wrappers use some Python libraries like `numpy`. Many of the\nexamples scripts also use the `matplotlib` plotting library. You can install these dependencies with pip as follows:\n\n    pip install -r requirements.txt\n    pip install -r requirements-for-examples.txt\n\n### Driver-agnostic examples\n\nThe `anyScopeExamples` folder contains examples in pure python which do the same thing as the C-style examples, but\nin a driver-generic way.  These examples are currently not being developed further but are still avaliable to use \nand develop futher yourself.\n\n### Python Classes\n\n#### Library\n\n`picosdk.library.Library` contains a base class for each of the driver classes. It does the job of translating python\ntypes into C ones, and back again, and some unit conversions to get rid of nano, micro and milli-style prefixes. It also\nhandles any differences in programming API between PicoScope driver versions.\n\n#### Device\n\n`picosdk.device.Device` contains the concrete class which represents a PicoScope with a valid handle. It caches some\ninformation about the device state, like the currently selected voltage ranges of the channels.\n\nIt is implemented in terms of the Library class' public interface, and deals almost entirely with python types. The\nmain exception is its handling of numpy arrays - it (knowing the voltage ranges) is responsible for converting the raw\nADC counts that the driver uses for amplitude into physical units.\n\n## Testing this code\n\nCheck which device driver your device uses, and check the constants at the top of test/test_helpers.py to enable the \nrelevant drivers for connected-device tests. (most tests use this).\n\nTo check which driver your device uses, you can use `picosdk.discover`:\n\n    from picosdk.discover import find_all_units\n    \n    scopes = find_all_units()\n    \n    for scope in scopes:\n        print(scope.info)\n        scope.close()\n\nYou should then configure test/test_helpers.py's list of connected devices, so it can run all the tests we have\non your device.\n\nTo run the unit tests, you will need to install nose (e.g. `pip install nose`.) Then, run `nosetests` in the root of \nthe repo. \n\n## Obtaining support\n\nPlease visit our [Support page](https://www.picotech.com/tech-support) to contact us directly or visit our [Test and Measurement Forum](https://www.picotech.com/support/forum17.html) to post questions.\n\n## Copyright and licensing\n\nSee [LICENSE.md](LICENSE.md) for license terms. \n\n*PicoScope*, *PicoLog* and *PicoSDK* are registered trademarks of Pico Technology Ltd. \n\n*Windows* is a registered trademark of Microsoft Corporation. \n\n*macOS* is a registered trademark of Apple Inc. \n\n*Linux* is the registered trademark of Linus Torvalds in the U.S. and other countries.\n\nCopyright © 2018-2019 Pico Technology Ltd. All rights reserved. \n"
  },
  {
    "path": "discontinuedExamples/anyScopeExamples/block.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\nfrom __future__ import print_function\nfrom picosdk.discover import find_unit\nfrom picosdk.device import ChannelConfig, TimebaseOptions\nimport matplotlib.pyplot as plt\n\nwith find_unit() as device:\n\n    print(\"found PicoScope: %s\" % (device.info,))\n\n    channel_configs = [ChannelConfig('A', True, 'DC', 5.)]\n    microsecond = 1.e-6\n    # the entry-level scopes only have about 8k-samples of memory onboard for block mode, so only ask for 6k samples.\n    timebase_options = TimebaseOptions(microsecond, None, 6000 * microsecond)\n\n    times, voltages, overflow_warnings = device.capture_block(timebase_options, channel_configs)\n\n    for channel, data in voltages.items():\n        label = \"Channel %s\" % channel\n        if channel in overflow_warnings:\n            label += \" (over range)\"\n        plt.plot(times, data, label=label)\n\n    plt.xlabel('Time / s')\n    plt.ylabel('Amplitude / V')\n    plt.legend()\n    plt.show()\n\n"
  },
  {
    "path": "picohrdlExamples/picohrdlSingleModeExample.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PICOLOG HIGH RESOLUTION DATA LOGGER SINGLE MODE EXAMPLE\r\n#\r\n# This example demonstrates how to capture a single value from an ADC-20 or ADC-24 Precision Data Logger.\r\n\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.picohrdl import picohrdl as hrdl\r\nfrom picosdk.functions import assert_pico2000_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open unit\r\nstatus[\"openUnit\"] = hrdl.HRDLOpenUnit()\r\nassert_pico2000_ok(status[\"openUnit\"])\r\nchandle=status[\"openUnit\"]\r\n\r\n# Set mains noise rejection\r\n# Reject 50 Hz mains noise\r\nstatus[\"mainsRejection\"] = hrdl.HRDLSetMains(chandle, 0)\r\nassert_pico2000_ok(status[\"mainsRejection\"])\r\n\r\n# Set single reading\r\nrange = hrdl.HRDL_VOLTAGERANGE[\"HRDL_2500_MV\"]\r\nconversionTime = hrdl.HRDL_CONVERSIONTIME[\"HRDL_100MS\"]\r\noverflow = ctypes.c_int16(0)\r\nvalue = ctypes.c_int32()\r\nstatus[\"getSingleValue\"] = hrdl.HRDLGetSingleValue(chandle, 5, range, conversionTime, 1, ctypes.byref(overflow), ctypes.byref(value))\r\nassert_pico2000_ok(status[\"getSingleValue\"])\r\n\r\n# Display value\r\nprint(value.value)\r\n\r\n# Close unit\r\nstatus[\"closeUnit\"] = hrdl.HRDLCloseUnit(chandle)\r\nassert_pico2000_ok(status[\"closeUnit\"])\r\n\r\n# Print status\r\nprint(status)"
  },
  {
    "path": "picohrdlExamples/picohrdlStreamingModeExample.py",
    "content": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PICOLOG HIGH RESOLUTION DATA LOGGER STREAMING MODE EXAMPLE\n#\n# This example demonstrates how to capture data streaming from an ADC-20 or ADC-24 Precision Data Logger.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.picohrdl import picohrdl as hrdl\nfrom picosdk.functions import assert_pico2000_ok\nimport matplotlib.pyplot as plt\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16(16384)\nstatus = {}\nmaxSamples = 200 #1_000\n\nstatus[\"closeUnit\"] = hrdl.HRDLCloseUnit(chandle)\n\n# Open unit\nstatus[\"openUnit\"] = hrdl.HRDLOpenUnit()\nassert_pico2000_ok(status[\"openUnit\"])\nchandle = status[\"openUnit\"]\n\n# Set mains noise rejection\n# Reject 50 Hz mains noise\nstatus[\"mainsRejection\"] = hrdl.HRDLSetMains(chandle, 0)\nassert_pico2000_ok(status[\"mainsRejection\"])\n\n# Setup Channel(s)\nrange = ctypes.c_int16(0)\nrange = hrdl.HRDL_VOLTAGERANGE[\"HRDL_2500_MV\"]\noverflow = ctypes.c_int16(0)\nvalue = ctypes.c_int32()\n\nchannel = ctypes.c_int16(1) # (Ch number) ADC-20: Ch1 to Ch8 , ADC-24: Ch1 to Ch16\nenabled = ctypes.c_int16(1)\nsingleEnded = ctypes.c_int16(1) # 0: differential, Not 0: for single ended\n\nstatus[\"SetAnalogInChannel\"] = hrdl.HRDLSetAnalogInChannel(chandle, channel, enabled, range, singleEnded)\nassert_pico2000_ok(status[\"SetAnalogInChannel\"])\n\n# Streaming\n# sampleInterval_ms = conversionTime x NumberOfChannels + 20ms\n# 20ms = 1/3 of the fastest sample time for one channel\nsampleInterval_ms = ctypes.c_int32(100 * 1 + 20)\nconversionTime = hrdl.HRDL_CONVERSIONTIME[\"HRDL_100MS\"]\nstatus[\"SetInterval\"] = hrdl.HRDLSetInterval(chandle, sampleInterval_ms, conversionTime)\nassert_pico2000_ok(status[\"SetInterval\"])\n\nnValues = ctypes.c_int32(20)\nmethod = ctypes.c_int16(2) # BM_STREAM (2)\nstatus[\"Run\"] = hrdl.HRDLRun(chandle, nValues, method)\nassert_pico2000_ok(status[\"Run\"])\n\nTotalValues = 0\n# Buffers\nTempBuffer = (ctypes.c_int32 * 100)()\nBufValues = []\n\nmyready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\n# Check for data collection\nwhile TotalValues < maxSamples:\n    while myready.value == check.value:\n        myready.value = hrdl.HRDLReady(chandle)\n        time.sleep(0.02) # 20ms = 1/3 of the fastest sample time for one channel\n        # print(\"ready = \", myready) # DEBUG\n    noOfValues = ctypes.c_int32(20) # Ask for 20 samples\n    noOfValues = hrdl.HRDLGetValues(chandle, ctypes.byref(TempBuffer), ctypes.byref(overflow), noOfValues)  \n    TotalValues = TotalValues + int(noOfValues)\n    print(\"TotalValues = \",TotalValues ,\", noOfValues = \", int(noOfValues) ) # DEBUG\n    #sleep (sampleInterval_ms - 20ms /1000)\n    time.sleep( ((100 * 1 + 20) - 20) /1000)\n\n    #for i in range(noOfValues):\n        ####TempBuffer[i] =  adc2mV(TempBuffer[i], channelRange, maxADC)\n        #BufValues.append(float(TempBuffer[i]))\n    #if(noOfValues != 0):\n    #    BufValues.append(float(TempBuffer[0]))\n\n    # Convert to mV and Append values App Buffer\n    loop = noOfValues\n    while (loop != 0):\n        loop = loop -1\n        # TempBuffer[loop] =  adc2mVpl1000(TempBuffer[loop], 2500, 8388607) # adc2mVpl1000(value, Max range in mV, Max ADC count)\n        #TempBuffer[loop] = (TempBuffer[loop] * 2500) / 8388607\n        BufValues.append(float((TempBuffer[loop] * 2500) / 8388607))\n\n# Stop data collection\nhrdl.HRDLStop(chandle)\n\n# Create time data\ntimeMs = np.linspace(0, (len(BufValues) -1) * 0.1, len(BufValues))\n\n# plot data\nplt.plot(timeMs, BufValues[:])\nplt.xlabel('Time (s)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Close unit\nstatus[\"closeUnit\"] = hrdl.HRDLCloseUnit(chandle)\nassert_pico2000_ok(status[\"closeUnit\"])\n\n# Print status\nprint(status)"
  },
  {
    "path": "picosdk/PicoConnectProbes.py",
    "content": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the enumerations from the PicoConnectProbes.h C header\r\nfile for use with various PicoScope oscilloscopes driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.constants import make_enum\r\nfrom picosdk.library import Library\r\n\r\nclass PicoConnectProbeslib(Library):\r\n    def __init__(self):\r\n        super(PicoConnectProbeslib, self).__init__(\"picoConnectProbes\")\r\n\r\n\r\npicoConnectProbes  = PicoConnectProbeslib()\r\n\r\ndef _define_pico_probe_range_info():\r\n    PICO_PROBE_NONE_NV = 0\r\n    PICO_X1_PROBE_NV = 1\r\n    PICO_X10_PROBE_NV = 10\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoConnectProbes.PICO_PROBE_RANGE_INFO = _define_pico_probe_range_info"
  },
  {
    "path": "picosdk/PicoDeviceEnums.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the enumerations from the PicoDeviceEnums.h C header\r\nfile for use with PicoScope 6000 A Series oscilloscopes using the ps6000a driver API\r\nfunctions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.constants import make_enum\r\nfrom picosdk.library import Library\r\n\r\nclass PicoEnumlib(Library):\r\n    def __init__(self):\r\n        super(PicoEnumlib, self).__init__(\"ps6000a\")\r\n\r\n\r\npicoEnum  = PicoEnumlib()\r\n\r\ndef _define_ratio_mode():\r\n    PICO_RATIO_MODE_AGGREGATE = 1\r\n    PICO_RATIO_MODE_DECIMATE = 2\r\n    PICO_RATIO_MODE_AVERAGE = 4\r\n    PICO_RATIO_MODE_DISTRIBUTION = 8\r\n    PICO_RATIO_MODE_SUM = 16\r\n    PICO_RATIO_MODE_TRIGGER_DATA_FOR_TIME_CALCUATION = 0x10000000\r\n    PICO_RATIO_MODE_SEGMENT_HEADER = 0x20000000\r\n    PICO_RATIO_MODE_TRIGGER = 0x40000000\r\n    PICO_RATIO_MODE_RAW = 0x80000000\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_RATIO_MODE = _define_ratio_mode()\r\n\r\ndef _define_channel():\r\n    PICO_CHANNEL_A = 0\r\n    PICO_CHANNEL_B = 1\r\n    PICO_CHANNEL_C = 2\r\n    PICO_CHANNEL_D = 3\r\n    PICO_CHANNEL_E = 4\r\n    PICO_CHANNEL_F = 5\r\n    PICO_CHANNEL_G = 6\r\n    PICO_CHANNEL_H = 7\r\n    PICO_PORT0 = 128\r\n    PICO_PORT1 = 129\r\n    PICO_PORT2 = 130\r\n    PICO_PORT3 = 131\r\n    PICO_EXTERNAL = 1000\r\n    PICO_TRIGGER_AUX = 1001\r\n    PICO_PULSE_WIDTH_SOURCE = 0x10000000\r\n    PICO_DIGITAL_SOURCE = 0x10000001\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_CHANNEL = _define_channel()\r\n\r\ndef _define_channel_flags():\r\n    PICO_CHANNEL_A_FLAGS = 1\r\n    PICO_CHANNEL_B_FLAGS = 2\r\n    PICO_CHANNEL_C_FLAGS = 4\r\n    PICO_CHANNEL_D_FLAGS = 8\r\n    PICO_CHANNEL_E_FLAGS = 16\r\n    PICO_CHANNEL_F_FLAGS = 32\r\n    PICO_CHANNEL_G_FLAGS = 64\r\n    PICO_CHANNEL_H_FLAGS = 128\r\n    PICO_PORT0_FLAGS = 65536\r\n    PICO_PORT1_FLAGS = 131072\r\n    PICO_PORT2_FLAGS = 262144\r\n    PICO_PORT3_FLAGS = 524288\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n\r\npicoEnum.PICO_CHANNEL_FLAGS = _define_channel_flags()\r\n\r\npicoEnum.PICO_PORT_DIGITAL_CHANNEL = make_enum([\r\n    \"PICO_PORT_DIGITAL_CHANNEL0\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL1\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL2\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL3\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL4\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL5\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL6\",\r\n    \"PICO_PORT_DIGITAL_CHANNEL7\",\r\n    ])\r\n    \r\npicoEnum.PICO_DATA_TYPE = make_enum([\r\n    \"PICO_INT8_T\",\r\n    \"PICO_INT16_T\",\r\n    \"PICO_INT32_T\",\r\n    \"PICO_UINT32_T\",\r\n    \"PICO_INT64_T\",\r\n    ])\r\n\r\ndef _define_coupling():\r\n    PICO_AC = 0\r\n    PICO_DC = 1\r\n    PICO_DC_50OHM = 50\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n\r\npicoEnum.PICO_COUPLING = _define_coupling()\r\n\r\n# PicoBandwitdthLimiterFlags\r\n# needs implementing still\r\n\r\ndef _define_bandwidth_limiter():\r\n    PICO_BW_FULL = 0\r\n    PICO_BW_100KHZ = 100000\r\n    PICO_BW_20KHZ = 20000\r\n    PICO_BW_1MHZ = 1000000\r\n    PICO_BW_20MHZ = 20000000\r\n    PICO_BW_25MHZ = 25000000\r\n    PICO_BW_50MHZ = 50000000\r\n    PICO_BW_200HMZ = 200000000\r\n    PICO_BW_250MHZ = 250000000\r\n    PICO_BW_500MHZ = 500000000\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_BANDWIDTH_LIMITER = _define_bandwidth_limiter()\r\n\r\npicoEnum.PICO_PULSE_WIDTH_TYPE = make_enum([\r\n    \"PICO_PW_TYPE_NONE\",\r\n    \"PICO_PW_TYPE_LESS_THAN\",\r\n    \"PICO_PW_TYPE_GREATER_THAN\",\r\n    \"PICO_PW_IN_RANGE\",\r\n    \"PICO_PW_TYPE_OUT_OF_RANGE\"\r\n    ])\r\n    \r\npicoEnum.PICO_SWEEP_TYPE = make_enum([\r\n    \"PICO_UP\",\r\n    \"PICO_DOWN\",\r\n    \"PICO_UPDOWN\",\r\n    \"PICO_DOWNUP\"\r\n    ])\r\n    \r\ndef _define_wave_type():\r\n    PICO_SINE = 0x00000011\r\n    PICO_SQUARE = 0x00000012\r\n    PICO_TRIANGLE = 0x00000013\r\n    PICO_RAMP_UP = 0x00000014\r\n    PICO_RAMP_DOWN = 0x00000015\r\n    PICO_SINC = 0x00000016\r\n    PICO_GAUSSIAN = 0x00000017\r\n    PICO_HALF_SINE = 0x00000018\r\n    PICO_DC_VOLTAGE = 0x00000400\r\n    PICO_PWM = 0x00001000\r\n    PICO_WHITENOISE = 0x00002001\r\n    PICO_PRBS = 0x00002002\r\n    PICO_ARBITRARY = 0x10000000\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n\r\npicoEnum.PICO_WAVE_TYPE = _define_wave_type()\r\n\r\npicoEnum.PICO_SIGGEN_TRIG_TYPE = make_enum([\r\n    \"PICO_SIGGEN_RISING\",\r\n    \"PICO_SIGGEN_FALLING\",\r\n    \"PICO_SIGGEN_GATE_HIGH\",\r\n    \"PICO_SIGGEN_GATE_LOW\"\r\n    ])\r\n    \r\npicoEnum.PICO_SIGGEN_TRIG_SOURCE = make_enum([\r\n    \"PICO_SIGGEN_NONE\",\r\n    \"PICO_SIGGEN_SCOPE_TRIG\",\r\n    \"PICO_SGGEN_AUX_IN\",\r\n    \"PICO_SIGGEN_EXT_IN\",\r\n    \"PICO_SIGGEN_SOFT_TRIG\",\r\n    \"PICO_SIGGEN_TRIGGER_RAW\"\r\n    ])\r\n    \r\npicoEnum.PICO_SIGGEN_FILTER_STATE = make_enum([\r\n    \"PICO_SIGGEN_FILTER_AUTO\",\r\n    \"PICO_SIGGEN_FILTER_OFF\",\r\n    \"PICO_SIGGEN_FILTER_ON\"\r\n    ])\r\n    \r\npicoEnum.PICO_SIGGEN_PARAMETER = make_enum([\r\n    \"PICO_SIGGEN_PARAM_OUTPUT_VOLTS\",\r\n    \"PICO_SIGGEN_PARAM_SAMPLE\",\r\n    \"PICO_SIGGEN_BUFFER_LENGTH\"\r\n    ])\r\n    \r\npicoEnum.PICO_TIME_UNITS = make_enum([\r\n    \"PICO_FS\",\r\n    \"PICO_PS\",\r\n    \"PICO_NS\",\r\n    \"PICO_US\",\r\n    \"PICO_MS\",\r\n    \"PICO_S\"\r\n    ])\r\n\r\ndef _define_threshold_direction():\r\n    PICO_ABOVE = PICO_INSIDE = 0\r\n    PICO_BELOW = PICO_OUTSIDE = 1\r\n    PICO_RISING = PICO_ENTER = PICO_NONE = 2 \r\n    PICO_FALLING = PICO_EXIT = 3\r\n    PICO_RISING_OR_FALLING = PICO_ENTER_OR_EXIT = 4\r\n    PICO_ABOVE_LOWER = 5\r\n    PICO_BELOW_LOWER = 6\r\n    PICO_RISING_LOWER = 7\r\n    PICO_FALLING_LOWER = 8\r\n    PICO_POSITIVE_RUNT = 9\r\n    PICO_NEGATIVE_RUNT = 10\r\n    PICO_LOGIC_LOWER = 1000\r\n    PICO_LOGIC_UPPER = 1001\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_THRESHOLD_DIRECTION = _define_threshold_direction()\r\n\r\npicoEnum.PICO_THRESHOLD_MODE = make_enum([\r\n    \"PICO_LEVEL\",\r\n    \"PICO_WINDOW\"\r\n    ])\r\n    \r\npicoEnum.PICO_ETS_MODE = make_enum([\r\n    \"PICO_ETS_OFF\",\r\n    \"PICO_ETS_FAST\",\r\n    \"PICO_ETS_SLOW\"\r\n    ])\r\n    \r\npicoEnum.PICO_INDEX_MODE = make_enum([\r\n    \"PICO_SINGLE\",\r\n    \"PICO_DUAL\",\r\n    \"PICO_QUAD\"\r\n    ])\r\n    \r\ndef _define_action():\r\n    PICO_CLEAR_ALL = 0x00000001\r\n    PICO_ADD = 0x00000002\r\n    PICO_CLEAR_THIS_DATA_BUFFER = 0x00001000\r\n    PICO_CLEAR_WAVEFORM_DATA_BUFFERS = 0x00002000\r\n    PICO_CLEAR_WAVEFORM_READ_DATA_BUFFERS = 0x00004000\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_ACTION = _define_action()\r\n\r\npicoEnum.PICO_TRIGGER_STATE = make_enum([\r\n    \"PICO_CONDITION_DONT_CARE\",\r\n    \"PICO_CONDITION_TRUE\",\r\n    \"PICO_CONDITION_FALSE\"\r\n    ])\r\n    \r\ndef _define_resolution():\r\n    PICO_DR_8BIT = 0\r\n    PICO_DR_12BIT = 1\r\n    PICO_DR_14BIT = 2\r\n    PICO_DR_15BIT = 3\r\n    PICO_DR_16BIT = 4\r\n    PICO_DR_10BIT = 10\r\n    PICO_DR_10BIT_TURBO = 0x1A\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_DEVICE_RESOLUTION = _define_resolution()\r\n\r\npicoEnum.PICO_READ_SELECTION = make_enum([\r\n    \"PICO_READSELECTION_NONE\",\r\n    \"PICO_TRIGGER_READ\",\r\n    \"PICO_DATA_READ1\",\r\n    \"PICO_DATA_READ2\",\r\n    \"PICO_DATA_READ3\"\r\n    ])\r\n\r\npicoEnum.PICO_TRIM_ACTION = make_enum([\r\n    \"PICO_OLDEST\",\r\n    \"PICO_RECENT\"\r\n    ])\r\n\r\npicoEnum.PICO_DIGITAL_PORT_HYSTERESIS = make_enum([\r\n    \"PICO_VERY_HIGH_400MV\",\r\n    \"PICO_HIGH_200MV\",\r\n    \"PICO_NORMAL_100MV\",\r\n    \"PICO_LOW_50MV\"\r\n    ])\r\n    \r\npicoEnum.PICO_DIGITAL_DIRECTION = make_enum([\r\n    \"PICO_DIGITAL_DONT_CARE\",\r\n    \"PICO_DIGITAL_DIRECTION_LOW\",\r\n    \"PICO_DIGITAL_DIRECTION_HIGH\",\r\n    \"PICO_DIGITAL_DIRECTION_RISING\",\r\n    \"PICO_DIGITAL_DIRECTION_FALLING\",\r\n    \"PICO_DIGITAL_DIRECTION_RISING_OR_FALLING\",\r\n    \"PICO_DIGITAL_DIRECTION_MAX_DIRECTION\"\r\n    ])\r\n    \r\ndef _define_conditions_info():\r\n    PICO_CLEAR_CONDITIONS = 0x00000001\r\n    PICO_ADD_CONDITIONS = 0x00000002\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_CONDITIONS_INFO = _define_conditions_info()\r\n\r\npicoEnum.PICO_CLOCK_REFERENCE = make_enum([\r\n    \"PICO_INTERNAL_REF\",\r\n    \"PICO_EXTERNAL_REF\"\r\n    ])\r\n    \r\npicoEnum.PICO_TRIGGER_WITHIN_PRE_TRIGGER = make_enum([\r\n    \"PICO_DISABLE\",\r\n    \"PICO_ARM\"\r\n    ])\r\n    \r\npicoEnum.PICO_TEMPERATURE_REFERENCE = make_enum([\r\n    \"PICO_TEMPERATURE_UNINITIALISED\",\r\n    \"PICO_TEMPERATURE_NORMAL\",\r\n    \"PICO_TEMPERATURE_WARNING\",\r\n    \"PICO_TEMPERATURE_CRITICAL\",\r\n    \"PICO_TEMPERATURE_REFERENCE\"\r\n    ])\r\n    \r\ndef _define_digital_port():\r\n    PICO_DIGITAL_PORT_NONE = 0\r\n    PICO_DIGITAL_PORT_MSO_POD = 1000\r\n    PICO_DIGITAL_PORT_UNKNOWN_DEVICE = -2\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_DIGITAL_PORT = _define_digital_port\r\n\r\npicoEnum.PICO_EXTERNAL_FREQUENCY = make_enum([\r\n    \"PICO_FREQUENCY_OFF\",\r\n    \"PICO_FREQUENCY_5MHZ\",\r\n    \"PICO_FREQUENCY_10MHZ\",\r\n    \"PICO_FREQUENCY_20MHZ\",\r\n    \"PICO_FREQUENCY_25MHZ\"\r\n    ])\r\n    \r\ndef _define_power_delivery_device_type():\r\n    PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_NOTHING = 0\r\n    PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_SOURCE = 2\r\n    PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_DEBUG = 3\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PICO\")}\r\n    \r\npicoEnum.PICO_USB_POWER_DELIEVRY_DEVICE_TYPE = _define_power_delivery_device_type\r\n\r\npicoEnum.PICO_AUXIO_MODE = make_enum([\r\n    \"PICO_AUXIO_INPUT\",\r\n    \"PICO_AUXIO_HIGH_OUT\",\r\n    \"PICO_AUXIO_LOW_OUT\",\r\n    \"PICO_AUXIO_TRIGGER_OUT\"\r\n    ])"
  },
  {
    "path": "picosdk/PicoDeviceStructs.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the structures from the PicoDeviceStructs.h C header\r\nfile for use with PicoScope 6000 A Series oscilloscopes using the ps6000a driver API\r\nfunctions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\n\r\nclass PicoStructlib(Library):\r\n    def __init__(self):\r\n        super(PicoStructlib, self).__init__(\"ps6000a\")\r\n\r\n\r\npicoStruct = PicoStructlib()\r\n\r\nclass PICO_TRIGGER_INFO(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"status\", c_uint32),\r\n                (\"segmentIndex\", c_uint64),\r\n                (\"triggerIndex\", c_uint64),\r\n                (\"triggerTime\", c_double),\r\n                (\"timeUnits\", c_uint32),\r\n                (\"missedTriggers\", c_uint64),\r\n                (\"timeStampCounter\", c_uint64)]\r\n                \r\npicoStruct.PICO_TRIGGER_INFO = PICO_TRIGGER_INFO\r\n\r\nclass PICO_TRIGGER_CHANNEL_PROPERTIES(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"thresholdUpper\", c_int16),\r\n                (\"thresholdUpperHysteresis\", c_uint16),\r\n                (\"thresholdLower\", c_int16),\r\n                (\"thresholdLowerHysteresis\", c_uint16),\r\n                (\"channel\", c_uint32)]\r\n                \r\npicoStruct.PICO_TRIGGER_CHANNEL_PROPERTIES = PICO_TRIGGER_CHANNEL_PROPERTIES\r\n\r\nclass PICO_CONDITION(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"source\", c_uint32),\r\n                (\"condition\", c_uint32)]\r\n                \r\npicoStruct.PICO_CONDITION = PICO_CONDITION\r\n\r\nclass PICO_DIRECTION(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"direction\", c_uint32),\r\n                (\"thresholdMode\", c_uint32)]\r\n                \r\npicoStruct.PICO_DIRECTION = PICO_DIRECTION\r\n\r\nclass PICO_USER_PROBE_INTERACTIONS(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"connected\", c_uint16),\r\n                (\"channel\", c_uint32),\r\n                (\"enabled\", c_uint16),\r\n                (\"probeName\", c_uint32),\r\n                (\"requiresPower\", c_uint8),\r\n                (\"isPowered\", c_uint8),\r\n                (\"status\", c_uint32),\r\n                (\"probeOff\", c_uint32),\r\n                (\"rangeFirst\", c_uint32),\r\n                (\"rangeLast\", c_uint32),\r\n                (\"rangeCurrent\", c_uint32),\r\n                (\"couplingFirst\", c_uint32),\r\n                (\"couplingLast\", c_uint32),\r\n                (\"couplingCurrent\", c_uint32),\r\n                (\"filterFlags\", c_uint32),\r\n                (\"filterCurrent\", c_uint32)]\r\n                \r\npicoStruct.PICO_USER_PROBE_INTERACTIONS = PICO_USER_PROBE_INTERACTIONS\r\n\r\nclass PICO_DATA_BUFFERS(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"waveform\", c_uint64),\r\n                (\"downSampleRatioMode\", c_uint32),\r\n                (\"read\", c_uint32),\r\n                (\"bufferMax\", c_void_p),\r\n                (\"bufferMin\", c_void_p),\r\n                (\"dataType\", c_uint32),\r\n                (\"nDistributionPoints\", c_uint32)]\r\n                \r\npicoStruct.PICO_DATA_BUFFERS = PICO_DATA_BUFFERS\r\n\r\nclass PICO_STREAMING_DATA_INFO(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"mode\", c_uint32),\r\n                (\"type\", c_uint32),\r\n                (\"noOfSamples\", c_int32),\r\n                (\"bufferIndex\", c_uint64),\r\n                (\"startIndex\", c_int32),\r\n                (\"overflow\", c_int16)]\r\n                \r\npicoStruct.PICO_STREAMING_DATA_INFO = PICO_STREAMING_DATA_INFO\r\n\r\nclass PICO_STREAMING_DATA_TRIGGER_INFO(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"triggerAt\", c_uint64),\r\n                (\"triggered\", c_int16),\r\n                (\"autoStop\", c_int16)]\r\n                \r\npicoStruct.PICO_STREAMING_DATA_TRIGGER_INFO = PICO_STREAMING_DATA_TRIGGER_INFO\r\n\r\nclass PICO_SCALING_FACTORS(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"range\", c_uint32),\r\n                (\"offset\", c_int16),\r\n                (\"scalingFactor\", c_double)]\r\n                \r\npicoStruct.PICO_SCALING_FACTORS = PICO_SCALING_FACTORS\r\n\r\nclass PICO_SCALING_FACTORS_FOR_RANGE_TYPES(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"rangeMin\", c_int64),\r\n                (\"rangeMax\", c_int64),\r\n                (\"rangeType\", c_uint32),\r\n                (\"offset\", c_int16),\r\n                (\"scalingFactor\", c_double)]\r\n                \r\npicoStruct.PICO_SCALING_FACTORS_FOR_RANGE_TYPES = PICO_SCALING_FACTORS_FOR_RANGE_TYPES\r\n\r\nclass PROBE_APP(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"id\", c_int32),\r\n                (\"appMajorVersion\", c_int32),\r\n                (\"appMinorVersion\", c_int32)]\r\n               \r\npicoStruct.PROBE_APP = PROBE_APP\r\n\r\nclass DIGITAL_CHANNEL_DIRECTIONS(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"direction\", c_uint32)]\r\n                \r\npicoStruct.DIGITAL_CHANNEL_DIRECTIONS = DIGITAL_CHANNEL_DIRECTIONS\r\n\r\nclass PICO_DIGITAL_PORT_INTERACTIONS(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"connected\", c_uint16),\r\n                (\"channel\", c_uint32),\r\n                (\"digitalPortName\", c_uint32),\r\n                (\"status\", c_uint32),\r\n                (\"serial\", c_int8),\r\n                (\"calibrationDate\", c_int8)]\r\n                \r\npicoStruct.PICO_DIGITAL_PORT_INTERACTIONS = PICO_DIGITAL_PORT_INTERACTIONS\r\n\r\nclass PICO_CHANNEL_OVERVOLTAGE_TRIPPED(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"channel\", c_uint32),\r\n                (\"tripped\", c_uint8)]\r\n                \r\npicoStruct.PICO_CHANNEL_OVERVOLTAGE_TRIPPED = PICO_CHANNEL_OVERVOLTAGE_TRIPPED\r\n\r\nclass PICO_USB_POWER_DELIVERY(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"valid\", c_uint8),\r\n                (\"busVoltagemV\", c_uint32),\r\n                (\"rpCurrentLimitmA\", c_uint32),\r\n                (\"partnerConnected\", c_uint8),\r\n                (\"ccPolarity\", c_uint8),\r\n                (\"attachedDevice\", c_uint32),\r\n                (\"contractExists\", c_uint8),\r\n                (\"currentPdo\", c_uint32),\r\n                (\"currentRdo\", c_uint32)]\r\n                \r\npicoStruct.PICO_USB_POWER_DELIVERY = PICO_USB_POWER_DELIVERY\r\n\r\nclass PICO_USB_POWER_DETAILS(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"dataPort\", c_uint32),\r\n                (\"powerPort\", c_uint32)]\r\n                \r\npicoStruct.PICO_USB_POWER_DETAILS = PICO_USB_POWER_DETAILS"
  },
  {
    "path": "picosdk/__init__.py",
    "content": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n"
  },
  {
    "path": "picosdk/constants.py",
    "content": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nDefines python-visible versions of preprocessor-macros from Pico SDK C header files.\nAll constants in this file are exposed directly on the Library class specific to each driver. That\n(rather than importing this file directly) is the supported way of accessing them, since some\nolder drivers have different names/values for some of the macros.\n\"\"\"\nfrom picosdk.errors import UnknownConstantError\n\n\n# convenience functions provided in the old python SDK:\ndef pico_tag(number):\n    \"\"\"Get the macro name for a given PICO_STATUS value.\"\"\"\n    try:\n        return PICO_STATUS_LOOKUP[number]\n    except KeyError:\n        raise UnknownConstantError(\"%s is not a known PICO_STATUS value.\" % number)\n\n\ndef pico_num(tag):\n    \"\"\"Resolve the numerical constant associated with a PICO_STATUS macro.\"\"\"\n    try:\n        return PICO_STATUS[tag]\n    except KeyError:\n        raise UnknownConstantError(\"%s is not a known PICO_STATUS macro.\" % tag)\n\n\ndef make_enum(members):\n    \"\"\"All C enums with no specific values follow the pattern 0, 1, 2... in the order they are in source.\"\"\"\n    enum = {}\n    for i, member in enumerate(members):\n        keys = [member]\n        if isinstance(member, tuple):\n            # this member has multiple names!\n            keys = member\n        for key in keys:\n            enum[key] = i\n    return enum\n\n\nPICO_STATUS = {\n    \"PICO_OK\": 0x00000000,\n    \"PICO_MAX_UNITS_OPENED\": 0x00000001,\n    \"PICO_MEMORY_FAIL\": 0x00000002,\n    \"PICO_NOT_FOUND\": 0x00000003,\n    \"PICO_FW_FAIL\": 0x00000004,\n    \"PICO_OPEN_OPERATION_IN_PROGRESS\": 0x00000005,\n    \"PICO_OPERATION_FAILED\": 0x00000006,\n    \"PICO_NOT_RESPONDING\": 0x00000007,\n    \"PICO_CONFIG_FAIL\": 0x00000008,\n    \"PICO_KERNEL_DRIVER_TOO_OLD\": 0x00000009,\n    \"PICO_EEPROM_CORRUPT\": 0x0000000A,\n    \"PICO_OS_NOT_SUPPORTED\": 0x0000000B,\n    \"PICO_INVALID_HANDLE\": 0x0000000C,\n    \"PICO_INVALID_PARAMETER\": 0x0000000D,\n    \"PICO_INVALID_TIMEBASE\": 0x0000000E,\n    \"PICO_INVALID_VOLTAGE_RANGE\": 0x0000000F,\n    \"PICO_INVALID_CHANNEL\": 0x00000010,\n    \"PICO_INVALID_TRIGGER_CHANNEL\": 0x00000011,\n    \"PICO_INVALID_CONDITION_CHANNEL\": 0x00000012,\n    \"PICO_NO_SIGNAL_GENERATOR\": 0x00000013,\n    \"PICO_STREAMING_FAILED\": 0x00000014,\n    \"PICO_BLOCK_MODE_FAILED\": 0x00000015,\n    \"PICO_NULL_PARAMETER\": 0x00000016,\n    \"PICO_ETS_MODE_SET\": 0x00000017,\n    \"PICO_DATA_NOT_AVAILABLE\": 0x00000018,\n    \"PICO_STRING_BUFFER_TO_SMALL\": 0x00000019,\n    \"PICO_ETS_NOT_SUPPORTED\": 0x0000001A,\n    \"PICO_AUTO_TRIGGER_TIME_TO_SHORT\": 0x0000001B,\n    \"PICO_BUFFER_STALL\": 0x0000001C,\n    \"PICO_TOO_MANY_SAMPLES\": 0x0000001D,\n    \"PICO_TOO_MANY_SEGMENTS\": 0x0000001E,\n    \"PICO_PULSE_WIDTH_QUALIFIER\": 0x0000001F,\n    \"PICO_DELAY\": 0x00000020,\n    \"PICO_SOURCE_DETAILS\": 0x00000021,\n    \"PICO_CONDITIONS\": 0x00000022,\n    \"PICO_USER_CALLBACK\": 0x00000023,\n    \"PICO_DEVICE_SAMPLING\": 0x00000024,\n    \"PICO_NO_SAMPLES_AVAILABLE\": 0x00000025,\n    \"PICO_SEGMENT_OUT_OF_RANGE\": 0x00000026,\n    \"PICO_BUSY\": 0x00000027,\n    \"PICO_STARTINDEX_INVALID\": 0x00000028,\n    \"PICO_INVALID_INFO\": 0x00000029,\n    \"PICO_INFO_UNAVAILABLE\": 0x0000002A,\n    \"PICO_INVALID_SAMPLE_INTERVAL\": 0x0000002B,\n    \"PICO_TRIGGER_ERROR\": 0x0000002C,\n    \"PICO_MEMORY\": 0x0000002D,\n    \"PICO_SIG_GEN_PARAM\": 0x0000002E,\n    \"PICO_SHOTS_SWEEPS_WARNING\": 0x0000002F,\n    \"PICO_SIGGEN_TRIGGER_SOURCE\": 0x00000030,\n    \"PICO_AUX_OUTPUT_CONFLICT\": 0x00000031,\n    \"PICO_AUX_OUTPUT_ETS_CONFLICT\": 0x00000032,\n    \"PICO_WARNING_EXT_THRESHOLD_CONFLICT\": 0x00000033,\n    \"PICO_WARNING_AUX_OUTPUT_CONFLICT\": 0x00000034,\n    \"PICO_SIGGEN_OUTPUT_OVER_VOLTAGE\": 0x00000035,\n    \"PICO_DELAY_NULL\": 0x00000036,\n    \"PICO_INVALID_BUFFER\": 0x00000037,\n    \"PICO_SIGGEN_OFFSET_VOLTAGE\": 0x00000038,\n    \"PICO_SIGGEN_PK_TO_PK\": 0x00000039,\n    \"PICO_CANCELLED\": 0x0000003A,\n    \"PICO_SEGMENT_NOT_USED\": 0x0000003B,\n    \"PICO_INVALID_CALL\": 0x0000003C,\n    \"PICO_GET_VALUES_INTERRUPTED\": 0x0000003D,\n    \"PICO_NOT_USED\": 0x0000003F,\n    \"PICO_INVALID_SAMPLERATIO\": 0x00000040,\n    \"PICO_INVALID_STATE\": 0x00000041,\n    \"PICO_NOT_ENOUGH_SEGMENTS\": 0x00000042,\n    \"PICO_DRIVER_FUNCTION\": 0x00000043,\n    \"PICO_RESERVED\": 0x00000044,\n    \"PICO_INVALID_COUPLING\": 0x00000045,\n    \"PICO_BUFFERS_NOT_SET\": 0x00000046,\n    \"PICO_RATIO_MODE_NOT_SUPPORTED\": 0x00000047,\n    \"PICO_RAPID_NOT_SUPPORT_AGGREGATION\": 0x00000048,\n    \"PICO_INVALID_TRIGGER_PROPERTY\": 0x00000049,\n    \"PICO_INTERFACE_NOT_CONNECTED\": 0x0000004A,\n    \"PICO_RESISTANCE_AND_PROBE_NOT_ALLOWED\": 0x0000004B,\n    \"PICO_POWER_FAILED\": 0x0000004C,\n    \"PICO_SIGGEN_WAVEFORM_SETUP_FAILED\": 0x0000004D,\n    \"PICO_FPGA_FAIL\": 0x0000004E,\n    \"PICO_POWER_MANAGER\": 0x0000004F,\n    \"PICO_INVALID_ANALOGUE_OFFSET\": 0x00000050,\n    \"PICO_PLL_LOCK_FAILED\": 0x00000051,\n    \"PICO_ANALOG_BOARD\": 0x00000052,\n    \"PICO_CONFIG_FAIL_AWG\": 0x00000053,\n    \"PICO_INITIALISE_FPGA\": 0x00000054,\n    \"PICO_EXTERNAL_FREQUENCY_INVALID\": 0x00000056,\n    \"PICO_CLOCK_CHANGE_ERROR\": 0x00000057,\n    \"PICO_TRIGGER_AND_EXTERNAL_CLOCK_CLASH\": 0x00000058,\n    \"PICO_PWQ_AND_EXTERNAL_CLOCK_CLASH\": 0x00000059,\n    \"PICO_UNABLE_TO_OPEN_SCALING_FILE\": 0x0000005A,\n    \"PICO_MEMORY_CLOCK_FREQUENCY\": 0x0000005B,\n    \"PICO_I2C_NOT_RESPONDING\": 0x0000005C,\n    \"PICO_NO_CAPTURES_AVAILABLE\": 0x0000005D,\n    \"PICO_NOT_USED_IN_THIS_CAPTURE_MODE\": 0x0000005E,\n    \"PICO_TOO_MANY_TRIGGER_CHANNELS_IN_USE\": 0x0000005F,\n    \"PICO_INVALID_TRIGGER_DIRECTION\": 0x00000060,\n    \"PICO_INVALID_TRIGGER_STATES\": 0x00000061,\n    \"PICO_GET_DATA_ACTIVE\": 0x00000103,\n    \"PICO_IP_NETWORKED\": 0x00000104,\n    \"PICO_INVALID_IP_ADDRESS\": 0x00000105,\n    \"PICO_IPSOCKET_FAILED\": 0x00000106,\n    \"PICO_IPSOCKET_TIMEDOUT\": 0x00000107,\n    \"PICO_SETTINGS_FAILED\": 0x00000108,\n    \"PICO_NETWORK_FAILED\": 0x00000109,\n    \"PICO_WS2_32_DLL_NOT_LOADED\": 0x0000010A,\n    \"PICO_INVALID_IP_PORT\": 0x0000010B,\n    \"PICO_COUPLING_NOT_SUPPORTED\": 0x0000010C,\n    \"PICO_BANDWIDTH_NOT_SUPPORTED\": 0x0000010D,\n    \"PICO_INVALID_BANDWIDTH\": 0x0000010E,\n    \"PICO_AWG_NOT_SUPPORTED\": 0x0000010F,\n    \"PICO_ETS_NOT_RUNNING\": 0x00000110,\n    \"PICO_SIG_GEN_WHITENOISE_NOT_SUPPORTED\": 0x00000111,\n    \"PICO_SIG_GEN_WAVETYPE_NOT_SUPPORTED\": 0x00000112,\n    \"PICO_INVALID_DIGITAL_PORT\": 0x00000113,\n    \"PICO_INVALID_DIGITAL_CHANNEL\": 0x00000114,\n    \"PICO_INVALID_DIGITAL_TRIGGER_DIRECTION\": 0x00000115,\n    \"PICO_SIG_GEN_PRBS_NOT_SUPPORTED\": 0x00000116,\n    \"PICO_ETS_NOT_AVAILABLE_WITH_LOGIC_CHANNELS\": 0x00000117,\n    \"PICO_WARNING_REPEAT_VALUE\": 0x00000118,\n    \"PICO_POWER_SUPPLY_CONNECTED\": 0x00000119,\n    \"PICO_POWER_SUPPLY_NOT_CONNECTED\": 0x0000011A,\n    \"PICO_POWER_SUPPLY_REQUEST_INVALID\": 0x0000011B,\n    \"PICO_POWER_SUPPLY_UNDERVOLTAGE\": 0x0000011C,\n    \"PICO_CAPTURING_DATA\": 0x0000011D,\n    \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\": 0x0000011E,\n    \"PICO_NOT_SUPPORTED_BY_THIS_DEVICE\": 0x0000011F,\n    \"PICO_INVALID_DEVICE_RESOLUTION\": 0x00000120,\n    \"PICO_INVALID_NUMBER_CHANNELS_FOR_RESOLUTION\": 0x00000121,\n    \"PICO_CHANNEL_DISABLED_DUE_TO_USB_POWERED\": 0x00000122,\n    \"PICO_SIGGEN_DC_VOLTAGE_NOT_CONFIGURABLE\": 0x00000123,\n    \"PICO_NO_TRIGGER_ENABLED_FOR_TRIGGER_IN_PRE_TRIG\": 0x00000124,\n    \"PICO_TRIGGER_WITHIN_PRE_TRIG_NOT_ARMED\": 0x00000125,\n    \"PICO_TRIGGER_WITHIN_PRE_NOT_ALLOWED_WITH_DELAY\": 0x00000126,\n    \"PICO_TRIGGER_INDEX_UNAVAILABLE\": 0x00000127,\n    \"PICO_AWG_CLOCK_FREQUENCY\": 0x00000128,\n    \"PICO_TOO_MANY_CHANNELS_IN_USE\": 0x00000129,\n    \"PICO_NULL_CONDITIONS\": 0x0000012A,\n    \"PICO_DUPLICATE_CONDITION_SOURCE\": 0x0000012B,\n    \"PICO_INVALID_CONDITION_INFO\": 0x0000012C,\n    \"PICO_SETTINGS_READ_FAILED\": 0x0000012D,\n    \"PICO_SETTINGS_WRITE_FAILED\": 0x0000012E,\n    \"PICO_ARGUMENT_OUT_OF_RANGE\": 0x0000012F,\n    \"PICO_HARDWARE_VERSION_NOT_SUPPORTED\": 0x00000130,\n    \"PICO_DIGITAL_HARDWARE_VERSION_NOT_SUPPORTED\": 0x00000131,\n    \"PICO_ANALOGUE_HARDWARE_VERSION_NOT_SUPPORTED\": 0x00000132,\n    \"PICO_UNABLE_TO_CONVERT_TO_RESISTANCE\": 0x00000133,\n    \"PICO_DUPLICATED_CHANNEL\": 0x00000134,\n    \"PICO_INVALID_RESISTANCE_CONVERSION\": 0x00000135,\n    \"PICO_INVALID_VALUE_IN_MAX_BUFFER\": 0x00000136,\n    \"PICO_INVALID_VALUE_IN_MIN_BUFFER\": 0x00000137,\n    \"PICO_SIGGEN_FREQUENCY_OUT_OF_RANGE\": 0x00000138,\n    \"PICO_EEPROM2_CORRUPT\": 0x00000139,\n    \"PICO_EEPROM2_FAIL\": 0x0000013A,\n    \"PICO_SERIAL_BUFFER_TOO_SMALL\": 0x0000013B,\n    \"PICO_SIGGEN_TRIGGER_AND_EXTERNAL_CLOCK_CLASH\": 0x0000013C,\n    \"PICO_WARNING_SIGGEN_AUXIO_TRIGGER_DISABLED\": 0x0000013D,\n    \"PICO_SIGGEN_GATING_AUXIO_NOT_AVAILABLE\": 0x00000013E,\n    \"PICO_SIGGEN_GATING_AUXIO_ENABLED\": 0x00000013F,\n    \"PICO_RESOURCE_ERROR\": 0x00000140,\n    \"PICO_TEMPERATURE_TYPE_INVALID\": 0x00000141,\n    \"PICO_TEMPERATURE_TYPE_NOT_SUPPORTED\": 0x00000142,\n    \"PICO_TIMEOUT\": 0x00000143,\n    \"PICO_DEVICE_NOT_FUNCTIONING\": 0x00000144,\n    \"PICO_INTERNAL_ERROR\": 0x00000145,\n    \"PICO_MULTIPLE_DEVICES_FOUND\": 0x00000146,\n    \"PICO_WARNING_NUMBER_OF_SEGMENTS_REDUCED\": 0x00000147,\n    \"PICO_CAL_PINS_STATES\": 0x00000148,\n    \"PICO_CAL_PINS_FREQUENCY\": 0x00000149,\n    \"PICO_CAL_PINS_AMPLITUDE\": 0x0000014A,\n    \"PICO_CAL_PINS_WAVETYPE\": 0x0000014B,\n    \"PICO_CAL_PINS_OFFSET\": 0x0000014C,\n    \"PICO_PROBE_FAULT\": 0x0000014D,\n    \"PICO_PROBE_IDENTITY_UNKNOWN\": 0x0000014E,\n    \"PICO_PROBE_POWER_DC_POWER_SUPPLE_REQUIRED\": 0x0000014F,\n    \"PICO_PROBE_NOT_POWERED_THROUGH_DC_POWER_SUPPLY\": 0x00000150,\n    \"PICO_PROBE_CONFIG_FAILURE\": 0x00000151,\n    \"PICO_PROBE_INTERACTION_CALLBACK\": 0x00000152,\n    \"PICO_UNKNOWN_INTELLIGENT_PROBE\": 0x00000153,\n    \"PICO_INTELLIGENT_PROBE_CORRUPT\": 0x00000154,\n    \"PICO_PROBE_COLLECTION_NOT_STARTED\": 0x00000155,\n    \"PICO_PROBE_POWER_CONSUMPTION_EXCEEDED\": 0x00000156,\n    \"PICO_WARNING_PROBE_CHANNEL_OUT_OF_SYNC\": 0x00000157,\n    \"PICO_ENDPOINT_MISSING\": 0x00000158,\n    \"PICO_UNKNOWN_ENDPOINT_REQUEST\": 0x00000159,\n    \"PICO_ADC_TYPE_ERROR\": 0x0000015A,\n    \"PICO_FPGA2_FAILED\": 0x0000015B,\n    \"PICO_FPGA2_DEVICE_STATUS\": 0x0000015C,\n    \"PICO_ENABLED_PROGRAM_FPGA2_FAILED\": 0x0000015D,\n    \"PICO_NO_CANNELS_OR_PORTS_ENABLED\": 0x0000015E,\n    \"PICO_INVALID_RATIO_MODE\": 0x0000015F,\n    \"PICO_READS_NOT_SUPPORTED_IN_CURRENT_CAPTURE_MODE\": 0x00000160,\n    \"PICO_TRIGGER_READ_SELECTION_CHECK_FAILED\": 0x00000161,\n    \"PICO_DATA_READ1_SELECTION_CHECK_FAILED\": 0x00000162,\n    \"PICO_DATA_READ2_SELECTION_CHECK_FAILED\": 0x00000164,\n    \"PICO_DATA_READ3_SELECTION_CHECK_FAILED\": 0x00000168,\n    \"PICO_READ_SELECTION_OUT_OF_RANGE\": 0x00000170,\n    \"PICO_MULTIPLE_RATIO_MODES\": 0x00000171,\n    \"PICO_NO_SAMPLES_READ\": 0x00000172,\n    \"PICO_RATIO_MODE_NOT_REQUESTED\": 0x00000173,\n    \"PICO_NO_USER_READ_REQUESTS\": 0x00000174,\n    \"PICO_ZERO_SAMPLES_INVALID\": 0x00000175,\n    \"PICO_ANALOGUE_HARDWARE_MISSING\": 0x00000176,\n    \"PICO_ANALOGUE_HARDWARE_PINS\": 0x00000177,\n    \"PICO_ANALOGUE_SMPS_FAULT\": 0x00000178,\n    \"PICO_DIGITAL_ANALOGUE_HARDWARE_CONFLICT\": 0x00000179,\n    \"PICO_RATIO_MODE_BUFFER_NOT_SET\": 0x0000017A,\n    \"PICO_RESOLUTION_NOT_SUPPORTED_BY_VARIENT\": 0x0000017B,\n    \"PICO_THRESHOLD_OUT_OF_RANGE\": 0x0000017C,\n    \"PICO_INVALID_SIMPLE_TRIGGER_DIRECTION\": 0x0000017D,\n    \"PICO_AUX_NOT_SUPPORTED\": 0x0000017E,\n    \"PICO_NULL_DIRECTIONS\": 0x0000017F,\n    \"PICO_NULL_CHANNEL_PROPERTIES\": 0x00000180,\n    \"PICO_TRIGGER_CHANNEL_NOT_ENABLED\": 0x00000181,\n    \"PICO_CONDITION_HAS_NO_TRIGGER_PROPERTY\": 0x00000182,\n    \"PICO_RATIO_MODE_TRIGGER_MASKING_INVALID\": 0x00000183,\n    \"PICO_TRIGGER_DATA_REQUIRES_MIN_BUFFER_SIZE_OF_40_SAMPLES\": 0x00000184,\n    \"PICO_NO_OF_CAPTURES_OUT_OF_RANGE\": 0x00000185,\n    \"PICO_RATIO_MODE_SEGMENT_HEADER_DOES_NOT_REQUIRE_BUFFERS\": 0x00000186,\n    \"PICO_FOR_SEGMENT_HEADER_USE_GETTRIGGERINFO\": 0x00000187,\n    \"PICO_READ_NOT_SET\": 0x00000188,\n    \"PICO_ADC_SETTING_MISMATCH\": 0x00000189,\n    \"PICO_DATATYPE_INVALID\": 0x0000018A,\n    \"PICO_RATIO_MODE_DOES_NOT_SUPPORT_DATATYPE\": 0x0000018B,\n    \"PICO_CHANNEL_COMBINATION_NOT_VALID_IN_THIS_RESOLUTION\": 0x0000018C,\n    \"PICO_USE_8BIT_RESOLUTION\": 0x0000018D,\n    \"PICO_AGGREGATE_BUFFERS_SAME_POINTER\": 0x0000018E,\n    \"PICO_OVERLAPPED_READ_VALUES_OUT_OF_RANGE\": 0x0000018F,\n    \"PICO_OVERLAPPED_READ_SEGMENTS_OUT_OF_RANGE\": 0x00000190,\n    \"PICO_CHANNELFLAGSCOMBINATIONS_ARRAY_SIZE_TOO_SMALL\": 0x00000191,\n    \"PICO_CAPTURES_EXCEEDS_NO_OF_SUPPORTED_SEGMENTS\": 0x00000192,\n    \"PICO_TIME_UNITS_OUT_OF_RANGE\": 0x00000193,\n    \"PICO_NO_SAMPLES_REQUESTED\": 0x00000194,\n    \"PICO_INVALID_ACTION\": 0x00000195,\n    \"PICO_NO_OF_SAMPLES_NEED_TO_BE_EQUAL_WHEN_ADDING_BUFFERS\": 0x00000196,\n    \"PICO_WAITING_FOR_DATA_BUFFERS\": 0x00000197,\n    \"PICO_STREAMING_ONLY_SUPPORTS_ONE_READ\": 0x00000198,\n    \"PICO_CLEAR_DATA_BUFFER_INVALID\": 0x00000199,\n    \"PICO_INVALID_ACTION_FLAGS_COMBINATION\": 0x0000019A,\n    \"PICO_PICO_MOTH_MIN_AND_MAX_NULL_BUFFERS_CANNOT_BE_ADDED\": 0x0000019B,\n    \"PICO_CONFLICT_IN_SET_DATA_BUFFERS_CALL_REMOVE_DATA_BUFFER_TO_RESET\": 0x0000019C,\n    \"PICO_REMOVING_DATA_BUFFER_ENTRIES_NOT_ALLOWED_WHILE_DATA_PROCESSING\": 0x0000019D,\n    \"PICO_CYUSB_REQUEST_FAILED\": 0x00000200,\n    \"PICO_STREAMING_DATA_REQUIRED\": 0x00000201,\n    \"PICO_INVALID_NUMBER_OF_SAMPLES\": 0x00000202,\n    \"PICO_INALID_DISTRIBUTION\": 0x00000203,\n    \"PICO_BUFFER_LENGTH_GREATER_THAN_INT32_T\": 0x00000204,\n    \"PICO_PLL_MUX_OUT_FAILED\": 0x00000209,\n    \"PICO_ONE_PULSE_WIDTH_DIRECTION_ALLOWED\": 0x0000020A,\n    \"PICO_EXTERNAL_TRIGGER_NOT_SUPPORTED\": 0x0000020B,\n    \"PICO_NO_TRIGGER_CONDITIONS_SET\": 0x0000020C,\n    \"PICO_NO_OF_CHANNEL_TRIGGER_PROPERTIES_OUT_OF_RANGE\": 0x0000020D,\n    \"PICO_PROBE_COMPNENT_ERROR\": 0x0000020E,\n    \"PICO_INVALID_TRIGGER_CHANNELS_FOR_ETS\": 0x00000210,\n    \"PICO_NOT_AVALIABLE_WHEN_STREAMING_IS_RUNNING\": 0x00000211,\n    \"PICO_INVALID_TRIGGER_WITHIN_PRE_TRIGGER_STATE\": 0x00000212,\n    \"PICO_ZERO_NUMBER_OF_CAPTURES_INVALID\": 0x00000213,\n    \"PICO_TRIGGER_DELAY_OUT_OF_RANGE\": 0x00000300,\n    \"PICO_INVALID_THRESHOLD_DIRECTION\": 0x00000301,\n    \"PICO_INVALID_THRESGOLD_MODE\": 0x00000302,\n    \"PICO_DEVICE_TIME_STAMP_RESET\": 0x01000000,\n    \"PICO_WATCHDOGTIMER\": 0x10000000,\n    \"PICO_IPP_NOT_FOUND\": 0x10000001,\n    \"PICO_IPP_NO_FUNCTION\": 0x10000002,\n    \"PICO_IPP_ERROR\": 0x10000003,\n    \"PICO_SHADOW_CAL_NOT_AVAILABLE\": 0x10000004,\n    \"PICO_SHADOW_CAL_DISABLED\": 0x10000005,\n    \"PICO_SHADOW_CAL_ERROR\": 0x10000006,\n    \"PICO_SHADOW_CAL_CORRUPT\": 0x10000007,\n}\n\nPICO_STATUS_LOOKUP = {v: k for k, v in PICO_STATUS.items()}\n\nPICO_INFO = {\n    \"PICO_DRIVER_VERSION\": 0x00000000,\n    \"PICO_USB_VERSION\": 0x00000001,\n    \"PICO_HARDWARE_VERSION\": 0x00000002,\n    \"PICO_VARIANT_INFO\": 0x00000003,\n    \"PICO_BATCH_AND_SERIAL\": 0x00000004,\n    \"PICO_CAL_DATE\": 0x00000005,\n    \"PICO_KERNEL_VERSION\": 0x00000006,\n    \"PICO_DIGITAL_HARDWARE_VERSION\": 0x00000007,\n    \"PICO_ANALOGUE_HARDWARE_VERSION\": 0x00000008,\n    \"PICO_FIRMWARE_VERSION_1\": 0x00000009,\n    \"PICO_FIRMWARE_VERSION_2\": 0x0000000A,\n    \"PICO_MAC_ADDRESS\": 0x0000000B,\n    \"PICO_SHADOW_CAL\": 0x0000000C,\n    \"PICO_IPP_VERSION\": 0x0000000D,\n}\n"
  },
  {
    "path": "picosdk/ctypes_wrapper.py",
    "content": "# coding=utf-8\n#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\nimport ctypes\nimport sys\n\nif sys.platform == 'win32':\n    C_CALLBACK_FUNCTION_FACTORY = ctypes.WINFUNCTYPE\nelse:\n    C_CALLBACK_FUNCTION_FACTORY = ctypes.CFUNCTYPE\n"
  },
  {
    "path": "picosdk/device.py",
    "content": "# coding=utf-8\n#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nDefinition of the Device class, which provides access to SDK functions which require a device handle, including\ncapturing data and configuring the AWG.\n\"\"\"\nfrom __future__ import print_function\nimport collections\nimport numpy\nimport math\nimport time\nfrom picosdk.errors import DeviceCannotSegmentMemoryError, InvalidTimebaseError, ClosedDeviceError, \\\n    NoChannelsEnabledError, NoValidTimebaseForOptionsError\n\n\ndef requires_open(error_message=\"This operation requires a device to be connected.\"):\n    def check_open_decorator(method):\n        def check_open_impl(self, *args, **kwargs):\n            if not self.is_open:\n                raise ClosedDeviceError(error_message)\n            return method(self, *args, **kwargs)\n        return check_open_impl\n    return check_open_decorator\n\n\n\"\"\"ChannelConfig: A type for specifying channel setup for capture (pass into Device.set_channel, or Device.capture_*)\nname = The channel name as a string (e.g. 'A'.)\nenabled = bool indicating whether the channel should be enabled or disabled.\ncoupling (optional) = 'AC' or 'DC', default is 'DC'.\nrange_peak (optional) = +/- max volts, the highest precision range which includes your value will be selected.\nanalog_offset (optional) = the meaning of 0 for this channel.\"\"\"\nChannelConfig = collections.namedtuple('ChannelConfig', ['name', 'enabled', 'coupling', 'range_peak', 'analog_offset'])\nChannelConfig.__new__.__defaults__ = (None, None, None)\n\n\n\"\"\"TimebaseOptions: A type for specifying timebase constraints (pass to Device.find_timebase or Device.capture_*)\nAll are optional. Please specify the options which matter to you: \n  - the maximum time interval (if you want the fastest/most precise timebase you can get),\n  - the number of samples in one buffer,\n  - the minimum total collection time (if you want at least x.y seconds of uninterrupted capture data)\n  - the oversample (if you want to sacrifice time precision for amplitude precision - see the programming guides.)\"\"\"\nTimebaseOptions = collections.namedtuple('TimebaseOptions', ['max_time_interval',\n                                                             'no_of_samples',\n                                                             'min_collection_time',\n                                                             'oversample'])\n_TIMEBASE_OPTIONS_DEFAULTS = (None, None, None, 1)\nTimebaseOptions.__new__.__defaults__ = _TIMEBASE_OPTIONS_DEFAULTS\n\n\nclass Device(object):\n    \"\"\"This object caches some information about the device state which cannot be queried from the driver. Please don't\n    mix and match calls to this object with calls directly to the driver (or the ctypes wrapper), as this may cause\n    unwanted behaviour (e.g. throwing an exception because no channels are enabled, when you enabled them yourself\n    on the driver object.)\"\"\"\n    def __init__(self, driver, handle):\n        self.driver = driver\n        self.handle = handle\n        self.is_open = handle > 0\n\n        # if a channel is missing from here, it is disabled (or in an undefined state).\n        self._channel_ranges = {}\n        self._channel_offsets = {}\n\n    @requires_open(\"The device either did not initialise correctly or has already been closed.\")\n    def close(self):\n        self.driver.close_unit(self)\n        self.handle = None\n        self.is_open = False\n\n    @property\n    @requires_open()\n    def info(self):\n        return self.driver.get_unit_info(self)\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, *args):\n        self.close()\n        if all(i is None for i in args):\n            return True\n        return False\n\n    @requires_open()\n    def set_channel(self, channel_config):\n        name = channel_config.name\n        if not channel_config.enabled:\n            self.driver.set_channel(self,\n                                    channel_name=name,\n                                    enabled=channel_config.enabled)\n            try:\n                del self._channel_ranges[name]\n                del self._channel_offsets[name]\n            except KeyError:\n                pass\n            return\n        # if enabled, we pass through the values from the channel config:\n        self._channel_ranges[name] = self.driver.set_channel(self,\n                                                             channel_name=name,\n                                                             enabled=channel_config.enabled,\n                                                             coupling=channel_config.coupling,\n                                                             range_peak=channel_config.range_peak,\n                                                             analog_offset=channel_config.analog_offset)\n        self._channel_offsets[name] = channel_config.analog_offset\n        return self._channel_ranges[name]\n\n    @requires_open()\n    def set_channels(self, *channel_configs):\n        \"\"\" set_channels(self, *channel_configs)\n        An alternative to calling set_channel for each one, you can call this method with some channel configs.\n        This method will also disable any missing channels from the passed configs, and disable ALL channels if the\n        collection is empty. \"\"\"\n        # Add channels which are missing as \"disabled\".\n        if len(channel_configs) < len(self.driver.PICO_CHANNEL):\n            channel_configs = list(channel_configs)\n            present_channels = set(c.name for c in channel_configs)\n            missing_channels = [cn for cn in self.driver.PICO_CHANNEL.keys() if cn not in present_channels]\n            for channel_name in missing_channels:\n                channel_configs.append(ChannelConfig(channel_name, False))\n\n        for channel_config in channel_configs:\n            self.set_channel(channel_config)\n\n    def _timebase_options_are_impossible(self, options):\n        device_max_samples_possible = self.driver.MAX_MEMORY\n        if options.no_of_samples is not None:\n            if options.no_of_samples > device_max_samples_possible:\n                return True\n        elif options.max_time_interval is not None and options.min_collection_time is not None:\n            effective_min_no_samples = math.ceil(options.min_collection_time / options.max_time_interval)\n            if effective_min_no_samples > device_max_samples_possible:\n                return True\n        if None not in (options.no_of_samples, options.max_time_interval, options.min_collection_time):\n            # if all 3 are requested, the result can be impossible.\n            effective_min_no_samples = int(math.ceil(options.min_collection_time / options.max_time_interval))\n            if effective_min_no_samples > options.no_of_samples:\n                return True\n        # Is it still possible that this device cannot handle this request, but we don't know without making calls to\n        # get_timebase.\n        return False\n\n    @staticmethod\n    def _validate_timebase(timebase_options, timebase_info):\n        \"\"\"validate whether a timebase result matches the options requested.\"\"\"\n        if timebase_options.max_time_interval is not None:\n            if timebase_info.time_interval > timebase_options.max_time_interval:\n                return False\n        if timebase_options.no_of_samples is not None:\n            if timebase_options.no_of_samples > timebase_info.max_samples:\n                return False\n        if timebase_options.min_collection_time is not None:\n            if timebase_options.min_collection_time > timebase_info.max_samples * timebase_info.time_interval:\n                return False\n        return True\n\n    @requires_open()\n    def find_timebase(self, timebase_options):\n        timebase_id = 0\n        # quickly validate that the request is not impossible.\n        if self._timebase_options_are_impossible(timebase_options):\n            raise NoValidTimebaseForOptionsError()\n        # TODO binary search?\n        last_error = None\n        found_one_good = False\n        while True:\n            try:\n                timebase_info = self.driver.get_timebase(self, timebase_id, 0, timebase_options.oversample)\n                found_one_good = True\n                if self._validate_timebase(timebase_options, timebase_info):\n                    return timebase_info\n            except InvalidTimebaseError as e:\n                if found_one_good:\n                    # we won't find a valid timebase.\n                    last_error = e\n                    break\n            timebase_id += 1\n        args = ()\n        if last_error is not None:\n            args = (last_error.args[0],)\n        raise NoValidTimebaseForOptionsError(*args)\n\n    @requires_open()\n    def capture_block(self, timebase_options, channel_configs=()):\n        \"\"\"device.capture_block(timebase_options, channel_configs)\n        timebase_options: TimebaseOptions object, specifying at least 1 constraint, and optionally oversample.\n        channel_configs: a collection of ChannelConfig objects. If present, will be passed to set_channels.\n        \"\"\"\n        # set_channel:\n\n        if channel_configs:\n            self.set_channels(*channel_configs)\n\n        if len(self._channel_ranges) == 0:\n            raise NoChannelsEnabledError(\"We cannot capture any data if no channels are enabled.\")\n\n        # memory_segments:\n        USE_SEGMENT_ID=0\n        try:\n            # always force the number of memory segments on the device to 1 before computing timebases for a one-off\n            # block capture.\n            max_samples_possible = self.driver.memory_segments(self, USE_SEGMENT_ID+1)\n            if timebase_options.no_of_samples is not None and timebase_options.no_of_samples > max_samples_possible.value:\n                raise NoValidTimebaseForOptionsError()\n        except DeviceCannotSegmentMemoryError:\n            pass\n\n        # get_timebase\n        timebase_info = self.find_timebase(timebase_options)\n\n        post_trigger_samples = timebase_options.no_of_samples\n        pre_trigger_samples = 0\n\n        if post_trigger_samples is None:\n            post_trigger_samples = int(math.ceil(timebase_options.min_collection_time / timebase_info.time_interval))\n\n        self.driver.set_null_trigger(self)\n\n        # tell the device to capture something:\n        approx_time_busy = self.driver.run_block(self,\n                                                 pre_trigger_samples,\n                                                 post_trigger_samples,\n                                                 timebase_info.timebase_id,\n                                                 timebase_options.oversample,\n                                                 USE_SEGMENT_ID)\n\n        is_ready = self.driver.is_ready(self)\n        while not is_ready:\n            time.sleep(approx_time_busy / 5)\n            is_ready = self.driver.is_ready(self)\n\n        raw_data, overflow_warnings = self.driver.get_values(self,\n                                                             self._channel_ranges.keys(),\n                                                             post_trigger_samples,\n                                                             USE_SEGMENT_ID)\n\n        self.driver.stop(self)\n\n        times = numpy.linspace(0.,\n                               post_trigger_samples * timebase_info.time_interval,\n                               post_trigger_samples,\n                               dtype=numpy.dtype('float32'))\n\n        voltages = {}\n\n        max_adc = self.driver.maximum_value(self)\n        for channel, raw_array in raw_data.items():\n            array = raw_array.astype(numpy.dtype('float32'), casting='safe')\n            factor = self._channel_ranges[channel] / max_adc\n            array = array * factor\n            voltages[channel] = array\n\n        return times, voltages, overflow_warnings\n"
  },
  {
    "path": "picosdk/discover.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\nfrom picosdk.errors import DeviceNotFoundError\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.ps2000a import ps2000a\nfrom picosdk.ps3000 import ps3000\nfrom picosdk.ps3000a import ps3000a\nfrom picosdk.ps4000 import ps4000\nfrom picosdk.ps4000a import ps4000a\nfrom picosdk.ps5000a import ps5000a\nfrom picosdk.ps6000 import ps6000\nfrom picosdk.ps6000a import ps6000a\n\n\n# the A drivers are faster to enumerate devices, so search them first.\ndrivers = [\n    ps2000a,\n    ps3000a,\n    ps4000a,\n    ps5000a,\n    ps6000a,\n    ps6000,\n    ps2000,\n    ps3000,\n    ps4000,\n]\n\n\ndef find_unit():\n    \"\"\"Search for, open and return the first device connected, on any driver.\"\"\"\n    for driver in drivers:\n        try:\n            device = driver.open_unit()\n        except DeviceNotFoundError:\n            continue\n        return device\n    raise DeviceNotFoundError(\"Could not find any devices on any drivers.\")\n\n\ndef find_all_units():\n    \"\"\"Search for, open and return ALL devices on ALL pico drivers (supported in this SDK wrapper).\"\"\"\n    devices = []\n    for driver in drivers:\n        try:\n            device = driver.open_unit()\n        except DeviceNotFoundError:\n            continue\n        devices.append(device)\n    if not devices:\n        raise DeviceNotFoundError(\"Could not find any devices on any drivers.\")\n    return devices"
  },
  {
    "path": "picosdk/errors.py",
    "content": "#\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n\n\nclass PicoError(Exception):\n    \"\"\"All errors thrown explicitly by this package will be PicoError's.\"\"\"\n    pass\n\n\nclass FeatureNotSupportedError(PicoError):\n    \"\"\"raised when a feature is not supported on the connected device.\"\"\"\n    pass\n\n\nclass CannotFindPicoSDKError(PicoError, IOError):\n    pass\n\n\nclass CannotOpenPicoSDKError(PicoError, IOError):\n    pass\n\n\nclass DeviceNotFoundError(PicoError, IOError):\n    pass\n\n\nclass ArgumentOutOfRangeError(PicoError, ValueError):\n    pass\n\n\nclass ValidRangeEnumValueNotValidForThisDevice(FeatureNotSupportedError, ValueError):\n    pass\n\n\nclass DeviceCannotSegmentMemoryError(FeatureNotSupportedError, TypeError):\n    pass\n\n\nclass InvalidMemorySegmentsError(PicoError, ValueError):\n    pass\n\n\nclass InvalidTimebaseError(PicoError, ValueError):\n    pass\n\n\nclass InvalidTriggerParameters(PicoError, ValueError):\n    pass\n\n\nclass InvalidCaptureParameters(PicoError, ValueError):\n    pass\n\n\nclass PicoSDKCtypesError(PicoError, IOError):\n    pass\n\n\nclass ClosedDeviceError(PicoError, IOError):\n    pass\n\n\nclass NoChannelsEnabledError(PicoError, ValueError):\n    pass\n\n\nclass NoValidTimebaseForOptionsError(PicoError, ValueError):\n    pass\n\n\nclass UnknownConstantError(PicoError, TypeError):\n    pass\n"
  },
  {
    "path": "picosdk/functions.py",
    "content": "#\n# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\nfrom __future__ import division\nimport numpy as np\nfrom picosdk.constants import PICO_STATUS, PICO_STATUS_LOOKUP\nfrom picosdk.errors import PicoSDKCtypesError\n\n\ndef adc2mV(bufferADC, range, maxADC):\n    \"\"\" \n        adc2mc(\n                c_short_Array           bufferADC\n                int                     range\n                c_int32                 maxADC\n                )\n               \n        Takes a buffer of raw adc count values and converts it into millivolts\n    \"\"\"\n\n    channelInputRanges = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000]\n    vRange = channelInputRanges[range]\n    bufferV = [(np.int64(x) * vRange) / maxADC.value for x in bufferADC]\n    \n    return bufferV\n\t\ndef adc2mVpl1000(bufferADC, range, maxADC):\n\t\"\"\"\n\t\tadc2mVpl1000(\n\t\t\t\t\t\tc_short_Array\t\tbufferADC,\n\t\t\t\t\t\tint \t\t\t\trange,\n\t\t\t\t\t\tc_int32\t\t\t\tmaxADC\n\t\t\t\t\t\t)\n\t\t\n\t\tTakes a buffer of raw adc count values and converts it into millvolts\n\t\"\"\"\n\t\n\tbufferV = [(x * range) / maxADC.value for x in bufferADC]\n\t\n\treturn bufferV\n\ndef mV2adc(millivolts, range, maxADC):\n    \"\"\"\n        mV2adc(\n                float                   millivolts\n\t\t\t\tint                     range\n                c_int32                 maxADC\n                )\n        Takes a voltage value and converts it into adc counts\n    \"\"\"\n    channelInputRanges = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000]\n    vRange = channelInputRanges[range]\n    adcValue = round((millivolts * maxADC.value)/vRange)\n\n    return adcValue\n\ndef mV2adcpl1000(millivolts, range, maxADC):\n\t\"\"\"\n\t\tmV2adc(\n\t\t\t\tfloat\t\t\t\tmillivolts,\n\t\t\t\tint\t\t\t\t\trange,\n\t\t\t\tc_int32\t\t\t\tmaxADC\n\t\t\t\t)\n\t\tTakes a voltage value and converts it to adc counts\n\t\"\"\"\n\tadcValue = round((millivolts * maxADC.value)/range)\n\t\n\treturn adcValue\n\n\ndef splitMSOData(dataLength, data):\n    \"\"\"\n    This method converts an array of values for a ditial port into the binary equivalent, splitting the bits by\n    digital channel.\n\n    Returns a set of 8 variables, each of which corresponds to the binary data values over time of the different\n    digital channels from the lowest significant bit to the most significant bit. For PORT0 this will be in the order\n    (D0, D1, D2, ... D7) and for PORT1 this will be (D8, D9, D10, ... D15).\n\n        splitMSOData(\n                        c_int32         dataLength\n                        c_int16 array   data\n                        )\n    \"\"\"\n    # Makes an array for each digital channel\n    binaryBufferD0 = np.chararray((dataLength.value, 1))\n    binaryBufferD1 = np.chararray((dataLength.value, 1))\n    binaryBufferD2 = np.chararray((dataLength.value, 1))\n    binaryBufferD3 = np.chararray((dataLength.value, 1))\n    binaryBufferD4 = np.chararray((dataLength.value, 1))\n    binaryBufferD7 = np.chararray((dataLength.value, 1))\n    binaryBufferD5 = np.chararray((dataLength.value, 1))\n    binaryBufferD6 = np.chararray((dataLength.value, 1))\n    \n    # Changes the data from int type to a binary type and then separates the data for each digital channel\n    for i in range(0, dataLength.value):\n        MSOData = data[i]\n        binaryMSOData = bin(MSOData)\n        binaryMSOData = binaryMSOData[2:]\n        binaryMSOData = binaryMSOData.zfill(8)\n        binaryBufferD0[i] = binaryMSOData[7]\n        binaryBufferD1[i] = binaryMSOData[6]\n        binaryBufferD2[i] = binaryMSOData[5]\n        binaryBufferD3[i] = binaryMSOData[4]\n        binaryBufferD4[i] = binaryMSOData[3]\n        binaryBufferD5[i] = binaryMSOData[2]\n        binaryBufferD6[i] = binaryMSOData[1]\n        binaryBufferD7[i] = binaryMSOData[0]\n\n    return binaryBufferD0, \\\n           binaryBufferD1, \\\n           binaryBufferD2, \\\n           binaryBufferD3, \\\n           binaryBufferD4, \\\n           binaryBufferD5, \\\n           binaryBufferD6, \\\n           binaryBufferD7\n\n\ndef splitMSODataFast(dataLength, data):\n    \"\"\"\n    # This implementation will work on either channel in the same way as the splitMSOData method above, albeit in a\n    more efficient manner.\n\n    Returns a tuple of 8 arrays, each of which is the values over time of a different digital channel.\n    The tuple contains the channels in order (D7, D6, D5, ... D0) or equivalently (D15, D14, D13, ... D8).\n\n        splitMSODataFast(\n                        c_int32         dataLength\n                        c_int16 array   data\n                        )\n    \"\"\"\n    # Makes an array for each digital channel\n    bufferBinaryDj = (\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n        np.chararray(dataLength.value),\n    )\n    # Splits out the individual bits from the port into the binary values for each digital channel/pin.\n    for i in range(dataLength.value):\n        for j in range(8):\n            bufferBinaryDj[j][i] = 1 if (data[i] & (1 << (7-j))) else 0\n\n    return bufferBinaryDj\n\n\ndef assert_pico_ok(status):\n    \"\"\"\n        assert_pico_ok(\n                        status\n                       )\n    \"\"\"\n    # checks for PICO_OK status return\n    if status != PICO_STATUS['PICO_OK']:\n        raise PicoSDKCtypesError(\"PicoSDK returned '{}'\".format(PICO_STATUS_LOOKUP[status]))\n\n\ndef assert_pico2000_ok(status):\n    \"\"\"\n        assert_pico_ok(\n                        status\n                       )\n    \"\"\"\n    # checks for PICO_OK status return\n    if status > 0:\n        errorCheck = True\n    else:\n        errorCheck = False\n        raise PicoSDKCtypesError(\"Unsuccessful API call\")\n        \ndef mV2adcV2(millivolts, rangeMax, maxADC):\n    \"\"\"\n        mV2adcV2(\n                float                   millivolts\n\t\t\t\tint                     rangeMax\n                c_int32                 maxADC\n                )\n        Takes a voltage value and converts it into adc counts for psospa driver scopes\n    \"\"\"\n    adcValue = round((millivolts * maxADC.value)/(rangeMax/1000000))\n\n    return adcValue\n    \ndef adc2mVV2(bufferADC, rangeMax, maxADC):\n    \"\"\" \n        adc2mVV2(\n                c_short_Array           bufferADC\n                int                     rangeMax\n                c_int32                 maxADC\n                )\n               \n        Takes a buffer of raw adc count values and converts it into millivolts for psospa driver scopes\n    \"\"\"\n    buffermV = [(x * (rangeMax/1000000)) / maxADC.value for x in bufferADC]\n    \n    return buffermV"
  },
  {
    "path": "picosdk/functionsExhibitions.py",
    "content": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\r\nimport numpy as np\r\nimport openpyxl\r\nfrom math import floor, log2, log10\r\nimport shutil\r\nimport os\r\nimport toml\r\n\r\ndef dataImporter(name):\r\n\r\n    workbook = openpyxl.load_workbook(name, data_only = True)\r\n    \r\n    sheet = workbook['filterParameters']\r\n    \r\n    noOfChannels = sheet.cell(row = 2, column = 1).value\r\n    bits = sheet.cell(row = 2, column = 2).value\r\n    samplingRate = sheet.cell(row = 2, column = 3).value\r\n    sampleLength = sheet.cell(row = 2, column = 4).value\r\n    \r\n    return noOfChannels, bits, samplingRate, sampleLength\r\n    \r\n    \r\ndef ps6000aTimebase(samplingRate):\r\n    \r\n    sampleInterval = (1/samplingRate)/1000000 #s\r\n    \r\n    breakPoint = 6.4/1000000000\r\n    \r\n    if sampleInterval >= breakPoint:\r\n        timebase = floor((sampleInterval * 156250000)+5)\r\n    else:\r\n        timebase = floor(log2(sampleInterval * 5000000000))\r\n    \r\n    return timebase\r\n    \r\ndef ps5000aTimebase(samplingRate):\r\n    \r\n    sampleInterval = (1/samplingRate)/1000000 #s\r\n    \r\n    breakPoint = 8/1000000000\r\n    \r\n    if sampleInterval >= breakPoint:\r\n        timebase = floor((sampleInterval * 125000000)+2)\r\n    else:\r\n        timebase = floor(log2(sampleInterval * 1000000000))\r\n    \r\n    return timebase\r\n    \r\ndef ps3000aTimebase(samplingRate):\r\n    \r\n    sampleInterval = (1/samplingRate)/1000000 #s\r\n    \r\n    breakPoint = 8/1000000000\r\n    \r\n    if sampleInterval >= breakPoint:\r\n        timebase = floor((sampleInterval * 125000000)+2)\r\n    else:\r\n        timebase = floor(log2(sampleInterval * 1000000000))\r\n    \r\n    return timebase\r\n  \r\ndef ps4000aTimebase(samplingRate):\r\n    \r\n    timebase = floor((80/samplingRate)-1)\r\n    \r\n    return timebase\r\n    \r\ndef ps2000aTimebase(samplingRate):\r\n    \r\n    sampleInterval = (1/samplingRate)/1000000 #s\r\n    \r\n    breakPoint = 4/1000000000\r\n    \r\n    if sampleInterval>= breakPoint:\r\n        timebase = floor((sampleInterval*125000000)+2)\r\n    else:\r\n        timebase = floor(log2(sampleInterval * 1000000000))\r\n        \r\n    return timebase\r\n    \r\ndef ps2000Timebase(sampleRate):\r\n    #assumes sample rate is in Hz\r\n    #assumes sample interval in s\r\n    \r\n    sampleInterval = (1/sampleRate)\r\n    \r\n    timebase = floor(log10(sampleInterval*1000000000))\r\n    \r\n    return timebase\r\n    \r\n    \r\ndef BitEnumSelector(bits):\r\n\r\n    if bits <= 8:\r\n        enum = 0\r\n    elif bits <= 10:\r\n        enum = 10\r\n    else:\r\n        enum = 1\r\n        \r\n    return enum\r\n    \r\ndef saveConfigFile(channels, bits, sampleRate,captureLength, segments):\r\n    \r\n    # configValues = [channels, bits, sampleRate, captureLength, segments]\r\n    data = {\r\n        \"Active Channels\" : int(channels),\r\n        \"Scope Bit Resolution\" : int(bits),\r\n        \"Sampling Rate (MHz)\" : float(sampleRate),\r\n        \"Capture Length (Samples)\" : int(captureLength),\r\n        \"Number of Capture Segments for Rapid Block\" : int(segments),\r\n        }\r\n    # # Save the list to a text file\r\n    with open('configValues.toml', 'w') as file:\r\n        toml.dump(data,file)  \r\n    \r\n        \r\n    return\r\n    \r\ndef loadConfigValues():\r\n    \r\n    with open('configValues.toml', 'r') as file:\r\n        restored_configValues = toml.load(file)\r\n            \r\n    channels = int(restored_configValues[\"Active Channels\"])\r\n    bits = int(restored_configValues[\"Scope Bit Resolution\"])\r\n    sampleRate = float(restored_configValues[\"Sampling Rate (MHz)\"])\r\n    captureLength = int(float(restored_configValues[\"Capture Length (Samples)\"]))\r\n    segments = int(restored_configValues[\"Number of Capture Segments for Rapid Block\"])\r\n    \r\n    return channels, bits, sampleRate, captureLength, segments\r\n    \r\ndef copyFile(source_directory, filename):\r\n    \r\n    destination_directory = 'D:/'\r\n\r\n    # Define the destination file path\r\n    source_file = os.path.join(source_directory, filename)\r\n    destination_file = os.path.join(destination_directory, filename)\r\n\r\n    # Copy the file to the new location\r\n    shutil.copy(source_file, destination_file)\r\n    \r\n    return "
  },
  {
    "path": "picosdk/library.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nDefinition of the Library class, which is the abstract representation of a picotech device driver.\nNote: Many of the functions in this class are missing: these are populated by the psN000(a).py modules, which subclass\nthis type and attach the missing methods.\n\"\"\"\n\nfrom __future__ import print_function\n\nimport sys\nfrom ctypes import c_int16, c_int32, c_uint32, c_float, create_string_buffer, byref\nfrom ctypes.util import find_library\nimport collections\nimport picosdk.constants as constants\nimport numpy\n\nfrom picosdk.errors import CannotFindPicoSDKError, CannotOpenPicoSDKError, DeviceNotFoundError, \\\n    ArgumentOutOfRangeError, ValidRangeEnumValueNotValidForThisDevice, DeviceCannotSegmentMemoryError, \\\n    InvalidMemorySegmentsError, InvalidTimebaseError, InvalidTriggerParameters, InvalidCaptureParameters\n\n\nfrom picosdk.device import Device\n\n\n\"\"\"TimebaseInfo: A type for holding the particulars of a timebase configuration.\n\"\"\"\nTimebaseInfo = collections.namedtuple('TimebaseInfo', ['timebase_id',\n                                                       'time_interval',\n                                                       'time_units',\n                                                       'max_samples',\n                                                       'segment_id'])\n\n\ndef requires_device(error_message=\"This method requires a Device instance registered to this Library instance.\"):\n    def check_device_decorator(method):\n        def check_device_impl(self, device, *args, **kwargs):\n            if not isinstance(device, Device) or device.driver != self:\n                raise TypeError(error_message)\n            return method(self, device, *args, **kwargs)\n        return check_device_impl\n    return check_device_decorator\n\n\nclass Library(object):\n    def __init__(self, name):\n        self.name = name\n        self._clib = self._load()\n        # ! some drivers will replace these dicts at import time, where they have different constants (notably ps2000).\n        self.PICO_INFO = constants.PICO_INFO\n        self.PICO_STATUS = constants.PICO_STATUS\n        self.PICO_STATUS_LOOKUP = constants.PICO_STATUS_LOOKUP\n        # these must be set in each driver file.\n        self.PICO_CHANNEL = {}\n        self.PICO_COUPLING = {}\n        self.PICO_VOLTAGE_RANGE = {}\n\n        # most series of scopes top out at 512MS.\n        self.MAX_MEMORY = 2**29\n\n        # These are set in some driver files, but not all.\n        self.PICO_RATIO_MODE = {}\n        self.PICO_THRESHOLD_DIRECTION = {}\n\n    def _load(self):\n        library_path = find_library(self.name)\n\n        # 'find_library' fails in Cygwin.\n        if not sys.platform == 'cygwin':\n            if library_path is None:\n                env_var_name = \"PATH\" if sys.platform == 'win32' else \"LD_LIBRARY_PATH\"\n                raise CannotFindPicoSDKError(\"PicoSDK (%s) not found, check %s\" % (self.name, env_var_name))\n\n        try:\n            if sys.platform == 'win32':\n                from ctypes import WinDLL\n                result = WinDLL(library_path)\n            elif sys.platform == 'cygwin':\n                from ctypes import CDLL\n                library_path = self.name\n                result = CDLL(library_path + \".dll\")\n            else:\n                from ctypes import cdll\n                result = cdll.LoadLibrary(library_path)\n        except OSError as e:\n            raise CannotOpenPicoSDKError(\"PicoSDK (%s) not compatible (check 32 vs 64-bit): %s\" % (self.name, e))\n        return result\n\n    def __str__(self):\n        return \"picosdk %s library\" % self.name\n\n    def make_symbol(self, python_name, c_name, return_type, argument_types, docstring=None):\n        \"\"\"Used by python wrappers for particular drivers to register C functions on the class.\"\"\"\n        c_function = getattr(self._clib, c_name)\n        c_function.restype = return_type\n        c_function.argtypes = argument_types\n        if docstring is not None:\n            c_function.__doc__ = docstring\n        # make the functions available under *both* their original and generic names\n        setattr(self, python_name, c_function)\n        setattr(self, c_name, c_function)\n        # AND if the function is camel case, add an \"underscore-ized\" version:\n        if python_name.lower() != python_name:\n            acc = []\n            for c in python_name[1:]:\n                # Be careful to exclude both digits (lower index) and lower case (higher index).\n                if ord('A') <= ord(c) <= ord('Z'):\n                    c = \"_\" + c.lower()\n                acc.append(c)\n            if acc[:2] == ['_', '_']:\n                acc = acc[1:]\n            setattr(self, \"\".join(acc), c_function)\n\n    def list_units(self):\n        \"\"\"Returns: a list of dictionaries which identify connected devices which use this driver.\"\"\"\n        handles = []\n        device_infos = []\n        try:\n            while True:\n                handle = self._python_open_unit()\n                device_infos.append(self._python_get_unit_info_wrapper(handle, []))\n                handles.append(handle)\n        except DeviceNotFoundError:\n            pass\n\n        for handle in handles:\n            self._python_close_unit(handle)\n\n        return device_infos\n\n    def open_unit(self, serial=None, resolution=None):\n        \"\"\"optional arguments:\n        serial: If no serial number is provided, this function opens the first device discovered.\n        resolution: for some devices, you may specify a resolution as you open the device. You should retrieve this\n            numeric constant from the relevant driver module.\n        returns: a Device instance, which has functions on it for collecting data and using the waveform generator (if\n            present).\n        Note: Either use this object in a context manager, or manually call .close() on it when you are finished.\"\"\"\n        return Device(self, self._python_open_unit(serial=serial, resolution=resolution))\n\n    @requires_device(\"close_unit requires a picosdk.device.Device instance, passed to the correct owning driver.\")\n    def close_unit(self, device):\n        self._python_close_unit(device.handle)\n\n    @requires_device(\"get_unit_info requires a picosdk.device.Device instance, passed to the correct owning driver.\")\n    def get_unit_info(self, device, *args):\n        return self._python_get_unit_info_wrapper(device.handle, args)\n\n    def _python_open_unit(self, serial=None, resolution=None):\n        if serial is None:\n            handle, status = self._python_open_any_unit(resolution)\n        else:\n            handle, status = self._python_open_specific_unit(serial, resolution)\n\n        if handle < 1:\n            message = (\"Driver %s could find no device\" % self.name) + (\"s\" if serial is None else\n                                                                        (\" matching %s\" % serial))\n            if status is not None:\n                message += \" (%s)\" % constants.pico_tag(status)\n            raise DeviceNotFoundError(message)\n\n        return handle\n\n    def _python_open_any_unit(self, resolution):\n        status = None\n        if len(self._open_unit.argtypes) == 3:\n            if resolution is None:\n                resolution = self.DEFAULT_RESOLUTION\n            chandle = c_int16()\n            cresolution = c_int32()\n            cresolution.value = resolution\n            status = self._open_unit(byref(chandle), None, cresolution)\n            handle = chandle.value\n        elif len(self._open_unit.argtypes) == 2:\n            chandle = c_int16()\n            status = self._open_unit(byref(chandle), None)\n            handle = chandle.value\n        else:\n            handle = self._open_unit()\n\n        return handle, status\n\n    def _python_open_specific_unit(self, serial, resolution):\n        handle = -1\n        status = None\n        if len(self._open_unit.argtypes) == 3:\n            if resolution is None:\n                resolution = self.DEFAULT_RESOLUTION\n            chandle = c_int16()\n            cresolution = c_int32()\n            cresolution.value = resolution\n            cserial = create_string_buffer(serial)\n            status = self._open_unit(byref(chandle), cserial, cresolution)\n            handle = chandle.value\n        elif len(self._open_unit.argtypes) == 2:\n            chandle = c_int16()\n            cserial = create_string_buffer(serial)\n            status = self._open_unit(byref(chandle), cserial)\n            handle = chandle.value\n        else:\n            open_handles = []\n            temp_handle = self._open_unit()\n\n            while temp_handle > 0:\n                this_serial = self._python_get_unit_info(temp_handle, self.PICO_INFO[\"PICO_BATCH_AND_SERIAL\"])\n                if this_serial == serial:\n                    handle = temp_handle\n                    break\n                open_handles.append(temp_handle)\n                temp_handle = self._open_unit()\n\n            for temp_handle in open_handles:\n                self._python_close_unit(temp_handle)\n\n        return handle, status\n\n    def _python_close_unit(self, handle):\n        return self._close_unit(c_int16(handle))\n\n    @staticmethod\n    def _create_empty_string_buffer():\n        try:\n            return create_string_buffer(\"\\0\", 255)\n        except TypeError:\n            return create_string_buffer(\"\\0\".encode('utf8'), 255)\n\n    def _python_get_unit_info(self, handle, info_type):\n        string_size = 255\n        info = self._create_empty_string_buffer()\n        if len(self._get_unit_info.argtypes) == 4:\n            info_len = self._get_unit_info(c_int16(handle), info, c_int16(string_size), c_int16(info_type))\n            if info_len > 0:\n                return info.value[:info_len]\n        elif len(self._get_unit_info.argtypes) == 5:\n            required_size = c_int16(0)\n            status = self._get_unit_info(c_int16(handle),\n                                         info,\n                                         c_int16(string_size),\n                                         byref(required_size),\n                                         c_uint32(info_type))\n            if status == self.PICO_STATUS['PICO_OK']:\n                if required_size.value < string_size:\n                    return info.value[:required_size.value]\n        return \"\"\n\n    def _python_get_unit_info_wrapper(self, handle, keys):\n        # verify that the requested keys are valid for this driver:\n        invalid_info_lines = list(set(keys) - set(self.PICO_INFO.keys()))\n        if invalid_info_lines:\n            raise ArgumentOutOfRangeError(\"%s not available for %s devices\" % (\",\".join(invalid_info_lines), self.name))\n\n        if not keys:\n            # backwards compatible behaviour from first release of this wrapper, which works on all drivers.\n            UnitInfo = collections.namedtuple('UnitInfo', ['driver', 'variant', 'serial'])\n            return UnitInfo(\n                driver=self,\n                variant=self._python_get_unit_info(handle, self.PICO_INFO[\"PICO_VARIANT_INFO\"]),\n                serial=self._python_get_unit_info(handle, self.PICO_INFO[\"PICO_BATCH_AND_SERIAL\"])\n            )\n\n        # make a new type here, with the relevant keys.\n        UnitInfo = collections.namedtuple('UnitInfo', list(keys))\n\n        info_lines = {}\n\n        for line in keys:\n            info_lines[line] = self._python_get_unit_info(handle, self.PICO_INFO[line])\n\n        return UnitInfo(**info_lines)\n\n    @requires_device(\"set_channel requires a picosdk.device.Device instance, passed to the correct owning driver.\")\n    def set_channel(self, device, channel_name='A', enabled=True, coupling='DC', range_peak=float('inf'),\n                    analog_offset=None):\n        \"\"\"optional arguments:\n        channel_name: a single channel (e.g. 'A')\n        enabled: whether to enable the channel (boolean)\n        coupling: string of the relevant enum member for your driver less the driver name prefix. e.g. 'DC' or 'AC'.\n        range_peak: float which is the largest value you expect in the input signal. We will throw an exception if no\n                    range on the device is large enough for that value.\n        analog_offset: the meaning of 0 for this channel.\n        return value: Max voltage of new range. Raises an exception in error cases.\"\"\"\n\n        excluded = ()\n        reliably_resolved = False\n\n        max_voltage = None\n\n        while not reliably_resolved:\n            if enabled:\n                range_id, max_voltage = self._resolve_range(range_peak, excluded)\n            else:\n                range_id = 0\n                max_voltage = None\n\n            try:\n                self._python_set_channel(device.handle,\n                                         self.PICO_CHANNEL[channel_name],\n                                         1 if enabled else 0,\n                                         self.PICO_COUPLING[coupling],\n                                         range_id,\n                                         analog_offset)\n\n                reliably_resolved = True\n            except ValidRangeEnumValueNotValidForThisDevice:\n                excluded += (range_id,)\n\n        return max_voltage\n\n    def _resolve_range(self, signal_peak, exclude=()):\n        # we use >= so that someone can specify the range they want precisely.\n        # we allow exclude so that if the smallest range in the header file isn't available on this device (or in this\n        # configuration) we can exclude it from the collection. It should be the numerical enum constant (the key in\n        # PICO_VOLTAGE_RANGE).\n        possibilities = list(filter(lambda tup: tup[1] >= signal_peak and tup[0] not in exclude,\n                                    self.PICO_VOLTAGE_RANGE.items()))\n\n        if not possibilities:\n            raise ArgumentOutOfRangeError(\"%s device doesn't support a range as wide as %sV\" % (self.name, signal_peak))\n\n        return min(possibilities, key=lambda i: i[1])\n\n    def _python_set_channel(self, handle, channel_id, enabled, coupling_id, range_id, analog_offset):\n        if len(self._set_channel.argtypes) == 5 and self._set_channel.argtypes[1] == c_int16:\n            if analog_offset is not None:\n                raise ArgumentOutOfRangeError(\"This device doesn't support analog offset\")\n            return_code = self._set_channel(c_int16(handle),\n                                            c_int16(channel_id),\n                                            c_int16(enabled),\n                                            c_int16(coupling_id),\n                                            c_int16(range_id))\n            if return_code == 0:\n                raise ValidRangeEnumValueNotValidForThisDevice(\"%sV is out of range for this device.\" % (\n                    self.PICO_VOLTAGE_RANGE[range_id]))\n        elif len(self._set_channel.argtypes) == 5 and self._set_channel.argtypes[1] == c_int32 or (\n             len(self._set_channel.argtypes) == 6):\n            status = self.PICO_STATUS['PICO_OK']\n            if len(self._set_channel.argtypes) == 6:\n                if analog_offset is None:\n                    analog_offset = 0.0\n                status = self._set_channel(c_int16(handle),\n                                           c_int32(channel_id),\n                                           c_int16(enabled),\n                                           c_int32(coupling_id),\n                                           c_int32(range_id),\n                                           c_float(analog_offset))\n            elif len(self._set_channel.argtypes) == 5 and self._set_channel.argtypes[1] == c_int32:\n                if analog_offset is not None:\n                    raise ArgumentOutOfRangeError(\"This device doesn't support analog offset\")\n                status = self._set_channel(c_int16(handle),\n                                           c_int32(channel_id),\n                                           c_int16(enabled),\n                                           c_int16(coupling_id),\n                                           c_int32(range_id))\n            if status != self.PICO_STATUS['PICO_OK']:\n                if status == self.PICO_STATUS['PICO_INVALID_VOLTAGE_RANGE']:\n                    raise ValidRangeEnumValueNotValidForThisDevice(\"%sV is out of range for this device.\" % (\n                        self.PICO_VOLTAGE_RANGE[range_id]))\n                if status == self.PICO_STATUS['PICO_INVALID_CHANNEL'] and not enabled:\n                    # don't throw errors if the user tried to disable a missing channel.\n                    return\n                raise ArgumentOutOfRangeError(\"problem configuring channel (%s)\" % constants.pico_tag(status))\n\n        else:\n            raise NotImplementedError(\"not done other driver types yet\")\n\n    @requires_device(\"memory_segments requires a picosdk.device.Device instance, passed to the correct owning driver.\")\n    def memory_segments(self, device, number_segments):\n        if not hasattr(self, '_memory_segments'):\n            raise DeviceCannotSegmentMemoryError()\n        max_samples = c_int32(0)\n        status = self._memory_segments(c_int16(device.handle), c_uint32(number_segments), byref(max_samples))\n        if status != self.PICO_STATUS['PICO_OK']:\n            raise InvalidMemorySegmentsError(\"could not segment the device memory into (%s) segments (%s)\" % (\n                                              number_segments, constants.pico_tag(status)))\n        return max_samples\n\n    @requires_device(\"get_timebase requires a picosdk.device.Device instance, passed to the correct owning driver.\")\n    def get_timebase(self, device, timebase_id, no_of_samples, oversample=1, segment_index=0):\n        \"\"\"query the device about what time precision modes it can handle.\n        note: the driver returns the timebase in nanoseconds, this function converts that into SI units (seconds)\"\"\"\n        nanoseconds_result = self._python_get_timebase(device.handle,\n                                                       timebase_id,\n                                                       no_of_samples,\n                                                       oversample,\n                                                       segment_index)\n\n        return TimebaseInfo(nanoseconds_result.timebase_id,\n                            nanoseconds_result.time_interval * 1.e-9,\n                            nanoseconds_result.time_units,\n                            nanoseconds_result.max_samples,\n                            nanoseconds_result.segment_id)\n\n    def _python_get_timebase(self, handle, timebase_id, no_of_samples, oversample, segment_index):\n        # We use get_timebase on ps2000 and ps3000 and parse the nanoseconds-int into a float.\n        # on other drivers, we use get_timebase2, which gives us a float in the first place.\n        if len(self._get_timebase.argtypes) == 7 and self._get_timebase.argtypes[1] == c_int16:\n            time_interval = c_int32(0)\n            time_units = c_int16(0)\n            max_samples = c_int32(0)\n            return_code = self._get_timebase(c_int16(handle),\n                                             c_int16(timebase_id),\n                                             c_int32(no_of_samples),\n                                             byref(time_interval),\n                                             byref(time_units),\n                                             c_int16(oversample),\n                                             byref(max_samples))\n            if return_code == 0:\n                raise InvalidTimebaseError()\n\n            return TimebaseInfo(timebase_id, float(time_interval.value), time_units.value, max_samples.value, None)\n        elif hasattr(self, '_get_timebase2') and (\n                     len(self._get_timebase2.argtypes) == 7 and self._get_timebase2.argtypes[1] == c_uint32):\n            time_interval = c_float(0.0)\n            max_samples = c_int32(0)\n            status = self._get_timebase2(c_int16(handle),\n                                         c_uint32(timebase_id),\n                                         c_int32(no_of_samples),\n                                         byref(time_interval),\n                                         c_int16(oversample),\n                                         byref(max_samples),\n                                         c_uint32(segment_index))\n            if status != self.PICO_STATUS['PICO_OK']:\n                raise InvalidTimebaseError(\"get_timebase2 failed (%s)\" % constants.pico_tag(status))\n\n            return TimebaseInfo(timebase_id, time_interval.value, None, max_samples.value, segment_index)\n        else:\n            raise NotImplementedError(\"not done other driver types yet\")\n\n    @requires_device()\n    def set_null_trigger(self, device):\n        auto_trigger_after_millis = 1\n        if hasattr(self, '_set_trigger') and len(self._set_trigger.argtypes) == 6:\n            PS2000_NONE = 5\n            return_code = self._set_trigger(c_int16(device.handle),\n                                            c_int16(PS2000_NONE),\n                                            c_int16(0),\n                                            c_int16(0),\n                                            c_int16(0),\n                                            c_int16(auto_trigger_after_millis))\n            if return_code == 0:\n                raise InvalidTriggerParameters()\n        elif hasattr(self, '_set_simple_trigger') and len(self._set_simple_trigger.argtypes) == 7:\n            enabled = False\n            status = self._set_simple_trigger(c_int16(device.handle),\n                                              c_int16(int(enabled)),\n                                              c_int32(self.PICO_CHANNEL['A']),\n                                              c_int16(0),\n                                              c_int32(self.PICO_THRESHOLD_DIRECTION['NONE']),\n                                              c_uint32(0),\n                                              c_int16(auto_trigger_after_millis))\n            if status != self.PICO_STATUS['PICO_OK']:\n                raise InvalidTriggerParameters(\"set_simple_trigger failed (%s)\" % constants.pico_tag(status))\n        else:\n            raise NotImplementedError(\"not done other driver types yet\")\n\n    @requires_device()\n    def run_block(self, device, pre_trigger_samples, post_trigger_samples, timebase_id, oversample=1, segment_index=0):\n        \"\"\"tell the device to arm any triggers and start capturing in block mode now.\n        returns: the approximate time (in seconds) which the device will take to capture with these settings.\"\"\"\n        return self._python_run_block(device.handle,\n                                      pre_trigger_samples,\n                                      post_trigger_samples,\n                                      timebase_id,\n                                      oversample,\n                                      segment_index)\n\n    def _python_run_block(self, handle, pre_samples, post_samples, timebase_id, oversample, segment_index):\n        time_indisposed = c_int32(0)\n        if len(self._run_block.argtypes) == 5:\n            return_code = self._run_block(c_int16(handle),\n                                          c_int32(pre_samples + post_samples),\n                                          c_int16(timebase_id),\n                                          c_int16(oversample),\n                                          byref(time_indisposed))\n            if return_code == 0:\n                raise InvalidCaptureParameters()\n        elif len(self._run_block.argtypes) == 9:\n            status = self._run_block(c_int16(handle),\n                                     c_int32(pre_samples),\n                                     c_int32(post_samples),\n                                     c_uint32(timebase_id),\n                                     c_int16(oversample),\n                                     byref(time_indisposed),\n                                     c_uint32(segment_index),\n                                     None,\n                                     None)\n            if status != self.PICO_STATUS['PICO_OK']:\n                raise InvalidCaptureParameters(\"run_block failed (%s)\" % constants.pico_tag(status))\n        else:\n            raise NotImplementedError(\"not done other driver types yet\")\n\n        return float(time_indisposed.value) * 0.001\n\n    @requires_device()\n    def is_ready(self, device):\n        \"\"\"poll this function to find out when block mode is ready or has triggered.\n        returns: True if data is ready, False otherwise.\"\"\"\n        if hasattr(self, '_ready') and len(self._ready.argtypes) == 1:\n            return_code = self._ready(c_int16(device.handle))\n            return bool(return_code)\n        elif hasattr(self, '_is_ready') and len(self._is_ready.argtypes) == 2:\n            is_ready = c_int16(0)\n            status = self._is_ready(c_int16(device.handle), byref(is_ready))\n            if status != self.PICO_STATUS['PICO_OK']:\n                raise InvalidCaptureParameters(\"is_ready failed (%s)\" % constants.pico_tag(status))\n            return bool(is_ready.value)\n        else:\n            raise NotImplementedError(\"not done other driver types yet\")\n\n    @requires_device()\n    def maximum_value(self, device):\n        if not hasattr(self, '_maximum_value'):\n            return (2**15)-1\n        max_adc = c_int16(0)\n        self._maximum_value(c_int16(device.handle), byref(max_adc))\n        return max_adc.value\n\n    @requires_device()\n    def get_values(self, device, active_channels, num_samples, segment_index=0):\n        # Initialise buffers to hold the data:\n        results = {channel: numpy.empty(num_samples, numpy.dtype('int16')) for channel in active_channels}\n\n        overflow = c_int16(0)\n\n        if len(self._get_values.argtypes) == 7 and self._get_timebase.argtypes[1] == c_int16:\n            inputs = {k: None for k in 'ABCD'}\n            for k, arr in results.items():\n                inputs[k] = arr.ctypes.data\n            return_code = self._get_values(c_int16(device.handle),\n                                           inputs['A'],\n                                           inputs['B'],\n                                           inputs['C'],\n                                           inputs['D'],\n                                           byref(overflow),\n                                           c_int32(num_samples))\n            if return_code == 0:\n                raise InvalidCaptureParameters()\n        elif len(self._get_values.argtypes) == 7 and self._get_timebase.argtypes[1] == c_uint32:\n            # For this function pattern, we first call a function (self._set_data_buffer) to register each buffer. Then,\n            # we can call self._get_values to actually populate them.\n            for channel, array in results.items():\n                status = self._set_data_buffer(c_int16(device.handle),\n                                               c_int32(self.PICO_CHANNEL[channel]),\n                                               array.ctypes.data,\n                                               c_int32(num_samples),\n                                               c_uint32(segment_index),\n                                               c_int32(self.PICO_RATIO_MODE['NONE']))\n                if status != self.PICO_STATUS['PICO_OK']:\n                    raise InvalidCaptureParameters(\"set_data_buffer failed (%s)\" % constants.pico_tag(status))\n\n            samples_collected = c_uint32(num_samples)\n            status = self._get_values(c_int16(device.handle),\n                                      c_uint32(0),\n                                      byref(samples_collected),\n                                      c_uint32(1),\n                                      c_int32(self.PICO_RATIO_MODE['NONE']),\n                                      c_uint32(segment_index),\n                                      byref(overflow))\n            if status != self.PICO_STATUS['PICO_OK']:\n                raise InvalidCaptureParameters(\"get_values failed (%s)\" % constants.pico_tag(status))\n\n        overflow_warning = {}\n        if overflow.value:\n            for channel in results.keys():\n                if overflow.value & (1 >> self.PICO_CHANNEL[channel]):\n                    overflow_warning[channel] = True\n\n        return results, overflow_warning\n\n    @requires_device()\n    def stop(self, device):\n        if self._stop.restype == c_int16:\n            return_code = self._stop(c_int16(device.handle))\n            if isinstance(return_code, c_int16):\n                if return_code == 0:\n                    raise InvalidCaptureParameters()\n        else:\n            status = self._stop(c_int16(device.handle))\n            if status != self.PICO_STATUS['PICO_OK']:\n                raise InvalidCaptureParameters(\"stop failed (%s)\" % constants.pico_tag(status))\n"
  },
  {
    "path": "picosdk/picoMeasurements.py",
    "content": "#\r\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\r\nimport numpy as np\r\n"
  },
  {
    "path": "picosdk/picohrdl.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the picohrdl.h C header file\r\nfor ADC-20/24 Data Loggers using the picohrdl driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.errors import ArgumentOutOfRangeError\r\nfrom picosdk.constants import make_enum\r\n\r\nclass picohrdllib(Library):\r\n    def __init__(self):\r\n        super(picohrdllib, self).__init__(\"picohrdl\")\r\n\t\t\r\npicohrdl = picohrdllib()\r\n\r\npicohrdl.HRDL_VOLTAGERANGE = make_enum([\r\n    \"HRDL_2500_MV\",\r\n\t\"HRDL_1250_MV\",\r\n\t\"HRDL_625_MV\",\r\n\t\"HRDL_313_MV\",\r\n\t\"HRDL_156_MV\",\r\n\t\"HRDL_78_MV\",\r\n\t\"HRDL_39_MV\",\r\n])\r\n\r\npicohrdl.HRDL_CONVERSIONTIME = make_enum([\r\n    \"HRDL_60MS\",\r\n\t\"HRDL_100MS\",\r\n\t\"HRDL_180MS\",\r\n\t\"HRDL_340MS\",\r\n\t\"HRDL_660MS\",\r\n])\r\n\r\ndoc = \"\"\" int16_t HRDLCloseUnit\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_closeUnit_\", \"HRDLCloseUnit\", c_int16, [c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLCollectSingleValueAsync\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    channel,\r\n\t\tint16_t    range,\r\n\t\tint16_t    conversionTime,\r\n\t\tint16_t    singleEnded\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_collectSingleValue_Async_\", \"HRDLCollectSingleValueAsync\", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLGetMinMaxAdcCounts\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    *minAdc,\r\n\t\tint32_t    *maxAdc,\r\n\t\tint16_t    channel\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getMinMaxAdcCounts_\", \"HRDLGetMinMaxAdcCounts\", c_int16, [c_int16, c_void_p, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLGetNumberOfEnabledChannels\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    *nEnabledChannels\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getNumberOfEnabledChannels_\", \"HRDLGetNumberOfEnabledChannels\", c_int16, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLGetSingleValue\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    channel,\r\n\t\tint16_t    range,\r\n\t\tint16_t    conversionTime,\r\n\t\tint16_t    singleEnded,\r\n\t\tint16_t    *overflow,\r\n\t\tint32_t    *value\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getSingleValue_\", \"HRDLGetSingleValue\", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLGetSingleValueAsync\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    *value,\r\n\t\tint16_t    *overflow\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getSingleValueAsync_\", \"HRDLGetSingleValueAsync\", c_int16, [c_int16, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" int32_t HRDLGetTimesAndVAlues\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    *times,\r\n\t\tint32_t    *values,\r\n\t\tint16_t    *overflow,\r\n\t\tint32_t    noOfValues\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getTimesAndValues_\", \"HRDLGetTimesAndValues\", c_int16, [c_int16, c_void_p, c_void_p, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLGetUnitInfo\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint8_t     *string,\r\n\t\tint16_t    stringLength,\r\n\t\tint16_t    info\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getUnitInfo_\", \"HRDLGetUnitInfo\", c_int16, [c_int16, c_void_p, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int32_t HRDLGetValues\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    *values,\r\n\t\tint16_t    *overflow,\r\n\t\tint32_t    noOfValues\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_getValues_\", \"HRDLGetValues\", c_int16, [c_int16, c_void_p, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLOpenUnit\r\n    (\r\n\t    void\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_openUnit_\", \"HRDLOpenUnit\", c_int16, [], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLOpenUnitAsync\r\n    (\r\n\t    void\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_openUnitAsync_\", \"HRDLOpenUnitAsync\", c_int16, [], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLOpenUnitProgress\r\n    (\r\n\t    int16_t    *handle,\r\n\t\tint16_t    *progress\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_openUnitProgress_\", \"HRDLOpenUnitProgress\", c_int16, [c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLReady\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_ready_\", \"HRDLReady\", c_int16, [c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLRun\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    nValues,\r\n\t\tint16_t    method\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_run_\", \"HRDLRun\", c_int16, [c_int16, c_int32, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLSetAnalogInChannel\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    channel,\r\n\t\tint16_t    enabled,\r\n\t\tint16_t    range,\r\n\t\tint16_t    singleEnded\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_setAnalogInChannel_\", \"HRDLSetAnalogInChannel\", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLSetDigitalIOChannel\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    directionOut,\r\n\t\tint16_t    digitalOutPinState,\r\n\t\tint16_t    enabledDigitalIn\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_setDigitalIOChannel_\", \"HRDLSetDigitalIOChannel\", c_int16, [c_int16, c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLSetInterval\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    samplesInterval_ms,\r\n\t\tint16_t    conversionTime\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_setInterval_\", \"HRDLSetInterval\", c_int16, [c_int16, c_int32, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t HRDLSetMains\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    sixtyHertz\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_setMains_\", \"HRDLSetMains\", c_int16, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" void HRDLStop\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\npicohrdl.make_symbol(\"_stop_\", \"HRDLStop\", c_int16, [c_int16], doc)"
  },
  {
    "path": "picosdk/picosynth.py",
    "content": "#\r\n# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the picosynth.h C header file\r\nfor the PicoSource AS108 Agile Synthesizer using the picosynth driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.errors import ArgumentOutOfRangeError\r\nfrom picosdk.constants import make_enum\r\n\r\nclass Picosynthlib(Library):\r\n    def __init__(self):\r\n        super(Picosynthlib, self).__init__(\"picosynth\")\r\n        \r\npicosynth = Picosynthlib()\r\n\r\npicosynth.PICO_SOURCE_MODEL = make_enum([\r\n    \"PICO_NONE_SPECIFIED\",\r\n    \"PICO_SYNTH\",\r\n])\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthOpenUnit\r\n    (\r\n        PICO_SOURCE_MODEL  model,\r\n        uint32_t  *handle,\r\n        unit8_t  *serialNumber\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_OpenUnit\",\"picosynthOpenUnit\",c_uint32,[c_uint32, c_void_p, c_void_p],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthEnumerateUnits\r\n    (\r\n        PICO_SOURCE_MODEL  model,\r\n        uint8_t  *serials,\r\n        unit16_t  *serialLth\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_EnumerateUnits\",\"picosynthEnumerateUnits\",c_uint32,[c_uint32, c_void_p, c_void_p],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthGetUnitInfo\r\n    (\r\n        int8_t  *string,\r\n        unit16_t  stringLength,\r\n        uint16_t  *requiredSize,\r\n        PICO_INFO  deviceInfo\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_GetUnitInfo\",\"picosynthGetUnitInfo\",c_uint32,[c_uint32, c_void_p, c_uint16, c_void_p, c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthPingUnit\r\n    (\r\n        uint32_t  *handle,\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_PingUnit\",\"picosynthPingUnit\",c_uint32,[c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthCloseUnit\r\n    (\r\n        uint32_t  *handle,\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_CloseUnit\",\"picosynthCloseUnit\",c_uint32,[c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetOutputOff\r\n    (\r\n        uint32_t  *handle,\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetOutputOff\",\"picosynthSetOutputOff\",c_uint32,[c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetFrequency\r\n    (\r\n        uint32_t  *handle,\r\n        double  frequencyHz,\r\n        double  powerLeveldBm\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetFrequency\",\"picosynthSetFrequency\",c_uint32,[c_uint32, c_double, c_double],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetPhase\r\n    (\r\n        uint32_t  handle,\r\n        double  phaseDeg\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetPhase\", \"picosynthSetPhase\", c_uint32,[c_uint32, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetAmplitudeModulation\r\n    (\r\n        uint32_t  handle,\r\n        double  frequencyHz,\r\n        double  powerLeveldBm,\r\n        double  modulationDepthPercent,\r\n        double  modulationRateHz,\r\n        MODULATION_SOURCE  modulationSource,\r\n        int16_t  enabled\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetAmplitudeModulation\",\"picosynthSetAmplitudeModulation\", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetFrequencyModulation\r\n    (\r\n        uint32_t  handle,\r\n        double  frequencyHz,\r\n        double  powerLeveldBm,\r\n        double  modulationDeviationHz,\r\n        double  modulationRateHz,\r\n        MODULATION_SOURCE  modulationSource,\r\n        int16_t  enabled\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetFrequencyModulation\",\"picosynthSetFrequencyModulation\",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetPhaseModulation\r\n    (\r\n        uint32_t  handle,\r\n        double  frequencyHz,\r\n        double  powerLeveldBm,\r\n        double  modulationDeviationHz,\r\n        double  modulationRateHz,\r\n        MODULATION_SOURCE  modulationSource,\r\n        int16_t  enabled\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetPhaseModulation\",\"picosynthSetPhaseModulation\",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetFrequencyAndLevelSweep\r\n    (\r\n        uint32_t  handle,\r\n        double  startFrequencyHz,\r\n        double  stopFrequencyHz,\r\n        double  startLevel,\r\n        double  stopLevel,\r\n        LEVEL_UNIT  levelUnit,\r\n        double  dwellTimeUs,\r\n        int32_t  pointsInSweep,\r\n        SWEEP_HOP_MODE  mode,\r\n        TRIGGER_MODE  triggerMode\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetFrequencyAndLevelSweep\",\"picosynthSetFrequencyAndLevelSweep\", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetPhaseAndLevelSweep\r\n    (\r\n        uint32_t  handle,\r\n        double  frequencyHz,\r\n        double  startPhaseDeg,\r\n        double  stopPhaseDeg,\r\n        double  startLevel,\r\n        double  stopLevel,\r\n        LEVEL_UNIT levelUnit,\r\n        double  dwellTimeUs,\r\n        int32_t  pointsInSweep,\r\n        SWEEP_HOP_MODE  mode,\r\n        TRIGGER_MODE  triggerMode\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetPhaseAndLevelSweep\",\"picosynthSetPhaseAndLevelSweep\", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetArbitraryPhaseAndLevel\r\n    (\r\n        uint32_t  handle,\r\n        double  frequencyHz,\r\n        double  *arbitraryPhaseDeg,\r\n        double  *arbitraryPowerLeveldBm,\r\n        int32_t  numberOfPoints,\r\n        double  dwellTimeUs,\r\n        TRIGGER_MODE  triggerMode\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetArbitraryPhaseAndLevel\",\"picosynthSetArbitraryPhaseAndLevel\",c_uint32,[c_uint32,c_double,c_double,c_double,c_int32,c_double,c_uint32],doc)\r\n\r\ndoc = \"\"\" PICO_STATUS picosynthSetArbitraryFrequencyAndLevel\r\n    (\r\n        uint32_t  handle,\r\n        double  *arbitraryFrequencyHz,\r\n        double  *arbitraryPowerLeveldBm,\r\n        int32_t  numberOfPoints,\r\n        double  dwellTimeUs,\r\n        TRIGGER_MODE  triggerMode\r\n    );\"\"\"\r\npicosynth.make_symbol(\"_SetArbitraryFrequencyAndLevel\",\"picosynthSetArbitraryFrequencyAndLevel\",c_uint32,[c_uint32,c_double,c_double,c_int32,c_double,c_uint32],doc)\r\n"
  },
  {
    "path": "picosdk/pl1000.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the pl1000.h C header\r\nfile for PicoLog 1000 Series datalogger using the pl1000 driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\nfrom picosdk.library import Library\r\nfrom picosdk.constants import make_enum\r\n\r\nclass Pl1000lib(Library):\r\n    def __init__(self):\r\n        super(Pl1000lib, self).__init__(\"pl1000\")\r\n\t\t\r\npl1000 = Pl1000lib()\r\n\r\ndef _pl1000Inputs():\r\n    PL1000_CHANNEL_1 = 1\r\n    PL1000_CHANNEL_2 = 2\r\n    PL1000_CHANNEL_3 = 3\r\n    PL1000_CHANNEL_4 = 4\r\n    PL1000_CHANNEL_5 = 5\r\n    PL1000_CHANNEL_6 = 6\r\n    PL1000_CHANNEL_7 = 7\r\n    PL1000_CHANNEL_8 = 8\r\n    PL1000_CHANNEL_9 = 9\r\n    PL1000_CHANNEL_10 = 10\r\n    PL1000_CHANNEL_11 = 11\r\n    PL1000_CHANNEL_12 = 12\r\n    PL1000_CHANNEL_13 = 13\r\n    PL1000_CHANNEL_14 = 14\r\n    PL1000_CHANNEL_15 = 15\r\n    PL1000_CHANNEL_16 = 16\r\n    PL1000_MAX_CHANNEL = PL1000_CHANNEL_16\r\n\t\r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PL1000\")}\r\n\t\r\npl1000.PL1000Inputs = _pl1000Inputs()\r\n\r\npl1000.PL1000DO_Channel = make_enum([\r\n    'PL1000_DO_CHANNEL_0',\r\n\t'PL1000_DO_CHANNEL_1',\r\n\t'PL1000_DO_CHANNEL_2',\r\n\t'PL1000_DO_CHANNEL_3',\r\n\t'PL1000_DO_CHANNEL_MAX',\r\n])\r\n\r\npl1000.PL1000OpenProgress = {\r\n    'PL1000_OPEN_PROGRESS_FAIL' : -1,\r\n\t'PL1000_OPEN_PROGRESS_PENDING': 0,\r\n\t'PL1000_OPEN_PROGRESS_COMPLETE' : 1,\r\n}\r\n\r\npl1000.PL1000_BLOCK_METHOD = make_enum([\r\n\t\"BM_SINGLE\",\r\n\t\"BM_WINDOW\",\r\n\t\"BM_STREAM\",\r\n])\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000CloseUnit\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_CloseUnit_\", \"pl1000CloseUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000GetSingle\r\n    (\r\n\t    int16_t  handle,\r\n\t\tPL1000_INPUTS  channel,\r\n\t\tunit16_t  *value\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_GetSingle_\", \"pl1000GetSingle\", c_uint32, [c_int16, c_int32, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000GetUnitInfo\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint8_t  *string,\r\n\t\tint16_t  stringLength,\r\n\t\tint16_t  *requiredSize,\r\n\t\tPICO_INFO  info\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_GetUnitInfo_\", \"pl1000GetUnitInfo\", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000GetValues\r\n    (\r\n\t    int16_t  handle,\r\n\t\tuint16_t  *values,\r\n\t\tuint32_t  *noOfValues,\r\n\t\tunit16_t  *overflow,\r\n\t\tuint32_t  *triggerIndex\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_GetValues_\", \"pl1000GetValues\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000MaxValue\r\n    (\r\n\t    int16_t  handle,\r\n\t\tuint16_t  *maxValue\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_MaxValue_\", \"pl1000MaxValue\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000OpenUnit\r\n    (\r\n\t    int16_t  *handle\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_OpenUnit_\", \"pl1000OpenUnit\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000OpenUnitAsync\r\n    (\r\n\t    int16_t  *status\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_OpenUnitAsync_\", \"pl1000OpenUnitAsync\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000OpenUnitProgress\r\n    (\r\n\t    int16_t  *handle,\r\n\t\tint16_t  *progress,\r\n\t\tint16_t  *complete\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_OpenUnitProgress_\", \"pl1000OpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000PingUnit\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_PingUnit_\", \"pl1000PingUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000Ready\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint16_t  *ready\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_Ready_\", \"pl1000Ready\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000Run\r\n    (\r\n\t    int16_t  handle,\r\n\t\tuint32_t  no_of_values,\r\n\t\tBLOCK_METHOD  method\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_Run_\", \"pl1000Run\", c_uint32, [c_int16, c_uint32, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000SetDo\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint16_t  do_value,\r\n\t\tint16_t  doNo\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_SetDo_\", \"pl1000SetDo\", c_uint32, [c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000SetInterval\r\n    (\r\n\t    int16_t  handle,\r\n\t\tuint32_t  *us_for_block,\r\n\t\tuint32_t  ideal_no_of_samples,\r\n\t\tint16_t  *channels,\r\n\t\tint16_t  no_of_channels\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_SetInterval_\", \"pl1000SetInterval\", c_uint32, [c_int16, c_void_p, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000SetPulseWidth\r\n    (\r\n\t    int16_t  handle,\r\n\t\tuint16_t  period,\r\n\t\tuint8_t  cycle\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_SetPulseWidth_\", \"pl1000SetPulseWidth\", c_uint32, [c_int16, c_int16, c_int8], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000SetTrigger\r\n    (\r\n\t    int16_t  handle,\r\n\t\tuint16_t  enabled,\r\n\t\tuint16_t  auto_trigger,\r\n\t\tuint16_t  auto_ms,\r\n\t\tuint16_t  channel,\r\n\t\tuint16_t  dir,\r\n\t\tuint16_t  threshold,\r\n\t\tuint16_t  hysteresis,\r\n\t\tfloat  delay\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_SetTrigger_\", \"pl1000SetTrigger\", c_uint32, [c_int16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16, c_float], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS pl1000Stop\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\npl1000.make_symbol(\"_Stop_\", \"pl1000Stop\", c_uint32, [c_int16], doc)\r\n\r\n"
  },
  {
    "path": "picosdk/ps2000.py",
    "content": "#\r\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the ps2000.h C header file\r\nfor PicoScope 2000 Series oscilloscopes using the ps2000 driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.errors import ArgumentOutOfRangeError\r\nfrom picosdk.constants import make_enum\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\n\r\n\r\nclass Ps2000lib(Library):\r\n    def __init__(self):\r\n        super(Ps2000lib, self).__init__(\"ps2000\")\r\n\r\n\r\nps2000 = Ps2000lib()\r\n\r\nps2000.PS2000_CHANNEL = make_enum([\r\n    \"PS2000_CHANNEL_A\",\r\n    \"PS2000_CHANNEL_B\",\r\n])\r\n\r\n# use the last character, i.e. the channel name:\r\nps2000.PICO_CHANNEL = {k[-1]: v for k, v in ps2000.PS2000_CHANNEL.items()}\r\n\r\n# This field is passed to the driver as a boolean, not an enum.\r\nps2000.PICO_COUPLING = {\r\n    'AC': 0,\r\n    'DC': 1\r\n}\r\n\r\nps2000.PS2000_WAVE_TYPE = make_enum([\r\n    \"PS2000_SINE\",\r\n    \"PS2000_SQUARE\",\r\n    \"PS2000_TRIANGLE\",\r\n    \"PS2000_RAMPUP\",\r\n    \"PS2000_RAMPDOWN\",\r\n    \"PS2000_DC_VOLTAGE\",\r\n    \"PS2000_GAUSSIAN\",\r\n    \"PS2000_SINC\",\r\n    \"PS2000_HALF_SINE\",\r\n])\r\n\r\nps2000.PS2000_SWEEP_TYPE = make_enum([\r\n    \"PS2000_UP\",\r\n    \"PS2000_DOWN\",\r\n    \"PS2000_UPDOWN\",\r\n    \"PS2000_DOWNUP\",\r\n])\r\n\r\n\r\nps2000.PS2000_VOLTAGE_RANGE = {\r\n    'PS2000_20MV':  1,\r\n    'PS2000_50MV':  2,\r\n    'PS2000_100MV': 3,\r\n    'PS2000_200MV': 4,\r\n    'PS2000_500MV': 5,\r\n    'PS2000_1V':    6,\r\n    'PS2000_2V':    7,\r\n    'PS2000_5V':    8,\r\n    'PS2000_10V':   9,\r\n    'PS2000_20V':   10,\r\n}\r\n\r\n# float voltage value max (multiplier for output voltages). Parse the value in the constant name.\r\nps2000.PICO_VOLTAGE_RANGE = {\r\n    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))\r\n    for k, v in ps2000.PS2000_VOLTAGE_RANGE.items()\r\n}\r\n\r\nps2000.MAX_MEMORY = 32e3\r\n\r\nps2000.PS2000_TIME_UNITS = make_enum([\r\n    'PS2000_FS',\r\n    'PS2000_PS',\r\n    'PS2000_NS',\r\n    'PS2000_US',\r\n    'PS2000_MS',\r\n    'PS2000_S',\r\n    'PS2000_MAX_TIME_UNITS',\r\n])\r\n\r\ndoc = \"\"\" int16_t ps2000_open_unit\r\n    (\r\n        void\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_open_unit\", \"ps2000_open_unit\", c_int16, [], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_get_unit_info\r\n    (\r\n        int16_t  handle,\r\n        int8_t  *string,\r\n        int16_t  string_length,\r\n        int16_t  line\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_unit_info\", \"ps2000_get_unit_info\", c_int16, [c_int16, c_char_p, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_flash_led\r\n    (\r\n        int16_t handle\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_flash_led\", \"ps2000_flash_led\", c_int16, [c_int16, ], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_close_unit\r\n    (\r\n        int16_t handle\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_close_unit\", \"ps2000_close_unit\", c_int16, [c_int16, ], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_channel\r\n    (\r\n        int16_t  handle,\r\n        int16_t  channel,\r\n        int16_t  enabled,\r\n        int16_t  dc,\r\n        int16_t  range\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_channel\", \"ps2000_set_channel\", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_get_timebase\r\n    (\r\n        int16_t  handle,\r\n        int16_t  timebase,\r\n        int32_t  no_of_samples,\r\n        int32_t *time_interval,\r\n        int16_t *time_units,\r\n        int16_t  oversample,\r\n        int32_t *max_samples\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_timebase\", \"ps2000_get_timebase\", c_int16,\r\n                   [c_int16, c_int16, c_int32, c_void_p, c_void_p, c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_trigger\r\n    (\r\n        int16_t  handle,\r\n        int16_t  source,\r\n        int16_t  threshold,\r\n        int16_t  direction,\r\n        int16_t  delay,\r\n        int16_t  auto_trigger_ms\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_trigger\", \"ps2000_set_trigger\", c_int16,\r\n                   [c_int16, c_int16, c_int16, c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_trigger2\r\n    (\r\n        int16_t  handle,\r\n        int16_t  source,\r\n        int16_t  threshold,\r\n        int16_t  direction,\r\n        float    delay,\r\n        int16_t  auto_trigger_ms\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_trigger2\", \"ps2000_set_trigger2\", c_int16,\r\n                   [c_int16, c_int16, c_int16, c_int16, c_float, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_run_block\r\n    (\r\n        int16_t handle,\r\n        int32_t  no_of_values,\r\n        int16_t  timebase,\r\n        int16_t  oversample,\r\n        int32_t * time_indisposed_ms\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_run_block\", \"ps2000_run_block\", c_int16, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_run_streaming\r\n    (\r\n        int16_t  handle,\r\n        int16_t  sample_interval_ms,\r\n        int32_t  max_samples,\r\n        int16_t  windowed\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_run_streaming\", \"ps2000_run_streaming\", c_int16, [c_int16, c_int16, c_int32, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_run_streaming_ns\r\n    (\r\n        int16_t            handle,\r\n        uint32_t           sample_interval,\r\n        PS2000_TIME_UNITS  time_units,\r\n        uint32_t           max_samples,\r\n        int16_t            auto_stop,\r\n        uint32_t           noOfSamplesPerAggregate,\r\n        uint32_t           overview_buffer_size\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_run_streaming_ns\", \"ps2000_run_streaming_ns\", c_int16,\r\n                   [c_int16, c_uint32, c_int32, c_uint32, c_int16, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_ready\r\n    (\r\n        int16_t  handle\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_ready\", \"ps2000_ready\", c_int16, [c_int16, ], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_stop\r\n    (\r\n        int16_t  handle\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_stop\", \"ps2000_stop\", c_int16, [c_int16, ], doc)\r\n\r\ndoc = \"\"\" int32_t ps2000_get_values\r\n    (\r\n        int16_t  handle,\r\n        int16_t *buffer_a,\r\n        int16_t *buffer_b,\r\n        int16_t *buffer_c,\r\n        int16_t *buffer_d,\r\n        int16_t *overflow,\r\n        int32_t  no_of_values\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_values\", \"ps2000_get_values\", c_int32,\r\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" int32_t ps2000_get_times_and_values\r\n    (\r\n        int16_t  handle,\r\n        int32_t *times,\r\n        int16_t *buffer_a,\r\n        int16_t *buffer_b,\r\n        int16_t *buffer_c,\r\n        int16_t *buffer_d,\r\n        int16_t *overflow,\r\n        int16_t  time_units,\r\n        int32_t  no_of_values\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_times_and_values\", \"ps2000_get_times_and_values\", c_int32,\r\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int16, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_last_button_press\r\n    (\r\n        int16_t  handle\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_last_button_press\", \"ps2000_last_button_press\", c_int16, [c_int16, ], doc)\r\n\r\ndoc = \"\"\" int32_t ps2000_set_ets\r\n    (\r\n        int16_t  handle,\r\n        int16_t  mode,\r\n        int16_t  ets_cycles,\r\n        int16_t  ets_interleave\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_ets\", \"ps2000_set_ets\", c_int32, [c_int16, c_int16, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_led\r\n    (\r\n        int16_t  handle,\r\n        int16_t  state\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_led\", \"ps2000_set_led\", c_int16, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_open_unit_async\r\n    (\r\n        void\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_open_unit_async\", \"ps2000_open_unit_async\", c_int16, [], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_open_unit_progress\r\n    (\r\n        int16_t *handle,\r\n        int16_t *progress_percent\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_open_unit_progress\", \"ps2000_open_unit_progress\", c_int16, [c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_get_streaming_last_values\r\n    (\r\n        int16_t  handle,\r\n        GetOverviewBuffersMaxMin\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_streaming_last_values\", \"ps2000_get_streaming_last_values\", c_int16, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_overview_buffer_status\r\n    (\r\n        int16_t  handle,\r\n        int16_t *previous_buffer_overrun\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_overview_buffer_status\", \"ps2000_overview_buffer_status\", c_int16, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" uint32_t ps2000_get_streaming_values\r\n    (\r\n        int16_t  handle,\r\n        double   *start_time,\r\n        int16_t  *pbuffer_a_max,\r\n        int16_t  *pbuffer_a_min,\r\n        int16_t  *pbuffer_b_max,\r\n        int16_t  *pbuffer_b_min,\r\n        int16_t  *pbuffer_c_max,\r\n        int16_t  *pbuffer_c_min,\r\n        int16_t  *pbuffer_d_max,\r\n        int16_t  *pbuffer_d_min,\r\n        int16_t  *overflow,\r\n        uint32_t *triggerAt,\r\n        int16_t  *triggered,\r\n        uint32_t  no_of_values,\r\n        uint32_t  noOfSamplesPerAggregate\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_streaming_values\", \"ps2000_get_streaming_values\", c_uint32,\r\n                   [c_int16, c_void_p,\r\n                    c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p,\r\n                    c_void_p, c_void_p, c_void_p, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" uint32_t ps2000_get_streaming_values_no_aggregation\r\n    (\r\n        int16_t handle,\r\n        double *start_time,\r\n        int16_t * pbuffer_a,\r\n        int16_t * pbuffer_b,\r\n        int16_t * pbuffer_c,\r\n        int16_t * pbuffer_d,\r\n        int16_t * overflow,\r\n        uint32_t * triggerAt,\r\n        int16_t * trigger,\r\n        uint32_t no_of_values\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_get_streaming_values_no_aggregation\", \"ps2000_get_streaming_values_no_aggregation\", c_uint32,\r\n                   [c_int16, c_void_p,\r\n                    c_void_p, c_void_p, c_void_p, c_void_p,\r\n                    c_void_p, c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_light\r\n    (\r\n        int16_t  handle,\r\n        int16_t  state\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_light\", \"ps2000_set_light\", c_int16, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_sig_gen_arbitrary\r\n    (\r\n        int16_t            handle,\r\n        int32_t            offsetVoltage,\r\n        uint32_t           pkToPk,\r\n        uint32_t           startDeltaPhase,\r\n        uint32_t           stopDeltaPhase,\r\n        uint32_t           deltaPhaseIncrement,\r\n        uint32_t           dwellCount,\r\n        uint8_t           *arbitraryWaveform,\r\n        int32_t            arbitraryWaveformSize,\r\n        PS2000_SWEEP_TYPE  sweepType,\r\n        uint32_t           sweeps\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_sig_gen_arbitrary\", \"ps2000_set_sig_gen_arbitrary\", c_int16,\r\n                   [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,\r\n                    c_uint32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000_set_sig_gen_built_in\r\n    (\r\n        int16_t            handle,\r\n        int32_t            offsetVoltage,\r\n        uint32_t           pkToPk,\r\n        PS2000_WAVE_TYPE   waveType,\r\n        float              startFrequency,\r\n        float              stopFrequency,\r\n        float              increment,\r\n        float              dwellTime,\r\n        PS2000_SWEEP_TYPE  sweepType,\r\n        uint32_t           sweeps\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_set_sig_gen_built_in\", \"ps2000_set_sig_gen_built_in\", c_int16,\r\n                   [c_int16, c_int32, c_uint32, c_int32, c_float, c_float, c_float, c_float, c_int32, c_uint32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000SetAdvTriggerChannelProperties\r\n    (\r\n        int16_t                            handle,\r\n        PS2000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\r\n        int16_t                            nChannelProperties,\r\n        int32_t                            autoTriggerMilliseconds\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_SetAdvTriggerChannelProperties\", \"ps2000SetAdvTriggerChannelProperties\", c_int16,\r\n                   [c_int16, c_void_p, c_int16, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000SetAdvTriggerChannelConditions\r\n    (\r\n        int16_t                    handle,\r\n        PS2000_TRIGGER_CONDITIONS *conditions,\r\n        int16_t                    nConditions\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_SetAdvTriggerChannelConditions\", \"ps2000SetAdvTriggerChannelConditions\", c_int16,\r\n                   [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000SetAdvTriggerChannelDirections\r\n    (\r\n        int16_t                     handle,\r\n        PS2000_THRESHOLD_DIRECTION  channelA,\r\n        PS2000_THRESHOLD_DIRECTION  channelB,\r\n        PS2000_THRESHOLD_DIRECTION  channelC,\r\n        PS2000_THRESHOLD_DIRECTION  channelD,\r\n        PS2000_THRESHOLD_DIRECTION  ext\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_SetAdvTriggerChannelDirections\", \"ps2000SetAdvTriggerChannelDirections\", c_int16,\r\n                   [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000SetPulseWidthQualifier\r\n    (\r\n        int16_t                     handle,\r\n        PS2000_PWQ_CONDITIONS      *conditions,\r\n        int16_t                     nConditions,\r\n        PS2000_THRESHOLD_DIRECTION  direction,\r\n        uint32_t                    lower,\r\n        uint32_t                    upper,\r\n        PS2000_PULSE_WIDTH_TYPE     type\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_SetPulseWidthQualifier\", \"ps2000SetPulseWidthQualifier\", c_int16,\r\n                   [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000SetAdvTriggerDelay\r\n    (\r\n        int16_t   handle,\r\n        uint32_t  delay,\r\n        float     preTriggerDelay\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_SetAdvTriggerDelay\", \"ps2000SetAdvTriggerDelay\", c_int16, [c_int16, c_uint32, c_float], doc)\r\n\r\ndoc = \"\"\" int16_t ps2000PingUnit\r\n    (\r\n        int16_t  handle\r\n    ); \"\"\"\r\nps2000.make_symbol(\"_PingUnit\", \"ps2000PingUnit\", c_int16, [c_int16, ], doc)\r\n\r\nps2000.PICO_INFO = {k: v for k, v in ps2000.PICO_INFO.items() if v <= 0x00000005}\r\nps2000.PICO_INFO[\"PICO_ERROR_CODE\"] = 0x00000006\r\nps2000.PICO_INFO[\"PICO_KERNEL_DRIVER_VERSION\"] = 0x00000007\r\n\r\n\r\ndoc = \"\"\" void *my_get_overview_buffers\r\n    (\r\n        int16_t    **overviewBuffers\r\n        int16_t   overflow,\r\n        uint32_t  triggerAt,\r\n        int16_t   triggered,\r\n        int16_t   autoStop,\r\n        uint32_t    nValues\r\n    );\r\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\r\n    \"\"\"\r\n\r\nps2000.GetOverviewBuffersType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                         POINTER(POINTER(c_int16)),\r\n                                                         c_int16,\r\n                                                         c_uint32,\r\n                                                         c_int16,\r\n                                                         c_int16,\r\n                                                         c_uint32)\r\n\r\nps2000.GetOverviewBuffersType.__doc__ = doc"
  },
  {
    "path": "picosdk/ps2000a.py",
    "content": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps2000aApi.h C header\nfile for PicoScope 2000 Series oscilloscopes using the ps2000a driver API functions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\nfrom picosdk.library import Library\nfrom picosdk.constants import make_enum\n\n\nclass Ps2000alib(Library):\n    def __init__(self):\n        super(Ps2000alib, self).__init__(\"ps2000a\")\n\n\nps2000a = Ps2000alib()\n\n# A tuple in an enum like this is 2 names for the same value.\nps2000a.PS2000A_CHANNEL = make_enum([\n    \"PS2000A_CHANNEL_A\",\n    \"PS2000A_CHANNEL_B\",\n    \"PS2000A_CHANNEL_C\",\n    \"PS2000A_CHANNEL_D\",\n    (\"PS2000A_EXTERNAL\", \"PS2000A_MAX_CHANNELS\"),\n    \"PS2000A_TRIGGER_AUX\",\n    \"PS2000A_MAX_TRIGGER_SOURCE\",\n])\n\n# only include the normal analog channels for now:\nps2000a.PICO_CHANNEL = {k[-1]: v for k, v in ps2000a.PS2000A_CHANNEL.items() if \"PS2000A_CHANNEL_\" in k}\n\n\nps2000a.PS2000A_COUPLING = make_enum([\n    'PS2000A_AC',\n    'PS2000A_DC',\n])\n\n# Just use AC and DC.\nps2000a.PICO_COUPLING = {k[-2:]: v for k, v in ps2000a.PS2000A_COUPLING.items()}\n\nps2000a.PS2000A_RANGE = make_enum([\n    \"PS2000A_10MV\",\n    \"PS2000A_20MV\",\n    \"PS2000A_50MV\",\n    \"PS2000A_100MV\",\n    \"PS2000A_200MV\",\n    \"PS2000A_500MV\",\n    \"PS2000A_1V\",\n    \"PS2000A_2V\",\n    \"PS2000A_5V\",\n    \"PS2000A_10V\",\n    \"PS2000A_20V\",\n    \"PS2000A_50V\",\n    \"PS2000A_MAX_RANGES\",\n])\n\nps2000a.PICO_VOLTAGE_RANGE = {\n    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))\n    for k, v in ps2000a.PS2000A_RANGE.items() if k != \"PS2000A_MAX_RANGES\"\n}\n\nps2000a.MAX_MEMORY = 128e6\n\nps2000a.PS2000A_RATIO_MODE = {\n    'PS2000A_RATIO_MODE_NONE': 0,\n    'PS2000A_RATIO_MODE_AGGREGATE': 1,\n    'PS2000A_RATIO_MODE_DECIMATE': 2,\n    'PS2000A_RATIO_MODE_AVERAGE': 4,\n}\n\nps2000a.PS2000A_TIME_UNITS = make_enum([\n    'PS2000A_FS',\n    'PS2000A_PS',\n    'PS2000A_NS',\n    'PS2000A_US',\n    'PS2000A_MS',\n    'PS2000A_S',\n    'PS2000A_MAX_TIME_UNITS',\n])\n\nps2000a.PICO_RATIO_MODE = {k[19:]: v for k, v in ps2000a.PS2000A_RATIO_MODE.items()}\n\n\ndef _define_threshold_direction():\n    ps2000a_above = 0\n    ps2000a_below = 1\n    ps2000a_rising = 2\n    ps2000a_falling = 3\n    ps2000a_rising_or_falling = 4\n    ps2000a_above_lower = 5\n    ps2000a_below_lower = 6\n    ps2000a_rising_lower = 7\n    ps2000a_falling_lower = 8\n\n    ps2000a_inside = ps2000a_above\n    ps2000a_outside = ps2000a_below\n    ps2000a_enter = ps2000a_rising\n    ps2000a_exit = ps2000a_falling\n    ps2000a_enter_or_exit = ps2000a_rising_or_falling\n    ps2000a_positive_runt = 9\n    ps2000a_negative_runt = 10\n\n    ps2000a_none = ps2000a_rising\n\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"ps2000a\")}\n\n\nps2000a.PS2000A_THRESHOLD_DIRECTION = _define_threshold_direction()\n\nps2000a.PICO_THRESHOLD_DIRECTION = {\n    k[8:]: v for k, v in ps2000a.PS2000A_THRESHOLD_DIRECTION.items()\n}\n\nps2000a.PS2000A_THRESHOLD_MODE = make_enum([\n    \"PS2000A_LEVEL\",\n    \"PS2000A_WINDOW\",\n])\n\nps2000a.PS2000A_TRIGGER_STATE = make_enum([\n    \"PS2000A_CONDITION_DONT_CARE\",\n    \"PS2000A_CONDITION_TRUE\",\n    \"PS2000A_CONDITION_FALSE\",\n    \"PS2000A_CONDITION_MAX\",\n])\n\n\ndef _define_digital_port():\n    ps2000a_digital_port0 = 0x80\n    ps2000a_digital_port1 = ps2000a_digital_port0 + 1\n    ps2000a_digital_port2 = ps2000a_digital_port0 + 2\n    ps2000a_digital_port3 = ps2000a_digital_port0 + 3\n    ps2000a_max_digital_ports = ps2000a_digital_port3 - ps2000a_digital_port0 + 1\n    \n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"ps2000a\")}\n\nps2000a.PS2000A_DIGITAL_PORT = _define_digital_port()\n\nps2000a.PS2000A_DIGITAL_CHANNEL = make_enum([\n    \"PS2000A_DIGITAL_CHANNEL_0\",\n    \"PS2000A_DIGITAL_CHANNEL_1\",\n    \"PS2000A_DIGITAL_CHANNEL_2\",\n    \"PS2000A_DIGITAL_CHANNEL_3\",\n    \"PS2000A_DIGITAL_CHANNEL_4\",\n    \"PS2000A_DIGITAL_CHANNEL_5\",\n    \"PS2000A_DIGITAL_CHANNEL_6\",\n    \"PS2000A_DIGITAL_CHANNEL_7\",\n    \"PS2000A_DIGITAL_CHANNEL_8\",\n    \"PS2000A_DIGITAL_CHANNEL_9\",\n    \"PS2000A_DIGITAL_CHANNEL_10\",\n    \"PS2000A_DIGITAL_CHANNEL_11\",\n    \"PS2000A_DIGITAL_CHANNEL_12\",\n    \"PS2000A_DIGITAL_CHANNEL_13\",\n    \"PS2000A_DIGITAL_CHANNEL_14\",\n    \"PS2000A_DIGITAL_CHANNEL_15\",\n    \"PS2000A_DIGITAL_CHANNEL_16\",\n    \"PS2000A_DIGITAL_CHANNEL_17\",\n    \"PS2000A_DIGITAL_CHANNEL_18\",\n    \"PS2000A_DIGITAL_CHANNEL_19\",\n    \"PS2000A_DIGITAL_CHANNEL_20\",\n    \"PS2000A_DIGITAL_CHANNEL_21\",\n    \"PS2000A_DIGITAL_CHANNEL_22\",\n    \"PS2000A_DIGITAL_CHANNEL_23\",\n    \"PS2000A_DIGITAL_CHANNEL_24\",\n    \"PS2000A_DIGITAL_CHANNEL_25\",\n    \"PS2000A_DIGITAL_CHANNEL_26\",\n    \"PS2000A_DIGITAL_CHANNEL_27\",\n    \"PS2000A_DIGITAL_CHANNEL_28\",\n    \"PS2000A_DIGITAL_CHANNEL_29\",\n    \"PS2000A_DIGITAL_CHANNEL_30\",\n    \"PS2000A_DIGITAL_CHANNEL_31\",\n    \"PS2000A_MAX_DIGITAL_CHANNELS\",\n])\n\nps2000a.PS2000A_DIGITAL_DIRECTION = make_enum([\n    \"PS2000A_DIGITAL_DONT_CARE\",\n    \"PS2000A_DIGITAL_DIRECTION_LOW\",\n    \"PS2000A_DIGITAL_DIRECTION_HIGH\",\n    \"PS2000A_DIGITAL_DIRECTION_RISING\",\n    \"PS2000A_DIGITAL_DIRECTION_FALLING\",\n    \"PS2000A_DIGITAL_DIRECTION_RISING_OR_FALLING\",\n    \"PS2000A_DIGITAL_MAX_DIRECTION\",\n])\n\nps2000a.PS2000A_PULSE_WIDTH_TYPE = make_enum([\n    \"PS2000A_PW_TYPE_NONE\",\n    \"PS2000A_PW_TYPE_LESS_THAN\",\n    \"PS2000A_PW_TYPE_GREATER_THAN\",\n    \"PS2000A_PW_TYPE_IN_RANGE\",\n    \"PS2000A_PW_TYPE_OUT_OF_RANGE\"\n])\n\n\nclass PS2000A_TRIGGER_CONDITIONS(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channelA\", c_int32),\n                (\"channelB\", c_int32),\n                (\"channelC\", c_int32),\n                (\"channelD\", c_int32),\n                (\"external\", c_int32),\n                (\"aux\", c_int32),\n                (\"pulseWidthQualifier\", c_int32),\n                (\"digital\", c_int32)]\n               \nps2000a.PS2000A_TRIGGER_CONDITIONS = PS2000A_TRIGGER_CONDITIONS\n\n\nclass PS2000A_PWQ_CONDITIONS(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channelA\", c_int32),\n                (\"channelB\", c_int32),\n                (\"channelC\", c_int32),\n                (\"channelD\", c_int32),\n                (\"external\", c_int32),\n                (\"aux\", c_int32),\n                (\"digital\", c_int32)]\n                \nps2000a.PS2000A_PWQ_CONDITIONS = PS2000A_PWQ_CONDITIONS\n\n\nclass PS2000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channel\", c_int32),\n                (\"direction\", c_int32)]\n               \nps2000a.PS2000A_DIGITAL_CHANNEL_DIRECTIONS = PS2000A_DIGITAL_CHANNEL_DIRECTIONS\n\n\nclass PS2000A_TRIGGER_CHANNEL_PROPERTIES(Structure):\n    _pack_ = 1\n    _fields_ = [(\"thresholdUpper\", c_int16),\n                (\"thresholdHysteresis\", c_uint16),\n                (\"thresholdLower\", c_int16),\n                (\"thresholdLowerHysteresis\", c_uint16),\n                (\"channel\", c_int32),\n                (\"thresholdMode\", c_int32)]\n\nps2000a.PS2000A_TRIGGER_CHANNEL_PROPERTIES = PS2000A_TRIGGER_CHANNEL_PROPERTIES\n\ndoc = \"\"\" PICO_STATUS ps2000aOpenUnit\n    (\n        int16_t *status,\n        int8_t  *serial\n    ); \"\"\"\nps2000a.make_symbol(\"_OpenUnit\", \"ps2000aOpenUnit\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aOpenUnitAsync\n    (\n        int16_t *status,\n        int8_t    *serial\n    ); \"\"\"\nps2000a.make_symbol(\"_OpenUnitAsync\", \"ps2000aOpenUnitAsync\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aOpenUnitProgress\n    (\n        int16_t *handle,\n        int16_t *progressPercent,\n        int16_t *complete\n    ); \"\"\"\nps2000a.make_symbol(\"_OpenUnitProgress\", \"ps2000aOpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetUnitInfo\n    (\n        int16_t   handle,\n        int8_t   *string,\n        int16_t   stringLength,\n        int16_t  *requiredSize,\n        PICO_INFO info\n    ); \"\"\"\nps2000a.make_symbol(\"_GetUnitInfo\", \"ps2000aGetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32],\n                    doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aFlashLed\n    (\n        int16_t handle,\n        int16_t start\n    ); \"\"\"\nps2000a.make_symbol(\"_FlashLed\", \"ps2000aFlashLed\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aCloseUnit\n    (\n        int16_t handle\n    ); \"\"\"\nps2000a.make_symbol(\"_CloseUnit\", \"ps2000aCloseUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aMemorySegments\n    (\n        int16_t   handle,\n        uint32_t  nSegments,\n        int32_t  *nMaxSamples\n    ); \"\"\"\nps2000a.make_symbol(\"_MemorySegments\", \"ps2000aMemorySegments\", c_uint32, [c_int16, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetChannel\n    (\n        int16_t          handle,\n        PS2000A_CHANNEL  channel,\n        int16_t          enabled,\n        PS2000A_COUPLING type,\n        PS2000A_RANGE    range,\n        float            analogOffset\n    ); \"\"\"\nps2000a.make_symbol(\"_SetChannel\", \"ps2000aSetChannel\", c_uint32,\n                    [c_int16, c_int32, c_int16, c_int32, c_int32, c_float], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetDigitalPort\n    (\n        int16_t              handle,\n        PS2000A_DIGITAL_PORT port,\n        int16_t              enabled,\n        int16_t              logicLevel\n    ); \"\"\"\nps2000a.make_symbol(\"_SetDigitalPort\", \"ps2000aSetDigitalPort\", c_uint32, [c_int16, c_int32, c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetNoOfCaptures\n    (\n        int16_t  handle,\n        uint32_t nCaptures\n    ); \"\"\"\nps2000a.make_symbol(\"_SetNoOfCaptures\", \"ps2000aSetNoOfCaptures\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetTimebase\n    (\n        int16_t  handle,\n        uint32_t timebase,\n        int32_t  noSamples,\n        int32_t *timeIntervalNanoseconds,\n        int16_t  oversample,\n        int32_t *totalSamples,\n        uint32_t segmentIndex\n    ); \"\"\"\nps2000a.make_symbol(\"_GetTimebase\", \"ps2000aGetTimebase\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetTimebase2\n    (\n        int16_t  handle,\n        uint32_t timebase,\n        int32_t  noSamples,\n        float   *timeIntervalNanoseconds,\n        int16_t  oversample,\n        int32_t *totalSamples,\n        uint32_t segmentIndex\n    ); \"\"\"\nps2000a.make_symbol(\"_GetTimebase2\", \"ps2000aGetTimebase2\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetSigGenArbitrary\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        int16_t                    *arbitraryWaveform,\n        int32_t                     arbitraryWaveformSize,\n        PS2000A_SWEEP_TYPE          sweepType,\n        PS2000A_EXTRA_OPERATIONS    operation,\n        PS2000A_INDEX_MODE          indexMode,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS2000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps2000a.make_symbol(\"_SetSigGenArbitrary\", \"ps2000aSetSigGenArbitrary\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,\n                     c_int32,\n                     c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetSigGenBuiltIn\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        int16_t                     waveType,\n        float                       startFrequency,\n        float                       stopFrequency,\n        float                       increment,\n        float                       dwellTime,\n        PS2000A_SWEEP_TYPE          sweepType,\n        PS2000A_EXTRA_OPERATIONS    operation,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS2000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps2000a.make_symbol(\"_SetSigGenBuiltIn\", \"ps2000aSetSigGenBuiltIn\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_int16, c_float, c_float, c_float, c_float, c_int32, c_int32,\n                     c_uint32,\n                     c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetSigGenPropertiesArbitrary\n    (\n        int16_t                     handle,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        PS2000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS2000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps2000a.make_symbol(\"_SetSigGenPropertiesArbitrary\", \"ps2000aSetSigGenPropertiesArbitrary\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetSigGenPropertiesBuiltIn\n    (\n        int16_t                     handle,\n        double                      startFrequency,\n        double                      stopFrequency,\n        double                      increment,\n        double                      dwellTime,\n        PS2000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS2000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps2000a.make_symbol(\"_SetSigGenPropertiesBuiltIn\", \"ps2000aSetSigGenPropertiesBuiltIn\", c_uint32,\n                    [c_int16, c_double, c_double, c_double, c_double, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSigGenFrequencyToPhase\n    (\n        int16_t             handle,\n        double              frequency,\n        PS2000A_INDEX_MODE  indexMode,\n        uint32_t            bufferLength,\n        uint32_t           *phase\n    ); \"\"\"\nps2000a.make_symbol(\"_SigGenFrequencyToPhase\", \"ps2000aSigGenFrequencyToPhase\", c_uint32,\n                    [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSigGenArbitraryMinMaxValues\n    (\n        int16_t   handle,\n        int16_t  *minArbitraryWaveformValue,\n        int16_t  *maxArbitraryWaveformValue,\n        uint32_t *minArbitraryWaveformSize,\n        uint32_t *maxArbitraryWaveformSize\n    ); \"\"\"\nps2000a.make_symbol(\"_SigGenArbitraryMinMaxValues\", \"ps2000aSigGenArbitraryMinMaxValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSigGenSoftwareControl\n    (\n        int16_t  handle,\n        int16_t  state\n    ); \"\"\"\nps2000a.make_symbol(\"_SigGenSoftwareControl\", \"ps2000aSigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetEts\n    (\n        int16_t           handle,\n        PS2000A_ETS_MODE  mode,\n        int16_t           etsCycles,\n        int16_t           etsInterleave,\n        int32_t          *sampleTimePicoseconds\n    ); \"\"\"\nps2000a.make_symbol(\"_SetEts\", \"ps2000aSetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetSimpleTrigger\n    (\n        int16_t                      handle,\n        int16_t                      enable,\n        PS2000A_CHANNEL              source,\n        int16_t                      threshold,\n        PS2000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     delay,\n        int16_t                      autoTrigger_ms\n    ); \"\"\"\nps2000a.make_symbol(\"_SetSimpleTrigger\", \"ps2000aSetSimpleTrigger\", c_uint32,\n                    [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetTriggerDigitalPortProperties\n    (\n        int16_t                             handle,\n        PS2000A_DIGITAL_CHANNEL_DIRECTIONS *directions,\n        int16_t                             nDirections\n    ); \"\"\"\nps2000a.make_symbol(\"_SetTriggerDigitalPortProperties\", \"ps2000aSetTriggerDigitalPortProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetDigitalAnalogTriggerOperand\n    (\n        int16_t handle,\n        PS2000A_TRIGGER_OPERAND operand\n    ); \"\"\"\nps2000a.make_symbol(\"_SetDigitalAnalogTriggerOperand\", \"ps2000aSetDigitalAnalogTriggerOperand\", c_uint32,\n                    [c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetTriggerChannelProperties\n    (\n        int16_t                             handle,\n        PS2000A_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                             nChannelProperties,\n        int16_t                             auxOutputEnable,\n        int32_t                             autoTriggerMilliseconds\n    ); \"\"\"\nps2000a.make_symbol(\"_SetTriggerChannelProperties\", \"ps2000aSetTriggerChannelProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetTriggerChannelConditions\n    (\n        int16_t                     handle,\n        PS2000A_TRIGGER_CONDITIONS *conditions,\n        int16_t                     nConditions\n    ); \"\"\"\nps2000a.make_symbol(\"_SetTriggerChannelConditions\", \"ps2000aSetTriggerChannelConditions\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetTriggerChannelDirections\n    (\n        int16_t                      handle,\n        PS2000A_THRESHOLD_DIRECTION  channelA,\n        PS2000A_THRESHOLD_DIRECTION  channelB,\n        PS2000A_THRESHOLD_DIRECTION  channelC,\n        PS2000A_THRESHOLD_DIRECTION  channelD,\n        PS2000A_THRESHOLD_DIRECTION  ext,\n        PS2000A_THRESHOLD_DIRECTION  aux\n    ); \"\"\"\nps2000a.make_symbol(\"_SetTriggerChannelDirections\", \"ps2000aSetTriggerChannelDirections\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay\n    ); \"\"\"\nps2000a.make_symbol(\"_SetTriggerDelay\", \"ps2000aSetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetPulseWidthQualifier\n    (\n        int16_t                      handle,\n        PS2000A_PWQ_CONDITIONS      *conditions,\n        int16_t                      nConditions,\n        PS2000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     lower,\n        uint32_t                     upper,\n        PS2000A_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps2000a.make_symbol(\"_SetPulseWidthQualifier\", \"ps2000aSetPulseWidthQualifier\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aIsTriggerOrPulseWidthQualifierEnabled\n    (\n        int16_t  handle,\n        int16_t *triggerEnabled,\n        int16_t *pulseWidthQualifierEnabled\n    ); \"\"\"\nps2000a.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps2000aIsTriggerOrPulseWidthQualifierEnabled\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetTriggerTimeOffset64\n    (\n        int16_t             handle,\n        int64_t            *time,\n        PS2000A_TIME_UNITS *timeUnits,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps2000a.make_symbol(\"_GetTriggerTimeOffset\", \"ps2000aGetTriggerTimeOffset64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS PREF2 PREF3 (ps2000aGetValuesTriggerTimeOffsetBulk64)\n    (\n        int16_t             handle,\n        int64_t            *times,\n        PS2000A_TIME_UNITS *timeUnits,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex\n    ); \"\"\"\nps2000a.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps2000aGetValuesTriggerTimeOffsetBulk64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t *nCaptures\n    ); \"\"\"\nps2000a.make_symbol(\"_GetNoOfCaptures\", \"ps2000aGetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetNoOfProcessedCaptures\n    (\n        int16_t   handle,\n        uint32_t *nProcessedCaptures\n    ); \"\"\"\nps2000a.make_symbol(\"_GetNoOfProcessedCaptures\", \"ps2000aGetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetDataBuffer\n    (\n        int16_t            handle,\n        int32_t            channelOrPort,\n        int16_t           *buffer,\n        int32_t            bufferLth,\n        uint32_t           segmentIndex,\n        PS2000A_RATIO_MODE mode\n    ); \"\"\"\nps2000a.make_symbol(\"_SetDataBuffer\", \"ps2000aSetDataBuffer\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetDataBuffers\n    (\n        int16_t            handle,\n        int32_t            channelOrPort,\n        int16_t           *bufferMax,\n        int16_t           *bufferMin,\n        int32_t            bufferLth,\n        uint32_t           segmentIndex,\n        PS2000A_RATIO_MODE mode\n    ); \"\"\"\nps2000a.make_symbol(\"_SetDataBuffers\", \"ps2000aSetDataBuffers\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aSetEtsTimeBuffer\n    (\n        int16_t  handle,\n        int64_t *buffer,\n        int32_t  bufferLth\n    ); \"\"\"\nps2000a.make_symbol(\"_SetEtsTimeBuffer\", \"ps2000aSetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aIsReady\n    (\n        int16_t  handle,\n        int16_t *ready\n    ); \"\"\"\nps2000a.make_symbol(\"_IsReady\", \"ps2000aIsReady\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aRunBlock\n    (\n        int16_t            handle,\n        int32_t            noOfPreTriggerSamples,\n        int32_t            noOfPostTriggerSamples,\n        uint32_t           timebase,\n        int16_t            oversample,\n        int32_t           *timeIndisposedMs,\n        uint32_t           segmentIndex,\n        ps2000aBlockReady  lpReady,\n        void              *pParameter\n    ); \"\"\"\nps2000a.make_symbol(\"_RunBlock\", \"ps2000aRunBlock\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_uint32, c_int16, c_void_p, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aRunStreaming\n    (\n        int16_t             handle,\n        uint32_t            *sampleInterval,\n        PS2000A_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t            maxPreTriggerSamples,\n        uint32_t            maxPostPreTriggerSamples,\n        int16_t             autoStop,\n        uint32_t            downSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            overviewBufferSize\n    ); \"\"\"\nps2000a.make_symbol(\"_RunStreaming\", \"ps2000aRunStreaming\", c_uint32,\n                    [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetStreamingLatestValues\n    (\n        int16_t                handle,\n        ps2000aStreamingReady  lpPs2000aReady,\n        void                   *pParameter\n    ); \"\"\"\nps2000a.make_symbol(\"_GetStreamingLatestValues\", \"ps2000aGetStreamingLatestValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" void *ps2000aStreamingReady\n    (\n        int16_t   handle,\n        int32_t   noOfSamples,\n        uint32_t  startIndex,\n        int16_t   overflow,\n        uint32_t  triggerAt,\n        int16_t   triggered,\n        int16_t   autoStop,\n        void     *pParameter\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n\nps2000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                         c_int16,\n                                                         c_int32,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_int16,\n                                                         c_void_p)\n\nps2000a.StreamingReadyType.__doc__ = doc\n\ndoc = \"\"\" PICO_STATUS ps2000aNoOfStreamingValues\n    (\n        int16_t   handle,\n        uint32_t *noOfValues\n    ); \"\"\"\nps2000a.make_symbol(\"_NoOfStreamingValues\", \"ps2000aNoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetMaxDownSampleRatio\n    (\n        int16_t             handle,\n        uint32_t            noOfUnaggreatedSamples,\n        uint32_t           *maxDownSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps2000a.make_symbol(\"_GetMaxDownSampleRatio\", \"ps2000aGetMaxDownSampleRatio\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetValues\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps2000a.make_symbol(\"_GetValues\", \"ps2000aGetValues\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetValuesBulk\n    (\n        int16_t             handle,\n        uint32_t           *noOfSamples,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        uint32_t            downSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        int16_t            *overflow\n    ); \"\"\"\nps2000a.make_symbol(\"_GetValuesBulk\", \"ps2000aGetValuesBulk\", c_uint32,\n                    [c_int16, c_void_p, c_uint32, c_uint32, c_uint32, c_int32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetValuesAsync\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t            noOfSamples,\n        uint32_t            downSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        void               *lpDataReady,\n        void               *pParameter\n    ); \"\"\"\nps2000a.make_symbol(\"_GetValuesAsync\", \"ps2000aGetValuesAsync\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetValuesOverlapped\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps2000a.make_symbol(\"_GetValuesOverlapped\", \"ps2000aGetValuesOverlapped\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetValuesOverlappedBulk\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS2000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps2000a.make_symbol(\"_GetValuesOverlappedBulk\", \"ps2000aGetValuesOverlappedBulk\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_int32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aStop\n    (\n        int16_t  handle\n    ); \"\"\"\nps2000a.make_symbol(\"_Stop\", \"ps2000aStop\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aHoldOff\n    (\n        int16_t               handle,\n        uint64_t              holdoff,\n        PS2000A_HOLDOFF_TYPE  type\n    ); \"\"\"\nps2000a.make_symbol(\"_HoldOff\", \"ps2000aHoldOff\", c_uint32, [c_int16, c_uint64, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetChannelInformation\n    (\n        int16_t               handle,\n        PS2000A_CHANNEL_INFO  info,\n        int32_t               probe,\n        int32_t              *ranges,\n        int32_t              *length,\n        int32_t               channels\n    ); \"\"\"\nps2000a.make_symbol(\"_GetChannelInformation\", \"ps2000aGetChannelInformation\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aEnumerateUnits\n    (\n        int16_t *count,\n        int8_t  *serials,\n        int16_t *serialLth\n    ); \"\"\"\nps2000a.make_symbol(\"_EnumerateUnits\", \"ps2000aEnumerateUnits\", c_uint32, [c_void_p, c_char_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aPingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps2000a.make_symbol(\"_PingUnit\", \"ps2000aPingUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aMaximumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps2000a.make_symbol(\"_MaximumValue\", \"ps2000aMaximumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aMinimumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps2000a.make_symbol(\"_MinimumValue\", \"ps2000aMinimumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetAnalogueOffset\n    (\n        int16_t           handle,\n        PS2000A_RANGE     range,\n        PS2000A_COUPLING  coupling,\n        float            *maximumVoltage,\n        float            *minimumVoltage\n    ); \"\"\"\nps2000a.make_symbol(\"_GetAnalogueOffset\", \"ps2000aGetAnalogueOffset\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps2000aGetMaxSegments\n    (\n        int16_t   handle,\n        uint32_t *maxSegments\n    ); \"\"\"\nps2000a.make_symbol(\"_GetMaxSegments\", \"ps2000aGetMaxSegments\", c_uint32, [c_int16, c_void_p], doc)\n\nps2000a.INI_LOGIC_VOLTS = 1.5\n\ndoc = \"\"\" void *ps2000aBlockReady\n    (\n        int16_t    handle,\n        PICO_STATUS    status,\n        void    *pParameter\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n    \nps2000a.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                     c_int16,\n                                                     c_uint32,\n                                                     c_void_p)\n\nps2000a.BlockReadyType.__doc__ = doc"
  },
  {
    "path": "picosdk/ps3000.py",
    "content": "#\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps3000.h C header file\nfor PicoScope 3000 Series oscilloscopes using the ps3000 driver API functions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.library import Library\nfrom picosdk.constants import make_enum\n\n\nclass Ps3000lib(Library):\n    def __init__(self):\n        super(Ps3000lib, self).__init__(\"ps3000\")\n\n\nps3000 = Ps3000lib()\n\nps3000.PS3000_CHANNEL = make_enum([\n    \"PS3000_CHANNEL_A\",\n    \"PS3000_CHANNEL_B\",\n    \"PS3000_CHANNEL_C\",\n    \"PS3000_CHANNEL_D\",\n])\n\n# use the last character, i.e. the channel name:\nps3000.PICO_CHANNEL = {k[-1]: v for k, v in ps3000.PS3000_CHANNEL.items()}\n\n# This field is passed to the driver as a boolean, not an enum.\nps3000.PICO_COUPLING = {\n    'AC': 0,\n    'DC': 1\n}\n\nps3000.PS3000_VOLTAGE_RANGE = {\n    'PS3000_20MV':  1,\n    'PS3000_50MV':  2,\n    'PS3000_100MV': 3,\n    'PS3000_200MV': 4,\n    'PS3000_500MV': 5,\n    'PS3000_1V':    6,\n    'PS3000_2V':    7,\n    'PS3000_5V':    8,\n    'PS3000_10V':   9,\n    'PS3000_20V':   10,\n    'PS3000_50V':   11,\n    'PS3000_100V':  12,\n    'PS3000_200V':  13,\n    'PS3000_400V':  14,\n}\n\n# float voltage value max (multiplier for output voltages). Parse the value in the constant name.\nps3000.PICO_VOLTAGE_RANGE = {\n    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))\n    for k, v in ps3000.PS3000_VOLTAGE_RANGE.items()\n}\n\ndoc = \"\"\" int16_t ps3000_open_unit\n    (\n        void\n    ); \"\"\"\nps3000.make_symbol(\"_open_unit\", \"ps3000_open_unit\", c_int16, [], doc)\n\ndoc = \"\"\" int16_t ps3000_get_unit_info\n    (\n        int16_t  handle,\n        int8_t  *string,\n        int16_t  string_length,\n        int16_t  line\n    ); \"\"\"\nps3000.make_symbol(\"_get_unit_info\", \"ps3000_get_unit_info\", c_int16, [c_int16, c_char_p, c_int16, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000_flash_led\n    (\n        int16_t handle\n    ); \"\"\"\nps3000.make_symbol(\"_flash_led\", \"ps3000_flash_led\", c_int16, [c_int16, ], doc)\n\ndoc = \"\"\" int16_t ps3000_close_unit\n    (\n        int16_t handle\n    ); \"\"\"\nps3000.make_symbol(\"_close_unit\", \"ps3000_close_unit\", c_int16, [c_int16, ], doc)\n\ndoc = \"\"\" int16_t ps3000_set_channel\n    (\n        int16_t  handle,\n        int16_t  channel,\n        int16_t  enabled,\n        int16_t  dc,\n        int16_t  range\n    ); \"\"\"\nps3000.make_symbol(\"_set_channel\", \"ps3000_set_channel\", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000_get_timebase\n    (\n        int16_t  handle,\n        int16_t  timebase,\n        int32_t  no_of_samples,\n        int32_t *time_interval,\n        int16_t *time_units,\n        int16_t  oversample,\n        int32_t *max_samples\n    ); \"\"\"\nps3000.make_symbol(\"_get_timebase\", \"ps3000_get_timebase\", c_int16,\n                   [c_int16, c_int16, c_int32, c_void_p, c_void_p, c_int16, c_void_p], doc)\n\ndoc = \"\"\" int32_t ps3000_set_siggen\n    (\n        int16_t  handle,\n        int16_t  wave_type,\n        int32_t  start_frequency,\n        int32_t  stop_frequency,\n        float    increment,\n        int16_t  dwell_time,\n        int16_t  repeat,\n        int16_t  dual_slope\n    ); \"\"\"\nps3000.make_symbol(\"_set_siggen\", \"ps3000_set_siggen\", c_int32,\n                   [c_int16, c_int16, c_int32, c_int32, c_float, c_int16, c_int16, c_int16], doc)\n\ndoc = \"\"\" int32_t ps3000_set_ets\n    (\n        int16_t  handle,\n        int16_t  mode,\n        int16_t  ets_cycles,\n        int16_t  ets_interleave\n    ); \"\"\"\nps3000.make_symbol(\"_set_ets\", \"ps3000_set_ets\", c_int32, [c_int16, c_int16, c_int16, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000_set_trigger\n    (\n        int16_t  handle,\n        int16_t  source,\n        int16_t  threshold,\n        int16_t  direction,\n        int16_t  delay,\n        int16_t  auto_trigger_ms\n    ); \"\"\"\nps3000.make_symbol(\"_set_trigger\", \"ps3000_set_trigger\", c_int16,\n                   [c_int16, c_int16, c_int16, c_int16, c_int16, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000_set_trigger2\n    (\n        int16_t  handle,\n        int16_t  source,\n        int16_t  threshold,\n        int16_t  direction,\n        float    delay,\n        int16_t  auto_trigger_ms\n    ); \"\"\"\nps3000.make_symbol(\"_set_trigger2\", \"ps3000_set_trigger2\", c_int16,\n                   [c_int16, c_int16, c_int16, c_int16, c_float, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000_run_block\n    (\n        int16_t handle,\n        int32_t  no_of_values,\n        int16_t  timebase,\n        int16_t  oversample,\n        int32_t * time_indisposed_ms\n    ); \"\"\"\nps3000.make_symbol(\"_run_block\", \"ps3000_run_block\", c_int16, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" int16_t ps3000_run_streaming\n    (\n        int16_t  handle,\n        int16_t  sample_interval_ms,\n        int32_t  max_samples,\n        int16_t  windowed\n    ); \"\"\"\nps3000.make_symbol(\"_run_streaming\", \"ps3000_run_streaming\", c_int16, [c_int16, c_int16, c_int32, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000_run_streaming_ns\n    (\n        int16_t            handle,\n        uint32_t           sample_interval,\n        PS3000_TIME_UNITS  time_units,\n        uint32_t           max_samples,\n        int16_t            auto_stop,\n        uint32_t           noOfSamplesPerAggregate,\n        uint32_t           overview_buffer_size\n    ); \"\"\"\nps3000.make_symbol(\"_run_streaming_ns\", \"ps3000_run_streaming_ns\", c_int16,\n                   [c_int16, c_uint32, c_int32, c_uint32, c_int16, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" int16_t ps3000_ready\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000.make_symbol(\"_ready\", \"ps3000_ready\", c_int16, [c_int16, ], doc)\n\ndoc = \"\"\" int16_t ps3000_stop\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000.make_symbol(\"_stop\", \"ps3000_stop\", c_int16, [c_int16, ], doc)\n\ndoc = \"\"\" int32_t ps3000_get_values\n    (\n        int16_t  handle,\n        int16_t *buffer_a,\n        int16_t *buffer_b,\n        int16_t *buffer_c,\n        int16_t *buffer_d,\n        int16_t *overflow,\n        int32_t  no_of_values\n    ); \"\"\"\nps3000.make_symbol(\"_get_values\", \"ps3000_get_values\", c_int32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int32], doc)\n\ndoc = \"\"\" void ps3000_release_stream_buffer\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000.make_symbol(\"_release_stream_buffer\", \"ps3000_release_stream_buffer\", None, [c_int16, ], doc)\n\ndoc = \"\"\" int32_t ps3000_get_times_and_values\n    (\n        int16_t  handle,\n        int32_t *times,\n        int16_t *buffer_a,\n        int16_t *buffer_b,\n        int16_t *buffer_c,\n        int16_t *buffer_d,\n        int16_t *overflow,\n        int16_t  time_units,\n        int32_t  no_of_values\n    ); \"\"\"\nps3000.make_symbol(\"_get_times_and_values\", \"ps3000_get_times_and_values\", c_int32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int16, c_int32], doc)\n\ndoc = \"\"\" int16_t ps3000_open_unit_async\n    (\n        void\n    ); \"\"\"\nps3000.make_symbol(\"_open_unit_async\", \"ps3000_open_unit_async\", c_int16, [], doc)\n\ndoc = \"\"\" int16_t ps3000_open_unit_progress\n    (\n        int16_t *handle,\n        int16_t *progress_percent\n    ); \"\"\"\nps3000.make_symbol(\"_open_unit_progress\", \"ps3000_open_unit_progress\", c_int16, [c_void_p, c_void_p], doc)\n\ndoc = \"\"\" int16_t ps3000_streaming_ns_get_interval_stateless\n    (\n        int16_t   handle,\n        int16_t   nChannels,\n        uint32_t *sample_interval\n    ); \"\"\"\nps3000.make_symbol(\"_streaming_ns_get_interval_stateless\", \"ps3000_streaming_ns_get_interval_stateless\", c_int16,\n                   [c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" int16_t ps3000_get_streaming_last_values\n    (\n        int16_t  handle,\n        GetOverviewBuffersMaxMin\n    ); \"\"\"\nps3000.make_symbol(\"_get_streaming_last_values\", \"ps3000_get_streaming_last_values\", c_int16, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" int16_t ps3000_overview_buffer_status\n    (\n        int16_t  handle,\n        int16_t *previous_buffer_overrun\n    ); \"\"\"\nps3000.make_symbol(\"_overview_buffer_status\", \"ps3000_overview_buffer_status\", c_int16, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" uint32_t ps3000_get_streaming_values\n    (\n        int16_t  handle,\n        double   *start_time,\n        int16_t  *pbuffer_a_max,\n        int16_t  *pbuffer_a_min,\n        int16_t  *pbuffer_b_max,\n        int16_t  *pbuffer_b_min,\n        int16_t  *pbuffer_c_max,\n        int16_t  *pbuffer_c_min,\n        int16_t  *pbuffer_d_max,\n        int16_t  *pbuffer_d_min,\n        int16_t  *overflow,\n        uint32_t *triggerAt,\n        int16_t  *triggered,\n        uint32_t  no_of_values,\n        uint32_t  noOfSamplesPerAggregate\n    ); \"\"\"\nps3000.make_symbol(\"_get_streaming_values\", \"ps3000_get_streaming_values\", c_uint32,\n                   [c_int16, c_void_p,\n                    c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p,\n                    c_void_p, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" uint32_t ps3000_get_streaming_values_no_aggregation\n    (\n        int16_t handle,\n        double *start_time,\n        int16_t * pbuffer_a,\n        int16_t * pbuffer_b,\n        int16_t * pbuffer_c,\n        int16_t * pbuffer_d,\n        int16_t * overflow,\n        uint32_t * triggerAt,\n        int16_t * trigger,\n        uint32_t no_of_values\n    ); \"\"\"\nps3000.make_symbol(\"_get_streaming_values_no_aggregation\", \"ps3000_get_streaming_values_no_aggregation\", c_uint32,\n                   [c_int16, c_void_p,\n                    c_void_p, c_void_p, c_void_p, c_void_p,\n                    c_void_p, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" int16_t ps3000_save_streaming_data\n    (\n        int16_t               handle,\n        PS3000_CALLBACK_FUNC  lpCallbackFunc,\n        int16_t              *dataBuffers,\n        int16_t               dataBufferSize\n    ); \"\"\"\nps3000.make_symbol(\"_save_streaming_data\", \"ps3000_save_streaming_data\", c_int16,\n                   [c_int16, c_void_p, c_void_p, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000SetAdvTriggerChannelProperties\n    (\n        int16_t                            handle,\n        PS3000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                            nChannelProperties,\n        int32_t                            autoTriggerMilliseconds\n    ); \"\"\"\nps3000.make_symbol(\"_SetAdvTriggerChannelProperties\", \"ps3000SetAdvTriggerChannelProperties\", c_int16,\n                   [c_int16, c_void_p, c_int16, c_int32], doc)\n\ndoc = \"\"\" int16_t ps3000SetAdvTriggerChannelConditions\n    (\n        int16_t                    handle,\n        PS3000_TRIGGER_CONDITIONS *conditions,\n        int16_t                    nConditions\n    ); \"\"\"\nps3000.make_symbol(\"_SetAdvTriggerChannelConditions\", \"ps3000SetAdvTriggerChannelConditions\", c_int16,\n                   [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" int16_t ps3000SetAdvTriggerChannelDirections\n    (\n        int16_t                     handle,\n        PS3000_THRESHOLD_DIRECTION  channelA,\n        PS3000_THRESHOLD_DIRECTION  channelB,\n        PS3000_THRESHOLD_DIRECTION  channelC,\n        PS3000_THRESHOLD_DIRECTION  channelD,\n        PS3000_THRESHOLD_DIRECTION  ext\n    ); \"\"\"\nps3000.make_symbol(\"_SetAdvTriggerChannelDirections\", \"ps3000SetAdvTriggerChannelDirections\", c_int16,\n                   [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" int16_t ps3000SetPulseWidthQualifier\n    (\n        int16_t                     handle,\n        PS3000_PWQ_CONDITIONS      *conditions,\n        int16_t                     nConditions,\n        PS3000_THRESHOLD_DIRECTION  direction,\n        uint32_t                    lower,\n        uint32_t                    upper,\n        PS3000_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps3000.make_symbol(\"_SetPulseWidthQualifier\", \"ps3000SetPulseWidthQualifier\", c_int16,\n                   [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" int16_t ps3000SetAdvTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay,\n        float     preTriggerDelay\n    ); \"\"\"\nps3000.make_symbol(\"_SetAdvTriggerDelay\", \"ps3000SetAdvTriggerDelay\", c_int16, [c_int16, c_uint32, c_float], doc)\n\ndoc = \"\"\" int16_t ps3000PingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000.make_symbol(\"_PingUnit\", \"ps3000PingUnit\", c_int16, [c_int16, ], doc)\n\nps3000.PICO_INFO = {k: v for k, v in ps3000.PICO_INFO.items() if v <= 0x00000005}\nps3000.PICO_INFO[\"PICO_ERROR_CODE\"] = 0x00000006\n"
  },
  {
    "path": "picosdk/ps3000a.py",
    "content": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps3000aApi.h C header\nfile for PicoScope 3000 Series oscilloscopes using the ps3000a driver API\nfunctions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\nfrom picosdk.library import Library\nfrom picosdk.constants import make_enum\n\n\nclass Ps3000alib(Library):\n    def __init__(self):\n        super(Ps3000alib, self).__init__(\"ps3000a\")\n\n\nps3000a = Ps3000alib()\n\nps3000a.PS3000A_COUPLING = make_enum([\n    'PS3000A_AC',\n    'PS3000A_DC',\n])\n\n# Just use AC and DC.\nps3000a.PICO_COUPLING = {k[-2:]: v for k, v in ps3000a.PS3000A_COUPLING.items()}\n\n# A tuple in an enum like this is 2 names for the same value.\nps3000a.PS3000A_CHANNEL = make_enum([\n    \"PS3000A_CHANNEL_A\",\n    \"PS3000A_CHANNEL_B\",\n    \"PS3000A_CHANNEL_C\",\n    \"PS3000A_CHANNEL_D\",\n    (\"PS3000A_EXTERNAL\", \"PS3000A_MAX_CHANNELS\"),\n    \"PS3000A_TRIGGER_AUX\",\n    \"PS3000A_MAX_TRIGGER_SOURCE\",\n])\n\n# only include the normal analog channels for now:\nps3000a.PICO_CHANNEL = {k[-1]: v for k, v in ps3000a.PS3000A_CHANNEL.items() if \"PS3000A_CHANNEL_\" in k}\n\nps3000a.PS3000A_RANGE = make_enum([\n    \"PS3000A_10MV\",\n    \"PS3000A_20MV\",\n    \"PS3000A_50MV\",\n    \"PS3000A_100MV\",\n    \"PS3000A_200MV\",\n    \"PS3000A_500MV\",\n    \"PS3000A_1V\",\n    \"PS3000A_2V\",\n    \"PS3000A_5V\",\n    \"PS3000A_10V\",\n    \"PS3000A_20V\",\n    \"PS3000A_50V\",\n    \"PS3000A_MAX_RANGES\",\n])\n\nps3000a.PICO_VOLTAGE_RANGE = {\n    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))\n    for k, v in ps3000a.PS3000A_RANGE.items() if k != \"PS3000A_MAX_RANGES\"\n}\n\nps3000a.PS3000A_RATIO_MODE = {\n    'PS3000A_RATIO_MODE_NONE': 0,\n    'PS3000A_RATIO_MODE_AGGREGATE': 1,\n    'PS3000A_RATIO_MODE_DECIMATE': 2,\n    'PS3000A_RATIO_MODE_AVERAGE': 4,\n}\n\nps3000a.PS3000A_TIME_UNITS = make_enum([\n    'PS3000A_FS',\n    'PS3000A_PS',\n    'PS3000A_NS',\n    'PS3000A_US',\n    'PS3000A_MS',\n    'PS3000A_S',\n    'PS3000A_MAX_TIME_UNITS',\n])\n\nps3000a.PS3000A_DIGITAL_CHANNEL = make_enum([\n    \"PS3000A_DIGITAL_CHANNEL_0\",\n    \"PS3000A_DIGITAL_CHANNEL_1\",\n    \"PS3000A_DIGITAL_CHANNEL_2\",\n    \"PS3000A_DIGITAL_CHANNEL_3\",\n    \"PS3000A_DIGITAL_CHANNEL_4\",\n    \"PS3000A_DIGITAL_CHANNEL_5\",\n    \"PS3000A_DIGITAL_CHANNEL_6\",\n    \"PS3000A_DIGITAL_CHANNEL_7\",\n    \"PS3000A_DIGITAL_CHANNEL_8\",\n    \"PS3000A_DIGITAL_CHANNEL_9\",\n    \"PS3000A_DIGITAL_CHANNEL_10\",\n    \"PS3000A_DIGITAL_CHANNEL_11\",\n    \"PS3000A_DIGITAL_CHANNEL_12\",\n    \"PS3000A_DIGITAL_CHANNEL_13\",\n    \"PS3000A_DIGITAL_CHANNEL_14\",\n    \"PS3000A_DIGITAL_CHANNEL_15\",\n    \"PS3000A_DIGITAL_CHANNEL_16\",\n    \"PS3000A_DIGITAL_CHANNEL_17\",\n    \"PS3000A_DIGITAL_CHANNEL_18\",\n    \"PS3000A_DIGITAL_CHANNEL_19\",\n    \"PS3000A_DIGITAL_CHANNEL_20\",\n    \"PS3000A_DIGITAL_CHANNEL_21\",\n    \"PS3000A_DIGITAL_CHANNEL_22\",\n    \"PS3000A_DIGITAL_CHANNEL_23\",\n    \"PS3000A_DIGITAL_CHANNEL_24\",\n    \"PS3000A_DIGITAL_CHANNEL_25\",\n    \"PS3000A_DIGITAL_CHANNEL_26\",\n    \"PS3000A_DIGITAL_CHANNEL_27\",\n    \"PS3000A_DIGITAL_CHANNEL_28\",\n    \"PS3000A_DIGITAL_CHANNEL_29\",\n    \"PS3000A_DIGITAL_CHANNEL_30\",\n    \"PS3000A_DIGITAL_CHANNEL_31\",\n    \"PS3000A_MAX_DIGITAL_CHANNELS\"\n])\n\nps3000a.PS3000A_DIGITAL_DIRECTION = make_enum([\n    \"PS3000A_DIGITAL_DONT_CARE\",\n    \"PS3000A_DIGITAL_DIRECTION_LOW\",\n    \"PS3000A_DIGITAL_DIRECTION_HIGH\",\n    \"PS3000A_DIGITAL_DIRECTION_RISING\",\n    \"PS3000A_DIGITAL_DIRECTION_FALLING\",\n    \"PS3000A_DIGITAL_DIRECTION_RISING_OR_FALLING\",\n    \"PS3000A_DIGITAL_MAX_DIRECTION\"\n])\n\ndef _define_digital_port():\n    PS3000A_DIGITAL_PORT0 = 0x80\n    PS3000A_DIGITAL_PORT1 = PS3000A_DIGITAL_PORT0 + 1\n    PS3000A_DIGITAL_PORT2 = PS3000A_DIGITAL_PORT0 + 2\n    PS3000A_DIGITAL_PORT3 = PS3000A_DIGITAL_PORT0 + 3\n    PS3000A_MAX_DIGITAL_PORTS = (PS3000A_DIGITAL_PORT3 - PS3000A_DIGITAL_PORT0) + 1\n\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PS3000A\")}\n\nps3000a.PS3000A_DIGITAL_PORT = _define_digital_port()\n\nps3000a.PS3000A_TRIGGER_STATE = make_enum([\n    \"PS3000A_CONDITION_DONT_CARE\",\n    \"PS3000A_CONDITION_TRUE\",\n    \"PS3000A_CONDITION_FALSE\",\n    \"PS3000A_CONDITION_MAX\"\n    ])\n    \nps3000a.PS3000A_THRESHOLD_DIRECTION = make_enum([\n    (\"PS3000A_ABOVE\", \"PS3000A_INSIDE\"),\n    (\"PS3000A_BELOW\", \"PS3000A_OUTSIDE\",\"PS3000A_NONE\"),\n    (\"PS3000A_RISING\", \"PS3000A_ENTER\"),\n    (\"PS3000A_FALLING\", \"PS3000A_EXIT\"),\n    (\"PS3000A_RISING_OR_FALLING\", \"PS3000A_ENTER_OR_EXIT\"),\n    \"PS3000A_ABOVE_LOWER\",\n    \"PS3000A_BELOW_LOWER\",\n    \"PS3000A_RISING_LOWER\",\n    \"PS3000A_FALLING_LOWER\",\n    \"PS3000A_POSITIVE_RUNT\",\n    \"PS3000A_NEGATIVE_RUNT\"\n    ])\n    \nps3000a.PS3000A_THRESHOLD_MODE = make_enum([\n    \"PS3000A_LEVEL\",\n    \"PS3000A_WINDOW\"\n    ])\n\nclass PS3000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channel\", c_int32),\n                (\"direction\", c_int32)]\n                \nps3000a.PS3000A_DIGITAL_CHANNEL_DIRECTIONS = PS3000A_DIGITAL_CHANNEL_DIRECTIONS\n                \nclass PS3000A_TRIGGER_CONDITIONS(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channelA\", c_uint32),\n                (\"channelB\", c_uint32),\n                (\"channelC\", c_uint32),\n                (\"channelD\", c_uint32),\n                (\"external\", c_uint32),\n                (\"aux\", c_uint32),\n                (\"pulseWidthQualifier\", c_uint32)]\n\nps3000a.PS3000A_TRIGGER_CONDITIONS = PS3000A_TRIGGER_CONDITIONS\n                \nclass PS3000A_TRIGGER_CONDITIONS_V2(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channelA\", c_uint32),\n                (\"channelB\", c_uint32),\n                (\"channelC\", c_uint32),\n                (\"channelD\", c_uint32),\n                (\"external\", c_uint32),\n                (\"aux\", c_uint32),\n                (\"pulseWidthQualifier\", c_uint32),\n                (\"digital\", c_uint32)]\nps3000a.PS3000A_TRIGGER_CONDITIONS_V2 = PS3000A_TRIGGER_CONDITIONS_V2\n                \nclass PS3000A_TRIGGER_CHANNEL_PROPERTIES(Structure):\n    _pack_ = 1\n    _fields_ = [(\"thresholdUpper\", c_int16),\n                (\"thresholdUpperHysteresis\", c_uint16),\n                (\"thresholdLower\", c_int16),\n                (\"thresholdLowerHysteresis\", c_uint16),\n                (\"channel\", c_uint32),\n                (\"thresholdMode\", c_uint32)]\nps3000a.PS3000A_TRIGGER_CHANNEL_PROPERTIES = PS3000A_TRIGGER_CHANNEL_PROPERTIES\n                \ndoc = \"\"\" PICO_STATUS ps3000aOpenUnit\n    (\n        int16_t *handle,\n        int8_t  *serial\n    ); \"\"\"\nps3000a.make_symbol(\"_OpenUnit\", \"ps3000aOpenUnit\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aOpenUnitAsync\n    (\n        int16_t *status,\n        int8_t  *serial\n    ); \"\"\"\nps3000a.make_symbol(\"_OpenUnitAsync\", \"ps3000aOpenUnitAsync\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aOpenUnitProgress\n    (\n        int16_t *handle,\n        int16_t *progressPercent,\n        int16_t *complete\n    ); \"\"\"\nps3000a.make_symbol(\"_OpenUnitProgress\", \"ps3000aOpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetUnitInfo\n    (\n        int16_t    handle,\n        int8_t    *string,\n        int16_t    stringLength,\n        int16_t   *requiredSize,\n        PICO_INFO  info\n    ); \"\"\"\nps3000a.make_symbol(\"_GetUnitInfo\", \"ps3000aGetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32],\n                    doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aFlashLed\n    (\n        int16_t  handle,\n        int16_t  start\n    ); \"\"\"\nps3000a.make_symbol(\"_FlashLed\", \"ps3000aFlashLed\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aCloseUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000a.make_symbol(\"_CloseUnit\", \"ps3000aCloseUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aMemorySegments\n    (\n        int16_t   handle,\n        uint32_t  nSegments,\n        int32_t  *nMaxSamples\n    ); \"\"\"\nps3000a.make_symbol(\"_MemorySegments\", \"ps3000aMemorySegments\", c_uint32, [c_int16, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetChannel\n    (\n        int16_t          handle,\n        PS3000a_CHANNEL  channel,\n        int16_t          enabled,\n        PS3000a_COUPLING type,\n        PS3000a_RANGE    range,\n        float            analogOffset\n    ); \"\"\"\nps3000a.make_symbol(\"_SetChannel\", \"ps3000aSetChannel\", c_uint32,\n                    [c_int16, c_int32, c_int16, c_int32, c_int32, c_float], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetDigitalPort\n    (\n        int16_t              handle,\n        PS3000a_DIGITAL_PORT port,\n        int16_t              enabled,\n        int16_t              logicLevel\n    ); \"\"\"\nps3000a.make_symbol(\"_SetDigitalPort\", \"ps3000aSetDigitalPort\", c_uint32, [c_int16, c_int32, c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetBandwidthFilter\n    (\n        int16_t                    handle,\n        PS3000A_CHANNEL            channel,\n        PS3000A_BANDWIDTH_LIMITER  bandwidth\n    ); \"\"\"\nps3000a.make_symbol(\"_SetBandwidthFilter\", \"ps3000aSetBandwidthFilter\", c_uint32, [c_int16, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t  nCaptures\n    ); \"\"\"\nps3000a.make_symbol(\"_SetNoOfCaptures\", \"ps3000aSetNoOfCaptures\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetTimebase\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        int32_t  *timeIntervalNanoseconds,\n        int16_t   oversample,\n        int32_t  *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps3000a.make_symbol(\"_GetTimebase\", \"ps3000aGetTimebase\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\n\ndoc = \"\"\" PICO_STATUS ps3000aGetTimebase2\n    (\n        int16_t  handle,\n        uint32_t timebase,\n        int32_t  noSamples,\n        float   *timeIntervalNanoseconds,\n        int16_t  oversample,\n        int32_t *maxSamples,\n        uint32_t segmentIndex\n    ); \"\"\"\nps3000a.make_symbol(\"_GetTimebase2\", \"ps3000aGetTimebase2\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetSigGenArbitrary\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        int16_t                    *arbitraryWaveform,\n        int32_t                     arbitraryWaveformSize,\n        PS3000A_SWEEP_TYPE          sweepType,\n        PS3000A_EXTRA_OPERATIONS    operation,\n        PS3000A_INDEX_MODE          indexMode,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS3000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps3000a.make_symbol(\"_SetSigGenArbitrary\", \"ps3000aSetSigGenArbitrary\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,\n                     c_int32,\n                     c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetSigGenBuiltIn\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        int16_t                     waveType,\n        float                       startFrequency,\n        float                       stopFrequency,\n        float                       increment,\n        float                       dwellTime,\n        PS3000A_SWEEP_TYPE          sweepType,\n        PS3000A_EXTRA_OPERATIONS    operation,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS3000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps3000a.make_symbol(\"_SetSigGenBuiltIn\", \"ps3000aSetSigGenBuiltIn\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_int16, c_float, c_float, c_float, c_float, c_int32, c_int32,\n                     c_uint32,\n                     c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetSigGenPropertiesArbitrary\n    (\n        int16_t                     handle,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        PS3000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS3000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps3000a.make_symbol(\"_SetSigGenPropertiesArbitrary\", \"ps3000aSetSigGenPropertiesArbitrary\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetSigGenPropertiesBuiltIn\n    (\n        int16_t                     handle,\n        double                      startFrequency,\n        double                      stopFrequency,\n        double                      increment,\n        double                      dwellTime,\n        PS3000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS3000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps3000a.make_symbol(\"_SetSigGenPropertiesBuiltIn\", \"ps3000aSetSigGenPropertiesBuiltIn\", c_uint32,\n                    [c_int16, c_double, c_double, c_double, c_double, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSigGenFrequencyToPhase\n    (\n        int16_t             handle,\n        double              frequency,\n        PS3000A_INDEX_MODE  indexMode,\n        uint32_t            bufferLength,\n        uint32_t           *phase\n    ); \"\"\"\nps3000a.make_symbol(\"_SigGenFrequencyToPhase\", \"ps3000aSigGenFrequencyToPhase\", c_uint32,\n                    [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSigGenArbitraryMinMaxValues\n    (\n        int16_t   handle,\n        int16_t  *minArbitraryWaveformValue,\n        int16_t  *maxArbitraryWaveformValue,\n        uint32_t *minArbitraryWaveformSize,\n        uint32_t *maxArbitraryWaveformSize\n    ); \"\"\"\nps3000a.make_symbol(\"_SigGenArbitraryMinMaxValues\", \"ps3000aSigGenArbitraryMinMaxValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetMaxEtsValues\n    (\n        int16_t  handle,\n        int16_t *etsCycles,\n        int16_t *etsInterleave\n    ); \"\"\"\nps3000a.make_symbol(\"_GetMaxEtsValues\", \"ps3000aGetMaxEtsValues\", c_uint32, [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSigGenSoftwareControl\n    (\n        int16_t  handle,\n        int16_t  state\n    ); \"\"\"\nps3000a.make_symbol(\"_SigGenSoftwareControl\", \"ps3000aSigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetEts\n    (\n        int16_t           handle,\n        PS3000A_ETS_MODE  mode,\n        int16_t           etsCycles,\n        int16_t           etsInterleave,\n        int32_t          *sampleTimePicoseconds\n    ); \"\"\"\nps3000a.make_symbol(\"_SetEts\", \"ps3000aSetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetSimpleTrigger\n    (\n        int16_t                      handle,\n        int16_t                      enable,\n        PS3000A_CHANNEL              source,\n        int16_t                      threshold,\n        PS3000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     delay,\n        int16_t                      autoTrigger_ms\n    ); \"\"\"\nps3000a.make_symbol(\"_SetSimpleTrigger\", \"ps3000aSetSimpleTrigger\", c_uint32,\n                    [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetTriggerDigitalPortProperties\n    (\n        int16_t                             handle,\n        PS3000A_DIGITAL_CHANNEL_DIRECTIONS *directions,\n        int16_t                             nDirections\n    ); \"\"\"\nps3000a.make_symbol(\"_SetTriggerDigitalPortProperties\", \"ps3000aSetTriggerDigitalPortProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetPulseWidthDigitalPortProperties\n    (\n        int16_t                             handle,\n        PS3000A_DIGITAL_CHANNEL_DIRECTIONS *directions,\n        int16_t                             nDirections\n    ); \"\"\"\nps3000a.make_symbol(\"_SetPulseWidthDigitalPortProperties\", \"ps3000aSetPulseWidthDigitalPortProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetTriggerChannelProperties\n    (\n        int16_t                             handle,\n        PS3000A_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                             nChannelProperties,\n        int16_t                             auxOutputEnable,\n        int32_t                             autoTriggerMilliseconds\n    ); \"\"\"\nps3000a.make_symbol(\"_SetTriggerChannelProperties\", \"ps3000aSetTriggerChannelProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetTriggerChannelConditions\n    (\n        int16_t                     handle,\n        PS3000A_TRIGGER_CONDITIONS *conditions,\n        int16_t                     nConditions\n    ); \"\"\"\nps3000a.make_symbol(\"_SetTriggerChannelConditions\", \"ps3000aSetTriggerChannelConditions\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetTriggerChannelConditionsV2\n    (\n        int16_t                        handle,\n        PS3000A_TRIGGER_CONDITIONS_V2 *conditions,\n        int16_t                        nConditions\n    ); \"\"\"\nps3000a.make_symbol(\"_SetTriggerChannelConditionsV2\", \"ps3000aSetTriggerChannelConditionsV2\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetTriggerChannelDirections\n    (\n        int16_t                      handle,\n        PS3000A_THRESHOLD_DIRECTION  channelA,\n        PS3000A_THRESHOLD_DIRECTION  channelB,\n        PS3000A_THRESHOLD_DIRECTION  channelC,\n        PS3000A_THRESHOLD_DIRECTION  channelD,\n        PS3000A_THRESHOLD_DIRECTION  ext,\n        PS3000A_THRESHOLD_DIRECTION  aux\n    ); \"\"\"\nps3000a.make_symbol(\"_SetTriggerChannelDirections\", \"ps3000aSetTriggerChannelDirections\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay\n    ); \"\"\"\nps3000a.make_symbol(\"_SetTriggerDelay\", \"ps3000aSetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetPulseWidthQualifier\n    (\n        int16_t                      handle,\n        PS3000A_PWQ_CONDITIONS      *conditions,\n        int16_t                      nConditions,\n        PS3000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     lower,\n        uint32_t                     upper,\n        PS3000A_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps3000a.make_symbol(\"_SetPulseWidthQualifier\", \"ps3000aSetPulseWidthQualifier\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetPulseWidthQualifierV2\n    (\n        int16_t                      handle,\n        PS3000A_PWQ_CONDITIONS_V2   *conditions,\n        int16_t                      nConditions,\n        PS3000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     lower,\n        uint32_t                     upper,\n        PS3000A_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps3000a.make_symbol(\"_SetPulseWidthQualifierV2\", \"ps3000aSetPulseWidthQualifierV2\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aIsTriggerOrPulseWidthQualifierEnabled\n    (\n        int16_t  handle,\n        int16_t *triggerEnabled,\n        int16_t *pulseWidthQualifierEnabled\n    ); \"\"\"\nps3000a.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps3000aIsTriggerOrPulseWidthQualifierEnabled\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetTriggerTimeOffset64\n    (\n        int16_t             handle,\n        int64_t            *time,\n        PS3000A_TIME_UNITS *timeUnits,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps3000a.make_symbol(\"_GetTriggerTimeOffset\", \"ps3000aGetTriggerTimeOffset64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetValuesTriggerTimeOffsetBulk64\n    (\n        int16_t             handle,\n        int64_t            *times,\n        PS3000A_TIME_UNITS *timeUnits,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex\n    ); \"\"\"\nps3000a.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps3000aGetValuesTriggerTimeOffsetBulk64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t *nCaptures\n    ); \"\"\"\nps3000a.make_symbol(\"_GetNoOfCaptures\", \"ps3000aGetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetNoOfProcessedCaptures\n    (\n        int16_t   handle,\n        uint32_t *nProcessedCaptures\n    ); \"\"\"\nps3000a.make_symbol(\"_GetNoOfProcessedCaptures\", \"ps3000aGetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetDataBuffer\n    (\n        int16_t            handle,\n        int32_t            channelOrPort,\n        int16_t           *buffer,\n        int32_t            bufferLth,\n        uint32_t           segmentIndex,\n        PS3000a_RATIO_MODE mode\n    ); \"\"\"\nps3000a.make_symbol(\"_SetDataBuffer\", \"ps3000aSetDataBuffer\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetDataBuffers\n    (\n        int16_t            handle,\n        int32_t            channelOrPort,\n        int16_t           *bufferMax,\n        int16_t           *bufferMin,\n        int32_t            bufferLth,\n        uint32_t           segmentIndex,\n        PS3000a_RATIO_MODE mode\n    ); \"\"\"\nps3000a.make_symbol(\"_SetDataBuffers\", \"ps3000aSetDataBuffers\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aSetEtsTimeBuffer\n    (\n        int16_t    handle,\n        int64_t *buffer,\n        int32_t     bufferLth\n    ); \"\"\"\nps3000a.make_symbol(\"_SetEtsTimeBuffer\", \"ps3000aSetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aIsReady\n    (\n        int16_t  handle,\n        int16_t *ready\n    ); \"\"\"\nps3000a.make_symbol(\"_IsReady\", \"ps3000aIsReady\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aRunBlock\n    (\n        int16_t            handle,\n        int32_t            noOfPreTriggerSamples,\n        int32_t            noOfPostTriggerSamples,\n        uint32_t           timebase,\n        int16_t            oversample,\n        int32_t           *timeIndisposedMs,\n        uint32_t           segmentIndex,\n        ps3000aBlockReady  lpReady,\n        void              *pParameter\n    ); \"\"\"\nps3000a.make_symbol(\"_RunBlock\", \"ps3000aRunBlock\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_uint32, c_int16, c_void_p, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aRunStreaming\n    (\n        int16_t             handle,\n        uint32_t            *sampleInterval,\n        PS3000A_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t            maxPreTriggerSamples,\n        uint32_t            maxPostPreTriggerSamples,\n        int16_t             autoStop,\n        uint32_t            downSampleRatio,\n        PS3000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            overviewBufferSize\n    ); \"\"\"\nps3000a.make_symbol(\"_RunStreaming\", \"ps3000aRunStreaming\", c_uint32,\n                    [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetStreamingLatestValues\n    (\n        int16_t                handle,\n        ps3000aStreamingReady  lpPs3000aReady,\n        void                   *pParameter\n    ); \"\"\"\nps3000a.make_symbol(\"_GetStreamingLatestValues\", \"ps3000aGetStreamingLatestValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" void *ps3000aStreamingReady\n    (\n        int16_t   handle,\n        int32_t   noOfSamples,\n        uint32_t  startIndex,\n        int16_t   overflow,\n        uint32_t  triggerAt,\n        int16_t   triggered,\n        int16_t   autoStop,\n        void     *pParameter\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n\nps3000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                         c_int16,\n                                                         c_int32,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_int16,\n                                                         c_void_p)\n\nps3000a.StreamingReadyType.__doc__ = doc\n\ndoc = \"\"\" PICO_STATUS ps3000aNoOfStreamingValues\n    (\n        int16_t   handle,\n        uint32_t *noOfValues\n    ); \"\"\"\nps3000a.make_symbol(\"_NoOfStreamingValues\", \"ps3000aNoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetMaxDownSampleRatio\n(\n  int16_t               handle,\n  uint32_t       noOfUnaggreatedSamples,\n  uint32_t      *maxDownSampleRatio,\n  PS3000A_RATIO_MODE  downSampleRatioMode,\n  uint32_t      segmentIndex\n); \"\"\"\nps3000a.make_symbol(\"_GetMaxDownSampleRatio\", \"ps3000aGetMaxDownSampleRatio\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetValues\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS3000a_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps3000a.make_symbol(\"_GetValues\", \"ps3000aGetValues\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetValuesBulk\n    (\n        int16_t             handle,\n        uint32_t           *noOfSamples,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        uint32_t            downSampleRatio,\n        PS3000A_RATIO_MODE  downSampleRatioMode,\n        int16_t            *overflow\n    ); \"\"\"\nps3000a.make_symbol(\"_GetValuesBulk\", \"ps3000aGetValuesBulk\", c_uint32,\n                    [c_int16, c_void_p, c_uint32, c_uint32, c_uint32, c_int32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetValuesAsync\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t            noOfSamples,\n        uint32_t            downSampleRatio,\n        PS3000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        void               *lpDataReady,\n        void               *pParameter\n    ); \"\"\"\nps3000a.make_symbol(\"_GetValuesAsync\", \"ps3000aGetValuesAsync\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetValuesOverlapped\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS3000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps3000a.make_symbol(\"_GetValuesOverlapped\", \"ps3000aGetValuesOverlapped\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetValuesOverlappedBulk\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS3000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps3000a.make_symbol(\"_GetValuesOverlappedBulk\", \"ps3000aGetValuesOverlappedBulk\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetTriggerInfoBulk\n    (\n        int16_t               handle,\n        PS3000A_TRIGGER_INFO *triggerInfo,\n        uint32_t              fromSegmentIndex,\n        uint32_t              toSegmentIndex\n    ); \"\"\"\nps3000a.make_symbol(\"_GetTriggerInfoBulk\", \"ps3000aGetTriggerInfoBulk\", c_uint32,\n                    [c_int16, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aStop\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000a.make_symbol(\"_Stop\", \"ps3000aStop\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aHoldOff\n    (\n        int16_t               handle,\n        uint64_t              holdoff,\n        PS3000A_HOLDOFF_TYPE  type\n    ); \"\"\"\nps3000a.make_symbol(\"_HoldOff\", \"ps3000aHoldOff\", c_uint32, [c_int16, c_uint64, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetChannelInformation\n    (\n        int16_t               handle,\n        PS3000A_CHANNEL_INFO  info,\n        int32_t               probe,\n        int32_t              *ranges,\n        int32_t              *length,\n        int32_t               channels\n    ); \"\"\"\nps3000a.make_symbol(\"_GetChannelInformation\", \"ps3000aGetChannelInformation\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aEnumerateUnits\n    (\n        int16_t *count,\n        int8_t  *serials,\n        int16_t *serialLth\n    ); \"\"\"\nps3000a.make_symbol(\"_EnumerateUnits\", \"ps3000aEnumerateUnits\", c_uint32, [c_void_p, c_char_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aPingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps3000a.make_symbol(\"_PingUnit\", \"ps3000aPingUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aMaximumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps3000a.make_symbol(\"_MaximumValue\", \"ps3000aMaximumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\"\" PICO_STATUS ps3000aMinimumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps3000a.make_symbol(\"_MinimumValue\", \"ps3000aMinimumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetAnalogueOffset\n    (\n        int16_t           handle,\n        PS3000A_RANGE     range,\n        PS3000A_COUPLING  coupling,\n        float            *maximumVoltage,\n        float            *minimumVoltage\n    ); \"\"\"\nps3000a.make_symbol(\"_GetAnalogueOffset\", \"ps3000aGetAnalogueOffset\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aGetMaxSegments\n    (\n        int16_t   handle,\n        uint32_t *maxSegments\n    ); \"\"\"\nps3000a.make_symbol(\"_GetMaxSegments\", \"ps3000aGetMaxSegments\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aChangePowerSource\n    (\n        int16_t     handle,\n        PICO_STATUS powerState\n    ); \"\"\"\nps3000a.make_symbol(\"_ChangePowerSource\", \"ps3000aChangePowerSource\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps3000aCurrentPowerSource\n    (\n        int16_t handle\n    ); \"\"\"\nps3000a.make_symbol(\"_CurrentPowerSource\", \"ps3000aCurrentPowerSource\", c_uint32, [c_int16, c_uint32], doc)\n\nps3000a.INI_LOGIC_VOLTS = 1.5\n"
  },
  {
    "path": "picosdk/ps4000.py",
    "content": "#\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps4000Api.h C header\nfile for PicoScope 4000 Series oscilloscopes using the ps4000 driver API\nfunctions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\nfrom picosdk.library import Library\nfrom picosdk.constants import make_enum\n\n\nclass Ps4000lib(Library):\n    def __init__(self):\n        super(Ps4000lib, self).__init__(\"ps4000\")\n\n\nps4000 = Ps4000lib()\n\n# This field is passed to the driver as a boolean, not an enum.\nps4000.PICO_COUPLING = {\n    'AC': 0,\n    'DC': 1\n}\n\n# A tuple in an enum like this is 2 names for the same value.\nps4000.PS4000_CHANNEL = make_enum([\n    \"PS4000_CHANNEL_A\",\n    \"PS4000_CHANNEL_B\",\n    \"PS4000_CHANNEL_C\",\n    \"PS4000_CHANNEL_D\",\n    (\"PS4000_EXTERNAL\", \"PS4000_MAX_CHANNELS\"),\n    \"PS4000_TRIGGER_AUX\",\n    \"PS4000_MAX_TRIGGER_SOURCE\",\n])\n\n# only include the normal analog channels for now:\nps4000.PICO_CHANNEL = {k[-1]: v for k, v in ps4000.PS4000_CHANNEL.items() if \"PS4000_CHANNEL_\" in k}\n\nps4000.PS4000_RANGE = make_enum([\n    \"PS4000_10MV\",\n    \"PS4000_20MV\",\n    \"PS4000_50MV\",\n    \"PS4000_100MV\",\n    \"PS4000_200MV\",\n    \"PS4000_500MV\",\n    \"PS4000_1V\",\n    \"PS4000_2V\",\n    \"PS4000_5V\",\n    \"PS4000_10V\",\n    \"PS4000_20V\",\n    \"PS4000_50V\",\n    \"PS4000_100V\",\n    (\"PS4000_RESISTANCE_100R\", \"PS4000_MAX_RANGES\"),\n    \"PS4000_RESISTANCE_1K\",\n    \"PS4000_RESISTANCE_10K\",\n    \"PS4000_RESISTANCE_100K\",\n    \"PS4000_RESISTANCE_1M\",\n    (\"PS4000_ACCELEROMETER_10MV\", \"PS4000_MAX_RESISTANCES\"),\n    \"PS4000_ACCELEROMETER_20MV\",\n    \"PS4000_ACCELEROMETER_50MV\",\n    \"PS4000_ACCELEROMETER_100MV\",\n    \"PS4000_ACCELEROMETER_200MV\",\n    \"PS4000_ACCELEROMETER_500MV\",\n    \"PS4000_ACCELEROMETER_1V\",\n    \"PS4000_ACCELEROMETER_2V\",\n    \"PS4000_ACCELEROMETER_5V\",\n    \"PS4000_ACCELEROMETER_10V\",\n    \"PS4000_ACCELEROMETER_20V\",\n    \"PS4000_ACCELEROMETER_50V\",\n    \"PS4000_ACCELEROMETER_100V\",\n    (\"PS4000_TEMPERATURE_UPTO_40\", \"PS4000_MAX_ACCELEROMETER\"),\n    \"PS4000_TEMPERATURE_UPTO_70\",\n    \"PS4000_TEMPERATURE_UPTO_100\",\n    \"PS4000_TEMPERATURE_UPTO_130\",\n    (\"PS4000_RESISTANCE_5K\", \"PS4000_MAX_TEMPERATURES\"),\n    \"PS4000_RESISTANCE_25K\",\n    \"PS4000_RESISTANCE_50K\",\n    \"PS4000_MAX_EXTRA_RESISTANCES\",\n])\n\n\ndef process_enum(enum):\n    \"\"\"The PS4000 range enum is complicated enough that we need some clearer logic:\"\"\"\n    import re\n    pattern = re.compile(r'PS4000_([0-9]+M?)V')\n\n    voltage_range = {}\n\n    for enum_item_name, enum_item_value in enum.items():\n        match = pattern.match(enum_item_name)\n        if match is None:\n            continue\n        voltage_string = match.group(1)\n        voltage = float(voltage_string) if voltage_string[-1] != 'M' else (0.001 * float(voltage_string[:-1]))\n\n        voltage_range[enum_item_value] = voltage\n\n    return voltage_range\n\n\nps4000.PICO_VOLTAGE_RANGE = process_enum(ps4000.PS4000_RANGE)\n\nps4000.PS4000_TIME_UNITS = make_enum([\n    'PS4000_FS',\n    'PS4000_PS',\n    'PS4000_NS',\n    'PS4000_US',\n    'PS4000_MS',\n    'PS4000_S',\n    'PS4000_MAX_TIME_UNITS',\n])\n\ndoc = \"\"\" PICO_STATUS ps4000OpenUnit\n    (\n        int16_t *handle\n    ); \"\"\"\nps4000.make_symbol(\"_OpenUnit0\", \"ps4000OpenUnit\", c_uint32, [c_void_p, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000OpenUnitAsync\n    (\n        int16_t *status\n    ); \"\"\"\nps4000.make_symbol(\"_OpenUnitAsync0\", \"ps4000OpenUnitAsync\", c_uint32, [c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000OpenUnitEx\n    (\n        int16_t *handle,\n        int8_t  *serial\n    ); \"\"\"\nps4000.make_symbol(\"_OpenUnit\", \"ps4000OpenUnitEx\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000OpenUnitAsyncEx\n    (\n        int16_t *status,\n        int8_t  *serial\n    ); \"\"\"\nps4000.make_symbol(\"_OpenUnitAsync\", \"ps4000OpenUnitAsync\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000OpenUnitProgress\n    (\n        int16_t *handle,\n        int16_t *progressPercent,\n        int16_t *complete\n    ); \"\"\"\nps4000.make_symbol(\"_OpenUnitProgress\", \"ps4000OpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetUnitInfo\n    (\n        int16_t    handle,\n        int8_t    *string,\n        int16_t    stringLength,\n        int16_t   *requiredSize,\n        PICO_INFO  info\n    ); \"\"\"\nps4000.make_symbol(\"_GetUnitInfo\", \"ps4000GetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000FlashLed\n    (\n        int16_t  handle,\n        int16_t  start\n    ); \"\"\"\nps4000.make_symbol(\"_FlashLed\", \"ps4000FlashLed\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000IsLedFlashing\n    (\n        int16_t  handle,\n        int16_t *status\n    ); \"\"\"\nps4000.make_symbol(\"_IsLedFlashing\", \"ps4000IsLedFlashing\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000CloseUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000.make_symbol(\"_CloseUnit\", \"ps4000CloseUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000MemorySegments\n    (\n        int16_t   handle,\n        uint16_t  nSegments,\n        int32_t  *nMaxSamples\n    ); \"\"\"\nps4000.make_symbol(\"_MemorySegments\", \"ps4000MemorySegments\", c_uint32, [c_int16, c_uint16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetChannel\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t         enabled,\n        int16_t         dc,\n        PS4000_RANGE    range\n    ); \"\"\"\nps4000.make_symbol(\"_SetChannel\", \"ps4000SetChannel\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetNoOfCaptures\n    (\n        int16_t   handle,\n        uint16_t  nCaptures\n    ); \"\"\"\nps4000.make_symbol(\"_SetNoOfCaptures\", \"ps4000SetNoOfCaptures\", c_uint32, [c_int16, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetTimebase\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        int32_t  *timeIntervalNanoseconds,\n        int16_t   oversample,\n        int32_t  *maxSamples,\n        uint16_t  segmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetTimebase\", \"ps4000GetTimebase\", c_uint32,\n                   [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetTimebase2\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        float    *timeIntervalNanoseconds,\n        int16_t   oversample,\n        int32_t  *maxSamples,\n        uint16_t  segmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetTimebase2\", \"ps4000GetTimebase2\", c_uint32,\n                   [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SigGenOff\n    (\n        int16_t handle\n    ); \"\"\"\nps4000.make_symbol(\"_SigGenOff\", \"ps4000SigGenOff\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetSigGenArbitrary\n    (\n        int16_t             handle,\n        int32_t             offsetVoltage,\n        uint32_t            pkToPk,\n        uint32_t            startDeltaPhase,\n        uint32_t            stopDeltaPhase,\n        uint32_t            deltaPhaseIncrement,\n        uint32_t            dwellCount,\n        int16_t            *arbitraryWaveform,\n        int32_t             arbitraryWaveformSize,\n        SWEEP_TYPE          sweepType,\n        int16_t             operationType,\n        INDEX_MODE          indexMode,\n        uint32_t            shots,\n        uint32_t            sweeps,\n        SIGGEN_TRIG_TYPE    triggerType,\n        SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t             extInThreshold\n    ); \"\"\"\nps4000.make_symbol(\"_SetSigGenArbitrary\", \"ps4000SetSigGenArbitrary\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p,\n                    c_int32, c_int32, c_int16, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetSigGenBuiltIn\n    (\n        int16_t             handle,\n        int32_t             offsetVoltage,\n        uint32_t            pkToPk,\n        int16_t             waveType,\n        float               startFrequency,\n        float               stopFrequency,\n        float               increment,\n        float               dwellTime,\n        SWEEP_TYPE          sweepType,\n        int16_t             operationType,\n        uint32_t            shots,\n        uint32_t            sweeps,\n        SIGGEN_TRIG_TYPE    triggerType,\n        SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t             extInThreshold\n    ); \"\"\"\nps4000.make_symbol(\"_SetSigGenBuiltIn\", \"ps4000SetSigGenBuiltIn\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_int16, c_float, c_float, c_float, c_float,\n                    c_int32, c_int16, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SigGenFrequencyToPhase\n    (\n        int16_t     handle,\n        double      frequency,\n        INDEX_MODE  indexMode,\n        uint32_t    bufferLength,\n        uint32_t   *phase\n    ); \"\"\"\nps4000.make_symbol(\"_SigGenFrequencyToPhase\", \"ps4000SigGenFrequencyToPhase\", c_uint32,\n                   [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SigGenArbitraryMinMaxValues\n    (\n        int16_t   handle,\n        int16_t  *minArbitraryWaveformValue,\n        int16_t  *maxArbitraryWaveformValue,\n        uint32_t *minArbitraryWaveformSize,\n        uint32_t *maxArbitraryWaveformSize\n    ); \"\"\"\nps4000.make_symbol(\"_SigGenArbitraryMinMaxValues\", \"ps4000SigGenArbitraryMinMaxValues\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SigGenSoftwareControl\n    (\n        int16_t  handle,\n        int16_t  state\n    ); \"\"\"\nps4000.make_symbol(\"_SigGenSoftwareControl\", \"ps4000SigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetEts\n    (\n        int16_t          handle,\n        PS4000_ETS_MODE  mode,\n        int16_t          etsCycles,\n        int16_t          etsInterleave,\n        int32_t         *sampleTimePicoseconds\n    ); \"\"\"\nps4000.make_symbol(\"_SetEts\", \"ps4000SetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetSimpleTrigger\n    (\n        int16_t              handle,\n        int16_t              enable,\n        PS4000_CHANNEL       source,\n        int16_t              threshold,\n        THRESHOLD_DIRECTION  direction,\n        uint32_t             delay,\n        int16_t              autoTrigger_ms\n    ); \"\"\"\nps4000.make_symbol(\"_SetSimpleTrigger\", \"ps4000SetSimpleTrigger\", c_uint32,\n                   [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetTriggerChannelProperties\n    (\n        int16_t                     handle,\n        TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                     nChannelProperties,\n        int16_t                     auxOutputEnable,\n        int32_t                     autoTriggerMilliseconds\n    ); \"\"\"\nps4000.make_symbol(\"_SetTriggerChannelProperties\", \"ps4000SetTriggerChannelProperties\", c_uint32,\n                   [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetExtTriggerRange\n    (\n        int16_t       handle,\n        PS4000_RANGE  extRange\n    ); \"\"\"\nps4000.make_symbol(\"_SetExtTriggerRange\", \"ps4000SetExtTriggerRange\", c_uint32, [c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetTriggerChannelConditions\n    (\n        int16_t             handle,\n        TRIGGER_CONDITIONS *conditions,\n        int16_t             nConditions\n    ); \"\"\"\nps4000.make_symbol(\"_SetTriggerChannelConditions\", \"ps4000SetTriggerChannelConditions\", c_uint32,\n                   [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetTriggerChannelDirections\n    (\n        int16_t              handle,\n        THRESHOLD_DIRECTION  channelA,\n        THRESHOLD_DIRECTION  channelB,\n        THRESHOLD_DIRECTION  channelC,\n        THRESHOLD_DIRECTION  channelD,\n        THRESHOLD_DIRECTION  ext,\n        THRESHOLD_DIRECTION  aux\n    ); \"\"\"\nps4000.make_symbol(\"_SetTriggerChannelDirections\", \"ps4000SetTriggerChannelDirections\", c_uint32,\n                   [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay\n    ); \"\"\"\nps4000.make_symbol(\"_SetTriggerDelay\", \"ps4000SetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetPulseWidthQualifier\n    (\n        int16_t              handle,\n        PWQ_CONDITIONS      *conditions,\n        int16_t              nConditions,\n        THRESHOLD_DIRECTION  direction,\n        uint32_t             lower,\n        uint32_t             upper,\n        PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps4000.make_symbol(\"_SetPulseWidthQualifier\", \"ps4000SetPulseWidthQualifier\", c_uint32,\n                   [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000IsTriggerOrPulseWidthQualifierEnabled\n    (\n        int16_t  handle,\n        int16_t *triggerEnabled,\n        int16_t *pulseWidthQualifierEnabled\n    ); \"\"\"\nps4000.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps4000IsTriggerOrPulseWidthQualifierEnabled\", c_uint32,\n                   [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetTriggerTimeOffset\n    (\n        int16_t            handle,\n        uint32_t          *timeUpper,\n        uint32_t          *timeLower,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           segmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetTriggerTimeOffset0\", \"ps4000GetTriggerTimeOffset\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetTriggerChannelTimeOffset\n    (\n        int16_t            handle,\n        uint32_t          *timeUpper,\n        uint32_t          *timeLower,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           segmentIndex,\n        PS4000_CHANNEL     channel\n    ); \"\"\"\nps4000.make_symbol(\"_GetTriggerChannelTimeOffset0\", \"ps4000GetTriggerChannelTimeOffset\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_uint16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetTriggerTimeOffset64\n    (\n        int16_t            handle,\n        int64_t           *time,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           segmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetTriggerTimeOffset\", \"ps4000GetTriggerTimeOffset64\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetTriggerChannelTimeOffset64\n    (\n        int16_t            handle,\n        int64_t           *time,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           segmentIndex,\n        PS4000_CHANNEL     channel\n    ); \"\"\"\nps4000.make_symbol(\"_GetTriggerChannelTimeOffset64\", \"ps4000GetTriggerChannelTimeOffset64\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_uint16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValuesTriggerTimeOffsetBulk\n    (\n        int16_t            handle,\n        uint32_t          *timesUpper,\n        uint32_t          *timesLower,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           fromSegmentIndex,\n        uint16_t           toSegmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetValuesTriggerTimeOffsetBulk0\", \"ps4000GetValuesTriggerTimeOffsetBulk\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_uint16, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValuesTriggerChannelTimeOffsetBulk\n    (\n        int16_t            handle,\n        uint32_t          *timesUpper,\n        uint32_t          *timesLower,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           fromSegmentIndex,\n        uint16_t           toSegmentIndex,\n        PS4000_CHANNEL     channel\n    ); \"\"\"\nps4000.make_symbol(\"_GetValuesTriggerChannelTimeOffsetBulk0\", \"ps4000GetValuesTriggerChannelTimeOffsetBulk\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_uint16, c_uint16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValuesTriggerTimeOffsetBulk64\n    (\n        int16_t            handle,\n        int64_t           *times,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           fromSegmentIndex,\n        uint16_t           toSegmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps4000GetValuesTriggerTimeOffsetBulk64\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_uint16, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValuesTriggerChannelTimeOffsetBulk64\n    (\n        int16_t            handle,\n        int64_t           *times,\n        PS4000_TIME_UNITS *timeUnits,\n        uint16_t           fromSegmentIndex,\n        uint16_t           toSegmentIndex,\n        PS4000_CHANNEL     channel\n    ); \"\"\"\nps4000.make_symbol(\"_GetValuesTriggerChannelTimeOffsetBulk\", \"ps4000GetValuesTriggerChannelTimeOffsetBulk64\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_uint16, c_uint16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetDataBufferBulk\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t        *buffer,\n        int32_t         bufferLth,\n        uint16_t        waveform\n    ); \"\"\"\nps4000.make_symbol(\"_SetDataBufferBulk\", \"ps4000SetDataBufferBulk\", c_uint32,\n                   [c_int16, c_int32, c_void_p, c_int32, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetDataBuffers\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t        *bufferMax,\n        int16_t        *bufferMin,\n        int32_t         bufferLth\n    ); \"\"\"\nps4000.make_symbol(\"_SetDataBuffers\", \"ps4000SetDataBuffers\", c_uint32, [c_int16, c_int32, c_void_p, c_void_p, c_int32],\n                   doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetDataBufferWithMode\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t        *buffer,\n        int32_t         bufferLth,\n        RATIO_MODE      mode\n    ); \"\"\"\nps4000.make_symbol(\"_SetDataBufferWithMode\", \"ps4000SetDataBufferWithMode\", c_uint32,\n                   [c_int16, c_int32, c_void_p, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetDataBuffersWithMode\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t        *bufferMax,\n        int16_t        *bufferMin,\n        int32_t         bufferLth,\n        RATIO_MODE      mode\n    ); \"\"\"\nps4000.make_symbol(\"_SetDataBuffersWithMode\", \"ps4000SetDataBuffersWithMode\", c_uint32,\n                   [c_int16, c_int32, c_void_p, c_void_p, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetDataBuffer\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t        *buffer,\n        int32_t         bufferLth\n    ); \"\"\"\nps4000.make_symbol(\"_SetDataBuffer\", \"ps4000SetDataBuffer\", c_uint32, [c_int16, c_int32, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetEtsTimeBuffer\n    (\n        int16_t  handle,\n        int64_t *buffer,\n        int32_t  bufferLth\n    ); \"\"\"\nps4000.make_symbol(\"_SetEtsTimeBuffer\", \"ps4000SetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetEtsTimeBuffers\n    (\n        int16_t   handle,\n        uint32_t *timeUpper,\n        uint32_t *timeLower,\n        int32_t   bufferLth\n    ); \"\"\"\nps4000.make_symbol(\"_SetEtsTimeBuffers\", \"ps4000SetEtsTimeBuffers\", c_uint32, [c_int16, c_void_p, c_void_p, c_int32],\n                   doc)\n\ndoc = \"\"\" PICO_STATUS ps4000RunBlock\n    (\n        int16_t           handle,\n        int32_t           noOfPreTriggerSamples,\n        int32_t           noOfPostTriggerSamples,\n        uint32_t          timebase,\n        int16_t           oversample,\n        int32_t          *timeIndisposedMs,\n        uint16_t          segmentIndex,\n        ps4000BlockReady  lpReady,\n        void             *pParameter\n    ); \"\"\"\nps4000.make_symbol(\"_RunBlock\", \"ps4000RunBlock\", c_uint32,\n                   [c_int16, c_int32, c_int32, c_uint32, c_int16, c_void_p, c_uint16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000RunStreaming\n    (\n        int16_t            handle,\n        uint32_t          *sampleInterval,\n        PS4000_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t           maxPreTriggerSamples,\n        uint32_t           maxPostPreTriggerSamples,\n        int16_t            autoStop,\n        uint32_t           downSampleRatio,\n        uint32_t           overviewBufferSize\n    ); \"\"\"\nps4000.make_symbol(\"_RunStreaming\", \"ps4000RunStreaming\", c_uint32,\n                   [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000RunStreamingEx\n    (\n        int16_t            handle,\n        uint32_t          *sampleInterval,\n        PS4000_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t           maxPreTriggerSamples,\n        uint32_t           maxPostPreTriggerSamples,\n        int16_t            autoStop,\n        uint32_t           downSampleRatio,\n        int16_t            downSampleRatioMode,\n        uint32_t           overviewBufferSize\n    ); \"\"\"\nps4000.make_symbol(\"_RunStreamingEx\", \"ps4000RunStreamingEx\", c_uint32,\n                   [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000IsReady\n    (\n        int16_t handle,\n        int16_t * ready\n    ); \"\"\"\nps4000.make_symbol(\"_IsReady\", \"ps4000IsReady\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetStreamingLatestValues\n    (\n        int16_t               handle,\n        ps4000StreamingReady  lpPs4000Ready,\n        void                 *pParameter\n    ); \"\"\"\nps4000.make_symbol(\"_GetStreamingLatestValues\", \"ps4000GetStreamingLatestValues\", c_uint32,\n                   [c_int16, c_void_p, c_void_p], doc)\n\t\t\t\t   \ndoc = \"\"\" void *ps4000StreamingReady\n    (\n        int16_t   handle,\n        int32_t   noOfSamples,\n        uint32_t  startIndex,\n        int16_t   overflow,\n        uint32_t  triggerAt,\n        int16_t   triggered,\n        int16_t   autoStop,\n        void     *pParameter\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n\nps4000.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                         c_int16,\n                                                         c_int32,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_int16,\n                                                         c_void_p)\n\nps4000.StreamingReadyType.__doc__ = doc\n\ndoc = \"\"\" PICO_STATUS ps4000NoOfStreamingValues\n    (\n        int16_t   handle,\n        uint32_t *noOfValues\n    ); \"\"\"\nps4000.make_symbol(\"_NoOfStreamingValues\", \"ps4000NoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetMaxDownSampleRatio\n    (\n        int16_t   handle,\n        uint32_t  noOfUnaggreatedSamples,\n        uint32_t *maxDownSampleRatio,\n        int16_t   downSampleRatioMode,\n        uint16_t  segmentIndex\n    ); \"\"\"\nps4000.make_symbol(\"_GetMaxDownSampleRatio\", \"ps4000GetMaxDownSampleRatio\", c_uint32,\n                   [c_int16, c_uint32, c_void_p, c_int16, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValues\n    (\n        int16_t   handle,\n        uint32_t  startIndex,\n        uint32_t *noOfSamples,\n        uint32_t  downSampleRatio,\n        int16_t   downSampleRatioMode,\n        uint16_t  segmentIndex,\n        int16_t  *overflow\n    ); \"\"\"\nps4000.make_symbol(\"_GetValues\", \"ps4000GetValues\", c_uint32,\n                   [c_int16, c_uint32, c_void_p, c_uint32, c_int16, c_uint16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValuesBulk\n    (\n        int16_t   handle,\n        uint32_t *noOfSamples,\n        uint16_t  fromSegmentIndex,\n        uint16_t  toSegmentIndex,\n        int16_t  *overflow\n    ); \"\"\"\nps4000.make_symbol(\"_GetValuesBulk\", \"ps4000GetValuesBulk\", c_uint32, [c_int16, c_void_p, c_uint16, c_uint16, c_void_p],\n                   doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetValuesAsync\n    (\n        int16_t   handle,\n        uint32_t  startIndex,\n        uint32_t  noOfSamples,\n        uint32_t  downSampleRatio,\n        int16_t   downSampleRatioMode,\n        uint16_t  segmentIndex,\n        void     *lpDataReady,\n        void     *pParameter\n    ); \"\"\"\nps4000.make_symbol(\"_GetValuesAsync\", \"ps4000GetValuesAsync\", c_uint32,\n                   [c_int16, c_uint32, c_uint32, c_uint32, c_int16, c_uint16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000Stop\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000.make_symbol(\"_Stop\", \"ps4000Stop\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetProbe\n    (\n        int16_t       handle,\n        PS4000_PROBE  probe,\n        PS4000_RANGE  range\n    ); \"\"\"\nps4000.make_symbol(\"_SetProbe\", \"ps4000SetProbe\", c_uint32, [c_int16, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000HoldOff\n    (\n        int16_t              handle,\n        uint64_t             holdoff,\n        PS4000_HOLDOFF_TYPE  type\n    ); \"\"\"\nps4000.make_symbol(\"_HoldOff\", \"ps4000HoldOff\", c_uint32, [c_int16, c_uint64, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetProbe\n    (\n        int16_t       handle,\n        PS4000_PROBE *probe\n    ); \"\"\"\nps4000.make_symbol(\"_GetProbe\", \"ps4000GetProbe\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetChannelInformation\n    (\n        int16_t              handle,\n        PS4000_CHANNEL_INFO  info,\n        int32_t              probe,\n        int32_t             *ranges,\n        int32_t             *length,\n        int32_t              channels\n    ); \"\"\"\nps4000.make_symbol(\"_GetChannelInformation\", \"ps4000GetChannelInformation\", c_uint32,\n                   [c_int16, c_int32, c_int32, c_void_p, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetFrequencyCounter\n    (\n        int16_t                         handle,\n        PS4000_CHANNEL                  channel,\n        int16_t                         enabled,\n        PS4000_FREQUENCY_COUNTER_RANGE  range,\n        int16_t                         thresholdMajor,\n        int16_t                         thresholdMinor\n    ); \"\"\"\nps4000.make_symbol(\"_SetFrequencyCounter\", \"ps4000SetFrequencyCounter\", c_uint32,\n                   [c_int16, c_int32, c_int16, c_int32, c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000EnumerateUnits\n    (\n        int16_t *count,\n        int8_t  *serials,\n        int16_t *serialLth\n    ); \"\"\"\nps4000.make_symbol(\"_EnumerateUnits\", \"ps4000EnumerateUnits\", c_uint32, [c_void_p, c_char_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000PingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000.make_symbol(\"_PingUnit\", \"ps4000PingUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000SetBwFilter\n    (\n        int16_t         handle,\n        PS4000_CHANNEL  channel,\n        int16_t         enable\n    ); \"\"\"\nps4000.make_symbol(\"_SetBwFilter\", \"ps4000SetBwFilter\", c_uint32, [c_int16, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000TriggerWithinPreTriggerSamples\n    (\n        int16_t  handle,\n        int16_t  state\n    ); \"\"\"\nps4000.make_symbol(\"_TriggerWithinPreTriggerSamples\", \"ps4000TriggerWithinPreTriggerSamples\", c_uint32,\n                   [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000GetNoOfCaptures\n    (\n        int16_t   handle,\n        uint16_t *nCaptures\n    ); \"\"\"\nps4000.make_symbol(\"_GetNoOfCaptures\", \"ps4000GetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\n"
  },
  {
    "path": "picosdk/ps4000a.py",
    "content": "#\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps4000aApi.h C header\nfile for PicoScope 4000 Series oscilloscopes using the ps4000a driver API\nfunctions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.library import Library\nfrom picosdk.constants import make_enum\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\n\nclass Ps4000alib(Library):\n    def __init__(self):\n        super(Ps4000alib, self).__init__(\"ps4000a\")\n\n\nps4000a = Ps4000alib()\n\nps4000a.PS4000A_BANDWIDTH_LIMITER = make_enum([\n    'PS4000A_BW_FULL',\n    'PS4000A_BW_20KHZ',\n    'PS4000A_BW_100KHZ',\n    'PS4000A_BW_1MHZ',\n])\n\nps4000a.PS4000A_COUPLING = make_enum([\n    'PS4000A_AC',\n    'PS4000A_DC',\n])\n\n# Just use AC and DC.\nps4000a.PICO_COUPLING = {k[-2:]: v for k, v in ps4000a.PS4000A_COUPLING.items()}\n\n# A tuple in an enum like this is 2 names for the same value.\nps4000a.PS4000A_CHANNEL = {\n    \"PS4000A_CHANNEL_A\" : 0,\n    \"PS4000A_CHANNEL_B\" : 1,\n    \"PS4000A_CHANNEL_C\" : 2,\n    \"PS4000A_CHANNEL_D\" : 3,\n    (\"PS4000A_CHANNEL_E\", \"PS4000A_MAX_4_CHANNELS\") : 4,\n    \"PS4000A_CHANNEL_F\" : 5,\n    \"PS4000A_CHANNEL_G\" : 6 ,\n    \"PS4000A_CHANNEL_H\" : 7,\n    (\"PS4000A_MAX_CHANNELS\", \"PS4000A_EXTERNAL\") : 8,\n    \"PS4000A_TRIGGER_AUX\" : 9,\n    \"PS4000A_MAX_TRIGGER_SOURCES\" : 10,\n    \"PS4000A_PULSE_WIDTH_SOURCE\" : 0x10000000\n}\n\nps4000a.PICO_CHANNEL = {k[19:]: v for k, v in ps4000a.PS4000A_CHANNEL.items()}\n\n\n\n# The voltage ranges for this driver are so oddly defined, that it is easier to describe them as a literal than trying\n# to use make_enum:\n\ndef _define_ranges():\n    # These are lower case to keep the python style police happy. They are available in the range dictionary with their\n    # usual upper case names precisely as in the C header file.\n    pico_x1_probe_10mv = 0\n    pico_x1_probe_20mv = 1\n    pico_x1_probe_50mv = 2\n    pico_x1_probe_100mv = 3\n    pico_x1_probe_200mv = 4\n    pico_x1_probe_500mv = 5\n    pico_x1_probe_1v = 6\n    pico_x1_probe_2v = 7\n    pico_x1_probe_5v = 8\n    pico_x1_probe_10v = 9\n    pico_x1_probe_20v = 10\n    pico_x1_probe_50v = 11\n    pico_x1_probe_100v = 12\n    pico_x1_probe_200v = 13\n    pico_x1_probe_ranges = (pico_x1_probe_200v + 1) - pico_x1_probe_10mv\n\n    pico_ps4000a_resistance_315k = 0x00000200\n    pico_ps4000a_resistance_1100k = pico_ps4000a_resistance_315k + 1\n    pico_ps4000a_resistance_10m = pico_ps4000a_resistance_315k + 2\n    pico_ps4000a_max_resistance_ranges = (pico_ps4000a_resistance_10m + 1) - pico_ps4000a_resistance_315k\n    pico_ps4000a_resistance_adcv_flag = 0x10000000\n\n    pico_connect_probe_off = 1024\n\n    pico_d9_bnc_10mv = 0\n    pico_d9_bnc_20mv = 1\n    pico_d9_bnc_50mv = 2\n    pico_d9_bnc_100mv = 3\n    pico_d9_bnc_200mv = 4\n    pico_d9_bnc_500mv = 5\n    pico_d9_bnc_1v = 6\n    pico_d9_bnc_2v = 7\n    pico_d9_bnc_5v = 8\n    pico_d9_bnc_10v = 9\n    pico_d9_bnc_20v = 10\n    pico_d9_bnc_50v = 11\n    pico_d9_bnc_100v = 12\n    pico_d9_bnc_200v = 13\n    pico_max_d9_bnc_ranges = (pico_d9_bnc_200v + 1) - pico_d9_bnc_10mv\n\n    pico_d9_2x_bnc_10mv = pico_d9_bnc_10mv\n    pico_d9_2x_bnc_20mv = pico_d9_bnc_20mv\n    pico_d9_2x_bnc_50mv = pico_d9_bnc_50mv\n    pico_d9_2x_bnc_100mv = pico_d9_bnc_100mv\n    pico_d9_2x_bnc_200mv = pico_d9_bnc_200mv\n    pico_d9_2x_bnc_500mv = pico_d9_bnc_500mv\n    pico_d9_2x_bnc_1v = pico_d9_bnc_1v\n    pico_d9_2x_bnc_2v = pico_d9_bnc_2v\n    pico_d9_2x_bnc_5v = pico_d9_bnc_5v\n    pico_d9_2x_bnc_10v = pico_d9_bnc_10v\n    pico_d9_2x_bnc_20v = pico_d9_bnc_20v\n    pico_d9_2x_bnc_50v = pico_d9_bnc_50v\n    pico_d9_2x_bnc_100v = pico_d9_bnc_100v\n    pico_d9_2x_bnc_200v = pico_d9_bnc_200v\n    pico_max_d9_2x_bnc_ranges = (pico_d9_2x_bnc_200v + 1) - pico_d9_2x_bnc_10mv\n\n    pico_differential_10mv = pico_d9_bnc_10mv\n    pico_differential_20mv = pico_d9_bnc_20mv\n    pico_differential_50mv = pico_d9_bnc_50mv\n    pico_differential_100mv = pico_d9_bnc_100mv\n    pico_differential_200mv = pico_d9_bnc_200mv\n    pico_differential_500mv = pico_d9_bnc_500mv\n    pico_differential_1v = pico_d9_bnc_1v\n    pico_differential_2v = pico_d9_bnc_2v\n    pico_differential_5v = pico_d9_bnc_5v\n    pico_differential_10v = pico_d9_bnc_10v\n    pico_differential_20v = pico_d9_bnc_20v\n    pico_differential_50v = pico_d9_bnc_50v\n    pico_differential_100v = pico_d9_bnc_100v\n    pico_differential_200v = pico_d9_bnc_200v\n    pico_max_differential_ranges = (pico_differential_200v + 1) - pico_differential_10mv,\n\n    pico_current_clamp_200a_2ka_1a = 4000\n    pico_current_clamp_200a_2ka_2a = pico_current_clamp_200a_2ka_1a + 1\n    pico_current_clamp_200a_2ka_5a = pico_current_clamp_200a_2ka_1a + 2\n    pico_current_clamp_200a_2ka_10a = pico_current_clamp_200a_2ka_1a + 3\n    pico_current_clamp_200a_2ka_20a = pico_current_clamp_200a_2ka_1a + 4\n    pico_current_clamp_200a_2ka_50a = pico_current_clamp_200a_2ka_1a + 5\n    pico_current_clamp_200a_2ka_100a = pico_current_clamp_200a_2ka_1a + 6\n    pico_current_clamp_200a_2ka_200a = pico_current_clamp_200a_2ka_1a + 7\n    pico_current_clamp_200a_2ka_500a = pico_current_clamp_200a_2ka_1a + 8\n    pico_current_clamp_200a_2ka_1000a = pico_current_clamp_200a_2ka_1a + 9\n    pico_current_clamp_200a_2ka_2000a = pico_current_clamp_200a_2ka_1a + 10\n    pico_max_current_clamp_200a_2ka_ranges = (pico_current_clamp_200a_2ka_2000a + 1) - pico_current_clamp_200a_2ka_1a\n\n    pico_current_clamp_40a_100ma = 5000\n    pico_current_clamp_40a_200ma = pico_current_clamp_40a_100ma + 1\n    pico_current_clamp_40a_500ma = pico_current_clamp_40a_100ma + 2\n    pico_current_clamp_40a_1a = pico_current_clamp_40a_100ma + 3\n    pico_current_clamp_40a_2a = pico_current_clamp_40a_100ma + 4\n    pico_current_clamp_40a_5a = pico_current_clamp_40a_100ma + 5\n    pico_current_clamp_40a_10a = pico_current_clamp_40a_100ma + 6\n    pico_current_clamp_40a_20a = pico_current_clamp_40a_100ma + 7\n    pico_current_clamp_40a_40a = pico_current_clamp_40a_100ma + 8\n    pico_max_current_clamp_40a_ranges = (pico_current_clamp_40a_40a + 1) - pico_current_clamp_40a_100ma\n\n    pico_1kv_2_5v = 6003\n    pico_1kv_5v = pico_1kv_2_5v + 1\n    pico_1kv_12_5v = pico_1kv_2_5v + 2\n    pico_1kv_25v = pico_1kv_2_5v + 3\n    pico_1kv_50v = pico_1kv_2_5v + 4\n    pico_1kv_125v = pico_1kv_2_5v + 5\n    pico_1kv_250v = pico_1kv_2_5v + 6\n    pico_1kv_500v = pico_1kv_2_5v + 7\n    pico_1kv_1000v = pico_1kv_2_5v + 8\n    pico_max_1kv_ranges = (pico_1kv_1000v + 1) - pico_1kv_2_5v\n\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"pico\")}\n\n\nps4000a.PICO_CONNECT_PROBE_RANGE = _define_ranges()\n\n\ndef process_enum(enum):\n    \"\"\"The PS4000a range enum is complicated enough that we need some clearer logic:\"\"\"\n    import re\n    pattern = re.compile(r'PICO_X1_PROBE_([0-9]+M?)V')\n\n    voltage_range = {}\n\n    for enum_item_name, enum_item_value in enum.items():\n        match = pattern.match(enum_item_name)\n        if match is None:\n            continue\n        voltage_string = match.group(1)\n        voltage = float(voltage_string) if voltage_string[-1] != 'M' else (0.001 * float(voltage_string[:-1]))\n\n        voltage_range[enum_item_value] = voltage\n\n    return voltage_range\n\n\nps4000a.PICO_VOLTAGE_RANGE = process_enum(ps4000a.PICO_CONNECT_PROBE_RANGE)\n\nclass PS4000A_USER_PROBE_INTERACTIONS(Structure):\n    _pack_ = 1\n    _fields_ = [    (\"connected\", c_uint16),\n                    (\"channel\", c_uint32),\n                    (\"enabled\", c_uint16),\n\n                    (\"probeName\", c_int32),\n\n                    (\"requiresPower_\", c_uint8),\n                    (\"isPowered_\", c_uint8),  \n\n                    (\"status\", c_uint32),\n\n                    (\"probeOff\", c_uint32),\n\n                    (\"rangeFirst_\", c_uint32),\n                    (\"rangeLast_\", c_uint32),\n                    (\"rangeCurrent_\", c_uint32),\n\n                    (\"couplingFirst_\", c_uint32),\n                    (\"couplingLast_\", c_uint32),\n                    (\"couplingCurrent_\", c_uint32),\n\n                    (\"filterFlags_\", c_uint32),\n                    (\"filterCurrent_\", c_uint32),\n                    (\"defaultFilter_\", c_uint32)]\nps4000a.PS4000A_USER_PROBE_INTERACTIONS = PS4000A_USER_PROBE_INTERACTIONS\n\nps4000a.PS4000A_RATIO_MODE = {\n    'PS4000A_RATIO_MODE_NONE': 0,\n    'PS4000A_RATIO_MODE_AGGREGATE': 1,\n    'PS4000A_RATIO_MODE_DECIMATE': 2,\n    'PS4000A_RATIO_MODE_AVERAGE': 4,\n}\n\nps4000a.PICO_RATIO_MODE = {k[19:]: v for k, v in ps4000a.PS4000A_RATIO_MODE.items()}\n\nps4000a.PS4000A_TIME_UNITS = make_enum([\n    'PS4000A_FS',\n    'PS4000A_PS',\n    'PS4000A_NS',\n    'PS4000A_US',\n    'PS4000A_MS',\n    'PS4000A_S',\n    'PS4000A_MAX_TIME_UNITS',\n])\n\nps4000a.PS4000A_WAVE_TYPE = make_enum([\n\t'PS4000A_SINE',\n\t'PS4000A_SQUARE',\n\t'PS4000A_TRIANGLE',\n\t'PS4000A_RAMP_UP',\n\t'PS4000A_RAMP_DOWN',\n\t'PS4000A_SINC',\n\t'PS4000A_GAUSSIAN',\n\t'PS4000A_HALF_SINE',\n\t'PS4000A_DC_VOLTAGE',\n\t'PS4000A_WHITE_NOISE',\n\t'PS4000A_MAX_WAVE_TYPES',\n])\n\nps4000a.PS4000A_SWEEP_TYPE = make_enum([\n\t'PS4000A_UP',\n\t'PS4000A_DOWN',\n\t'PS4000A_UPDOWN',\n\t'PS4000A_DOWNUP',\n\t'PS4000A_MAX_SWEEP_TYPES',\n])\n\nps4000a.PS4000A_SIGGEN_TRIG_TYPE = make_enum([\n\t'PS4000A_SIGGEN_RISING',\n\t'PS4000A_SIGGEN_FALLING',\n\t'PS4000A_SIGGEN_GATE_HIGH',\n\t'PS4000A_SIGGEN_GATE_LOW',\n])\n\nps4000a.PS4000A_SIGGEN_TRIG_SOURCE = make_enum([\n\t'PS4000A_SIGGEN_NONE',\n\t'PS4000A_SIGGEN_SCOPE_TRIG',\n\t'PS4000A_SIGGEN_AUX_IN',\n\t'PS4000A_SIGGEN_EXT_IN',\n\t'PS4000A_SIGGEN_SOFT_TRIG',\n])\n\nps4000a.PS4000A_INDEX_MODE = make_enum([\n\t'PS4000A_SINGLE',\n\t'PS4000A_DUAL',\n\t'PS4000A_QUAD',\n\t'PS4000A_MAX_INDEX_MODES',\n])\n\nps4000a.PS4000A_EXTRA_OPERATIONS = make_enum([\n\t'PS4000A_ES_OFF',\n\t'PS4000A_WHITENOISE',\n\t'PS4000A_PRBS',\n])\n\nps4000a.PS4000A_CONDITIONS_INFO = {\n    'PS4000A_CLEAR': 1,\n    'PS4000A_ADD': 2,\n}   \n\nps4000a.PS4000A_THRESHOLD_DIRECTION = make_enum([\n    (\"PS4000A_ABOVE\", \"PS4000A_INSIDE\"),\n    (\"PS4000A_BELOW\", \"PS4000A_OUTSIDE\"),\n    (\"PS4000A_RISING\", \"PS4000A_ENTER\", \"PS4000A_NONE\"),\n    (\"PS4000A_FALLING\", \"PS4000A_EXIT\"),\n    (\"PS4000A_RISING_OR_FALLING\", \"PS4000A_ENTER_OR_EXIT\"),\n    \"PS4000A_ABOVE_LOWER\",\n    \"PS4000A_BELOW_LOWER\",\n    \"PS4000A_RISING_LOWER\",\n    \"PS4000A_FALLING_LOWER\",\n    \"PS4000A_POSITIVE_RUNT\",\n    \"PS4000A_NEGATIVE_RUNT\",\n])\n\nps4000a.PS4000A_THRESHOLD_MODE = make_enum([\n    \"PS4000A_LEVEL\",\n    \"PS4000A_WINDOW\"\n])\n\nps4000a.PS4000A_TRIGGER_STATE = make_enum([\n    \"PS4000A_DONT_CARE\",\n    \"PS4000A_TRUE\",\n    \"PS4000A_FALSE\"\n])\n\nps4000a.PS4000A_PULSE_WIDTH_TYPE = make_enum([\n    \"PW_TYPE NONE\",\n    \"PW_TYPE_LESS_THAN\",\n    \"PW_TYPE_GREATER_THAN\",\n    \"PW_TYPE_IN_RANGE\",\n    \"PW_TYPE_OUT_OF_RANGE\"\n])\n\nclass PS4000A_CONDITION (Structure):\n\t_pack_ = 1\n\t_fields_ = [(\"source\", c_int32),\n\t(\"condition\", c_int32)]\n                \nps4000a.PS4000A_CONDITION = PS4000A_CONDITION\n\nclass PS4000A_DIRECTION(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channel\", c_int32),\n                (\"direction\", c_int32)]\n                \nps4000a.PS4000A_DIRECTION = PS4000A_DIRECTION\n\nclass PS4000A_TRIGGER_CHANNEL_PROPERTIES(Structure):\n    _pack_ = 1\n    _fields_ = [(\"thresholdUpper\", c_int16),\n                (\"thresholdUpperHysteresis\", c_uint16),\n                (\"thresholdLower\", c_int16),\n                (\"thresholdLowerHysteresis\", c_uint16),\n                (\"channel\", c_int32),\n                (\"thresholdMode\", c_int32)]\n                \nps4000a.PS4000A_TRIGGER_CHANNEL_PROPERTIES = PS4000A_TRIGGER_CHANNEL_PROPERTIES\n\ndoc = \"\"\" PICO_STATUS ps4000aOpenUnit\n    (\n        int16_t *handle,\n        int8_t  *serial\n    ); \"\"\"\nps4000a.make_symbol(\"_OpenUnit\", \"ps4000aOpenUnit\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aOpenUnitAsync\n    (\n        int16_t *status,\n        int8_t  *serial\n    ); \"\"\"\nps4000a.make_symbol(\"_OpenUnitAsync\", \"ps4000aOpenUnitAsync\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aOpenUnitProgress\n    (\n        int16_t *handle,\n        int16_t *progressPercent,\n        int16_t *complete\n    ); \"\"\"\nps4000a.make_symbol(\"_OpenUnitProgress\", \"ps4000aOpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetUnitInfo\n    (\n        int16_t    handle,\n        int8_t    *string,\n        int16_t    stringLength,\n        int16_t   *requiredSize,\n        PICO_INFO  info\n    ); \"\"\"\nps4000a.make_symbol(\"_GetUnitInfo\", \"ps4000aGetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32],\n                    doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aFlashLed\n    (\n        int16_t  handle,\n        int16_t  start\n    ); \"\"\"\nps4000a.make_symbol(\"_FlashLed\", \"ps4000aFlashLed\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetChannelLed\n    (\n        int16_t                      handle,\n        PS4000A_CHANNEL_LED_SETTING *ledStates,\n        uint16_t                     nLedStates\n    ); \"\"\"\nps4000a.make_symbol(\"_SetChannelLed\", \"ps4000aSetChannelLed\", c_uint32, [c_int16, c_void_p, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aIsLedFlashing\n    (\n        int16_t  handle,\n        int16_t *status\n    ); \"\"\"\nps4000a.make_symbol(\"_IsLedFlashing\", \"ps4000aIsLedFlashing\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aCloseUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000a.make_symbol(\"_CloseUnit\", \"ps4000aCloseUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aMemorySegments\n    (\n        int16_t   handle,\n        uint32_t  nSegments,\n        int32_t  *nMaxSamples\n    ); \"\"\"\nps4000a.make_symbol(\"_MemorySegments\", \"ps4000aMemorySegments\", c_uint32, [c_int16, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetChannel\n    (\n        int16_t           handle,\n        PS4000A_CHANNEL   channel,\n        int16_t           enabled,\n        PS4000A_COUPLING  type,\n        PS4000A_RANGE     range,\n        float             analogOffset\n    ); \"\"\"\nps4000a.make_symbol(\"_SetChannel\", \"ps4000aSetChannel\", c_uint32,\n                    [c_int16, c_int32, c_int16, c_int32, c_int32, c_float], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetBandwidthFilter\n    (\n        int16_t                    handle,\n        PS4000A_CHANNEL            channel,\n        PS4000A_BANDWIDTH_LIMITER  bandwidth\n    ); \"\"\"\nps4000a.make_symbol(\"_SetBandwidthFilter\", \"ps4000aSetBandwidthFilter\", c_uint32, [c_int16, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aApplyResistanceScaling\n    (\n        int16_t          handle,\n        PS4000A_CHANNEL  channel,\n        PS4000A_RANGE    range,\n        int16_t         *bufferMax,\n        int16_t         *bufferMin,\n        uint32_t         buffertLth,\n        int16_t         *overflow\n    ); \"\"\"\nps4000a.make_symbol(\"_ApplyResistanceScaling\", \"ps4000aApplyResistanceScaling\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_int16, c_int16, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetTimebase\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        int32_t  *timeIntervalNanoseconds,\n        int32_t  *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps4000a.make_symbol('_GetTimebase', 'ps4000aGetTimebase', c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetTimebase2\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        float    *timeIntervalNanoseconds,\n        int32_t  *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps4000a.make_symbol(\"_GetTimebase2\", \"ps4000aGetTimebase2\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetSigGenArbitrary\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        int16_t                    *arbitraryWaveform,\n        int32_t                     arbitraryWaveformSize,\n        PS4000A_SWEEP_TYPE          sweepType,\n        PS4000A_EXTRA_OPERATIONS    operation,\n        PS4000A_INDEX_MODE          indexMode,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS4000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS4000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps4000a.make_symbol(\"_SetSigGenArbitrary\", \"ps4000aSetSigGenArbitrary\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p,\n                     c_int32, c_int32, c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetSigGenBuiltIn\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        PS4000A_WAVE_TYPE           waveType,\n        double                      startFrequency,\n        double                      stopFrequency,\n        double                      increment,\n        double                      dwellTime,\n        PS4000A_SWEEP_TYPE          sweepType,\n        PS4000A_EXTRA_OPERATIONS    operation,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS4000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS4000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps4000a.make_symbol(\"_SetSigGenBuiltIn\", \"ps4000aSetSigGenBuiltIn\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_int32, c_double, c_double, c_double, c_double,\n                     c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetSigGenPropertiesArbitrary\n    (\n        int16_t                     handle,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        PS4000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS4000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS4000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps4000a.make_symbol(\"_SetSigGenPropertiesArbitrary\", \"ps4000aSetSigGenPropertiesArbitrary\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetSigGenPropertiesBuiltIn\n    (\n        int16_t                     handle,\n        double                      startFrequency,\n        double                      stopFrequency,\n        double                      increment,\n        double                      dwellTime,\n        PS4000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS4000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS4000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps4000a.make_symbol(\"_SetSigGenPropertiesBuiltIn\", \"ps4000aSetSigGenPropertiesBuiltIn\", c_uint32,\n                    [c_int16, c_double, c_double, c_double, c_double, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSigGenFrequencyToPhase\n    (\n        int16_t             handle,\n        double              frequency,\n        PS4000A_INDEX_MODE  indexMode,\n        uint32_t            bufferLength,\n        uint32_t           *phase\n    ); \"\"\"\nps4000a.make_symbol(\"_SigGenFrequencyToPhase\", \"ps4000aSigGenFrequencyToPhase\", c_uint32,\n                    [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSigGenArbitraryMinMaxValues\n    (\n        int16_t   handle,\n        int16_t  *minArbitraryWaveformValue,\n        int16_t  *maxArbitraryWaveformValue,\n        uint32_t *minArbitraryWaveformSize,\n        uint32_t *maxArbitraryWaveformSize\n    ); \"\"\"\nps4000a.make_symbol(\"_SigGenArbitraryMinMaxValues\", \"ps4000aSigGenArbitraryMinMaxValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSigGenSoftwareControl\n    (\n        int16_t  handle,\n        int16_t  state\n    );\"\"\"\nps4000a.make_symbol(\"_SigGenSoftwareControl\", \"ps4000aSigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetEts\n    (\n        int16_t           handle,\n        PS4000A_ETS_MODE  mode,\n        int16_t           etsCycles,\n        int16_t           etsInterleave,\n        int32_t          *sampleTimePicoseconds\n    ); \"\"\"\nps4000a.make_symbol(\"_SetEts\", \"ps4000aSetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetTriggerChannelProperties\n    (\n        int16_t                             handle,\n        PS4000A_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                             nChannelProperties,\n        int16_t                             auxOutputEnable,\n        int32_t                             autoTriggerMilliseconds\n    ); \"\"\"\nps4000a.make_symbol(\"_SetTriggerChannelProperties\", \"ps4000aSetTriggerChannelProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetTriggerChannelConditions\n    (\n        int16_t                  handle,\n        PS4000A_CONDITION       *conditions,\n        int16_t                  nConditions,\n        PS4000A_CONDITIONS_INFO  info\n    ); \"\"\"\nps4000a.make_symbol(\"_SetTriggerChannelConditions\", \"ps4000aSetTriggerChannelConditions\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetTriggerChannelDirections\n    (\n        int16_t            handle,\n        PS4000A_DIRECTION *directions,\n        int16_t            nDirections\n    ); \"\"\"\nps4000a.make_symbol(\"_SetTriggerChannelDirections\", \"ps4000aSetTriggerChannelDirections\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetSimpleTrigger\n    (\n        int16_t                      handle,\n        int16_t                      enable,\n        PS4000A_CHANNEL              source,\n        int16_t                      threshold,\n        PS4000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     delay,\n        int16_t                      autoTrigger_ms\n    ); \"\"\"\nps4000a.make_symbol(\"_SetSimpleTrigger\", \"ps4000aSetSimpleTrigger\", c_uint32,\n                    [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay\n    ); \"\"\"\nps4000a.make_symbol(\"_SetTriggerDelay\", \"ps4000aSetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetPulseWidthQualifierProperties\n    (\n        int16_t                      handle,\n        PS4000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     lower,\n        uint32_t                     upper,\n        PS4000A_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps4000a.make_symbol(\"_SetPulseWidthQualifierProperties\", \"ps4000aSetPulseWidthQualifierProperties\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetPulseWidthQualifierConditions\n    (\n        int16_t                  handle,\n        PS4000A_CONDITION       *conditions,\n        int16_t                  nConditions,\n        PS4000A_CONDITIONS_INFO  info\n    ); \"\"\"\nps4000a.make_symbol(\"_SetPulseWidthQualifierConditions\", \"ps4000aSetPulseWidthQualifierConditions\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aIsTriggerOrPulseWidthQualifierEnabled\n    (\n        int16_t  handle,\n        int16_t *triggerEnabled,\n        int16_t *pulseWidthQualifierEnabled\n    ); \"\"\"\nps4000a.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps4000aIsTriggerOrPulseWidthQualifierEnabled\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetTriggerTimeOffset\n    (\n        int16_t             handle,\n        uint32_t           *timeUpper,\n        uint32_t           *timeLower,\n        PS4000A_TIME_UNITS *timeUnits,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps4000a.make_symbol(\"_GetTriggerTimeOffset\", \"ps4000aGetTriggerTimeOffset\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetTriggerTimeOffset64\n    (\n        int16_t             handle,\n        int64_t            *time,\n        PS4000A_TIME_UNITS *timeUnits,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps4000a.make_symbol(\"_GetTriggerTimeOffset64\", \"ps4000aGetTriggerTimeOffset64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValuesTriggerTimeOffsetBulk\n    (\n        int16_t             handle,\n        uint32_t           *timesUpper,\n        uint32_t           *timesLower,\n        PS4000A_TIME_UNITS *timeUnits,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps4000aGetValuesTriggerTimeOffsetBulk\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValuesTriggerTimeOffsetBulk64\n    (\n        int16_t             handle,\n        int64_t            *times,\n        PS4000A_TIME_UNITS *timeUnits,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValuesTriggerTimeOffsetBulk64\", \"ps4000aGetValuesTriggerTimeOffsetBulk64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetDataBuffers\n    (\n        int16_t             handle,\n        PS4000A_CHANNEL     channel,\n        int16_t            *bufferMax,\n        int16_t            *bufferMin,\n        int32_t             bufferLth,\n        uint32_t            segmentIndex,\n        PS4000A_RATIO_MODE  mode\n    ); \"\"\"\nps4000a.make_symbol(\"_SetDataBuffers\", \"ps4000aSetDataBuffers\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetDataBuffer\n    (\n        int16_t             handle,\n        PS4000A_CHANNEL     channel,\n        int16_t            *buffer,\n        int32_t             bufferLth,\n        uint32_t            segmentIndex,\n        PS4000A_RATIO_MODE  mode\n    ); \"\"\"\nps4000a.make_symbol(\"_SetDataBuffer\", \"ps4000aSetDataBuffer\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetEtsTimeBuffer\n    (\n        int16_t  handle,\n        int64_t *buffer,\n        int32_t  bufferLth\n    ); \"\"\"\nps4000a.make_symbol(\"_SetEtsTimeBuffer\", \"ps4000aSetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetEtsTimeBuffers\n    (\n        int16_t   handle,\n        uint32_t *timeUpper,\n        uint32_t *timeLower,\n        int32_t   bufferLth\n    ); \"\"\"\nps4000a.make_symbol(\"_SetEtsTimeBuffers\", \"ps4000aSetEtsTimeBuffers\", c_uint32, [c_int16, c_void_p, c_void_p, c_int32],\n                    doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aIsReady\n    (\n        int16_t  handle,\n        int16_t *ready\n    ); \"\"\"\nps4000a.make_symbol(\"_IsReady\", \"ps4000aIsReady\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aRunBlock\n    (\n        int16_t            handle,\n        int32_t            noOfPreTriggerSamples,\n        int32_t            noOfPostTriggerSamples,\n        uint32_t           timebase,\n        int32_t           *timeIndisposedMs,\n        uint32_t           segmentIndex,\n        ps4000aBlockReady  lpReady,\n        void              *pParameter\n    ); \"\"\"\nps4000a.make_symbol(\"_RunBlock\", \"ps4000aRunBlock\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_uint32, c_void_p, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aRunStreaming\n    (\n        int16_t             handle,\n        uint32_t           *sampleInterval,\n        PS4000A_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t            maxPreTriggerSamples,\n        uint32_t            maxPostTriggerSamples,\n        int16_t             autoStop,\n        uint32_t            downSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            overviewBufferSize\n    ); \"\"\"\nps4000a.make_symbol(\"_RunStreaming\", \"ps4000aRunStreaming\", c_uint32,\n                    [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetStreamingLatestValues\n    (\n        int16_t                handle,\n        ps4000aStreamingReady  lpPs4000aReady,\n        void                  *pParameter\n    ); \"\"\"\nps4000a.make_symbol(\"_GetStreamingLatestValues\", \"ps4000aGetStreamingLatestValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" void *ps4000aStreamingReady\n    (\n        int16_t   handle,\n        int32_t   noOfSamples,\n        uint32_t  startIndex,\n        int16_t   overflow,\n        uint32_t  triggerAt,\n        int16_t   triggered,\n        int16_t   autoStop,\n        void     *pParameter\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n\nps4000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                         c_int16,\n                                                         c_int32,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_int16,\n                                                         c_void_p)\n\nps4000a.StreamingReadyType.__doc__ = doc\n\n\ndoc = \"\"\" PICO_STATUS ps4000aNoOfStreamingValues\n    (\n        int16_t   handle,\n        uint32_t *noOfValues\n    ); \"\"\"\nps4000a.make_symbol(\"_NoOfStreamingValues\", \"ps4000aNoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetMaxDownSampleRatio\n    (\n        int16_t             handle,\n        uint32_t            noOfUnaggreatedSamples,\n        uint32_t           *maxDownSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps4000a.make_symbol(\"_GetMaxDownSampleRatio\", \"ps4000aGetMaxDownSampleRatio\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValues\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValues\", \"ps4000aGetValues\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValuesAsync\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t            noOfSamples,\n        uint32_t            downSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        void               *lpDataReady,\n        void               *pParameter\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValuesAsync\", \"ps4000aGetValuesAsync\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValuesBulk\n    (\n        int16_t             handle,\n        uint32_t           *noOfSamples,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        uint32_t            downSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        int16_t            *overflow\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValuesBulk\", \"ps4000aGetValuesBulk\", c_uint32,\n                    [c_int16, c_void_p, c_uint32, c_uint32, c_uint32, c_int32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValuesOverlapped\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValuesOverlapped\", \"ps4000aGetValuesOverlapped\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetValuesOverlappedBulk\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS4000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps4000a.make_symbol(\"_GetValuesOverlappedBulk\", \"ps4000aGetValuesOverlappedBulk\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aEnumerateUnits\n    (\n        int16_t *count,\n        int8_t  *serials,\n        int16_t *serialLth\n    ); \"\"\"\nps4000a.make_symbol(\"_EnumerateUnits\", \"ps4000aEnumerateUnits\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetChannelInformation\n    (\n        int16_t               handle,\n        PS4000A_CHANNEL_INFO  info,\n        int32_t               probe,\n        int32_t              *ranges,\n        int32_t              *length,\n        int32_t               channels\n    ); \"\"\"\nps4000a.make_symbol(\"_GetChannelInformation\", \"ps4000aGetChannelInformation\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aConnectDetect\n    (\n        int16_t                 handle,\n        PS4000A_CONNECT_DETECT *sensor,\n        int16_t                 nSensors\n    ); \"\"\"\nps4000a.make_symbol(\"_ConnectDetect\", \"ps4000aConnectDetect\", c_uint32, [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aMaximumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps4000a.make_symbol(\"_MaximumValue\", \"ps4000aMaximumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aMinimumValue\n    (\n        int16_t\t\thandle,\n        int16_t * value\n    ); \"\"\"\nps4000a.make_symbol(\"_MinimumValue\", \"ps4000aMinimumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetAnalogueOffset\n    (\n        int16_t           handle,\n        PS4000A_RANGE     range,\n        PS4000A_COUPLING  coupling,\n        float            *maximumVoltage,\n        float            *minimumVoltage\n    ); \"\"\"\nps4000a.make_symbol(\"_GetAnalogueOffset\", \"ps4000aGetAnalogueOffset\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetMaxSegments\n    (\n        int16_t   handle,\n        uint32_t *maxSegments\n    ); \"\"\"\nps4000a.make_symbol(\"_GetMaxSegments\", \"ps4000aGetMaxSegments\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aChangePowerSource\n    (\n        int16_t      handle,\n        PICO_STATUS  powerState\n    ); \"\"\"\nps4000a.make_symbol(\"_ChangePowerSource\", \"ps4000aChangePowerSource\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aCurrentPowerSource\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000a.make_symbol(\"_CurrentPowerSource\", \"ps4000aCurrentPowerSource\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aStop\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000a.make_symbol(\"_Stop\", \"ps4000aStop\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aPingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps4000a.make_symbol(\"_PingUnit\", \"ps4000aPingUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t  nCaptures\n    ); \"\"\"\nps4000a.make_symbol(\"_SetNoOfCaptures\", \"ps4000aSetNoOfCaptures\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t *nCaptures\n    ); \"\"\"\nps4000a.make_symbol(\"_GetNoOfCaptures\", \"ps4000aGetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetNoOfProcessedCaptures\n    (\n        int16_t   handle,\n        uint32_t *nProcessedCaptures\n    ); \"\"\"\nps4000a.make_symbol(\"_GetNoOfProcessedCaptures\", \"ps4000aGetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aDeviceMetaData\n    (\n        int16_t                 handle,\n        int8_t                 *settings,\n        int32_t                *nSettingsLength,\n        PS4000A_META_TYPE       type,\n        PS4000A_META_OPERATION  operation,\n        PS4000A_META_FORMAT     format\n    ); \"\"\"\nps4000a.make_symbol(\"_DeviceMetaData\", \"ps4000aDeviceMetaData\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetString\n    (\n        int16_t            handle,\n        PICO_STRING_VALUE  stringValue,\n        int8_t            *string,\n        int32_t           *stringLength\n    ); \"\"\"\nps4000a.make_symbol(\"_GetString\", \"ps4000aGetString\", c_uint32, [c_int16, c_int32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetCommonModeOverflow\n    (\n        int16_t   handle,\n        uint16_t *overflow\n    ); \"\"\"\nps4000a.make_symbol(\"_GetCommonModeOverflow\", \"ps4000aGetCommonModeOverflow\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetFrequencyCounter\n    (\n        int16_t                          handle,\n        PS4000A_CHANNEL                  channel,\n        int16_t                          enabled,\n        PS4000A_FREQUENCY_COUNTER_RANGE  range,\n        int16_t                          thresholdMajor,\n        int16_t                          thresholdMinor\n    ); \"\"\"\nps4000a.make_symbol(\"_SetFrequencyCounter\", \"ps4000aSetFrequencyCounter\", c_uint32,\n                    [c_int16, c_int32, c_int16, c_int32, c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aOpenUnitWithResolution\n    (\n\t    int16_t    *handle,\n\t\tint8_t     *serial,\n\t\tPS4000A_DEVICE_RESOLUTION    resolution\n\t); \"\"\"\nps4000a.make_symbol(\"_OpenUnitWithResolution\", \"ps4000aOpenUnitWithResolution\", c_uint32, [c_void_p, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aGetDeviceResolution\n    (\n\t    int16_t    handle,\n\t\tPS4000A_DEVICE_RESOLUTION    *resolution\n\t); \"\"\"\nps4000a.make_symbol(\"_GetResolution\", \"ps4000aGetDeviceResolution\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetDeviceResolution\n    (\n\t    int16_t    handle,\n\t\tPS4000A_DEVICE_RESOLUTION    resolution\n\t); \"\"\"\nps4000a.make_symbol(\"_SetResolution\", \"ps4000aSetDeviceResolution\", c_uint32, [c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps4000aSetProbeInteractionCallback\n    (\n\t    int16_t    handle,\n\t\tps4000aProbeInteractions callback\n\t); \"\"\"\nps4000a.make_symbol(\"_SetProbeInteractionCallback\", \"ps4000aSetProbeInteractionCallback\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" void *ps4000aProbeInteractions\n    (\n\t\tint16_t    \t\t\t\t\t\t\t\t\t\t\t\thandle,\n\t\tPICO_STATUS\t\t\t\t\t\t\t\t\t\t\t\tstatus,\n\t\tPS4000A_USER_PROBE_INTERACTIONS * probes,\n\t\tuint32_t\t\t\t\t\t\t\t\t\t\t\t\t\tnProbes\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n\nps4000a.ps4000aProbeInteractions = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                         c_int16,\n                                                        c_uint32,\n                                                        POINTER(PS4000A_USER_PROBE_INTERACTIONS),\n                                                        c_uint32\n                                                        )\n\nps4000a.ps4000aProbeInteractions.__doc__ = doc\n"
  },
  {
    "path": "picosdk/ps5000.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the ps5000Api.h C header\r\nfile for PicoScope 5000 Series oscilloscopes using the ps5000 driver API\r\nfunctions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\nfrom picosdk.library import Library\r\nfrom picosdk.constants import make_enum\r\n\r\nclass Ps5000lib(Library):\r\n    def __init__(self):\r\n        super(Ps5000lib, self).__init__(\"ps5000\")\r\n\r\n\r\nps5000 = Ps5000lib()\r\n\r\nps5000.PS5000_CHANNEL = make_enum([\r\n\t\"PS5000_CHANNEL_A\",\r\n\t\"PS5000_CHANNEL_B\",\r\n\t\"PS5000_CHANNEL_C\",\r\n\t\"PS5000_CHANNEL_D\",\r\n\t(\"PS5000_MAX_CHANNELS\", \"PS5000_EXTERNAL\"),\r\n\t\"PS5000_TRIGGER_AUX\",\r\n\t\"PS5000_MAX_TRIGGER_SOURCES\",\r\n])\r\n\r\nps5000.PS5000_RANGE = make_enum([\r\n\t\"PS5000_10MV\",\r\n\t\"PS5000_20MV\",\r\n\t\"PS5000_50MV\",\r\n\t\"PS5000_100MV\",\r\n\t\"PS5000_200MV\",\r\n    \"PS5000_500MV\",\r\n\t\"PS5000_1V\",\r\n\t\"PS5000_2V\",\r\n\t\"PS5000_5V\",\r\n\t\"PS5000_10V\",\r\n\t\"PS5000_20V\",\r\n\t\"PS5000_50V\",\r\n\t\"PS5000_MAX_RANGES\",\r\n])\r\n\r\nps5000.PS5000_TIME_UNITS = make_enum([\r\n\t\"PS5000_FS\",\r\n\t\"PS5000_PS\",\r\n\t\"PS5000_NS\",\r\n\t\"PS5000_US\",\r\n\t\"PS5000_MS\",\r\n\t\"PS5000_S\",\r\n\t\"PS5000_MAX_TIME_UNITS\",\r\n])\r\n\t\r\n\r\nclass PWQ_CONDITIONS (Structure):\r\n\t_pack_ = 1\r\n\t_fields_ = [(\"channelA\", c_int32),\r\n\t\t\t\t(\"channelB\", c_int32),\r\n\t\t\t\t(\"channelC\", c_int32),\r\n\t\t\t\t(\"channelD\", c_int32),\r\n\t\t\t\t(\"external\", c_int32),\r\n\t\t\t\t(\"aux\", c_int32)]\r\n\r\nps5000.PWQ_CONDITIONS = PWQ_CONDITIONS\r\n\r\nclass TRIGGER_CONDITIONS (Structure):\r\n\t_pack_ = 1\r\n\t_fields_ = [(\"channelA\", c_int32),\r\n\t\t\t\t(\"channelB\", c_int32),\r\n\t\t\t\t(\"channelC\", c_int32),\r\n\t\t\t\t(\"channelD\", c_int32),\r\n\t\t\t\t(\"external\", c_int32),\r\n\t\t\t\t(\"aux\", c_int32),\r\n\t\t\t\t(\"pulseWidthQualifier\", c_int32)]\r\n\t\t\t\t\r\nps5000.TRIGGER_CONDITIONS = TRIGGER_CONDITIONS\r\n\r\nclass TRIGGER_CHANNEL_PROPERTIES (Structure):\r\n\t_pack_ = 1\r\n\t_fields_ = [(\"thresholdMajor\", c_int16),\r\n\t\t\t\t(\"thresholdMinor\", c_int16),\r\n\t\t\t\t(\"hysteresis\", c_uint16),\r\n\t\t\t\t(\"channel\", c_int32),\r\n\t\t\t\t(\"thresholdMode\", c_int32)]\r\n\t\t\t\t\r\nps5000.TRIGGER_CHANNEL_PROPERTIES = TRIGGER_CHANNEL_PROPERTIES\r\n\t\t\t\t\r\ndoc = \"\"\" PICO_STATUS ps5000CloseUnit\r\n    (\r\n        short  handle\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_CloseUnit\", \"ps5000CloseUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000FlashLed\r\n    (\r\n        short  handle,\r\n        short  start\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_FlashLed\", \"ps5000FlashLed\", c_uint32, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetMaxDownSampleRatio\r\n    (\r\n        short  handle,\r\n        unsigned long  noOfUnaggregatedSamples,\r\n        unsigned long  *maxDownSampleRatio,\r\n        short  downSampleRatioMode,\r\n        unsigned short  segmentIndex\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetMaxDownSampleRatio\", \"ps5000GetMaxDownSampleRatio\", c_uint32, [c_int16, c_uint32, c_void_p, c_int16, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetStreamingLatestValues\r\n    (\r\n        short  handle,\r\n        ps5000StreamingReady  lpPs5000Ready,\r\n        void  *pParameter\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetStreamingLatestValues\", \"ps5000GetStreamingLatestValues\", c_uint16, [c_int16, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetTimebase\r\n    (\r\n        short  handle,\r\n        unsigned long  timebase,\r\n        long  noSamples,\r\n        long  *timeIntervalNanoseconds,\r\n        short  oversample,\r\n        long  *maxSamples,\r\n        unsigned short  segmentIndex\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetTimebase\", \"ps5000GetTimebase\", c_uint16, [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetTriggerTimeOffset\r\n    (\r\n        short  handle,\r\n        unsigned long  *timeUpper,\r\n        unsigned long  *timeLower,\r\n        PS5000_TIME_UNITS  *timeUnits,\r\n        unsigned short  segmentIndex\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetTriggerTimeOffset\", \"ps5000GetTriggerTimeOffset\", c_uint16, [c_int16, c_void_p, c_void_p, c_void_p, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetTriggerTimeOffset64\r\n    (\r\n        short  handle,\r\n        int64_t  *time,\r\n        PS5000_TIME_UNITS  *timeUnits,\r\n        unsigned short  segmentIndex\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetTriggerTimeOffset64\", \"ps5000GetTriggerTimeOffset64\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetUnitInfo\r\n    (\r\n        short  handle,\r\n        char  *string,\r\n        short  stringLength,\r\n        short  *requiredSize,\r\n        PICO_INFO  info\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetUnitInfo\", \"ps5000GetUnitInfo\", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetValues\r\n    (\r\n        short  handle,\r\n        unsigned long  startIndex,\r\n        unsigned long  *noOfSamples,\r\n        unsigned long  downSampleRatio,\r\n        short  downSampleRatioMode,\r\n        unsigned short  segmentIndex,\r\n        short  *overflow\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetValues\", \"ps5000GetValues\", c_uint32, [c_int16, c_uint32, c_void_p, c_uint32, c_int16, c_uint16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetValuesAsync\r\n    (\r\n        short  handle,\r\n        unsigned long  startIndex,\r\n        unsigned long  noOfSamples,\r\n        unsigned long  downSampleRatio,\r\n        short  downSampleRatioMode,\r\n        unsigned short  segmentIndex,\r\n        void  *lpDataReady,\r\n        void  *pParameter\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetValuesAsync\", \"ps5000GetValuesAsync\", c_uint32, [c_int16, c_uint32, c_uint32, c_uint32, c_int16, c_uint16, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetValuesBulk\r\n    (\r\n        short  handle,\r\n        unsigned long  *noOfSamples,\r\n        unsigned short  fromSegmentIndex,\r\n        unsigned short  toSegmentIndex,\r\n        short  *overflow\r\n    ); \"\"\"\r\nps5000.make_symbol(\"_GetValuesBulk\", \"ps5000GetValuesBulk\", c_uint32, [c_int16, c_void_p, c_uint16, c_uint16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetValuesTriggerTimeOffsetBulk\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned long  *timesUpper,\r\n\t\tunsigned long  *timesLower,\r\n\t\tPS5000_TIME_UNITS  *timeUnits,\r\n\t\tunsigned short   fromSegmentIndex,\r\n\t\tunsigned short  toSegmentIndex\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps5000GetValuesTriggerTimeOffsetBulk\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_uint16, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000GetValuesTriggerTimeOffsetBulk64\r\n\t(\r\n\t\tshort  handle,\r\n\t\t_int64  *times,\r\n\t\tPS5000_TIME_UNITS  *timeUnits,\r\n\t\tunsigned short  fromSegmentIndex,\r\n\t\tunsigned short  toSegmentIndex\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_GetValuesTriggerTimeOffsetBulk64\", \"ps5000GetValuesTriggerTimeOffsetBulk64\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000IsLedFlashing\r\n\t(\r\n\t\tshort  handle,\r\n\t\tshort  *status\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_IsLedFlashing\", \"ps5000IsLedFlashing\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000IsReady\r\n\t(\r\n\t\tshort  handle,\r\n\t\tshort  *ready\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_IsReady\", \"ps5000IsReady\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000IsTriggerOrPulseWidthQualifierEnabled\r\n\t(\r\n\t\tshort  handle,\r\n\t\tshort  *triggerEnabled,\r\n\t\tshort  *pulseWidthQualifierEnabled\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps5000IsTriggerOrPulseWidthQualifierEnabled\", c_uint32, [c_int16, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000MemorySegments\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned short  nSegments,\r\n\t\tlong  *nMaxSamples\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_MemorySegments\", \"ps5000MemorySegments\", c_uint32, [c_int16, c_uint16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000NoOfStreamingValues\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned long  *noOfValues\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_NoOfStreamingValues\", \"ps5000NoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000OpenUnit\r\n\t(\r\n\t\tshort  *handle\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_OpenUnit\", \"ps5000OpenUnit\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000OpenUnitAsync\r\n\t(\r\n\t\tshort  *status\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_OpenUnitAsync\", \"ps5000OpenUnitAsync\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000OpenUnitProgress\r\n\t(\r\n\t\tshort  *handle,\r\n\t\tshort  *progressPercent,\r\n\t\tshort  *complete\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_OpenUnitProgress\", \"ps5000OpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000RunBlock\r\n\t(\r\n\t\tshort  handle,\r\n\t\tlong  noOfPreTriggerSamples,\r\n\t\tlong  noOfPostTriggerSamples,\r\n\t\tunsigned long  timebase,\r\n\t\tshort  oversample,\r\n\t\tlong  *timeIndisposedMs,\r\n\t\tunsigned short  segmentIndex,\r\n\t\tps5000BlockReady  lpReady,\r\n\t\tvoid  *pParameter\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_RunBlock\", \"ps5000RunBlock\", c_uint32, [c_int16, c_int32, c_int32, c_uint32, c_int16, c_void_p, c_uint16, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000RunStreaming\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned long  *sampleInterval,\r\n\t\tPS5000_TIME_UNITS  sampleIntervalTimeUnits,\r\n\t\tunsigned long  maxPreTriggerSamples,\r\n\t\tunsigned long  maxPostTriggerSamples,\r\n\t\tshort  autoStop,\r\n\t\tunsigned long  downSampleRatio,\r\n\t\tunsigned long  overviewBufferSize\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_RunStreaming\", \"ps5000RunStreaming\", c_uint32, [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetChannel\r\n\t(\r\n\t\tshort  handle,\r\n\t\tPS5000_CHANNEL  channel,\r\n\t\tshort  enabled,\r\n\t\tshort  dc,\r\n\t\tPS5000_RANGE  range\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetChannel\", \"ps5000SetChannel\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetDataBuffer\r\n\t(\r\n\t\tshort  handle,\r\n\t\tPS5000_CHANNEL  channel,\r\n\t\tshort  *buffer,\r\n\t\tlong  buggerLth\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetDataBuffer\", \"ps5000SetDataBuffer\", c_uint32, [c_int16, c_int32, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetDataBufferBulk\r\n\t(\r\n\t\tshort  handle,\r\n\t\tPS5000_CHANNEL  channel,\r\n\t\tshort  *buffer,\r\n\t\tlong  bufferLth,\r\n\t\tunsigned short  waveform\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetDataBufferBulk\", \"ps5000SetDataBufferBulk\", c_uint32, [c_int16, c_int32, c_void_p, c_int32, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetDataBuffers\r\n\t(\r\n\t\tshort  handle,\r\n\t\tPS5000_CHANNEL  channel,\r\n\t\tshort  *bufferMax,\r\n\t\tshort  *bufferMin,\r\n\t\tlong  bufferLth\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetDataBuffers\", \"ps5000SetDataBuffers\", c_uint32, [c_int16, c_int32, c_void_p, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetEts\r\n\t(\r\n\t\tshort  handle,\r\n\t\tPS5000_ETS_MODE  mode,\r\n\t\tshort  etsCycles,\r\n\t\tshort  etsInterleave,\r\n\t\tlong  *sampleTimePicoseconds\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetEts\", \"ps5000SetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetEtsTimeBuffer\r\n\t(\r\n\t\tshort  handle,\r\n\t\t_int64  *buffer,\r\n\t\tlong  bufferLth\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetEtsTimeBuffer\", \"ps5000SetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetEtsTimeBuffers\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned long  *timeUpper,\r\n\t\tunsigned long  *timeLower,\r\n\t\tlong  bufferLth\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetEtsTimeBuffers\", \"ps5000SetEtsTimeBuffers\", c_uint32, [c_int16, c_void_p, c_void_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetNoOfCaptures\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned short  nCaptures\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetNoOfCaptures\", \"ps5000SetNoOfCaptures\", c_uint32, [c_int16, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetPulseWidthQualifier\r\n\t(\r\n\t\tshort  handle,\r\n\t\tstruct PWQ_CONDITIONS  *conditions,\r\n\t\tshort  nConditions,\r\n\t\tTHRESHOLD_DIRECTION  direction,\r\n\t\tunsigned long  lower,\r\n\t\tunsigned long  upper,\r\n\t\tPULSE_WIDTH_TYPE  type\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetPulseWidthQualifier\", \"ps5000SetPulseWidthQualifier\", c_uint32, [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetSigGenArbitrary\r\n\t(\r\n\t\tshort  handle,\r\n\t\tlong  offsetVoltage,\r\n\t\tunsigned long  pkToPk,\r\n\t\tunsigned long  startDeltaPhase,\r\n\t\tunsigned long  stopDeltaPhase,\r\n\t\tunsigned long  deltaPhaseIncrement,\r\n\t\tunsigned long  dwellCount,\r\n\t\tshort  *arbitaryWaveform\r\n\t\tlong  arbitaryWaveformSize,\r\n\t\tSWEEP_TYPE  sweepType,\r\n\t\tshort  whiteNoise,\r\n\t\tINDEX_MODE  indexMode,\r\n\t\tunsigned long  shots,\r\n\t\tunsigned long sweeps,\r\n\t\tSIGGEN_TRIG_TYPE  triggerType,\r\n\t\tSIGGEN_TRIG_SOURCE  triggerSource,\r\n\t\tshort  extInThreshold\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetSigGenArbitrary\", \"ps5000SetSigGenArbitrary\", c_uint32, \r\n\t\t\t\t\t[c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, \r\n\t\t\t\t\t\tc_int32, c_int32, c_int16, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetSigGenBuiltIn\r\n\t(\r\n\t\tshort  handle,\r\n\t\tlong  offsetVoltage,\r\n\t\tunsigned long  pkToPk,\r\n\t\tshort  waveType,\r\n\t\tfloat  startFrequency,\r\n\t\tfloat  stopFrequency,\r\n\t\tfloat  increment,\r\n\t\tfloat  dwellTime,\r\n\t\tSWEEP_TYPE  sweepType,\r\n\t\tshort  whiteNoise,\r\n\t\tunsigned long  shots,\r\n\t\tunsigned long  sweeps,\r\n\t\tSIGGEN_TRIG_TYPE  triggerType,\r\n\t\tSIGGEN_TRIG_SOURCE  triggerSource,\r\n\t\tshort  extInThreshold\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetSigGenBuiltIn\", \"ps5000SetSigGenBuiltIn\", c_uint32, \r\n\t\t\t\t\t[c_int16, c_int32, c_uint32, c_int16, c_int64, c_int64, c_int64, c_int64, c_int64, c_int32, c_int16, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetSimpleTrigger\r\n\t(\r\n\t\tshort  handle,\r\n\t\tshort  enable,\r\n\t\tPS5000_CHANNEL  source,\r\n\t\tshort  threshold,\r\n\t\tTHRESHOLD_DIRECTION  direction,\r\n\t\tunsigned long  delay,\r\n\t\tshort  autoTrigger_ms\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetSimpleTrigger\", \"ps5000SetSimpleTrigger\", c_uint32, [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetTriggerChannelConditions\r\n\t(\r\n\t\tshort  handle,\r\n\t\tstruct TRIGGER_CONDITIONS  *conditions,\r\n\t\tshort  nConditions\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetTriggerChannelConditions\", \"ps5000SetTriggerChannelConditions\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetTriggerChannelDirections\r\n\t(\r\n\t\tshort  handle,\r\n\t\tTHRESHOLD_DIRECTION  channelA,\r\n\t\tTHRESHOLD_DIRECTION  channelB,\r\n\t\tTHRESHOLD_DIRECTION  channelC,\r\n\t\tTHRESHOLD_DIRECTION  channelD,\r\n\t\tTHRESHOLD_DIRECTION  ext,\r\n\t\tTHRESHOLD_DIRECTION  aux\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetTriggerChannelDirections\", \"ps5000SetTriggerChannelDirections\", c_uint32, [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetTriggerChannelProperties\r\n\t(\r\n\t\tshort  handle,\r\n\t\tstruct TRIGGER_CHANNEL_PROPERTIES  *channelProperties,\r\n\t\tshort  nChannelProperties,\r\n\t\tshort  auxOutputEnable,\r\n\t\tlong  autoTriggerMilliseconds\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetTriggerChannelProperties\", \"ps5000SetTriggerChannelProperties\", c_uint32, [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SetTriggerDelay\r\n\t(\r\n\t\tshort  handle,\r\n\t\tunsigned long  delay\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SetTriggerDelay\", \"ps5000SetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000SigGenSoftwareControl\r\n\t(\r\n\t\tshort  handle,\r\n\t\tshort  state\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_SigGenSoftwareControl\", \"ps5000SigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps5000Stop\r\n\t(\r\n\t\tshort  handle\r\n\t); \"\"\"\r\nps5000.make_symbol(\"_Stop\", \"ps5000Stop\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" void ps5000BlockReady\r\n\t(\r\n\t\tshort  handle,\r\n\t\tPICO_STATUS  status,\r\n\t\tvoid  *pParameter\r\n\t); \"\"\"\r\n\r\nps5000.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_void_p)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\r\nps5000.BlockReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void (CALLBACK *ps5000DataReady)\r\n\t(\r\n\t\tshort  handle,\r\n\t\tlong  noOfSamples,\r\n\t\tshort  overflow,\r\n\t\tunsigned long  triggerAt,\r\n\t\tshort  triggered,\r\n\t\tvoid  *pParameter\r\n\t); \"\"\"\r\n\t\r\nps5000.DataReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_int32,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tc_void_p)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\r\nps5000.DataReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void (CALLBACK *ps5000StreamingReady)\r\n\t(\r\n\t\tshort  handle,\r\n\t\tlong  noOfSamples,\r\n\t\tunsigned long  startIndex,\r\n\t\tshort  overflow,\r\n\t\tunsigned long  triggerAt,\r\n\t\tshort  triggered,\r\n\t\tshort  autoStop,\r\n\t\tvoid  *pParameter\r\n\t); \"\"\"\r\n\r\nps5000.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int32,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_void_p)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\nps5000.StreamingReadyType.__doc__ = doc\r\n"
  },
  {
    "path": "picosdk/ps5000a.py",
    "content": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps5000aApi.h C header\nfile for PicoScope 5000 Series oscilloscopes using the ps5000a driver API\nfunctions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\nfrom picosdk.library import Library\nfrom picosdk.constants import make_enum\n\n\nclass Ps5000alib(Library):\n    def __init__(self):\n        super(Ps5000alib, self).__init__(\"ps5000a\")\n\n\nps5000a = Ps5000alib()\n\nps5000a.PS5000A_DEVICE_RESOLUTION = make_enum([\n    \"PS5000A_DR_8BIT\",\n    \"PS5000A_DR_12BIT\",\n    \"PS5000A_DR_14BIT\",\n    \"PS5000A_DR_15BIT\",\n    \"PS5000A_DR_16BIT\",\n])\n\nps5000a.DEFAULT_RESOLUTION = ps5000a.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_8BIT\"]\n\nps5000a.PS5000A_COUPLING = make_enum([\n    'PS5000A_AC',\n    'PS5000A_DC',\n])\n\n# Just use AC and DC.\nps5000a.PICO_COUPLING = {k[-2:]: v for k, v in ps5000a.PS5000A_COUPLING.items()}\n\nps5000a.PS5000A_BANDWIDTH_LIMITER = make_enum([\n    'PS5000A_BW_FULL',\n    'PS5000A_BW_20MHZ',\n])\n\ndef _define_channel():\n    PS5000A_CHANNEL_A = 0\n    PS5000A_CHANNEL_B = 1\n    PS5000A_CHANNEL_C = 2\n    PS5000A_CHANNEL_D = 3\n    PS5000A_EXTERNAL = PS5000A_MAX_CHANNELS = 4\n    PS5000A_TRIGGER_AUX = 5\n    PS5000A_MAX_TRIGGER_SOURCE = 6\n    PS5000A_DIGITAL_PORT0 = 0x80\n    PS5000A_DIGITAL_PORT1 = PS5000A_DIGITAL_PORT0 + 1\n    PS5000A_DIGITAL_PORT2 = PS5000A_DIGITAL_PORT0 + 2\n    PS5000A_DIGITAL_PORT3 = PS5000A_DIGITAL_PORT0 + 3\n    PS5000A_PULSE_WIDTH_SOURCE = 0x10000000\n\t\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PS5000A\")}\n\nps5000a.PS5000A_CHANNEL = _define_channel()\n\n# only include the normal analog channels for now:\nps5000a.PICO_CHANNEL = {k[-1]: v for k, v in ps5000a.PS5000A_CHANNEL.items() if \"PS5000A_CHANNEL_\" in k}\n\nps5000a.PS5000A_RANGE = make_enum([\n    \"PS5000A_10MV\",\n    \"PS5000A_20MV\",\n    \"PS5000A_50MV\",\n    \"PS5000A_100MV\",\n    \"PS5000A_200MV\",\n    \"PS5000A_500MV\",\n    \"PS5000A_1V\",\n    \"PS5000A_2V\",\n    \"PS5000A_5V\",\n    \"PS5000A_10V\",\n    \"PS5000A_20V\",\n    \"PS5000A_50V\",\n    \"PS5000A_MAX_RANGES\",\n])\n\n\nps5000a.PS5000A_THRESHOLD_DIRECTION = make_enum([\n    (\"PS5000A_ABOVE\", \"PS5000A_INSIDE\"),\n    (\"PS5000A_BELOW\", \"PS5000A_OUTSIDE\"),\n    (\"PS5000A_RISING\", \"PS5000A_ENTER\", \"PS5000A_NONE\"),\n    (\"PS5000A_FALLING\", \"PS5000A_EXIT\"),\n    (\"PS5000A_RISING_OR_FALLING\", \"PS5000A_ENTER_OR_EXIT\"),\n    \"PS5000A_ABOVE_LOWER\",\n    \"PS5000A_BELOW_LOWER\",\n    \"PS5000A_RISING_LOWER\",\n    \"PS5000A_FALLING_LOWER\",\n    \"PS5000A_POSITIVE_RUNT\",\n    \"PS5000A_NEGATIVE_RUNT\",\n])\n\n\nps5000a.PICO_VOLTAGE_RANGE = {\n    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))\n    for k, v in ps5000a.PS5000A_RANGE.items() if k != \"PS5000A_MAX_RANGES\"\n}\n\nps5000a.PS5000A_DIGITAL_CHANNEL = make_enum([\n    \"PS5000A_DIGITAL_CHANNEL_0\",\n    \"PS5000A_DIGITAL_CHANNEL_1\",\n    \"PS5000A_DIGITAL_CHANNEL_2\",\n    \"PS5000A_DIGITAL_CHANNEL_3\",\n    \"PS5000A_DIGITAL_CHANNEL_4\",\n    \"PS5000A_DIGITAL_CHANNEL_5\",\n    \"PS5000A_DIGITAL_CHANNEL_6\",\n    \"PS5000A_DIGITAL_CHANNEL_7\",\n    \"PS5000A_DIGITAL_CHANNEL_8\",\n    \"PS5000A_DIGITAL_CHANNEL_9\",\n    \"PS5000A_DIGITAL_CHANNEL_10\",\n    \"PS5000A_DIGITAL_CHANNEL_11\",\n    \"PS5000A_DIGITAL_CHANNEL_12\",\n    \"PS5000A_DIGITAL_CHANNEL_13\",\n    \"PS5000A_DIGITAL_CHANNEL_14\",\n    \"PS5000A_DIGITAL_CHANNEL_15\",\n    \"PS5000A_DIGITAL_CHANNEL_16\",\n    \"PS5000A_DIGITAL_CHANNEL_17\",\n    \"PS5000A_DIGITAL_CHANNEL_18\",\n    \"PS5000A_DIGITAL_CHANNEL_19\",\n    \"PS5000A_DIGITAL_CHANNEL_20\",\n    \"PS5000A_DIGITAL_CHANNEL_21\",\n    \"PS5000A_DIGITAL_CHANNEL_22\",\n    \"PS5000A_DIGITAL_CHANNEL_23\",\n    \"PS5000A_DIGITAL_CHANNEL_24\",\n    \"PS5000A_DIGITAL_CHANNEL_25\",\n    \"PS5000A_DIGITAL_CHANNEL_26\",\n    \"PS5000A_DIGITAL_CHANNEL_27\",\n    \"PS5000A_DIGITAL_CHANNEL_28\",\n    \"PS5000A_DIGITAL_CHANNEL_29\",\n    \"PS5000A_DIGITAL_CHANNEL_30\",\n    \"PS5000A_DIGITAL_CHANNEL_31\",\n    \"PS5000A_MAX_DIGITAL_CHANNELS\"\n])\n\nps5000a.PS5000A_DIGITAL_DIRECTION = make_enum([\n    \"PS5000A_DIGITAL_DONT_CARE\",\n    \"PS5000A_DIGITAL_DIRECTION_LOW\",\n    \"PS5000A_DIGITAL_DIRECTION_HIGH\",\n    \"PS5000A_DIGITAL_DIRECTION_RISING\",\n    \"PS5000A_DIGITAL_DIRECTION_FALLING\",\n    \"PS5000A_DIGITAL_DIRECTION_RISING_OR_FALLING\",\n    \"PS5000A_DIGITAL_MAX_DIRECTION\"\n])\n\ndef _define_conditionsInfo():\n    PS5000A_CLEAR = 0x00000001\n    PS5000A_ADD = 0x00000002\n\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"PS5000A\")}\n\nps5000a.PS5000AConditionsInfo = _define_conditionsInfo()\n\nps5000a.PS5000A_THRESHOLD_MODE = make_enum([\n    \"PS5000A_LEVEL\",\n    \"PS5000A_WINDOW\"\n])\n\nps5000a.PS5000A_TRIGGER_STATE = make_enum([\n\t\"PS5000A_CONDITION_DONT_CARE\",\n\t\"PS5000A_CONDITION_TRUE\",\n\t\"PS5000A_CONDITION_FALSE\",\n\t\"PS5000A_CONDITION_MAX\"\n])\n\nps5000a.PS5000A_RATIO_MODE = {\n    'PS5000A_RATIO_MODE_NONE': 0,\n    'PS5000A_RATIO_MODE_AGGREGATE': 1,\n    'PS5000A_RATIO_MODE_DECIMATE': 2,\n    'PS5000A_RATIO_MODE_AVERAGE': 4,\n}\n\nps5000a.PICO_RATIO_MODE = {k[19:]: v for k, v in ps5000a.PS5000A_RATIO_MODE.items()}\n\nps5000a.PS5000A_TIME_UNITS = make_enum([\n    'PS5000A_FS',\n    'PS5000A_PS',\n    'PS5000A_NS',\n    'PS5000A_US',\n    'PS5000A_MS',\n    'PS5000A_S',\n    'PS5000A_MAX_TIME_UNITS',\n])\n\nps5000a.PS5000A_PULSE_WIDTH_TYPE = make_enum([\n    'PS5000A_PW_TYPE_NONE',\n    'PS5000A_PW_TYPE_LESS_THAN',\n    'PS5000A_PW_TYPE_GREATER_THAN',\n    'PS5000A_PW_TYPE_IN_RANGE',\n    'PS5000A_PW_TYPE_OUT_OF_RANGE',\n])\n\n\n\nclass PS5000A_TRIGGER_INFO(Structure):\n    _pack_ = 1\n    _fields_ = [(\"status\", c_uint32),\n                (\"segmentIndex\", c_uint32),\n                (\"triggerIndex\", c_uint32),\n                (\"triggerTime\", c_int64),\n                (\"timeUnits\", c_int16),\n                (\"reserved0\", c_int16),\n                (\"timeStampCounter\", c_uint64)]\n\nps5000a.PS5000A_TRIGGER_INFO = PS5000A_TRIGGER_INFO\n\nclass PS5000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channel\", c_int32),\n                (\"direction\", c_int32)]\n\nps5000a.PS5000A_DIGITAL_CHANNEL_DIRECTIONS = PS5000A_DIGITAL_CHANNEL_DIRECTIONS\n\t\t\t\t\nclass PS5000A_DIRECTION(Structure):\n    _pack_ = 1\n    _fields_ = [(\"channel\", c_int32),\n                (\"direction\", c_int32),\n                (\"mode\", c_int32)]\n                \nps5000a.PS5000A_DIRECTION = PS5000A_DIRECTION\n\n\t\t\t\t\nclass PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(Structure):\n    _pack_ = 1\n    _fields_ = [(\"thresholdUpper\", c_int16),\n                (\"thresholdUpperHysteresis\", c_uint16),\n                (\"thresholdLower\", c_int16),\n                (\"thresholdLowerHysteresis\", c_uint16),\n                (\"channel\", c_int32)]\n                \nps5000a.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 = PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2\n\t\t\t\t\n\t\t\t\t\nclass PS5000A_CONDITION (Structure):\n\t_pack_ = 1\n\t_fields_ = [(\"source\", c_int32),\n\t\t\t\t(\"condition\", c_int32)]\n                \nps5000a.PS5000A_CONDITION = PS5000A_CONDITION\n\nclass PS5000A_PWQ_CONDITIONS (Structure):\n    _pack_ = 1\n    _fields_ = [(\"channelA\", c_int16),\n                (\"channelB\", c_int16),\n                (\"channelC\", c_int16),\n                (\"channelD\", c_int16),\n                (\"external\", c_int16),\n                (\"aux\", c_int16)]\n\nps5000a.PS5000A_PWQ_CONDITIONS = PS5000A_PWQ_CONDITIONS\n\ndoc = \"\"\" PICO_STATUS (ps5000aOpenUnit)\n    (\n        int16_t                   *handle,\n        int8_t                    *serial,\n        PS5000A_DEVICE_RESOLUTION  resolution\n    ); \"\"\"\nps5000a.make_symbol(\"_OpenUnit\", \"ps5000aOpenUnit\", c_uint32, [c_void_p, c_char_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aOpenUnitAsync\n    (\n        int16_t                   *status,\n        int8_t                    *serial,\n        PS5000A_DEVICE_RESOLUTION  resolution\n    ); \"\"\"\nps5000a.make_symbol(\"_OpenUnitAsync\", \"ps5000aOpenUnitAsync\", c_uint32, [c_void_p, c_char_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aOpenUnitProgress\n    (\n        int16_t *handle,\n        int16_t *progressPercent,\n        int16_t *complete\n    ); \"\"\"\nps5000a.make_symbol(\"_OpenUnitProgress\", \"ps5000aOpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetUnitInfo\n    (\n        int16_t   handle,\n        int8_t   *string,\n        int16_t   stringLength,\n        int16_t  *requiredSize,\n        PICO_INFO info\n    ); \"\"\"\nps5000a.make_symbol(\"_GetUnitInfo\", \"ps5000aGetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32],\n                    doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aFlashLed\n    (\n        int16_t handle,\n        int16_t start\n    ); \"\"\"\nps5000a.make_symbol(\"_FlashLed\", \"ps5000aFlashLed\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aIsLedFlashing\n    (\n        int16_t  handle,\n        int16_t *status\n    ); \"\"\"\nps5000a.make_symbol(\"_IsLedFlashing\", \"ps5000aIsLedFlashing\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aCloseUnit\n    (\n        int16_t handle\n    ); \"\"\"\nps5000a.make_symbol(\"_CloseUnit\", \"ps5000aCloseUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aMemorySegments\n    (\n        int16_t   handle,\n        uint32_t  nSegments,\n        int32_t  *nMaxSamples\n    ); \"\"\"\nps5000a.make_symbol(\"_MemorySegments\", \"ps5000aMemorySegments\", c_uint32, [c_int16, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetChannel\n    (\n        int16_t          handle,\n        PS5000a_CHANNEL  channel,\n        int16_t          enabled,\n        PS5000a_COUPLING type,\n        PS5000a_RANGE    range,\n        float            analogOffset\n    ); \"\"\"\nps5000a.make_symbol(\"_SetChannel\", \"ps5000aSetChannel\", c_uint32,\n                    [c_int16, c_int32, c_int16, c_int32, c_int32, c_float], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetBandwidthFilter\n    (\n        int16_t                    handle,\n        PS5000A_CHANNEL            channel,\n        PS5000A_BANDWIDTH_LIMITER  bandwidth\n    ); \"\"\"\nps5000a.make_symbol(\"_SetBandwidthFilter\", \"ps5000aSetBandwidthFilter\", c_uint32, [c_int16, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetTimebase\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        int32_t  *timeIntervalNanoseconds,\n        int32_t  *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps5000a.make_symbol(\"_GetTimebase\", \"ps5000aGetTimebase\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_void_p, c_uint32], doc)\n\n\ndoc = \"\"\" PICO_STATUS ps5000aGetTimebase2\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        int32_t   noSamples,\n        float    *timeIntervalNanoseconds,\n        int32_t  *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps5000a.make_symbol(\"_GetTimebase2\", \"ps5000aGetTimebase2\", c_uint32,\n                    [c_int16, c_uint32, c_int32, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetSigGenArbitrary\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        int16_t                    *arbitraryWaveform,\n        int32_t                     arbitraryWaveformSize,\n        PS5000A_SWEEP_TYPE          sweepType,\n        PS5000A_EXTRA_OPERATIONS    operation,\n        PS5000A_INDEX_MODE          indexMode,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS5000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS5000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps5000a.make_symbol(\"_SetSigGenArbitrary\", \"ps5000aSetSigGenArbitrary\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,\n                     c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetSigGenBuiltInV2\n    (\n        int16_t                     handle,\n        int32_t                     offsetVoltage,\n        uint32_t                    pkToPk,\n        PS5000A_WAVE_TYPE           waveType,\n        double                      startFrequency,\n        double                      stopFrequency,\n        double                      increment,\n        double                      dwellTime,\n        PS5000A_SWEEP_TYPE          sweepType,\n        PS5000A_EXTRA_OPERATIONS    operation,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS5000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS5000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps5000a.make_symbol(\"_SetSigGenBuiltIn\", \"ps5000aSetSigGenBuiltInV2\", c_uint32,\n                    [c_int16, c_int32, c_uint32, c_int32, c_double, c_double, c_double, c_double,\n                     c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetSigGenPropertiesArbitrary\n    (\n        int16_t                     handle,\n        uint32_t                    startDeltaPhase,\n        uint32_t                    stopDeltaPhase,\n        uint32_t                    deltaPhaseIncrement,\n        uint32_t                    dwellCount,\n        PS5000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS5000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS5000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps5000a.make_symbol(\"_SetSigGenPropertiesArbitrary\", \"ps5000aSetSigGenPropertiesArbitrary\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetSigGenPropertiesBuiltIn\n    (\n        int16_t                     handle,\n        double                      startFrequency,\n        double                      stopFrequency,\n        double                      increment,\n        double                      dwellTime,\n        PS5000A_SWEEP_TYPE          sweepType,\n        uint32_t                    shots,\n        uint32_t                    sweeps,\n        PS5000A_SIGGEN_TRIG_TYPE    triggerType,\n        PS5000A_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                     extInThreshold\n    ); \"\"\"\nps5000a.make_symbol(\"_SetSigGenPropertiesBuiltIn\", \"ps5000aSetSigGenPropertiesBuiltIn\", c_uint32,\n                    [c_int16, c_double, c_double, c_double, c_double, c_int32, c_uint32, c_uint32, c_int32, c_int32,\n                     c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSigGenFrequencyToPhase\n    (\n        int16_t             handle,\n        double              frequency,\n        PS5000A_INDEX_MODE  indexMode,\n        uint32_t            bufferLength,\n        uint32_t           *phase\n    ); \"\"\"\nps5000a.make_symbol(\"_SigGenFrequencyToPhase\", \"ps5000aSigGenFrequencyToPhase\", c_uint32,\n                    [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSigGenArbitraryMinMaxValues\n    (\n        int16_t   handle,\n        int16_t  *minArbitraryWaveformValue,\n        int16_t  *maxArbitraryWaveformValue,\n        uint32_t *minArbitraryWaveformSize,\n        uint32_t *maxArbitraryWaveformSize\n    ); \"\"\"\nps5000a.make_symbol(\"_SigGenArbitraryMinMaxValues\", \"ps5000aSigGenArbitraryMinMaxValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSigGenSoftwareControl\n    (\n        int16_t  handle,\n        int16_t  state\n    ); \"\"\"\nps5000a.make_symbol(\"_SigGenSoftwareControl\", \"ps5000aSigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetEts\n    (\n        int16_t           handle,\n        PS5000A_ETS_MODE  mode,\n        int16_t           etsCycles,\n        int16_t           etsInterleave,\n        int32_t          *sampleTimePicoseconds\n    ); \"\"\"\nps5000a.make_symbol(\"_SetEts\", \"ps5000aSetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerChannelProperties\n    (\n        int16_t                             handle,\n        PS5000A_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                             nChannelProperties,\n        int16_t                             auxOutputEnable,\n        int32_t                             autoTriggerMilliseconds\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerChannelProperties\", \"ps5000aSetTriggerChannelProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerChannelPropertiesV2\n    (\n        int16_t                             handle,\n        PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 *channelProperties,\n        int16_t                             nChannelProperties,\n        int16_t                             auxOutputEnable,\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerChannelPropertiesV2\", \"ps5000aSetTriggerChannelPropertiesV2\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int16], doc)\n                    \ndoc = \"\"\" PICO_STATUS ps5000aSetAutoTriggerMicroSeconds\n    (\n        int16_t                             handle,\n        uint64_t                          autoTriggerMicroseconds,\n    ); \"\"\"\nps5000a.make_symbol(\"_SetAutoTriggerMicroSeconds\", \"ps5000aSetAutoTriggerMicroSeconds\", c_uint32,\n                    [c_int16, c_uint64], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerChannelConditions\n    (\n        int16_t                     handle,\n        PS5000A_TRIGGER_CONDITIONS *conditions,\n        int16_t                     nConditions\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerChannelConditions\", \"ps5000aSetTriggerChannelConditions\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerChannelConditionsV2\n    (\n        int16_t                     handle,\n        PS5000A_CONDITION *conditions,\n        int16_t                     nConditions\n        PS5000A_CONDITIONS_INFO     info\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerChannelConditionsV2\", \"ps5000aSetTriggerChannelConditionsV2\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerChannelDirections\n    (\n        int16_t                      handle,\n        PS5000A_THRESHOLD_DIRECTION  channelA,\n        PS5000A_THRESHOLD_DIRECTION  channelB,\n        PS5000A_THRESHOLD_DIRECTION  channelC,\n        PS5000A_THRESHOLD_DIRECTION  channelD,\n        PS5000A_THRESHOLD_DIRECTION  ext,\n        PS5000A_THRESHOLD_DIRECTION  aux\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerChannelDirections\", \"ps5000aSetTriggerChannelDirections\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerChannelDirectionsV2\n    (\n        int16_t                    handle,\n        PS5000A_DIRECTION          *directions\n        uint16_t                   nDirections\n     ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerChannelDirectionsV2\", \"ps5000aSetTriggerChannelDirectionsV2\", c_uint32,\n                   [c_int16, c_void_p, c_uint16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetSimpleTrigger\n    (\n        int16_t                      handle,\n        int16_t                      enable,\n        PS5000A_CHANNEL              source,\n        int16_t                      threshold,\n        PS5000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     delay,\n        int16_t                      autoTrigger_ms\n    ); \"\"\"\nps5000a.make_symbol(\"_SetSimpleTrigger\", \"ps5000aSetSimpleTrigger\", c_uint32,\n                    [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerDelay\", \"ps5000aSetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetPulseWidthQualifier\n    (\n        int16_t                      handle,\n        PS5000A_PWQ_CONDITIONS      *conditions,\n        int16_t                      nConditions,\n        PS5000A_THRESHOLD_DIRECTION  direction,\n        uint32_t                     lower,\n        uint32_t                     upper,\n        PS5000A_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps5000a.make_symbol(\"_SetPulseWidthQualifier\", \"ps5000aSetPulseWidthQualifier\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aIsTriggerOrPulseWidthQualifierEnabled\n    (\n        int16_t  handle,\n        int16_t *triggerEnabled,\n        int16_t *pulseWidthQualifierEnabled\n    ); \"\"\"\nps5000a.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps5000aIsTriggerOrPulseWidthQualifierEnabled\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetTriggerTimeOffset64\n    (\n        int16_t             handle,\n        int64_t            *time,\n        PS5000A_TIME_UNITS *timeUnits,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps5000a.make_symbol(\"_GetTriggerTimeOffset\", \"ps5000aGetTriggerTimeOffset64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetValuesTriggerTimeOffsetBulk64\n    (\n        int16_t             handle,\n        int64_t            *times,\n        PS5000A_TIME_UNITS *timeUnits,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex\n    ); \"\"\"\nps5000a.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps5000aGetValuesTriggerTimeOffsetBulk64\", c_uint32,\n                    [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetDataBuffers\n    (\n        int16_t            handle,\n        PS5000A_CHANNEL    channel,\n        int16_t           *bufferMax,\n        int16_t           *bufferMin,\n        int32_t            bufferLth,\n        uint32_t           segmentIndex,\n        PS5000A_RATIO_MODE mode\n    ); \"\"\"\nps5000a.make_symbol(\"_SetDataBuffers\", \"ps5000aSetDataBuffers\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetDataBuffer\n    (\n        int16_t            handle,\n        PS5000A_CHANNEL    channel,\n        int16_t           *buffer,\n        int32_t            bufferLth,\n        uint32_t           segmentIndex,\n        PS5000A_RATIO_MODE mode\n    ); \"\"\"\nps5000a.make_symbol(\"_SetDataBuffer\", \"ps5000aSetDataBuffer\", c_uint32,\n                    [c_int16, c_int32, c_void_p, c_int32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetEtsTimeBuffer\n    (\n        int16_t  handle,\n        int64_t *buffer,\n        int32_t  bufferLth\n    ); \"\"\"\nps5000a.make_symbol(\"_SetEtsTimeBuffer\", \"ps5000aSetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aIsReady\n    (\n        int16_t  handle,\n        int16_t *ready\n    ); \"\"\"\nps5000a.make_symbol(\"_IsReady\", \"ps5000aIsReady\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aRunBlock\n    (\n        int16_t            handle,\n        int32_t            noOfPreTriggerSamples,\n        int32_t            noOfPostTriggerSamples,\n        uint32_t           timebase,\n        int32_t           *timeIndisposedMs,\n        uint32_t           segmentIndex,\n        ps5000aBlockReady  lpReady,\n        void              *pParameter\n    ); \"\"\"\nps5000a.make_symbol(\"_RunBlock\", \"ps5000aRunBlock\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_uint32, c_void_p, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aRunStreaming\n    (\n        int16_t             handle,\n        uint32_t            *sampleInterval,\n        PS5000A_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t            maxPreTriggerSamples,\n        uint32_t            maxPostPreTriggerSamples,\n        int16_t             autoStop,\n        uint32_t            downSampleRatio,\n        PS5000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            overviewBufferSize\n    ); \"\"\"\nps5000a.make_symbol(\"_RunStreaming\", \"ps5000aRunStreaming\", c_uint32,\n                    [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetStreamingLatestValues\n    (\n        int16_t                handle,\n        ps5000aStreamingReady  lpPs5000aReady,\n        void                  *pParameter\n    ); \"\"\"\nps5000a.make_symbol(\"_GetStreamingLatestValues\", \"ps5000aGetStreamingLatestValues\", c_uint32,\n                    [c_int16, c_void_p, c_void_p], doc)\n\t\t\t\t\t\ndoc = \"\"\" void *ps5000aStreamingReady\n    (\n        int16_t   handle,\n        int32_t   noOfSamples,\n        uint32_t  startIndex,\n        int16_t   overflow,\n        uint32_t  triggerAt,\n        int16_t   triggered,\n        int16_t   autoStop,\n        void     *pParameter\n    );\n    define a python function which accepts the correct arguments, and pass it to the constructor of this type.\n    \"\"\"\n\nps5000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                         c_int16,\n                                                         c_int32,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_uint32,\n                                                         c_int16,\n                                                         c_int16,\n                                                         c_void_p)\n\nps5000a.StreamingReadyType.__doc__ = doc\n\ndoc = \"\"\"void *ps5000aBlockReady\n    (\n        int16_t    handle,\n        PICO_STATUS    status,\n        void    *pParameter\n    );\n    \"\"\"\n    \nps5000a.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                     c_int16,\n                                                     c_int32,\n                                                     c_void_p)\n                                                     \nps5000a.BlockReadyType.__doc__ = doc\n\ndoc = \"\"\" PICO_STATUS ps5000aNoOfStreamingValues\n    (\n        int16_t   handle,\n        uint32_t *noOfValues\n    ); \"\"\"\nps5000a.make_symbol(\"_NoOfStreamingValues\", \"ps5000aNoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetMaxDownSampleRatio\n    (\n        int16_t             handle,\n        uint32_t            noOfUnaggreatedSamples,\n        uint32_t           *maxDownSampleRatio,\n        PS5000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex\n    ); \"\"\"\nps5000a.make_symbol(\"_GetMaxDownSampleRatio\", \"ps5000aGetMaxDownSampleRatio\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetValues\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS5000a_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps5000a.make_symbol(\"_GetValues\", \"ps5000aGetValues\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetValuesAsync\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t            noOfSamples,\n        uint32_t            downSampleRatio,\n        PS5000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        void               *lpDataReady,\n        void               *pParameter\n    ); \"\"\"\nps5000a.make_symbol(\"_GetValuesAsync\", \"ps5000aGetValuesAsync\", c_uint32,\n                    [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetValuesBulk\n    (\n        int16_t             handle,\n        uint32_t           *noOfSamples,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        uint32_t            downSampleRatio,\n        PS5000A_RATIO_MODE  downSampleRatioMode,\n        int16_t            *overflow\n    ); \"\"\"\nps5000a.make_symbol(\"_GetValuesBulk\", \"ps5000aGetValuesBulk\", c_uint32,\n                    [c_int16, c_void_p, c_uint32, c_uint32, c_uint32, c_int32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetValuesOverlapped\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS5000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            segmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps5000a.make_symbol(\"_GetValuesOverlapped\", \"ps5000aGetValuesOverlapped\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetValuesOverlappedBulk\n    (\n        int16_t             handle,\n        uint32_t            startIndex,\n        uint32_t           *noOfSamples,\n        uint32_t            downSampleRatio,\n        PS5000A_RATIO_MODE  downSampleRatioMode,\n        uint32_t            fromSegmentIndex,\n        uint32_t            toSegmentIndex,\n        int16_t            *overflow\n    ); \"\"\"\nps5000a.make_symbol(\"_GetValuesOverlappedBulk\", \"ps5000aGetValuesOverlappedBulk\", c_uint32,\n                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aTriggerWithinPreTriggerSamples\n    (\n        int16_t                             handle,\n        PS5000A_TRIGGER_WITHIN_PRE_TRIGGER  state\n    ); \"\"\"\nps5000a.make_symbol(\"_TriggerWithinPreTriggerSamples\", \"ps5000aTriggerWithinPreTriggerSamples\", c_uint32,\n                    [c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetTriggerInfoBulk\n    (\n        int16_t               handle,\n        PS5000A_TRIGGER_INFO *triggerInfo,\n        uint32_t              fromSegmentIndex,\n        uint32_t              toSegmentIndex\n    ); \"\"\"\nps5000a.make_symbol(\"_GetTriggerInfoBulk\", \"ps5000aGetTriggerInfoBulk\", c_uint32,\n                    [c_int16, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aEnumerateUnits\n    (\n        int16_t *count,\n        int8_t  *serials,\n        int16_t *serialLth\n    ); \"\"\"\nps5000a.make_symbol(\"_EnumerateUnits\", \"ps5000aEnumerateUnits\", c_uint32, [c_void_p, c_char_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetChannelInformation\n    (\n        int16_t               handle,\n        PS5000A_CHANNEL_INFO  info,\n        int32_t               probe,\n        int32_t              *ranges,\n        int32_t              *length,\n        int32_t               channels\n    ); \"\"\"\nps5000a.make_symbol(\"_GetChannelInformation\", \"ps5000aGetChannelInformation\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aMaximumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps5000a.make_symbol(\"_MaximumValue\", \"ps5000aMaximumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aMinimumValue\n    (\n        int16_t  handle,\n        int16_t *value\n    ); \"\"\"\nps5000a.make_symbol(\"_MinimumValue\", \"ps5000aMinimumValue\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetAnalogueOffset\n    (\n        int16_t           handle,\n        PS5000A_RANGE     range,\n        PS5000A_COUPLING  coupling,\n        float            *maximumVoltage,\n        float            *minimumVoltage\n    ); \"\"\"\nps5000a.make_symbol(\"_GetAnalogueOffset\", \"ps5000aGetAnalogueOffset\", c_uint32,\n                    [c_int16, c_int32, c_int32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetMaxSegments\n    (\n        int16_t   handle,\n        uint32_t *maxSegments\n    ); \"\"\"\nps5000a.make_symbol(\"_GetMaxSegments\", \"ps5000aGetMaxSegments\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aChangePowerSource\n    (\n        int16_t     handle,\n        PICO_STATUS powerState\n    ); \"\"\"\nps5000a.make_symbol(\"_ChangePowerSource\", \"ps5000aChangePowerSource\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aCurrentPowerSource\n    (\n        int16_t handle\n    ); \"\"\"\nps5000a.make_symbol(\"_CurrentPowerSource\", \"ps5000aCurrentPowerSource\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aStop\n    (\n        int16_t  handle\n    ); \"\"\"\nps5000a.make_symbol(\"_Stop\", \"ps5000aStop\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aPingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps5000a.make_symbol(\"_PingUnit\", \"ps5000aPingUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t  nCaptures\n    ); \"\"\"\nps5000a.make_symbol(\"_SetNoOfCaptures\", \"ps5000aSetNoOfCaptures\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t *nCaptures\n    ); \"\"\"\nps5000a.make_symbol(\"_GetNoOfCaptures\", \"ps5000aGetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetNoOfProcessedCaptures\n    (\n         int16_t   handle,\n         uint32_t *nProcessedCaptures\n    ); \"\"\"\nps5000a.make_symbol(\"_GetNoOfProcessedCaptures\", \"ps5000aGetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetDeviceResolution\n    (\n      int16_t                    handle,\n      PS5000A_DEVICE_RESOLUTION  resolution\n    ); \"\"\"\nps5000a.make_symbol(\"_SetDeviceResolution\", \"ps5000aSetDeviceResolution\", c_uint32, [c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetDeviceResolution\n    (\n        int16_t                    handle,\n        PS5000A_DEVICE_RESOLUTION *resolution\n    ); \"\"\"\nps5000a.make_symbol(\"_GetDeviceResolution\", \"ps5000aGetDeviceResolution\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetDigitalPort\n    (\n        int16_t                 handle,\n        PS5000A_CHANNEL         port,\n        int16_t                 enabled,\n        int16_t                 logicLevel\n    ); \"\"\"\nps5000a.make_symbol(\"_SetDigitalPort\", \"ps5000aSetDigitalPort\", c_uint32, [c_int16, c_int32, c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetPulseWidthDigitalPortProperties\n    (\n        int16_t                             handle,\n        PS5000A_DIGITAL_CHANNEL_DIRECTIONS *directions,\n        int16_t                             nDirections\n    ); \"\"\"\nps5000a.make_symbol(\"_SetPulseWidthDigitalPortProperties\", \"ps5000aSetPulseWidthDigitalPortProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetTriggerDigitalPortProperties\n    (\n        int16_t                             handle,\n        PS5000A_DIGITAL_CHANNEL_DIRECTIONS *directions,\n        int16_t                             nDirections\n    ); \"\"\"\nps5000a.make_symbol(\"_SetTriggerDigitalPortProperties\", \"ps5000aSetTriggerDigitalPortProperties\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n                    \ndoc = \"\"\" PICO_STATUS ps5000aSetPulseWidthQualifierProperties\n    (\n        int16_t                            handle,\n        uint32_t                           lower,\n        uint32_t                           upper,\n        PS5000A_PULSE_WIDTH_TYPE           type\n    ); \"\"\"\nps5000a.make_symbol(\"_SetPulseWidthQualifierProperties\", \"ps5000aSetPulseWidthQualifierProperties\", c_uint32, \n                    [c_int16, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aSetPulseWidthQualifierConditions\n    (\n        int16_t                            handle,\n        PS5000A_CONDITION                  *conditions,\n        int16_t                            nConditions,\n        PS5000A_CONDITIONS_INFO            info\n    ); \"\"\"\nps5000a.make_symbol(\"_SetPulseWidthQualifierConditions\", \"ps5000aSetPulseWidthQualifierConditions\", c_uint32,\n                    [c_int16, c_void_p, c_int16, c_int32], doc)\n                    \ndoc = \"\"\" PICO_STATUS ps5000aSetPulseWidthQualifierDirections\n    (\n        int16_t                             handle,\n        PS5000A_DIRECTION                   *directions,\n        int16_t                             nDirections\n    ); \"\"\"\nps5000a.make_symbol(\"_SetPulseWidthQualifierDirections\", \"ps5000aSetPulseWidthQualifierDirections\", c_uint32,\n                    [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps5000aGetMinimumTimebaseStateless\n    (\n        int16_t                      handle,\n        PS5000A_CHANNEL_FLAGS        enabledChannelOrPortFlags,\n        uint32_t                     *timebase,\n        double                       *timeInterval,\n        PS5000A_DEVICE_RESOLUTION    resolution\n    ); \"\"\"\nps5000a.make_symbol(\"_GetMinimumTimebaseStateless\", \"ps5000aGetMinimumTimebaseStateless\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_uint32], doc)    \n"
  },
  {
    "path": "picosdk/ps6000.py",
    "content": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the functions from the ps6000Api.h C header\nfile for PicoScope 6000 Series oscilloscopes using the ps6000 driver API\nfunctions.\n\"\"\"\n\nfrom ctypes import *\nfrom picosdk.library import Library\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\nfrom picosdk.constants import make_enum\n\n\nclass Ps6000lib(Library):\n    def __init__(self):\n        super(Ps6000lib, self).__init__(\"ps6000\")\n\n\nps6000 = Ps6000lib()\n\nps6000.PS6000_RANGE = make_enum([\n    \"PS6000A_10MV\",\n    \"PS6000_20MV\",\n    \"PS6000_50MV\",\n    \"PS6000_100MV\",\n    \"PS6000_200MV\",\n    \"PS6000_500MV\",\n    \"PS6000_1V\",\n    \"PS6000_2V\",\n    \"PS6000_5V\",\n    \"PS6000_10V\",\n    \"PS6000_20V\",\n    \"PS6000_50V\",\n    \"PS6000_MAX_RANGES\",\n])\n\nps6000.PS6000_CHANNEL = make_enum([\n\t\"PS6000_CHANNEL_A\",\n\t\"PS6000_CHANNEL_B\",\n\t\"PS6000_CHANNEL_C\",\n\t\"PS6000_CHANNEL_D\",\n\t(\"PS6000_EXTERNAL\", \"PS6000_MAX_CHANNELS\"),\n\t\"PS6000_TRIGGER_AUX\",\n\t\"PS6000_MAX_TRIGGER_SOURCES\",\n])\n\nps6000.PS6000_COUPLING = make_enum([\n\t\"PS6000_AC\",\n\t\"PS6000_DC_1M\",\n\t\"PS6000_DC_50R\",\n])\n\nps6000.PS6000_BANDWIDTH_LIMITER = make_enum([\n\t\"PS6000_BW_FULL\",\n\t\"PS6000_BW_20MHZ\",\n\t\"PS6000_BW_25MHZ\",\n])\n\nps6000.PS6000_RATIO_MODE = {\n\t\"PS6000_RATIO_MODE_NONE\" : 0,\n\t\"PS6000_RATIO_MODE_AGGREGATE\" : 1,\n\t\"PS6000_RATIO_MODE_AVERAGE\" : 2,\n\t\"PS6000_RATIO_MODE_DECIMATE\" : 4,\n\t\"PS6000_RATIO_MODE_DISTRIBUTION\" : 8,\n}\n\nps6000.PS6000_TIME_UNITS = make_enum([\n\t\"PS6000_FS\",\n\t\"PS6000_PS\",\n\t\"PS6000_NS\",\n\t\"PS6000_US\",\n\t\"PS6000_MS\",\n\t\"PS6000_S\",\n\t\"PS6000_MAX_TIME_UNITS\",\n])\n\nps6000.PS6000_TRIGGER_STATE = make_enum([\n\t\"PS6000_CONDITION_DONT_CARE\",\n\t\"PS6000_CONDITION_TRUE\",\n\t\"PS6000_CONDITION_FALSE\",\n\t\"PS6000_CONDITION_MAX\",\n])\n\nps6000.PS6000_THRESHOLD_DIRECTION = make_enum([\n\t(\"PS6000_ABOVE\", \"PS6000_INSIDE\"),\n\t(\"PS6000_BELOW\", \"PS6000_BELOW\"),\n\t(\"PS6000_RISING\", \"PS6000_ENTER\", \"PS6000_NONE\"),\n\t(\"PS6000_FALLING\", \"PS6000_EXIT\"),\n\t(\"PS6000_RISING_OR_FALLING\", \"PS6000_ENTER_OR_EXIT\"),\n\t\"PS6000_ABOVE_LOWER\",\n\t\"PS6000_BELOW_LOWER\",\n\t\"PS6000_RISING_LOWER\",\n\t\"PS6000_FALLING_LOWER\",\n\t\"PS6000_POSITIVE_RUNT\",\n\t\"PS6000_NEGATIVE_RUNT\",\n])\n\t\nps6000.PS6000_THRESHOLD_MODE = make_enum([\n\t\"PS6000_LEVEL\",\n\t\"PS6000_WINDOW\",\n])\n\nps6000.PS6000_PULSE_WIDTH_TYPE = make_enum([\n\t\"PS6000_PW_TYPE_NONE\",\n\t\"PS6000_PW_TYPE_LESS_THAN\",\n\t\"PS6000_PW_TYPE_GREATER_THAN\",\n\t\"PS6000_PW_TYPE_IN_RANGE\",\n\t\"PS6000_PW_TYPE_OUT_OF_RANGE\"\n])\n\nps6000.PICO_INFO = {\n    \"PICO_DRIVER_VERSION\" : 0,\n    \"PICO_USB_VERSION\" : 1,\n    \"PICO_HARDWARE_VERSION\" : 2,\n    \"PICO_VARIANT_INFO\" : 3,\n    \"PICO_BATCH_AND_SERIAL\" : 4,\n    \"PICO_CAL_DATE\" : 5,\n    \"PICO_KERNAL_VERSION\" : 6,\n    \"PICO_DIGITAL_HARDWARE_VERSION\" : 7,\n    \"PICO_ANALOGUE_HARDWARE_VERSION\" : 8,\n    \"PICO_FIRMWARE_VERSION_1\" : 9,\n    \"PICO_FIREWARE_VERSION_2\" : 'A'\n}\n    \n\nclass PS6000_TRIGGER_CONDITIONS (Structure):\n    _pack_ = 1\n    _fields_ = [(\"channelA\", c_uint32),\n                (\"channelB\", c_uint32),\n\t\t\t\t(\"channelC\", c_uint32),\n\t\t\t\t(\"channelD\", c_uint32),\n\t\t\t\t(\"external\", c_uint32),\n\t\t\t\t(\"aux\", c_uint32),\n\t\t\t\t(\"pulseWidthQualifier\", c_uint32)]\n\t\t\t\t\nps6000.PS6000_TRIGGER_CONDITIONS = PS6000_TRIGGER_CONDITIONS\n\nclass PS6000_TRIGGER_CHANNEL_PROPERTIES (Structure):\n    _pack_ = 1\n    _fields_ = [(\"thresholdUpper\", c_int16),\n                (\"hysteresisUpper\", c_uint16),\n                (\"thresholdLower\", c_int16),\n                (\"hysteresisLower\", c_uint16),\n                (\"channel\", c_uint32),\n                (\"thresholdMode\", c_uint32)]\n\t\t\t\t\nps6000.PS6000_TRIGGER_CHANNEL_PROPERTIES = PS6000_TRIGGER_CHANNEL_PROPERTIES\n\nclass PS6000_PWQ_CONDITIONS (Structure):\n\t_pack_ = 1\n\t_fields_ = [(\"channelA\", c_uint32),\n\t\t\t\t(\"channelB\", c_uint32),\n\t\t\t\t(\"channelC\", c_uint32),\n\t\t\t\t(\"channelD\", c_uint32),\n\t\t\t\t(\"external\", c_uint32),\n\t\t\t\t(\"aux\", c_uint32)]\n\t\t\t\t\nps6000.PS6000_PWQ_CONDITIONS = PS6000_PWQ_CONDITIONS\n\nclass PS6000_TRIGGER_INFO (Structure):\n    _pack_ = 1\n    _fields_ = [(\"status\", c_uint32),\n                (\"segmentIndex\", c_uint32),\n                (\"triggerIndex\", c_uint32),\n                (\"triggerTime\", c_uint64),\n                (\"timeUnits\", c_uint16),\n                (\"reserved0\", c_uint16),\n                (\"timeStampCounter\", c_uint64)]\n                \nps6000.PS6000_TRIGGER_INFO = PS6000_TRIGGER_INFO\n\t\n\n\n# some ps6000 scopes have 2GS of memory.\nps6000.MAX_MEMORY = 2**31\n\ndoc = \"\"\" PICO_STATUS ps6000OpenUnit\n    (\n        int16_t *handle,\n        int8_t  *serial\n    ); \"\"\"\nps6000.make_symbol(\"_OpenUnit\", \"ps6000OpenUnit\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000OpenUnitAsync\n    (\n        int16_t *status,\n        int8_t  *serial\n    ); \"\"\"\nps6000.make_symbol(\"_OpenUnitAsync\", \"ps6000OpenUnitAsync\", c_uint32, [c_void_p, c_char_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000OpenUnitProgress\n    (\n      int16_t *handle,\n      int16_t *progressPercent,\n      int16_t *complete\n    ); \"\"\"\nps6000.make_symbol(\"_OpenUnitProgress\", \"ps6000OpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetUnitInfo\n    (\n        int16_t    handle,\n        int8_t    *string,\n        int16_t    stringLength,\n        int16_t   *requiredSize,\n        PICO_INFO  info\n    ); \"\"\"\nps6000.make_symbol(\"_GetUnitInfo\", \"ps6000GetUnitInfo\", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000FlashLed\n    (\n        int16_t  handle,\n        int16_t  start\n    ); \"\"\"\nps6000.make_symbol(\"_FlashLed\", \"ps6000FlashLed\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000CloseUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps6000.make_symbol(\"_CloseUnit\", \"ps6000CloseUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000MemorySegments\n    (\n        int16_t   handle,\n        uint32_t  nSegments,\n        uint32_t *nMaxSamples\n    ); \"\"\"\nps6000.make_symbol(\"_MemorySegments\", \"ps6000MemorySegments\", c_uint32, [c_int16, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetChannel\n    (\n        int16_t                   handle,\n        PS6000_CHANNEL            channel,\n        int16_t                   enabled,\n        PS6000_COUPLING           type,\n        PS6000_RANGE              range,\n        float                     analogueOffset,\n        PS6000_BANDWIDTH_LIMITER  bandwidth\n    ); \"\"\"\nps6000.make_symbol(\"_SetChannel\", \"ps6000SetChannel\", c_uint32,\n                   [c_int16, c_int32, c_int16, c_int32, c_int32, c_float, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetTimebase\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        uint32_t  noSamples,\n        int32_t  *timeIntervalNanoseconds,\n        int16_t   oversample,\n        uint32_t *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetTimebase\", \"ps6000GetTimebase\", c_uint32,\n                   [c_int16, c_uint32, c_uint32, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetTimebase2\n    (\n        int16_t   handle,\n        uint32_t  timebase,\n        uint32_t  noSamples,\n        float    *timeIntervalNanoseconds,\n        int16_t   oversample,\n        uint32_t *maxSamples,\n        uint32_t  segmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetTimebase2\", \"ps6000GetTimebase2\", c_uint32,\n                   [c_int16, c_uint32, c_uint32, c_void_p, c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetSigGenArbitrary\n    (\n        int16_t                    handle,\n        int32_t                    offsetVoltage,\n        uint32_t                   pkToPk,\n        uint32_t                   startDeltaPhase,\n        uint32_t                   stopDeltaPhase,\n        uint32_t                   deltaPhaseIncrement,\n        uint32_t                   dwellCount,\n        int16_t                   *arbitraryWaveform,\n        int32_t                    arbitraryWaveformSize,\n        PS6000_SWEEP_TYPE          sweepType,\n        PS6000_EXTRA_OPERATIONS    operation,\n        PS6000_INDEX_MODE          indexMode,\n        uint32_t                   shots,\n        uint32_t                   sweeps,\n        PS6000_SIGGEN_TRIG_TYPE    triggerType,\n        PS6000_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                    extInThreshold\n    ); \"\"\"\nps6000.make_symbol(\"_SetSigGenArbitrary\", \"ps6000SetSigGenArbitrary\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p,\n                    c_int32, c_int32, c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetSigGenBuiltIn\n    (\n        int16_t                    handle,\n        int32_t                    offsetVoltage,\n        uint32_t                   pkToPk,\n        int16_t                    waveType,\n        float                      startFrequency,\n        float                      stopFrequency,\n        float                      increment,\n        float                      dwellTime,\n        PS6000_SWEEP_TYPE          sweepType,\n        PS6000_EXTRA_OPERATIONS    operation,\n        uint32_t                   shots,\n        uint32_t                   sweeps,\n        PS6000_SIGGEN_TRIG_TYPE    triggerType,\n        PS6000_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                    extInThreshold\n    ); \"\"\"\nps6000.make_symbol(\"_SetSigGenBuiltIn\", \"ps6000SetSigGenBuiltIn\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_int16, c_float, c_float, c_float, c_float,\n                    c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetSigGenBuiltInV2\n    (\n        int16_t                    handle,\n        int32_t                    offsetVoltage,\n        uint32_t                   pkToPk,\n        int16_t                    waveType,\n        double                     startFrequency,\n        double                     stopFrequency,\n        double                     increment,\n        double                     dwellTime,\n        PS6000_SWEEP_TYPE          sweepType,\n        PS6000_EXTRA_OPERATIONS    operation,\n        uint32_t                   shots,\n        uint32_t                   sweeps,\n        PS6000_SIGGEN_TRIG_TYPE    triggerType,\n        PS6000_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                    extInThreshold\n    ); \"\"\"\nps6000.make_symbol(\"_SetSigGenBuiltInV2\", \"ps6000SetSigGenBuiltInV2\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_int16, c_double, c_double, c_double, c_double,\n                    c_int32, c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetSigGenPropertiesArbitrary\n    (\n        int16_t                    handle,\n        int32_t                    offsetVoltage,\n        uint32_t                   pkToPk,\n        uint32_t                   startDeltaPhase,\n        uint32_t                   stopDeltaPhase,\n        uint32_t                   deltaPhaseIncrement,\n        uint32_t                   dwellCount,\n        PS6000_SWEEP_TYPE          sweepType,\n        uint32_t                   shots,\n        uint32_t                   sweeps,\n        PS6000_SIGGEN_TRIG_TYPE    triggerType,\n        PS6000_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                    extInThreshold\n    ); \"\"\"\nps6000.make_symbol(\"_SigGenPropertiesArbitrary\", \"ps6000SetSigGenPropertiesArbitrary\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32,\n                    c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetSigGenPropertiesBuiltIn\n    (\n        int16_t                    handle,\n        int32_t                    offsetVoltage,\n        uint32_t                   pkToPk,\n        double                     startFrequency,\n        double                     stopFrequency,\n        double                     increment,\n        double                     dwellTime,\n        PS6000_SWEEP_TYPE          sweepType,\n        uint32_t                   shots,\n        uint32_t                   sweeps,\n        PS6000_SIGGEN_TRIG_TYPE    triggerType,\n        PS6000_SIGGEN_TRIG_SOURCE  triggerSource,\n        int16_t                    extInThreshold\n    ); \"\"\"\nps6000.make_symbol(\"_SetSigGenPropertiesBuiltIn\", \"ps6000SetSigGenPropertiesBuiltIn\", c_uint32,\n                   [c_int16, c_int32, c_uint32, c_double, c_double, c_double, c_double,\n                    c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SigGenFrequencyToPhase\n    (\n        int16_t            handle,\n        double             frequency,\n        PS6000_INDEX_MODE  indexMode,\n        uint32_t           bufferLength,\n        uint32_t          *phase\n    ); \"\"\"\nps6000.make_symbol(\"_SigGenFrequencyToPhase\", \"ps6000SigGenFrequencyToPhase\", c_uint32,\n                   [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SigGenArbitraryMinMaxValues\n    (\n        int16_t   handle,\n        int16_t  *minArbitraryWaveformValue,\n        int16_t  *maxArbitraryWaveformValue,\n        uint32_t *minArbitraryWaveformSize,\n        uint32_t *maxArbitraryWaveformSize\n    ); \"\"\"\nps6000.make_symbol(\"_SigGenArbitraryMinMaxValues\", \"ps6000SigGenArbitraryMinMaxValues\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SigGenSoftwareControl\n    (\n        int16_t  handle,\n        int16_t  state\n    ); \"\"\"\nps6000.make_symbol(\"_SigGenSoftwareControl\", \"ps6000SigGenSoftwareControl\", c_uint32, [c_int16, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetSimpleTrigger\n    (\n        int16_t                     handle,\n        int16_t                     enable,\n        PS6000_CHANNEL              source,\n        int16_t                     threshold,\n        PS6000_THRESHOLD_DIRECTION  direction,\n        uint32_t                    delay,\n        int16_t                     autoTrigger_ms\n    ); \"\"\"\nps6000.make_symbol(\"_SetSimpleTrigger\", \"ps6000SetSimpleTrigger\", c_uint32,\n                   [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetEts\n    (\n        int16_t          handle,\n        PS6000_ETS_MODE  mode,\n        int16_t          etsCycles,\n        int16_t          etsInterleave,\n        int32_t         *sampleTimePicoseconds\n    ); \"\"\"\nps6000.make_symbol(\"_SetEts\", \"ps6000SetEts\", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetTriggerChannelProperties\n    (\n        int16_t                            handle,\n        PS6000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,\n        int16_t                            nChannelProperties,\n        int16_t                            auxOutputEnable,\n        int32_t                            autoTriggerMilliseconds\n    ); \"\"\"\nps6000.make_symbol(\"_SetTriggerChannelProperties\", \"ps6000SetTriggerChannelProperties\", c_uint32,\n                   [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetTriggerChannelConditions\n    (\n        int16_t                    handle,\n        PS6000_TRIGGER_CONDITIONS *conditions,\n        int16_t                    nConditions\n    ); \"\"\"\nps6000.make_symbol(\"_SetTriggerChannelConditions\", \"ps6000SetTriggerChannelConditions\", c_uint32,\n                   [c_int16, c_void_p, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetTriggerChannelDirections\n    (\n        int16_t                       handle,\n        PS6000_THRESHOLD_DIRECTION  channelA,\n        PS6000_THRESHOLD_DIRECTION  channelB,\n        PS6000_THRESHOLD_DIRECTION  channelC,\n        PS6000_THRESHOLD_DIRECTION  channelD,\n        PS6000_THRESHOLD_DIRECTION  ext,\n        PS6000_THRESHOLD_DIRECTION  aux\n    ); \"\"\"\nps6000.make_symbol(\"_SetTriggerChannelDirections\", \"ps6000SetTriggerChannelDirections\", c_uint32,\n                   [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetTriggerDelay\n    (\n        int16_t   handle,\n        uint32_t  delay\n    ); \"\"\"\nps6000.make_symbol(\"_SetTriggerDelay\", \"ps6000SetTriggerDelay\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetPulseWidthQualifier\n    (\n        int16_t                     handle,\n        PS6000_PWQ_CONDITIONS      *conditions,\n        int16_t                     nConditions,\n        PS6000_THRESHOLD_DIRECTION  direction,\n        uint32_t                    lower,\n        uint32_t                    upper,\n        PS6000_PULSE_WIDTH_TYPE     type\n    ); \"\"\"\nps6000.make_symbol(\"_SetPulseWidthQualifier\", \"ps6000SetPulseWidthQualifier\", c_uint32,\n                   [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000IsTriggerOrPulseWidthQualifierEnabled\n    (\n        int16_t  handle,\n        int16_t *triggerEnabled,\n        int16_t *pulseWidthQualifierEnabled\n    ); \"\"\"\nps6000.make_symbol(\"_IsTriggerOrPulseWidthQualifierEnabled\", \"ps6000IsTriggerOrPulseWidthQualifierEnabled\", c_uint32,\n                   [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetTriggerTimeOffset\n    (\n        int16_t            handle,\n        uint32_t          *timeUpper,\n        uint32_t          *timeLower,\n        PS6000_TIME_UNITS *timeUnits,\n        uint32_t           segmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetTriggerTimeOffset\", \"ps6000GetTriggerTimeOffset\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetTriggerTimeOffset64\n    (\n        int16_t              handle,\n        int64_t           *time,\n        PS6000_TIME_UNITS *timeUnits,\n        uint32_t      segmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetTriggerTimeOffset64\", \"ps6000GetTriggerTimeOffset64\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesTriggerTimeOffsetBulk\n    (\n        int16_t            handle,\n        uint32_t          *timesUpper,\n        uint32_t          *timesLower,\n        PS6000_TIME_UNITS *timeUnits,\n        uint32_t           fromSegmentIndex,\n        uint32_t           toSegmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_ps6000GetValuesTriggerTimeOffsetBulk\", \"ps6000GetValuesTriggerTimeOffsetBulk\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesTriggerTimeOffsetBulk64\n    (\n        int16_t            handle,\n        int64_t           *times,\n        PS6000_TIME_UNITS *timeUnits,\n        uint32_t           fromSegmentIndex,\n        uint32_t           toSegmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetValuesTriggerTimeOffsetBulk64\", \"ps6000GetValuesTriggerTimeOffsetBulk64\", c_uint32,\n                   [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetDataBuffers\n    (\n        int16_t            handle,\n        PS6000_CHANNEL     channel,\n        int16_t           *bufferMax,\n        int16_t           *bufferMin,\n        uint32_t           bufferLth,\n        PS6000_RATIO_MODE  downSampleRatioMode\n    ); \"\"\"\nps6000.make_symbol(\"_SetDataBuffers\", \"ps6000SetDataBuffers\", c_uint32,\n                   [c_int16, c_int32, c_void_p, c_void_p, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetDataBuffer\n    (\n        int16_t            handle,\n        PS6000_CHANNEL     channel,\n        int16_t           *buffer,\n        uint32_t           bufferLth,\n        PS6000_RATIO_MODE  downSampleRatioMode\n    ); \"\"\"\nps6000.make_symbol(\"_SetDataBuffer\", \"ps6000SetDataBuffer\", c_uint32, [c_int16, c_int32, c_void_p, c_uint32, c_int32],\n                   doc)\n\ndoc = \"\"\" PICO_STATUS (ps6000SetDataBufferBulk)\n    (\n        int16_t            handle,\n        PS6000_CHANNEL     channel,\n        int16_t           *buffer,\n        uint32_t           bufferLth,\n        uint32_t           waveform,\n        PS6000_RATIO_MODE  downSampleRatioMode\n    ); \"\"\"\nps6000.make_symbol(\"_SetDataBufferBulk\", \"ps6000SetDataBufferBulk\", c_uint32,\n                   [c_int16, c_int32, c_void_p, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetDataBuffersBulk\n    (\n        int16_t            handle,\n        PS6000_CHANNEL     channel,\n        int16_t           *bufferMax,\n        int16_t           *bufferMin,\n        uint32_t           bufferLth,\n        uint32_t           waveform,\n        PS6000_RATIO_MODE  downSampleRatioMode\n    ); \"\"\"\nps6000.make_symbol(\"_SetDataBuffersBulk\", \"ps6000SetDataBuffersBulk\", c_uint32,\n                   [c_int16, c_int32, c_void_p, c_void_p, c_uint32, c_uint32, c_int32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetEtsTimeBuffer\n    (\n        int16_t   handle,\n        int64_t  *buffer,\n        uint32_t  bufferLth\n    ); \"\"\"\nps6000.make_symbol(\"_SetEtsTimeBuffer\", \"ps6000SetEtsTimeBuffer\", c_uint32, [c_int16, c_void_p, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetEtsTimeBuffers\n    (\n        int16_t   handle,\n        uint32_t *timeUpper,\n        uint32_t *timeLower,\n        uint32_t  bufferLth\n    ); \"\"\"\nps6000.make_symbol(\"_SetEtsTimeBuffers\", \"ps6000SetEtsTimeBuffers\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint32],\n                   doc)\n\ndoc = \"\"\" PICO_STATUS ps6000RunBlock\n    (\n        int16_t           handle,\n        uint32_t          noOfPreTriggerSamples,\n        uint32_t          noOfPostTriggerSamples,\n        uint32_t          timebase,\n        int16_t           oversample,\n        int32_t          *timeIndisposedMs,\n        uint32_t          segmentIndex,\n        ps6000BlockReady  lpReady,\n        void             *pParameter\n    ); \"\"\"\nps6000.make_symbol(\"_RunBlock\", \"ps6000RunBlock\", c_uint32,\n                   [c_int16, c_uint32, c_uint32, c_uint32, c_int16, c_void_p, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000IsReady\n    (\n        int16_t  handle,\n        int16_t *ready\n    ); \"\"\"\nps6000.make_symbol(\"_IsReady\", \"ps6000IsReady\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000RunStreaming\n    (\n        int16_t            handle,\n        uint32_t          *sampleInterval,\n        PS6000_TIME_UNITS  sampleIntervalTimeUnits,\n        uint32_t           maxPreTriggerSamples,\n        uint32_t           maxPostPreTriggerSamples,\n        int16_t            autoStop,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           overviewBufferSize\n    ); \"\"\"\nps6000.make_symbol(\"_RunStreaming\", \"ps6000RunStreaming\", c_uint32,\n                   [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)\n\t\t\t\t   \ndoc = \"\"\" void ps6000BlockReady\n    (\n        int16_t          handle,\n        PICO_STATUS      status,\n        void             *pParameter\n    ); \"\"\"\nps6000.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                    c_int16,\n                                                    c_uint32,\n                                                    c_void_p)\nps6000.BlockReadyType.__doc__ = doc\n\ndoc = \"\"\" void ps6000DataReadyType\n    (\n        int16_t          handle,\n        PICO_STATUS      status,\n        uint32_t         noOfSamples,\n        int16_t          overflow,\n        void             *pParameter\n    ); \"\"\"\nps6000.DataReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n                                                   c_int16,\n                                                   c_uint32,\n                                                   c_uint32,\n                                                   c_int16,\n                                                   c_void_p)\nps6000.DataReadyType.__doc__ = doc\n\ndoc = \"\"\" void ps6000StreamingReady\n\t(\n\t\tint16_t\t\t\t\thandle,\n\t\tuint32_t\t\t\tnoOfSamples,\n\t\tuint32_t\t\t\tstartIndex,\n\t\tint16_t\t\t\t\toverflow,\n\t\tuint32_t\t\t\ttriggerAt,\n\t\tint16_t\t\t\t\ttriggered,\n\t\tint16_t\t\t\t\tautoStop,\n\t\tvoid\t\t\t\t*pParameter\n\t); \"\"\"\nps6000.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_uint32,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_int16,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tc_void_p)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\nps6000.StreamingReadyType.__doc__ = doc\n\ndoc = \"\"\" PICO_STATUS ps6000GetStreamingLatestValues\n    (\n        int16_t               handle,\n        ps6000StreamingReady  lpPs6000Ready,\n        void                 *pParameter\n    ); \"\"\"\nps6000.make_symbol(\"_GetStreamingLatestValues\", \"ps6000GetStreamingLatestValues\", c_uint32,\n                   [c_int16, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000NoOfStreamingValues\n    (\n        int16_t   handle,\n        uint32_t *noOfValues\n    ); \"\"\"\nps6000.make_symbol(\"_NoOfStreamingValues\", \"ps6000NoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetMaxDownSampleRatio\n    (\n        int16_t            handle,\n        uint32_t           noOfUnaggreatedSamples,\n        uint32_t          *maxDownSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           segmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetMaxDownSampleRatio\", \"ps6000GetMaxDownSampleRatio\", c_uint32,\n                   [c_int16, c_uint32, c_void_p, c_int32, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValues\n    (\n        int16_t            handle,\n        uint32_t           startIndex,\n        uint32_t          *noOfSamples,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           segmentIndex,\n        int16_t           *overflow\n    ); \"\"\"\nps6000.make_symbol(\"_GetValues\", \"ps6000GetValues\", c_uint32,\n                   [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesBulk\n    (\n        int16_t            handle,\n        uint32_t          *noOfSamples,\n        uint32_t           fromSegmentIndex,\n        uint32_t           toSegmentIndex,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        int16_t           *overflow\n    ); \"\"\"\nps6000.make_symbol(\"_GetValuesBulk\", \"ps6000GetValuesBulk\", c_uint32,\n                   [c_int16, c_void_p, c_uint32, c_uint32, c_uint32, c_int32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesAsync\n    (\n        int16_t            handle,\n        uint32_t           startIndex,\n        uint32_t           noOfSamples,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           segmentIndex,\n        void              *lpDataReady,\n        void              *pParameter\n    ); \"\"\"\nps6000.make_symbol(\"_GetValuesAsync\", \"ps6000GetValuesAsync\", c_uint32,\n                   [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesOverlapped\n    (\n        int16_t            handle,\n        uint32_t           startIndex,\n        uint32_t          *noOfSamples,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           segmentIndex,\n        int16_t           *overflow\n    ); \"\"\"\nps6000.make_symbol(\"_GetValuesOverlapped\", \"ps6000GetValuesOverlapped\", c_uint32,\n                   [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesOverlappedBulk\n    (\n        int16_t            handle,\n        uint32_t           startIndex,\n        uint32_t          *noOfSamples,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           fromSegmentIndex,\n        uint32_t           toSegmentIndex,\n        int16_t           *overflow\n    ); \"\"\"\nps6000.make_symbol(\"_GetValuesOverlappedBulk\", \"ps6000GetValuesOverlappedBulk\", c_uint32,\n                   [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetValuesBulkAsyc\n    (\n        int16_t            handle,\n        uint32_t           startIndex,\n        uint32_t          *noOfSamples,\n        uint32_t           downSampleRatio,\n        PS6000_RATIO_MODE  downSampleRatioMode,\n        uint32_t           fromSegmentIndex,\n        uint32_t           toSegmentIndex,\n        int16_t           *overflow\n    ); \"\"\"\nps6000.make_symbol(\"_GetValuesBulkAsyc\", \"ps6000GetValuesBulkAsyc\", c_uint32,\n                   [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t *nCaptures\n    ); \"\"\"\nps6000.make_symbol(\"_GetNoOfCaptures\", \"ps6000GetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetNoOfProcessedCaptures\n    (\n        int16_t   handle,\n        uint32_t *nProcessedCaptures\n    ); \"\"\"\nps6000.make_symbol(\"_GetNoOfProcessedCaptures\", \"ps6000GetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\n\n\"\"\" PICO_STATUS ps6000Stop\n    (\n        int16_t  handle\n    ); \"\"\"\nps6000.make_symbol(\"_Stop\", \"ps6000Stop\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetNoOfCaptures\n    (\n        int16_t   handle,\n        uint32_t  nCaptures\n    ); \"\"\"\nps6000.make_symbol(\"_SetNoOfCaptures\", \"ps6000SetNoOfCaptures\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetWaveformLimiter\n    (\n        int16_t   handle,\n        uint32_t  nWaveformsPerSecond\n    ); \"\"\"\nps6000.make_symbol(\"_SetWaveformLimiter\", \"ps6000SetWaveformLimiter\", c_uint32, [c_int16, c_uint32], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000EnumerateUnits\n    (\n        int16_t *count,\n        int8_t  *serials,\n        int16_t *serialLth\n    ); \"\"\"\nps6000.make_symbol(\"_EnumerateUnits\", \"ps6000EnumerateUnits\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000SetExternalClock\n    (\n        int16_t                    handle,\n        PS6000_EXTERNAL_FREQUENCY  frequency,\n        int16_t                    threshold\n    ); \"\"\"\nps6000.make_symbol(\"_SetExternalClock\", \"ps6000SetExternalClock\", c_uint32, [c_int16, c_int32, c_int16], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000PingUnit\n    (\n        int16_t  handle\n    ); \"\"\"\nps6000.make_symbol(\"_PingUnit\", \"ps6000PingUnit\", c_uint32, [c_int16, ], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetAnalogueOffset\n    (\n        int16_t          handle,\n        PS6000_RANGE     range,\n        PS6000_COUPLING  coupling,\n        float           *maximumVoltage,\n        float           *minimumVoltage\n    ); \"\"\"\nps6000.make_symbol(\"_GetAnalogueOffset\", \"ps6000GetAnalogueOffset\", c_uint32,\n                   [c_int16, c_int32, c_int32, c_void_p, c_void_p], doc)\n\ndoc = \"\"\" PICO_STATUS ps6000GetTriggerInfoBulk\n    (\n        int16_t        handle,\n        PS6000_TRIGGER_INFO    *triggerInfo,\n        uint32_t      fromSegmentIndex,\n        uint32_t      toSegmentIndex\n    ); \"\"\"\nps6000.make_symbol(\"_GetTriggerInfoBulk\", \"ps6000GetTriggerInfoBulk\", c_uint16, [c_int16, c_void_p, c_uint32, c_uint32], doc)\n"
  },
  {
    "path": "picosdk/ps6000a.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the ps6000aApi.h C header\r\nfile for PicoScope 6000 A Series oscilloscopes using the ps6000a driver API\r\nfunctions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\nfrom picosdk.constants import make_enum\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\n\r\n\r\nclass Ps6000alib(Library):\r\n    def __init__(self):\r\n        super(Ps6000alib, self).__init__(\"ps6000a\")\r\n\r\nps6000a = Ps6000alib()\r\n\r\nps6000a.DEFAULT_RESOLUTION = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\n\r\ndoc = \"\"\" void ps6000aExternalReferenceInteractions\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        PICO_CLOCK_REFERENCE            reference\r\n    ); \"\"\"\r\nps6000a.ExternalReferenceInteractionsReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                     c_int16,\r\n                                                     c_uint32,\r\n                                                     c_uint32)\r\nps6000a.ExternalReferenceInteractionsReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void ps6000aBlockReady\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\nps6000a.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                     c_int16,\r\n                                                     c_uint32,\r\n                                                     c_void_p)\r\nps6000a.BlockReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void ps6000aStreamingReady\r\n    (\r\n        int16_t    handle,\r\n        int64_t    noOfSamples,\r\n        uint64_t    bufferIndex,\r\n        uint32_t    startIndex,\r\n        int16_t    overflow,\r\n        uint32_t    triggerAt,\r\n        int16_t    triggered,\r\n        int16_t    autoStop,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\nps6000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                         c_int16,\r\n                                                         c_int64,\r\n                                                         c_uint64,\r\n                                                         c_uint32,\r\n                                                         c_int16,\r\n                                                         c_uint32,\r\n                                                         c_int16,\r\n                                                         c_int16,\r\n                                                         c_void_p)\r\nps6000a.StreamingReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void ps6000aDataReady\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        uint64_t    noOfSamples,\r\n        int16_t    overflow,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\nps6000a.DataReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                    c_int16,\r\n                                                    c_uint32,\r\n                                                    c_uint64,\r\n                                                    c_int16,\r\n                                                    c_void_p)\r\nps6000a.DataReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void ps6000aProbeInteractions\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        PICO_USER_PROBE_INTERACTIONS    *probes,\r\n        uint32_t    nProbes\r\n    ); \"\"\"\r\nps6000a.ProbeInteractionsType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                            c_int16,\r\n                                                            c_uint32,\r\n                                                            c_void_p,\r\n                                                            c_uint32)\r\nps6000a.ProbeInteractionsType.__doc__ = doc\r\n\r\ndoc = \"\"\" void ps6000aDigitalPortInteractions\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        PICO_DIGITAL_PORT_INTERACTIONS    *ports,\r\n        uint32_t    nPorts\r\n    ); \"\"\"\r\nps6000a.DigitalPortInteractionsType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                                  c_int16,\r\n                                                                  c_uint32,\r\n                                                                  c_void_p,\r\n                                                                  c_uint32)\r\nps6000a.DigitalPortInteractionsType.__doc__ = doc\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aOpenUnit\r\n    (\r\n        int16_t *handle,\r\n        int8_t  *serial\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_OpenUnit\", \"ps6000aOpenUnit\", c_uint32, [c_void_p, c_char_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aOpenUnitAsync\r\n    (\r\n        int16_t    *handle,\r\n        int8_t    *serial,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_OpenUnitAsync\", \"ps6000aOpenUnitAsync\", c_uint32, [c_void_p, c_char_p, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aOpenUnitProgress\r\n    (\r\n        int16_t    *handle,\r\n        int16_t    *progressPercent,\r\n        int16_t    *complete\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_OpenUnitProgress\", \"ps6000aOpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetUnitInfo\r\n    (\r\n        int16_t    handle,\r\n        int8_t    *string,\r\n        int16_t    stringLength,\r\n        int16_t    *requiredSize,\r\n        PICO_INFO    info\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetUnitInfo\", \"ps6000aGetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aCloseUnit\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_CloseUnit\", \"ps6000aCloseUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aFlashLed\r\n    (\r\n        int16_t    handle,\r\n        int16_t    start\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_FlashLed\", \"ps6000aFlashLed\", c_uint32, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aMemorySegments\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nSegments,\r\n        uint64_t    *nMaxSegments\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_MemorySegments\", \"ps6000aMemorySegments\", c_uint32, [c_int16, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aMemorySegmentsBySamples\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nSamples,\r\n        uint64_t    *nMaxSegments\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_MemorySegmentsBySamples\", \"ps6000aMemorySegmentsBySamples\", c_uint32, [c_int16, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetMaximumAvailableMemory\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    *nMaxSamples,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetMaximumAvailableMemory\", \"ps6000aGetMaximumAvailableMemory\", c_uint32, [c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aQueryMaxSegmentsBySamples\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nSamples,\r\n        uint32_t    nChannelsEnabled,\r\n        uint64_t    *nMaxSegments,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_QueryMaxSegmentsBySamples\", \"ps6000aQueryMaxSegmentsBySamples\", c_uint32, [c_int16, c_uint64, c_int32, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetChannelOn\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel,\r\n        PICO_COUPLING    coupling,\r\n        PICO_CONNECT_PROBE_RANGE    range,\r\n        double    analogueOffset,\r\n        PICO_BANDWIDTH_LIMITER    bandwidth\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetChannelOn\", \"ps6000aSetChannelOn\", c_uint32, [c_int16, c_uint32, c_uint32, c_uint32, c_double, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetChannelOff\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetChannelOff\", \"ps6000aSetChannelOff\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetDigitalPortOn\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port,\r\n        int16_t    *logicThresholdLevel,\r\n        int16_t    logicThresholdLevelLength\r\n        PICO_DIGITAL_PORT_HYSTERESIS    hysteresis\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetDigitalPortOn\", \"ps6000aSetDigitalPortOn\", c_uint32, [c_int16, c_uint32, c_void_p, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetDigitalPortOff\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetDigitalPortOff\", \"ps6000aSetDigitalPortOff\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetTimebase\r\n    (\r\n        int16_t    handle,\r\n        uint32_t    timebase,\r\n        uint64_t    noSamples,\r\n        double    *timeIntervalNanoseconds,\r\n        uint64_t    *maxSamples,\r\n        uint64_t    segmentIndex\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetTimebase\", \"ps6000aGetTimebase\", c_uint32, [c_int16, c_uint32, c_uint64, c_void_p, c_void_p, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenWaveform\r\n    (\r\n        int16_t    handle,\r\n        PICO_WAVE_TYPE    wavetype,\r\n        int16_t    *buffer,\r\n        uint16    bufferLength\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenWaveform\", \"ps6000aSigGenWaveform\", c_uint32, [c_int16, c_uint32, c_void_p, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSignGenRange\r\n    (\r\n        int16_t    handle, \r\n        double    peakToPeakVolts,\r\n        double    offsetVolts\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenRange\", \"ps6000aSigGenRange\", c_uint32, [c_int16, c_double, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenWaveformDutyCycle\r\n    (\r\n        int16_t    handle,\r\n        double    dutyCyclePercent\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenWaveformDutyCycle\", \"ps6000aSigGenWaveformDutyCycle\", c_uint32, [c_int16, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenTrigger\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_TRIG_TYPE    triggerType,\r\n        PICO_SIGGEN_TRIG_SOURCE    triggerSource,\r\n        uint64_t    cycles,\r\n        uint64_t    autoTriggerPicoSeconds\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenTrigger\", \"ps6000aSigGenTrigger\", c_uint32, [c_int16, c_uint32, c_uint32, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenFilter\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_FILTER_STATE    filterState\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenFilter\", \"ps6000aSigGenFilter\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenFrequency\r\n    (\r\n        int16_t    handle,\r\n        double    frequencyHz\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenFrequency\", \"ps6000aSigGenFrequency\", c_uint32, [c_int16, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenFrequencySweep\r\n    (\r\n        int16_t    handle,\r\n        double    stopFrequencyHz,\r\n        double    frequencyIncrement,\r\n        double    dwellTimeSeconds,\r\n        PICO_SWEEP_TYPE    sweepType\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenFrequencySweep\", \"ps6000aSigGenFrequencySweep\", c_uint32, [c_int16, c_double, c_double, c_double, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenPhase\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    deltaPhase\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenPhase\", \"ps6000aSigGenPhase\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenPhaseSweep\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    stopDeltaPhase,\r\n        uint64_t    deltaPhaseIncrement,\r\n        uint64_t    dwellCount,\r\n        PICO_SWEEP_TYPE    sweepType\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenPhaseSweep\", \"ps6000aSigGenPhaseSweep\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint64, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenClockManual\r\n    (\r\n        int16_t    handle,\r\n        double    dacClockFrequency,\r\n        uint64_t    prescaleRatio\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenClockManual\", \"ps6000aSigGenClockManual\", c_uint32, [c_int16, c_double, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenSoftwareTriggerControl\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_TRIG_TYPE    triggerState\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenSoftwareTriggerControl\", \"ps6000aSigGenSoftwareTriggerControl\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenApply\r\n    (\r\n        int16_t    handle,\r\n        int16_t    sigGenEnabled,\r\n        int16_t    sweepEnabled,\r\n        int16_t    triggerEnabled,\r\n        int16_t    automaticClockOptimisationEnabled,\r\n        int16_t    overrideAutomaticClockAndPrescale,\r\n        double    *frequency,\r\n        double    *stopFrequency,\r\n        double    *frequencyIncrement,\r\n        double    *dwellTime\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenApply\", \"ps6000aSigGenApply\", c_uint32, [c_int16, c_int16, c_int16, c_int16, c_int16, c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenLimits\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_PARAMETER    parameter,\r\n        double    *minimumPermissibleValue,\r\n        double    *maximumPermissibleValue,\r\n        double    *step\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenLimits\", \"ps6000aSigGenLimits\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenFrequencyLimits\r\n    (\r\n        int16_t    handle,\r\n        PICO_WAVE_TYPE    waveType,\r\n        uint64_t    *numSamples,\r\n        double    *startFrequency,\r\n        int16_t    sweepEnabled,\r\n        double    *manualDacClockFrequency,\r\n        uint64_t    *manualPrescaleRatio,\r\n        double    *maxStopFrequencyOut,\r\n        double    *minFrequencyStepOut,\r\n        double    *maxFrequencyStepOut,\r\n        double    *minDwellTimeOut,\r\n        double    *maxDwellTimeOut\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenFrequencyLimits\", \"ps6000aSigGenFrequencyLimits\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenPause\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenPause\", \"ps6000aSigGenPause\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSigGenRestart\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SigGenRestart\", \"ps6000aSigGenRestart\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetSimpleTrigger\r\n    (\r\n        int16_t    handle\r\n        int16_t    enable,\r\n        PICO_CHANNEL    source,\r\n        int16_t    threshold,\r\n        PICO_THRESHOLD_DIRECTION    direction,\r\n        uint64_t    delay,\r\n        uint32_t    autoTriggerMicroSeconds\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetSimpleTrigger\", \"ps6000aSetSimpleTrigger\", c_uint32, [c_int16, c_int16, c_uint32, c_int16, c_uint32, c_uint64, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aTriggerWithinPreTriggerSamples\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_WITHIN_PRE_TRIGGER    state\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_TriggerWithinPreTriggerSamples\", \"ps6000aTriggerWithinPreTriggerSamples\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetTriggerChannelProperties\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_CHANNEL_PROPERTIES    *channelProperties,\r\n        int16_t    nChannelProperties,\r\n        int16_t    auxOutputEnable,\r\n        uint32_t    autoTriggerMicroSeconds\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetTriggerChannelProperties\", \"ps6000aSetTriggerChannelProperties\", c_uint32, [c_int16, c_void_p, c_int16, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetTriggerChannelConditions\r\n    (\r\n        int16_t    handle,\r\n        PICO_CONDITION    *conditions,\r\n        int16_t    nConditions,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetTriggerChannelConditions\", \"ps6000aSetTriggerChannelConditions\", c_uint32, [c_int16, c_void_p, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetTriggerChannelDirections\r\n    (\r\n        int16_t    handle,\r\n        PICO_DIRECTION    *directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetTriggerChannelDirections\", \"ps6000aSetTriggerChannelDirections\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetTriggerDelay\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    delay\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetTriggerDelay\", \"ps6000aSetTriggerDelay\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetPulseWidthQualifierProperties\r\n    (\r\n        int16_t    handle,\r\n        uint32_t    lower,\r\n        uint32_t    upper,\r\n        PICO_PULSE_WIDTH_TYPE    type\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetPulseWidthQualifierProperties\", \"ps6000aSetPulseWidthQualifierProperties\", c_uint32, [c_int16, c_uint32, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetPulseWidthQualifierConditions\r\n    (\r\n        int16_t    handle,\r\n        PICO_CONDITION    *conditions,\r\n        int16_t    nConditions,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetPulseWidthQualifierConditions\", \"ps6000aSetPulseWidthQualifierConditions\", c_uint32, [c_int16, c_void_p, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetPulseWidthQualifierDirections\r\n    (\r\n        int16_t    handle,\r\n        PICO_DIRECTION    *directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetPulseWidthQualifierDirections\", \"ps6000aSetPulseWidthQualifierDirections\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetTriggerDigitalPortProperties\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port,\r\n        PICO_DIGITAL_CHANNEL_DIRECTIONS    *directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetTriggerDigitalPortProperties\", \"ps6000aSetTriggerDigitalPortProperties\", c_uint32, [c_int16, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetPulseWidthDigitalPortProperties\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port,\r\n        PICO_DIGITAL_CHANNEL_DIRECTIONS    *directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetPulseWidthDigitalPortProperties\", \"ps6000aSetPulseWidthDigitalPortProperties\", c_uint32, [c_int16, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetTriggerTimeOffset\r\n    (\r\n        int16_t    handle,\r\n        int64_t    *time,\r\n        PICO_TIME_UNITS    *timeUnits,\r\n        uint64_t    segmentIndex\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetTriggerTimeOffset\", \"ps6000aGetTriggerTimeOffset\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetValuesTriggerTimeOffsetBulk\r\n    (\r\n        int16_t    handle,\r\n        int64_t    *time,\r\n        PICO_TIME_UNITS    *timeUnits,\r\n        uint64_t    fromSegementIndex,\r\n        uint64_t    toSegmentIndex\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\", \"ps6000aGetValuesTriggerTimeOffsetBulk\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetDataBuffer\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel,\r\n        PICO_POINTER    buffer,\r\n        int32_t    nSamples,\r\n        PICO_DATA_TYPE    dataType,\r\n        uint64_t    waveform,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetDataBuffer\", \"ps6000aSetDataBuffer\", c_uint32, [c_int16, c_uint32, c_void_p, c_int32, c_uint32, c_uint64, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetDataBuffers\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel,\r\n        PICO_POINTER    bufferMax,\r\n        PICO_POINTER    bufferMin,\r\n        int32_t    nSamples,\r\n        PICO_DATA_TYPE    dataType,\r\n        uint64_t    waveform,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetDataBuffers\", \"ps6000aSetDataBuffers\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_int32, c_uint32, c_uint64, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aRunBlock\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    noOfPreTriggerSamples,\r\n        uint64_t    noOfPostTriggerSamples,\r\n        uint32_t    timebase,\r\n        double    *timeIndisposedMs,\r\n        uint64_t    segmentIndex,\r\n        ps6000aBlockReady    lpReady,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_RunBlock\", \"ps6000aRunBlock\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint32, c_void_p, c_uint64, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aIsReady\r\n    (\r\n        int16_t    handle,\r\n        int16_t    *ready\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_IsReady\", \"ps6000aIsReady\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aRunStreaming\r\n    (\r\n        int16_t    handle,\r\n        double    *sampleInterval,\r\n        PICO_TIME_UNITS    sampleIntervalTimeUnits,\r\n        uint64_t    maxPreTriggerSamples,\r\n        uint64_t    maxPostTriggerSamples,\r\n        int16_t    autoStop,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampelRatioMode\r\n    ): \"\"\"\r\nps6000a.make_symbol(\"_RunStreaming\", \"ps6000aRunStreaming\", c_uint32, [c_int16, c_void_p, c_uint32, c_uint64, c_uint64, c_int16, c_uint64, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetStreamingLatestValues\r\n    (\r\n        int16_t    handle,\r\n        PICO_STREAMING_DATA_INFO    *streamingDataInfo,\r\n        uint64_t    nStreamingDataInfos,\r\n        PICO_STREAMING_DATA_TRIGGER_INFO    *triggerInfo\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetStreamingLatestValues\", \"ps6000aGetStreamingLatestValues\", c_uint32, [c_int16, c_void_p, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aNoOfStreamingValues\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    *noOfValues\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_NoOfStreamingValues\", \"ps6000aNoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetValues\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    *noOfSamples,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        uint64_t    segmentIndex,\r\n        int16_t    *overflow\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetValues\", \"ps6000aGetValues\", c_uint32, [c_int16, c_uint64, c_void_p, c_uint64, c_uint32, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetValuesBulk\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    *noOfSamples,\r\n        uint64_t    fromSegmentIndex,\r\n        uint64_t    toSegmentIndex,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        int16_t    *overflow\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetValuesBulk\", \"ps6000aGetValuesBulk\", c_uint32, [c_int16, c_uint64, c_void_p, c_uint64, c_uint64, c_uint64, c_uint32, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetTriggerInfo\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_INFO    *startIndex,\r\n        uint64_t    firstSegmentIndex,\r\n        uint64_t    segmentCount,\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetTriggerInfo\", \"ps6000aGetTriggerInfo\", c_uint32, [c_int16, c_void_p, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetValuesAsync\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    noOfSamples,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        uint64_t    segmentIndex,\r\n        PICO_POINTER    lpDataReady,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetValuesAsync\", \"ps6000aGetValuesAsync\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint64, c_uint32, c_uint64, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetValuesBulkAsync\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    noOfSamples,\r\n        uint64_t    fromSegmentIndex,\r\n        uint64_t    toSegmentIndex,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        PICO_POINTER    lpDataReady,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetValuesBulkAsync\", \"ps6000aGetValuesBulkAsync\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint64, c_uint64, c_uint64, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetValuesOverlapped\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    *noOfSamples,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        uint64_t    fromSegementIndex,\r\n        uint64_t    toSegmentIndex,\r\n        int16_t    *overflow\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetValuesOverlapped\", \"ps6000aGetValuesOverlapped\", c_uint32, [c_int16, c_uint64, c_void_p, c_uint64, c_uint32, c_uint64, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aStopUsingGetValuesOverlapped\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_StopUsingGetValuesOverlapped\", \"ps6000aStopUsingGetValuesOverlapped\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetNoOfCaptures\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    *nCaptures\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetNoOfCaptures\", \"ps6000aGetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetNoOfProcessedCaptures\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    *nProcessedCaptures\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetNoOfProcessedCaptures\", \"ps6000aGetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aStop\r\n    (\r\n        int16_t    handle,\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_Stop\", \"ps6000aStop\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetNoOfCaptures\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nCaptures\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetNoOfCaptures\", \"ps6000aSetNoOfCaptures\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetTriggerInfo\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_INFO    *triggerInfo,\r\n        uint64_t    firstSegmentIndex,\r\n        uint64_t    segmentCount\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_getTriggerInfo\", \"ps6000aGetTriggerInfo\", c_uint32, [c_int16, c_void_p, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aEnumerateUnits\r\n    (\r\n        int16_t    *count,\r\n        int8_t    *serials,\r\n        int16_t    *serialLth\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_EnumerateUnits\", \"ps6000aEnumerateUnits\", c_uint32, [c_void_p, c_char_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aPingUnit\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_PingUnit\", \"ps6000aPingUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetAnalogueOffsetLimits\r\n    (\r\n        int16_t    handle,\r\n        PICO_CONNECT_PROBE_RANGE    range,\r\n        PICO_COUPLING    coupling,\r\n        double    *maximumVoltage,\r\n        double    *minimumVoltage\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetAnalogueOffsetLimits\", \"ps6000aGetAnalogueOffsetLimits\", c_uint32, [c_int16, c_uint32, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetMinimumTimebaseStateless\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_FLAGS    enabledChannelFlags,\r\n        uint32_t    *timebase,\r\n        double    *timeInterval,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetMinimumTimebaseStateless\", \"ps6000aGetMinimumTimebaseStateless\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aNearestSampleIntervalStateless\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_FLAGS    enabledChannelFlags,\r\n        double    timeIntervalRequested,\r\n        PICO_DEVICE_RESOLUTION    resolution,\r\n        uint32_t    *timebase,\r\n        double    *timeIntervalAvailable\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_NearestSampleIntervalStateless\", \"ps6000aNearestSampleIntervalStateless\", c_uint32, [c_int16, c_uint32, c_double, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aChannelCombinationsStateless\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_FLAGS    *channelFlagsCombinations,\r\n        uint32_t    *nChannelCombinations,\r\n        PICO_DEVICE_RESOLUTION    resolution,\r\n        uint32_t    timebase\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_ChannelCombinationsStateless\", \"ps6000aChannelCombinationsStateless\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetDeviceResolution\r\n    (\r\n        int16_t    handle,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetDeviceResolution\", \"ps6000aSetDeviceResolution\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetDeviceResolution\r\n    (\r\n        int16_t    handle,\r\n        PICO_DEVICE_RESOLUTION    *resolution\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetDeviceResolution\", \"ps6000aGetDeviceResolution\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aQueryOutputEdgeDetect\r\n    (\r\n        int16_t    handle,\r\n        int16_t    *state\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_QueryOutputEdgeDetect\", \"ps6000aQueryOutputEdgeDetect\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetOutputEdgeDetect\r\n    (\r\n        int16_t    handle,\r\n        int16_t    state\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetOutputEdgeDetect\", \"ps6000aSetOutputEdgeDetect\", c_uint32, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetScalingValues\r\n    (\r\n        int16_t    handle,\r\n        PICO_SCALING_FACTORS_VALUES    *scalingValues,\r\n        int16_t    nChannels\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetScalingValues\", \"ps6000aGetScalingValues\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aGetAdcLimits\r\n    (\r\n        int16_t    handle,\r\n        PICO_DEVICE_RESOLUTION    resolution,\r\n        int16_t    *minValue,\r\n        int16_t    *maxValue\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_GetAdcLimits\", \"ps6000aGetAdcLimits\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aCheckForUpdate\r\n    (\r\n        int16_t    handle,\r\n        PICO_VERSION    *current,\r\n        PICO_VERSION    *update,\r\n        uint16_t    *updateRequired\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_CheckForUpdate\", \"ps6000aCheckForUpdate\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aStartFirmwareUpdate\r\n    (\r\n        int16_t    handle,\r\n        PicoUpdateFirmwareProgress    progress \r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_StartFirmwareUpdate\", \"ps6000aStartFirmwareUpdate\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetProbeInteractionCallback\r\n    (\r\n        int16_t    handle,\r\n        PicoProbeInteractions    callback\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetProbeInteractionCallback\", \"ps6000aSetProbeInteractionCallback\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetExternalReferenceInteractionCallback\r\n    (\r\n        int16_t    handle,\r\n        PicoExternalReferenceInteractions    callback\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetExternalReferenceInteractionCallback\", \"ps6000aSetExternalReferenceInteractionCallback\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetAWGOverrangeInteractionCallback\r\n    (\r\n        int16_t    handle,\r\n        PicoAWGOverrangeInteractions    callback\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetAWGOVerrangeInteractionCallback\", \"ps6000aSetAWGOverrangeInteractionCallback\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetTemperatureSensorInteractioNCallback\r\n    (\r\n        int16_t    handle,\r\n        PicoTemperatureSensorInteractions    callback\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetTemperatureSensroInteractionCallback\", \"ps6000aSetTemperatureSensorInteractionCallback\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS ps6000aSetAuxIoMode\r\n    (\r\n        int16_t    handle,\r\n        PICO_AUXIO_MODE    auxIoMode\r\n    ); \"\"\"\r\nps6000a.make_symbol(\"_SetAuxIoMode\", \"ps6000aSetAuxIoMode\", c_uint32, [c_int16, c_uint32], doc)"
  },
  {
    "path": "picosdk/psospa.py",
    "content": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the psospaApi.h C header\r\nfile for PicoScope 3000 A Series oscilloscopes using the psospa driver API\r\nfunctions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\nfrom picosdk.constants import make_enum\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\n\r\nclass Psospalib(Library):\r\n    def __init__(self):\r\n\t    super(Psospalib, self).__init__(\"psospa\")\r\n\t\r\npsospa = Psospalib()\r\n\r\ndoc = \"\"\" void psospaBlockReady\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\npsospa.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                    c_int16,\r\n                                                    c_uint32,\r\n                                                    c_void_p)\r\npsospa.BlockReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" void psospaDataReady\r\n    (\r\n        int16_t    handle,\r\n        PICO_STATUS    status,\r\n        uint64_t    noOfSamples,\r\n        int16_t    overflow,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\npsospa.DataReadyType = C_CALLBACK_FUNCTION_FACTORY(None,\r\n                                                    c_int16,\r\n                                                    c_uint32,\r\n                                                    c_uint64,\r\n                                                    c_int16,\r\n                                                    c_void_p)\r\npsospa.DataReadyType.__doc__ = doc\r\n\r\ndoc = \"\"\" PICO_STATUS psospaOpenUnit\r\n    (\r\n\t    int16_t*    handle,\r\n\t\tint8_t*     serial,\r\n\t\tPICO_DEVICE_RESOLUTION    resolution,\r\n\t\tPICO_USB_POWER_DETAILS*    powerDetails\r\n\t); \"\"\"\r\npsospa.make_symbol(\"_OpenUnit\",\"psospaOpenUnit\", c_uint32, [c_void_p, c_char_p, c_int32, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaCloseUnit\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\npsospa.make_symbol(\"_CloseUnit\", \"psospaCloseUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetUnitInfo\r\n    (\r\n        int16_t    handle,\r\n        int8_t*    string,\r\n        int16_t    stringLength,\r\n        int16_t*    requiredSize,\r\n        PICO_INFO    info\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetUnitInfo\",\"psospaGetUnitInfo\", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetVariantDetails\r\n    (\r\n        const int8_t*    variantName,\r\n        int16_t    variantNameLength,\r\n        int8_t*    outputString,\r\n        int32_t*    outputStringLength,\r\n        PICO_TEXT_FORMAT textFormat\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetVariantDetails\", \"psospaGetVariantDetails\", c_uint32, [c_char_p, c_int16, c_char_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaMemorySegments\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nSegments,\r\n        uint64_t*    nMaxSamples\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_MemorySegments\",\"psospaMemorySegments\", c_uint32,[c_int16, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaMemorySegmentsBySamples\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nSamples,\r\n        uint64_t*    nMaxSegments\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_MemorySegmentsBySamples\",\"psospaMemorySegmentsBySamples\", c_uint32, [c_int16, c_uint64, c_void_p], doc)\r\n\r\n# doc = \"\"\" PICO_STATUS psospaGetMaximumAvaliableMemory\r\n    # (\r\n        # int16_t    handle,\r\n        # uint64_t*    nMaxSamples,\r\n        # PICO_DEVICE_RESOLUTION    resolution\r\n    # ); \"\"\"\r\n# psospa.make_symbol(\"_GetMaximumAvaliableMemory\",\"psospaGetMaximumAvaliableMemory\", c_uint32, [c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaQueryMaxSegmentsBySamples\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nSamples,\r\n        uint32_t    nChannelEnabled,\r\n        uint64_t*    nMaxSegments,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_QUeryMaxSegmentsBySamples\",\"psospaQueryMaxSegmentsBySamples\", c_uint32, [c_int16, c_uint64, c_uint32, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetChannelOn\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel,\r\n        PICO_COUPLING    coupling,\r\n        int64_t    rangeMin,\r\n        int64_t    rangeMax\r\n        PICO_PROBE_RANGE_INFO    rangeType,\r\n        double    analogueOffset,\r\n        PICO_BANDWIDTH_LIMITER    bandwidth\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetChannelOn\",\"psospaSetChannelOn\", c_uint32, [c_int16, c_uint32, c_uint32, c_int64, c_int64, c_uint32, c_double, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetChannelOff\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetChannelOff\",\"psospaSetChannelOff\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetDigitalPortOn\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port,\r\n        int16_t*    logicThresholdLevel,\r\n        int16_t*    logicThresholdLengthLevel,\r\n        PICO_DIGITAL_PORT_HYSTERESIS    hysteresis\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetDigitalPortOn\",\"psospaSetDigitalPortOn\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetDigitalPortOff\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetDigitalPortOff\",\"psospaSetDigitalPortOff\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetTimebase\r\n    (\r\n        int16_t    handle,\r\n        uint32_t    timebase,\r\n        uint64_t    noSamples,\r\n        double*    timeIntervalNanoseconds,\r\n        uint64_t*    maxSamples,\r\n        uint64_t    segmentIndex\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetTimebase\",\"psospaGetTimebase\", c_uint32, [c_int16, c_uint32, c_uint64, c_void_p, c_void_p, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenWaveform\r\n    (\r\n        int16_t    handle,\r\n        PICO_WAVE_TYPE    waveType,\r\n        int16_t*    buffer,\r\n        uint64_t    bufferLength\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenWaveform\",\"psospaSigGenWaveform\", c_uint32, [c_int16, c_uint32, c_void_p, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenRange\r\n    (\r\n        int16_t    handle,\r\n        double    peakToPeakVolts,\r\n        double    offsetVolts\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenRange\",\"psospaSigGenRange\", c_uint32, [c_int16, c_double, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenWaveformDutyCycle\r\n    (\r\n        int16_t    handle,\r\n        double    dutyCyclePercent\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenWaveformDutyCycle\",\"psospaSigGenWaveformDutyCycle\", c_uint32, [c_int16, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenTrigger\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_TRIG_TYPE    triggerType,\r\n        PICO_SIGGEN_TRIG_SOURCE    triggerSource,\r\n        uint64_t    cycles,\r\n        uint64_t    autoTriggerPicoSeconds\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenTrigger\",\"psospaSigGenTrigger\", c_uint32, [c_int16, c_uint32, c_uint32, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenFrequency\r\n    (\r\n        int16_t    handle,\r\n        double    frequencyHz\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenFrequency\",\"psospaSigGenFrequency\", c_uint32, [c_int16, c_double], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenFrequencySweep\r\n    (\r\n        int16_t    handle,\r\n        double    stopFrequencyHz,\r\n        double    frequencyIncrement,\r\n        double    dwellTimeSeconds,\r\n        PICO_SWEEP_TYPE    sweepType\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenFrequencySweep\",\"psospaSigGenFrequencySweep\", c_uint32, [c_int16, c_double, c_double, c_double, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenPhase\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    deltaPhase\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenPhase\",\"psospaSigGenPhase\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenPhaseSweep\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    stopDeltaPhase,\r\n        uint64_t    deltaPhaseIncrement,\r\n        uint64_t    dwellCount,\r\n        PICO_SWEEP_TYPE    sweepType\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenPhaseSweep\",\"psospaSigGenPhaseSweep\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint64, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenSoftwareTriggerControl\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_TRIG_TYPE    triggerState\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenSoftwareTriggerControl\",\"psospaSigGenSoftwareTriggerControl\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenApply\r\n    (\r\n        int16_t    handle,\r\n        int16_t    sigGenEnabled,\r\n        int16_t    sweepEnabled,\r\n        int16_t    triggerEnabled,\r\n        double*    frequency\r\n        double*    stopFrequency,\r\n        double*    frequencyIncrement,\r\n        double*    dwellTime,\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenApply\",\"psospaSigGenApply\", c_uint32, [c_int16, c_int16, c_int16, c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenLimits\r\n    (\r\n        int16_t    handle,\r\n        PICO_SIGGEN_PARAMETER    parameter,\r\n        double*    minimumPermissibleValue,\r\n        double*    maximumPermissibleValue,\r\n        double*    step\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenLimits\",\"psospaSigGenLimits\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenFrequencyLimits\r\n    (\r\n        int16_t    handle,\r\n        PICO_WAVE_TYPE    waveType,\r\n        uint64_t*    numSamples,\r\n        double*    minFrequencyOut,\r\n        double*    maxFrequencyOut,\r\n        double*    minFrequencyStepOut,\r\n        double*    maxFrequencyStepOut,\r\n        double*    mindDwellTimeOut,\r\n        double*    maxDwellTimeOut\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenFrequencyLimits\",\"psospaSigGenFrequencyLimits\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenPause\r\n    (\r\n        int16_t    handle,\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenPause\",\"psospaSigGenPause\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSigGenRestart\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SigGenRestart\",\"psospaSigGenRestart\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetSimpleTrigger\r\n    (\r\n        int16_t    handle,\r\n        int16_t    enable,\r\n        PICO_CHANNEL    source,\r\n        int16_t    threshold,\r\n        PICO_THRESHOLD_DIRECTION    direction,\r\n        uint64_t    delay,\r\n        uint32_t    autoTriggerMicroSeconds\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetSimpleTrigger\",\"psospaSetSimpleTrigger\", c_uint32, [c_int16, c_int16, c_uint32, c_int16, c_uint32, c_uint64, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaTriggerWithinPreTriggerSamples\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_WITHIN_PRE_TRIGGER    state\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_TriggerWithinPreTriggerSamples\",\"psospaTriggerWithinPreTriggerSamples\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetTriggerChannelProperties\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_CHANNEL_PROPERTIES*    channelProperties,\r\n        int16_t    nChannelProperties,\r\n        uint32_t    autoTriggerMicroSeconds\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetTriggerChannelProperties\",\"psospaSetTriggerChannelProperties\", c_uint32, [c_int16, c_void_p, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetTriggerChannelConditions\r\n   (\r\n        int16_t   handle,\r\n        PICO_CONDITION*   conditions,\r\n        int16_t    nConditions,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetTriggerChannelConditions\",\"psospaSetTriggerChannelConditions\", c_uint32, [c_int16, c_void_p, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetTriggerChannelDirections\r\n    (\r\n        int16_t    handle,\r\n        PICO_DIRECTION*    directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetTriggerChannelDirections\",\"psospaSetTriggerChannelDirections\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetTriggerDelay\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    delay\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetTriggerDelay\",\"psospaSetTriggerDelay\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetTriggerHoldoffCounterBySamples\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    holdoffSamples\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetTriggerHoldoffCounterBySamples\",\"psospaSetTriggerHoldoffCounterBySamples\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetPulseWidthQualifierProperties\r\n    (\r\n        int16_t    handle,\r\n        uint32_t    lower,\r\n        uint32_t    upper,\r\n        PICO_PULSE_WIDTH_TYPE    type\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetPulseWidthQualifierProperties\",\"psospaSetPulseWidthQualifierProperties\", c_uint32, [c_int16, c_uint32, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetPulseWidthQualifierConditions\r\n   (\r\n        int16_t    handle,\r\n        PICO_CONDITION*    conditions,\r\n        int16_t    nConditions,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetPulseWidthQualifierConditions\",\"psospaSetPulseWidthQualifierConditions\", c_uint32, [c_int16, c_void_p, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetPulseWidthQualifierDirections\r\n    (\r\n        int16_t    handle,\r\n        PICO_DIRECTION*    directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetPulseWidthQualifierDirections\",\"psospaSetPulseWidthQualifierDirections\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetTriggerDigitalPortProperties\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    port,\r\n        PICO_DIGITAL_CHANNEL_DIRECTIONS*    directions,\r\n        int16_t    nDirections\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetTriggerDigitalPortProperties\",\"psospaSetTriggerDigitalPortProperties\", c_uint32, [c_int16, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetTriggerTimeOffset\r\n    (\r\n        int16_t    handle,\r\n        int64_t*    time,\r\n        PICO_TIME_UNITS*    timeUnits,\r\n        uint64_t    segmentIndex\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetTriggerTimeOffset\",\"psospaGetTriggerTimeOffset\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetValuesTriggerTimeOffsetBulk\r\n    (\r\n        int16_t    handle,\r\n        int64_t*    times,\r\n        PICO_TIME_UNITS*    timeUnits,\r\n        uint64_t    fromSegmentIndex,\r\n        uint64_t    toSegmentIndex\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetValuesTriggerTimeOffsetBulk\",\"psospaGetValuesTriggerTimeOffsetBulk\", c_uint32, [c_int16, c_void_p, c_void_p, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetDataBuffer\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel,\r\n        PICO_POINTER    buffer,\r\n        int64_t    nSamples,\r\n        PICO_DATA_TYPE    dataType,\r\n        uint64_t    waveform,\r\n        PICO_RATIO_MODE    downSampleRationMode,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetDataBuffer\",\"psospaSetDataBuffer\", c_uint32, [c_int16, c_uint32, c_void_p, c_uint64, c_uint32, c_uint64, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetDataBuffers\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL    channel,\r\n        PICO_POINTER    bufferMax,\r\n        PICO_POINTER    bufferMin,\r\n        int64_t    nSamples,\r\n        PICO_DATA_TYPE    dataType,\r\n        uint64_t    waveform,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        PICO_ACTION    action\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetDataBuffers\",\"psospaSetDataBuffers\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_int64, c_uint32, c_uint64, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaRunBlock\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    noOfPreTriggerSamples,\r\n        uint64_t    noOfPostTriggerSamples,\r\n        uint32_t    timebase,\r\n        double*    timeIndisposedMs,\r\n        uint64_t    segmentIndex,\r\n        psospaBlockReady    lpReady,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_RunBlock\",\"psospaRunBlock\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint32, c_void_p, c_uint64, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaIsReady\r\n    (\r\n        int16_t    handle,\r\n        int16_t*    ready\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_IsReady\",\"psospaIsReady\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaRunStreaming\r\n    (\r\n        int16_t    handle,\r\n        double*    sampleInterval,\r\n        PICO_TIME_UNITS    sampleIntervalTimeUnits,\r\n        uint64_t    maxPreTriggerSamples,\r\n        uint64_t    maxPostPreTriggerSamples,\r\n        int16_t    autoStop,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_RunStreaming\",\"psospaRunStreaming\", c_uint32, [c_int16, c_void_p, c_uint32, c_uint64, c_uint64, c_int16, c_uint64, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetStreamingLatestValues\r\n    (\r\n        int16_t    handle,\r\n        PICO_STREAMING_DATA_INFO*    streamingDataInfo,\r\n        uint64_t    nStreamingDataInfos,\r\n        PICO_STREAMING_DATA_TRIGGER_INFO*    triggerInfo\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetStreamingLatestValues\",\"psospaGetStreamingLatestValues\", c_uint32, [c_int16, c_void_p, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaNoOfStreamingValues\r\n    (\r\n        int16_t    handle,\r\n        uint64_t*    noOfValues\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_NoOfStreamingValues\",\"psospaNoOfStreamingValues\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetValues\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t*    noOfSamples,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        uint64_t    segmentIndex,\r\n        int16_t*    overflow\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetValues\",\"psospaGetValues\", c_uint32, [c_int16, c_uint64, c_void_p, c_uint64, c_uint32, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetValuesBulk\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t*    noOfSamples,\r\n        uint64_t    fromSegmentIndex,\r\n        uint64_t    toSegmentIndex,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        int16_t*    overflow\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetValuesBulk\",\"psospaGetValuesBulk\", c_uint32, [c_int16, c_uint64, c_void_p, c_uint64, c_uint64, c_uint64, c_uint32, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetValuesAsync\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    noOfSamples,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        uint64_t    segmentIndex,\r\n        PICO_POINTER    lpDataReady,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetValuesAsync\",\"psospaGetValuesAsync\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint64, c_uint32, c_uint64, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetValuesBulkAsync\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t    noOfSamples,\r\n        uint64_t    fromSegmentIndex,\r\n        uint64_t    toSegmentIndex,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        PICO_POINTER    lpDataReady,\r\n        PICO_POINTER    pParameter\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetValuesBulkAsync\",\"psospaGetValuesBulkAsync\", c_uint32, [c_int16, c_uint64, c_uint64, c_uint64, c_uint64, c_uint64, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetValuesOverlapped\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    startIndex,\r\n        uint64_t*    noOfSamples,\r\n        uint64_t    downSampleRatio,\r\n        PICO_RATIO_MODE    downSampleRatioMode,\r\n        uint64_t    fromSegmentIndex,\r\n        uint64_t    toSegmentIndex,\r\n        int16_t*    overflow\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetValuesOverlapped\",\"psospaGetValuesOverlapped\", c_uint32, [c_int16, c_uint64, c_void_p, c_uint64, c_uint32, c_uint64, c_uint64, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaStopUsingGetValuesOverlapped\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_StopUsingGetValuesOverlapped\",\"psospaStopUsingGetValuesOverlapped\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetNoOfCaptures\r\n    (\r\n        int16_t    handle,\r\n        uint64_t*    nCaptures\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetNoOfCaptures\",\"psospaGetNoOfCaptures\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetNoOfProcessedCaptures\r\n    (\r\n        int16_t    handle,\r\n        uint64_t*    nProcessedCaptures\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetNoOfProcessedCaptures\",\"psospaGetNoOfProcessedCaptures\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaStop\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_Stop\",\"psospaStop\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetNoOfCaptures\r\n    (\r\n        int16_t    handle,\r\n        uint64_t    nCaptures\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetNoOfCaptures\",\"psospaSetNoOfCaptures\", c_uint32, [c_int16, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetTriggerInfo\r\n    (\r\n        int16_t    handle,\r\n        PICO_TRIGGER_INFO*    triggerInfo,\r\n        uint64_t    firstSegmentIndex,\r\n        uint64_t     segmentIndex\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetTriggerInfo\",\"psospaGetTriggerInfo\", c_uint32, [c_int16, c_void_p, c_uint64, c_uint64], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaEnumerateUnits\r\n    (\r\n        int16_t*    count,\r\n        int8_t*    serials,\r\n        int16_t*    serialLth\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_EnumerateUnits\",\"psospaEnumerateUnits\", c_uint32, [c_void_p, c_char_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaPingUnit\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_PingUnit\",\"psospaPingUnit\", c_uint32, [c_int16], doc)\r\n \r\ndoc = \"\"\" PICO_STATUS psospaGetAnalogueOffsetLimits\r\n    (\r\n        int16_t     handle,\r\n        int64_t    rangeMin,\r\n        int64_t    rangeMax,\r\n        PICO_PROBE_RANGE_INFO    rangeType,\r\n        PICO_COUPLING    coupling,\r\n        double*    maximumVoltage,\r\n        double*    minimumVoltage\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetAnalogueOffsetLimits\",\"psospaGetAnalogueOffsetLimits\", c_uint32, [c_int16, c_int64, c_int64, c_uint32, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetMinimumTimebaseStateless\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_FLAGS    enabledChannelFlags,\r\n        uint32_t*    timebase,\r\n        double*    timeInterval,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetMinimumTimebaseStateless\",\"psospaGetMinimumTimebaseStateless\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaNearestSampleIntervalStateless\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_FLAGS    enabledChannelFlags,\r\n        double    timeIntervalRequested,\r\n        uint8_t    roundFaster,\r\n        PICO_DEVICE_RESOLUTION     resolution,\r\n        uint32_t*    timebase,\r\n        double*    timeIntervalAvailable\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_NearestSampleIntervalStateless\",\"psospaNearestSampleIntervalStateless\", c_uint32, [c_int16, c_uint32, c_double, c_char,c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetDeviceResolution\r\n    (\r\n        int16_t    handle,\r\n        PICO_DEVICE_RESOLUTION    resolution\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetDeviceResolution\",\"psospaSetDeviceResolution\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetDeviceResolution\r\n    (\r\n        int16_t    handle,\r\n        PICO_DEVICE_RESOLUTION*    resolution\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetDeviceResolution\",\"psospaGetDeviceResolution\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaQueryOutputEdgeDetect\r\n    (\r\n        int16_t    handle,\r\n        int16_t*    state\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_QueryOutputEdgeDetect\",\"psospaQueryOutputEdgeDetect\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaSetOutputEdgeDetect\r\n    (\r\n        int16_t    handle\r\n        int16_t    state\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_SetOutputEdgeDetect\",\"psospaSetOutputEdgeDetect\", c_uint32, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetScalingValues\r\n    (\r\n        int16_t    handle,\r\n        PICO_SCALING_FACTORS_FOR_RANGE_TYPES_VALUES*    scalingValues,\r\n        int16_t    nChannels\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetScalingValues\",\"psospaGetScalingValues\", c_uint32, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaGetAdcLimits\r\n   (\r\n        int16_t    handle,\r\n        PICO_DEVICE_RESOLUTION    resolution,\r\n        int16_t*    minValue,\r\n        int16_t*    maxValue\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_GetAdcLimits\",\"psospaGetAdcLimits\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaCheckForUpdate\r\n    (\r\n        int16_t    handle,\r\n        PICO_FIRMWARE_INFO*    firmwareInfos,\r\n        int16_t*    nFirmwareInfos,\r\n        uint16_t*    updatesRequired\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_CheckForUpdate\",\"psospaCheckForUpdate\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaStartFirmwareUpdate\r\n    (\r\n        int16_t    handle,\r\n        PicoUpdateFirmwareProgree    progress\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_StartFirmwareUpdate\",\"psospaStartFirmwareUpdate\", c_uint32, [c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaResetChannelsAndReportAllChannelsOvervoltageTripStatus\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_OVERVOLTAGE_TRIPPED*    allChannelsTriggedStatus,\r\n        uint8_t    nChannelTrippedStatus\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_ResetChannelsAndReportAllChannelsOVervoltageTripStatus\",\"psospaResetChannelsAndReportAllChannelsOvervoltageTripStatus\", c_uint32, [c_int16, c_void_p, c_char], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS psospaReportAllChannelsOvervoltageTripStatus\r\n    (\r\n        int16_t    handle,\r\n        PICO_CHANNEL_OVERVOLTAGE_TRIPPED*    allChannelsTriggedStatus,\r\n        uint8_t    nChannelTrippedStatus\r\n    ); \"\"\"\r\npsospa.make_symbol(\"_ReportAllChannelsOvervoltageTripStatus\",\"psospaReportAllChannelsOvervoltageTripStatus\", c_uint32, [c_int16, c_void_p, c_char], doc)"
  },
  {
    "path": "picosdk/psospaBlockExample.py",
    "content": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PSOSPA BLOCK MODE EXAMPLE\r\n# This example opens a psospa driver device, sets up two channels and a trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.psospa import psospa as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as structs\r\n# from picosdk.PicoConnectProbes import picoConnectProbes as probes\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mVV2, mV2adcV2, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open a psospa driver device\r\n# returns handle for future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openUnit\"] = ps.psospaOpenUnit(ctypes.byref(chandle), None, resolution, None)\r\nassert_pico_ok(status[\"openUnit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC\"]\r\nrangeMax = 2000000000 #nV\r\nrangeMin = -rangeMax #nV\r\nrangeType = 0 #probes.PICO_PROBE_RANGE_INFO[\"PICO_PROBE_NONE_NV\"]\r\nanalogueOffset = 0\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.psospaSetChannelOn(chandle, channelA, coupling, rangeMin, rangeMax, rangeType, analogueOffset, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\n# set channel B-D off\r\nfor x in range (1, 3, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.psospaSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.psospaGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.psospaSetSimpleTrigger(chandle, 1, source, mV2adcV2(100,rangeMax,maxADC), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# Get fastest available timebase\r\n# handle = chandle\r\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\r\ntimebase = ctypes.c_uint32(0)\r\ntimeInterval = ctypes.c_double(0)\r\n# resolution = resolution\r\nstatus[\"getMinimumTimebaseStateless\"] = ps.psospaGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"s\")\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataBuffers\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffers\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.psospaRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using psospaIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.psospaIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.psospaGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n\r\n\r\n# # convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mVV2(bufferAMax, rangeMax, maxADC)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.plot(time, bufferAMax[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Close the psospa driver device\r\nstatus[\"closeUnit\"] = ps.psospaCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeUnit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "picosdk/usbDrDaq.py",
    "content": "#\r\n# Copyright (C) 2014-2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the usbDrDaqApi.h C header\r\nfile for DrDaq Data Logger using the usbDrDaq driver API\r\nfunctions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\nfrom picosdk.library import Library\r\nfrom picosdk.constants import make_enum\r\n\r\nclass UsbDrDaqlib(Library):\r\n    def __init__(self):\r\n        super(UsbDrDaqlib, self).__init__(\"usbDrDaq\")\r\n\r\n\r\nusbDrDaq = UsbDrDaqlib()\r\n\r\nusbDrDaq.USB_DRDAQ_INPUTS = {\r\n    \"USB_DRDAQ_CHANNEL_EXT1\":\t1,\r\n\t\"USB_DRDAQ_CHANNEL_EXT2\":\t2,\r\n\t\"USB_DRDAQ_CHANNEL_EXT3\":\t3,\r\n\t\"USB_DRDAQ_CHANNEL_SCOPE\":\t4,\r\n\t\"USB_DRDAQ_CHANNEL_PH\":\t\t5,\r\n\t\"USB_DRDAQ_CHANNEL_RES\":\t6,\r\n\t\"USB_DRDAQ_CHANNEL_LIGHT\":\t7,\r\n\t\"USB_DRDAQ_CHANNEL_TEMP\":\t8,\r\n\t\"USB_DRDAQ_CHANNEL_MIC_WAVE\":\t9,\r\n\t(\"USB_DRDAQ_CHANNEL_MIC_LEVEL\", \"USB_DRDAQ_MAX_CHANNELS\"):\t10,\r\n}\r\n\r\nusbDrDaq.USB_DRDAQ_GPIO = {\r\n    \"USB_DRDAQ_GPIO_1\":1,\r\n\t\"USB_DRDAQ_GPIO_2\":2,\r\n\t\"USB_DRDAQ_GPIO_3\":3,\r\n\t\"USB_DRDAQ_GPIO_4\":4\r\n}\r\n\r\nusbDrDaq.USB_DRDAQ_SCOPE_RANGE = make_enum([\r\n    \"USB_DRDAQ_1V25\",\r\n\t\"USB_DRDAQ_2V5\",\r\n\t\"USB_DRDAQ_5V\",\r\n\t\"USB_DRDAQ_10V\"\r\n])\r\n\r\nusbDrDaq.USB_DRDAQ_WAVE = make_enum([\r\n    \"USB_DRDAQ_SINE\",\r\n\t\"USB_DRDAQ_SQUARE\",\r\n\t\"USB_DRDAQ_TRIANGLE\",\r\n\t\"USB_DRDAQ_RAMP_UP\",\r\n\t\"USB_DRDAQ_RAMP_DOWN\",\r\n\t\"USB_DRDAQ_DC\"\r\n])\r\n\r\nusbDrDaq.USB_DRDAQ_BLOCK_METHOD = make_enum([\r\n    \"BM_SINGLE\",\r\n\t\"BM_WINDOW\",\r\n\t\"BM_STREAM\"\r\n])\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqCloseUnit\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_CloseUnit\", \"UsbDrDaqCloseUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqEnabledRGBLED\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    enabled\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_EnableRGBLED\", \"UsbDrDaqEnableRGBLED\", c_uint32, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetChannelInfo\r\n    (\r\n\t    int16_t    handle,\r\n\t\tfloat      *min,\r\n\t\tfloat      *max,\r\n\t\tint16_t    *places,\r\n\t\tint16_t    *divider,\r\n\t\tUSB_DRDAQ_INPUTS    channel\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetChannelInfo\", \"UsbDrDaqGetChannelInfo\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetInput\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_GPIO    IOChannel,\r\n\t\tint16_t    pullUp,\r\n\t\tint16_t    *value\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetInput\", \"UsbDrDaqGetInput\", c_uint32, [c_int16, c_uint32, c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetPulseCount\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_GPIO    IOChannel,\r\n\t\tint16_t    *count\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetPulseCount\", \"UsbDrDaqGetPulseCount\", c_uint32, [c_int16, c_uint32, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetScalings\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_INPUTS    channel,\r\n\t\tint16_t    *nScales\r\n\t\tint16_t    *currentScale,\r\n\t\tint8_t     *names\r\n\t\tint16_t    namesSize\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetScalings\", \"UsbDrDaqGetScalings\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetSingle\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_INPUTS    channel,\r\n\t\tint16_t    *value,\r\n\t\tuint16_t    *overflow\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetSingle\", \"UsbDrDaqGetSingle\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetSingleF\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_INPUTS    channel,\r\n\t\tfloat    *value,\r\n\t\tuint16_t    *overflow\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_getSingleF\", \"UsbDrDaqGetSingleF\", c_uint32, [c_int16, c_uint32, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetTriggerTimeOffestNs\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint64_t    *time\r\n    ); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetTriggerTimeOffsetNs\", \"UsbDrDaqGetTriggerTimeOffsetNs\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetUnitInfo\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint8_t    *string,\r\n\t\tint16_t     stringLength,\r\n\t\tint16_t     *requiredSize,\r\n\t\tPICO_INFO     info\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetUnitInfo\", \"UsbDrDaqGetUnitInfo\", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetValues\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    *values,\r\n\t\tuint32_t    *noOfValues,\r\n\t\tuint16_t    *overflow,\r\n\t\tuint32_t    *triggerIndex\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetValues\", \"UsbDrDaqGetValues\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqGetValuesF\r\n    (\r\n\t    int16_t    handle,\r\n\t\tfloat     *values,\r\n\t\tuint32_t    *noOfValues,\r\n\t\tuint16_t    *overflow,\r\n\t\tuint32_t    *triggerIndex\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_GetValuesF\", \"UsbDrDaqGetValuesF\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqOpenUnit\r\n    (\r\n\t    int16_t    *handle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_OpenUnit\", \"UsbDrDaqOpenUnit\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqOpenUnitAsync\r\n    (\r\n\t    int16_t    *handle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_OpenUnitAsync\", \"UsbDrDaqOpenUnitAsync\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqOpenUnitProgress\r\n    (\r\n\t    int16_t    *handle,\r\n\t\tint16_t    *progress,\r\n\t\tint16_t    *complete\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_OpenUnitProgress\", \"UsbDrDaqOpenUnitProgress\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqPhTemperatureCompensation\r\n    (\r\n\t    int16_t    handle,\r\n\t\tuint16_t    enabled\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_PhTemperatureCompensation\", \"UsbDrDaqPhTemperatureCompensation\", c_uint32, [c_int16, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqPingUnit\r\n    (\r\n\t    int16_t    *handle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_PingUnit\", \"UsbDrDaqPingUnit\", c_uint32, [c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqReady\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint16_t    *ready\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_Ready\", \"UsbDrDaqReady\", c_uint32, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqRun\r\n    (\r\n\t    int16_t    handle,\r\n\t\tuint32_t    no_of_values,\r\n\t\tBLOCK_METHOD    method\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_Run\", \"UsbDrDaqRun\", c_uint32, [c_int16, c_uint32, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetDO\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_GPIO    IOChannel,\r\n\t\tint16_t    value\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetDO\", \"UsbDrDaqSetDO\", c_uint32, [c_int16, c_uint32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetInterval\r\n    (\r\n\t    int16_t    handle,\r\n\t\tuint32_t    *us_for_block,\r\n\t\tuint32_t    ideal_no_of_samples,\r\n\t\tUSB_DRDAQ_INPUTS    *channels,\r\n\t\tint16_t    no_of_channels\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetInterval\", \"UsbDrDaqSetInterval\", c_uint32, [c_int16, c_void_p, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetIntervalF\r\n    (\r\n\t    int16_t    handle,\r\n\t\tfloat    *us_for_block,\r\n\t\tuint32_t    ideal_no_of_samples,\r\n\t\tUSB_DRDAQ_INPUTS    *channels,\r\n\t\tint16_t    no_of_channels\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetIntervalF\", \"UsbDrDaqSetIntervalF\", c_uint32, [c_int16, c_void_p, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetPWM\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_GPIO    IOChannel,\r\n\t\tuint16_t    period,\r\n\t\tuint8_t    cycle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetPWM\", \"UsbDrDaqSetPWM\", c_uint32, [c_int16, c_uint32, c_uint16, c_uint8], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetRGBLED\r\n    (\r\n\t    int16_t    handle,\r\n\t\tuint16_t    red,\r\n\t\tuint16_t    green,\r\n\t\tuint16_t    blue\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetRGBLED\", \"UsbDrDaqSetRGBLED\", c_uint32, [c_int16, c_uint16, c_uint16, c_uint16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetScalings\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_INPUTS    channel,\r\n\t\tint16_t    scalingNumber\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetScalings\", \"UsbDrDaqSetScalings\", c_uint32, [c_int16, c_uint32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetSigGenArbitary\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    offsetVoltage,\r\n\t\tuint32_t    pkToPk,\r\n\t\tint16_t    *arbitaryWaveform,\r\n\t\tint16_t    arbitaryWaveformSize,\r\n\t\tint32_t    updateRate\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetSigGenArbitary\", \"UsbDrDaqSetSigGenArbitrary\", c_uint32, [c_int16, c_int32, c_uint32, c_void_p, c_int16, c_int32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetSigGenBuiltIn\r\n    (\r\n\t    int16_t    handle,\r\n\t\tint32_t    offsetVoltage,\r\n\t\tuint32_t    pkToPk,\r\n\t\tint16_t    frequency,\r\n\t\tUSB_DRDAQ_WAVE    waveType\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetSigGenBuiltIn\", \"UsbDrDaqSetSigGenBuiltIn\", c_uint32, [c_int16, c_int32, c_uint32, c_int16, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqSetTrigger\r\n    (\r\n\t    int16_t    handle,\r\n\t\tuint16_t    enabled,\r\n\t\tuint16_t    auto_trigger,\r\n\t\tuint16_t    auto_ms,\r\n\t\tuint16_t    channel,\r\n\t\tuint16_t    dir,\r\n\t\tint16_t    threshold,\r\n\t\tuint16_t    hysteresis,\r\n\t\tfloat    delay\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_SetTrigger\", \"UsbDrDaqSetTrigger\", c_uint32, [c_int16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16,c_int16, c_uint16, c_float], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqStartPulseCount\r\n    (\r\n\t    int16_t    handle,\r\n\t\tUSB_DRDAQ_GPIO    IOChannel,\r\n\t\tint16_t    direction\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_StartPulseCount\", \"UsbDrDaqStartPulseCount\", c_uint32, [c_int16, c_uint32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqStop\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_Stop\", \"UsbDrDaqStop\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbDrDaqStopSigGen\r\n    (\r\n\t    int16_t    handle\r\n\t); \"\"\"\r\nusbDrDaq.make_symbol(\"_StopSigGen\", \"UsbDrDaqStopSigGen\", c_uint32, [c_int16], doc)"
  },
  {
    "path": "picosdk/usbPT104.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the usbPT104Api.h C header\r\nfile for Pico USB PT-104 datalogger using the usb PT104 driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\r\nfrom picosdk.constants import make_enum\r\n\r\nclass usbpt104lib(Library):\r\n    def __init__(self):\r\n        super(usbpt104lib, self).__init__(\"usbpt104\")\r\n\r\n\r\nusbPt104 = usbpt104lib()\r\n\r\nusbPt104.PT104_CHANNELS = {\r\n    'USBPT104_CHANNEL_1' : 1,\r\n    'USBPT104_CHANNEL_2' : 2,\r\n    'USBPT104_CHANNEL_3' : 3,\r\n    'USBPT104_CHANNEL_4' : 4,\r\n    'USBPT104_CHANNEL_5' : 5,\r\n    'USBPT104_CHANNEL_6' : 6,\r\n    'USBPT104_CHANNEL_7' : 7,\r\n    'USBPT104_CHANNEL_8' : 8,\r\n    'USBPT104_MAX_CHANNELS' : 8\r\n}\r\n\r\nusbPt104.PT104_DATA_TYPE = make_enum([\r\n    'USBPT104_OFF',\r\n    'USBPT104_PT100',\r\n    'USBPT104_PT1000',\r\n    'USBPT104_RESISTANCE_TO_375R',\r\n    'USBPT104_RESISTANCE_TO_10K',\r\n    'USBPT104_DIFFERENTIAL_TO_115MV',\r\n    'USBPT104_DIFFERENTIAL_TO_2500MV',\r\n    'USBPT104_SINGLE_ENDED_TO_115MV',\r\n    'USBPT104_SINGLE_ENDED_TO_2500MV',\r\n    'USBPT104_MAX_DATA_TYPES'\r\n])\r\n\r\nusbPt104.IP_DETAILS_TYPE = make_enum([\r\n    'IDT_GET'\r\n    'IDT_SET'\r\n])\r\n\r\ndef _define_communication_type():\r\n    CT_USB = 0x00000001\r\n    CT_ETHERNET = 0x00000002\r\n    CT_ALL = 0xFFFFFFFF\r\n    \r\n    return {k.upper(): v for k, v in locals().items() if k.startswith(\"CT\")}\r\n    \r\nusbPt104.COMMUNICATION_TYPE = _define_communication_type()\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104CloseUnit\r\n    (\r\n        int16_t    handle\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_CloseUnit\", \"UsbPt104CloseUnit\", c_uint32, [c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104Enumerate\r\n    (\r\n        int8_t    *details,\r\n        uint32_t    *length,\r\n        COMMUNICATION_TYPE    type\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_Enumerate\", \"UsbPt104Enumerate\", c_uint32, [c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104GetUnitInfo\r\n    (\r\n        int16_t    handle,\r\n        int8_t    *string,\r\n        int16_t    stringLength,\r\n        int16_t    *requiredSize,\r\n        PICO_INFO    info\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_GetUnitInfo\", \"UsbPt104GetUnitInfo\", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104GetValue\r\n    (\r\n        int16_t    handle,\r\n        USBPT104_CHANNELS    channel,\r\n        int32_t    *value,\r\n        int16_t    filtered\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_GetValue\", \"UsbPt104GetValue\", c_uint32, [c_int16, c_uint32, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104IpDetails\r\n    (\r\n        int16_t    handle,\r\n        int16_t    *enabled,\r\n        int8_t    *ipaddress,\r\n        uint16_t    *length,\r\n        uint16_t    *listeningPort,\r\n        IP_DETAILS_TYPE    type\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_IpDetails\", \"UsbPt104IpDetails\", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_uint32], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104OpenUnit\r\n    (\r\n        int16_t    *handle,\r\n        int8_t    *serial\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_OpenUnit\", \"UsbPt104OpenUnit\", c_uint32, [c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104OpenUnitViaIp\r\n    (\r\n        int16_t    *handle,\r\n        int8_t    *serial,\r\n        int8_t    *ipAddress\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_OpenUnitViaIp\", \"UsbPt104OpenUnitViaIp\", c_uint32, [c_void_p, c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104SetChannel\r\n    (\r\n        int16_t    handle,\r\n        USBPT104_CHANNELS    channel,\r\n        USBPT104_DATA_TYPES    type,\r\n        int16_t    noOfWires\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_SetChannel\", \"UsbPt104SetChannel\", c_uint32, [c_int16, c_uint32, c_uint32, c_int16], doc)\r\n\r\ndoc = \"\"\" PICO_STATUS UsbPt104SetMains\r\n    (\r\n        int16_t    handle,\r\n        uint16_t    sixty_hertz\r\n    ); \"\"\"\r\nusbPt104.make_symbol(\"_SetMains\", \"UsbPt104SetMains\", c_uint32, [c_int16, c_uint16], doc)\r\n"
  },
  {
    "path": "picosdk/usbtc08.py",
    "content": "#\r\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the functions from the usbtc08.h C header file\r\nfor TC-08 Thermocouple Data Logger using the usbtc08 driver API functions.\r\n\"\"\"\r\n\r\nfrom ctypes import *\r\nfrom picosdk.library import Library\r\nfrom picosdk.errors import ArgumentOutOfRangeError\r\nfrom picosdk.constants import make_enum\r\n\r\nclass usbtc08lib(Library):\r\n    def __init__(self):\r\n        super(usbtc08lib, self).__init__(\"usbtc08\")\r\n\r\n\r\nusbtc08 = usbtc08lib()\r\n\r\nusbtc08.USBTC08_UNITS = make_enum([\r\n    \"USBTC08_UNITS_CENTIGRADE\",\r\n\t\"USBTC08_UNITS_FAHRENHEIT\",\r\n\t\"USBTC08_UNITS_KELVIN\",\r\n\t\"USBTC08_UNITS_RANKINE\",\r\n])\r\n\r\nclass USBTC08_INFO(Structure):\r\n    _pack_ = 1\r\n    _fields_ = [(\"size\", c_int16),\r\n                (\"DriverVersion\", c_char * 12),\r\n                (\"PicoppVersion\", c_int16),\r\n\t\t\t\t(\"HardwareVersion\", c_int16),\r\n\t\t\t\t(\"Variant\", c_int16),\r\n\t\t\t\t(\"szSerial[USBTC08_MAX_SERIAL_CHAR]\", c_char * 11),\r\n\t\t\t\t(\"szCalDate[USBTC08_MAX_DATE_CHARS]\", c_char * 9)]\r\n\r\ndoc = \"\"\" int16_t usb_tc08_open_unit\r\n    (\r\n\t    void\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_open_unit_\",\"usb_tc08_open_unit\", c_int16, [], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_open_unit_async\r\n    (\r\n\t    void\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_open_unit_async_\",\"usb_tc08_open_unit_async\", c_int16, [], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_open_unit_progress\r\n    (\r\n\t    int16_t  *handle,\r\n\t\tint16_t  *progress\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_open_unit_progress_\",\"usb_tc08_open_unit_progress\", c_int16, [c_void_p, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_close_unit\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_close_unit_\",\"usb_tc08_close_unit\", c_int16, [c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_stop\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_stop_\",\"usb_tc08_stop\", c_int16, [c_int16], doc)\r\n\r\ndoc = \"\"\" int16 usb_tc08_set_mains\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint16_t  sixty_hertz\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_set_mains_\",\"usb_tc08_set_mains\", c_int16, [c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int32_t usb_tc08_get_minimum_interval_ms\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_minimum_interval_ms_\",\"usb_tc08_get_minimum_interval_ms\", c_int16, [c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_get_unit_info\r\n    (\r\n\t    int16_t  handle\r\n\t\tUSBTC08_INFO  *info\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_unit_info_\",\"usb_tc08_get_unit_info\", c_int16, [c_int16, c_void_p], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_get_unit_info2\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint8_t  *string,\r\n\t\tint16_t  string_length,\r\n\t\tint16_t  line\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_unit_info2_\",\"usb_tc08_get_unit_info2\", c_int16, [c_int16, c_void_p, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_get_formatted_info\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint8_t  *unit_info,\r\n\t\tint16_t  string_length\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_formatted_info_\",\"usb_tc08_get_formatted_info\", c_int16, [c_int16, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_get_last_error\r\n    (\r\n\t    int16_t  handle\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_last_error_\",\"usb_tc08_get_last_error\", c_int16, [c_int16], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_set_channel\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint16_t  channel,\r\n\t\tint8_t  tc_type\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_set_channel_\",\"usb_tc08_set_channel\", c_int16, [c_int16, c_int16, c_int8], doc)\r\n\r\ndoc = \"\"\" int32_t usb_tc08_run\r\n    (\r\n\t    int16_t  handle,\r\n\t\tint32_t  interval\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_run_\",\"usb_tc08_run\", c_int16, [c_int16, c_int32], doc)\r\n\r\ndoc = \"\"\" int16_t usb_tc08_get_single\r\n    (\r\n\t    int16_t  handle,\r\n\t\tfloat  *temp,\r\n\t\tint16_t  *overflow_flags,\r\n\t\tint16_t  units\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_single_\",\"usb_tc08_get_single\", c_int16, [c_int16, c_void_p, c_void_p, c_int16], doc)\r\n\r\ndoc = \"\"\" int32_t usb_tc08_get_temp\r\n    (\r\n\t    int16_t  handle,\r\n\t\tfloat  *temp_buffer,\r\n\t\tint32_t  *times_ms_buffer,\r\n\t\tint32_t  buffer_length,\r\n\t\tint16_t  *overflow,\r\n\t\tint16_t  channel,\r\n\t\tint16_t  units,\r\n\t\tint16_t  fill_missing\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_temp_\",\"usb_tc08_get_temp\", c_int16, [c_int16, c_void_p, c_void_p, c_int32, c_void_p, c_void_p, c_int16, c_int16], doc)\r\n\r\ndoc = \"\"\" int32_t usb_tc08_get_temp_deskew\r\n    (\r\n\t    int16_t  handle,\r\n\t\tfloat  *temp_buffer,\r\n\t\tint32_t  *times,\r\n\t\tint32_t  buffer_length,\r\n\t\tint16_t  *overflow,\r\n\t\tint16_t  channel,\r\n\t\tint16_t  units,\r\n\t\tint16_t  fill_missing\r\n\t); \"\"\"\r\nusbtc08.make_symbol(\"_get_temp_deskew_\",\"usb_tc08_get_temp_deskew\", c_int16, [c_int16, c_void_p, c_void_p, c_int32, c_void_p, c_int16, c_int16, c_int16], doc)"
  },
  {
    "path": "picosynthExamples/picosynthFrequencySweepExample.py",
    "content": "#\r\n# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoSource AS108 Agile Synthesizer Example\r\n# This example demonstrates how to use the PicoSource AS108 picosynth driver API functions to set up the signal generator to output a frequency sweep.\r\n#\r\n\r\nimport ctypes\r\nfrom picosdk.picosynth import picosynth as ps\r\nimport time\r\nfrom picosdk.functions import assert_pico_ok\r\n\r\n# setup needed variables\r\nstatus = {}\r\nchandle = ctypes.c_uint32()\r\n\r\n# open AS108 device\r\nstatus[\"openunit\"] = ps.picosynthOpenUnit(ps.PICO_SOURCE_MODEL[\"PICO_SYNTH\"], ctypes.byref(chandle),0)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# set up a frequency sweep\r\n# handle = chandle\r\nstartFreqHz = 300000 #Hz\r\nstopFreqHz = 1000000 #Hz\r\nstartLevel = 2\r\nstopLevel = 2\r\nlevelUnit = 1 # VoltsPkToPk\r\ndwellTimeUs = 100\r\npointsInSweep = 1000\r\nmode = 0 #SweepAndFlyback\r\ntriggerMode = 0 # InternalTrigger\r\n\r\nstatus[\"setFrequencyAndLevelSweep\"] = ps.picosynthSetFrequencyAndLevelSweep(chandle,startFreqHz,stopFreqHz,startLevel,stopLevel,levelUnit,dwellTimeUs,pointsInSweep,mode,triggerMode)\r\nassert_pico_ok(status[\"setFrequencyAndLevelSweep\"])\r\n\r\ntime.sleep(10)\r\n\r\n# close AS108 device\r\nstatus[\"closeunit\"] = ps.picosynthCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\ntime.sleep(20)\r\n\r\n# open AS108 device\r\nstatus[\"openunit\"] = ps.picosynthOpenUnit(ps.PICO_SOURCE_MODEL[\"PICO_SYNTH\"], ctypes.byref(chandle),0)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# set output off\r\nstatus[\"setOutputOff\"] = ps.picosynthSetOutputOff(chandle)\r\n\r\n# close AS108 device\r\nstatus[\"closeunit\"] = ps.picosynthCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\n# Displays the status returns\r\nprint(status)"
  },
  {
    "path": "pl1000Examples/pl1000SingleModeExample.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PL1000 SINGLE MODE EXAMPLE\r\n# This example opens a pl1000 device, sets up the device for capturing data from channel 1.\r\n# Then this example collect a sample from channel 1 and displays it on the console.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.pl1000 import pl1000 as pl\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# open PicoLog 1000 device\r\nstatus[\"openUnit\"] = pl.pl1000OpenUnit(ctypes.byref(chandle))\r\nassert_pico_ok(status[\"openUnit\"])\r\n\r\nvalue = ctypes.c_int16()\r\n# get a single ADC count value from channel 1\r\nstatus[\"getSingle\"] = pl.pl1000GetSingle(chandle, pl.PL1000Inputs[\"PL1000_CHANNEL_1\"], ctypes.byref(value))\r\nassert_pico_ok(status[\"getSingle\"])\r\nprint(value.value)\r\n\r\n# close PicoLog 1000 device\r\nstatus[\"closeUnit\"] = pl.pl1000CloseUnit(chandle)\r\nassert_pico_ok(status[\"closeUnit\"])\r\n\r\n# display status returns\r\nprint(status)\r\n"
  },
  {
    "path": "pl1000Examples/pl1000StreamingModeExample.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PL1000 STREAMING MODE EXAMPLE\r\n# This example opens a PicoLog 1000 device, configures streaming mode to capture data from channel 1 at\r\n# a sampling rate of 100 kS/s for 10 seconds, retrieves the data, and displays it on a plot.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.pl1000 import pl1000 as pl\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mVpl1000, assert_pico_ok\r\nfrom time import sleep\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# open PicoLog 1000 device\r\nstatus[\"openUnit\"] = pl.pl1000OpenUnit(ctypes.byref(chandle))\r\nassert_pico_ok(status[\"openUnit\"])\r\n\r\n# set sampling interval\r\nusForBlock = ctypes.c_uint32(10000000)\r\nnoOfValues = ctypes.c_uint32(1000000)\r\nchannels = ctypes.c_int16(1)\r\n\r\nstatus[\"setInterval\"] = pl.pl1000SetInterval(chandle, ctypes.byref(usForBlock), noOfValues, ctypes.byref(channels), 1)\r\nassert_pico_ok(status[\"setInterval\"])\r\n\r\n# start streaming\r\nmode = pl.PL1000_BLOCK_METHOD[\"BM_STREAM\"]\r\nstatus[\"run\"] = pl.pl1000Run(chandle, 1000000, mode)\r\nassert_pico_ok(status[\"run\"])\r\n\r\nsleep(usForBlock.value / 1000000)\r\n\r\nvalues = (ctypes.c_uint16 * noOfValues.value)()\r\noveflow = ctypes.c_uint16()\r\n\r\nstatus[\"getValues\"] = pl.pl1000GetValues(chandle, ctypes.byref(values), ctypes.byref(noOfValues), ctypes.byref(oveflow), None)\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n# convert ADC counts data to mV\r\nmaxADC = ctypes.c_uint16()\r\nstatus[\"maxValue\"] = pl.pl1000MaxValue(chandle, ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"maxValue\"])\r\ninputRange = 2500\r\nmVValues =  adc2mVpl1000(values, inputRange, maxADC)\r\n\r\n# create time data\r\ninterval = (0.001 * usForBlock.value)/(noOfValues.value * 1)\r\n\r\ntimeMs = np.linspace(0, (len(mVValues) -1) * interval, len(mVValues))\r\n\r\n# plot data\r\n\r\nplt.plot(timeMs, mVValues[:])\r\nplt.xlabel('Time (ms)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# close PicoLog 1000 device\r\nstatus[\"closeUnit\"] = pl.pl1000CloseUnit(chandle)\r\nassert_pico_ok(status[\"closeUnit\"])\r\n\r\n# display status returns\r\nprint(status)\r\n"
  },
  {
    "path": "pl1000Examples/pl1000StreamingModeMultiChannelExample.py",
    "content": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PL1000 STREAMING MODE MULTICHANNEL EXAMPLE\n# This example opens a PicoLog 1000 device, configures streaming mode to capture data from N channels\n# at the set sample rate, retrieves the data, and displays it on a plot.\n\nimport ctypes\nimport time\nfrom typing import Optional\n\nimport numpy\nimport picosdk.pl1000\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import assert_pico_ok, adc2mVpl1000\n\n# Setup channels values and arrays\nchannel_list=(1,2,3,4,5,6,7,8,9,10,11,12) # Enable Chs 1-12, Max channels (1012)\n# channel_list=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) # Enable Chs 1-16, Max channels (1216)\nn_channels = len(channel_list)\nprint(f\"{n_channels} channels\")\nchannel_array = (ctypes.c_int16 * len(channel_list))()\nfor i, ch in enumerate(channel_list):\n    channel_array[i] = picosdk.pl1000.pl1000.PL1000Inputs[f\"PL1000_CHANNEL_{ch}\"]  \n\n# Max streaming sample rate for\n# 1012 - with all 12 channels on is = 100k /12 = 8333S/s\n# 1216 - with all 16 channels on is = 100k /16 = 6250S/s\nus_for_block = ctypes.c_uint32(1_000_000)   # 1 seconds in microseconds              \nideal_no_of_samples = 6250                  # Max sample rate for both 1012/1216 with 12 Chs on\n\n# As us_for_block is set to 1M, \"ideal_no_of_samples\" becomes the sample rate per channel (in Samples/second)       \nread_buffer_size = ideal_no_of_samples * n_channels\nread_sample_count = ctypes.c_uint32(read_buffer_size)      \n\n# reserve memory    \nread_buffer = (ctypes.c_uint16 * read_buffer_size)() # reserve memory for read_buffer\ncaptured_samples=numpy.zeros(shape=(0,n_channels), dtype=numpy.uint16)\nleftover_sample_buffer = numpy.zeros(shape=(0,), dtype=numpy.uint16)\nleftover_sample_counter = 0\n\n# Datatypes for Addition capture Info\noverflow = ctypes.c_uint16()\ntriggerIndex = ctypes.c_uint32()\n\n# Open the device\nhandle = ctypes.c_int16()\nassert_pico_ok(picosdk.pl1000.pl1000.pl1000OpenUnit(ctypes.byref(handle)))\n\n# Configure sampling interval\nassert_pico_ok(\n    picosdk.pl1000.pl1000.pl1000SetInterval(\n        handle,\n        ctypes.byref(us_for_block),\n        ctypes.c_uint32(ideal_no_of_samples),\n        channel_array,\n        len(channel_list)\n    )\n)\n\nprint(f'ideal_no_of_samples: {ideal_no_of_samples}')\nprint(f'read_buffer_size: {read_buffer_size}')\nprint(f'us_for_block: {us_for_block}')\n\n# start acquisition\nassert_pico_ok(\n    picosdk.pl1000.pl1000.pl1000Run(\n        handle,\n        ctypes.c_uint32(read_buffer_size),\n        picosdk.pl1000.pl1000.PL1000_BLOCK_METHOD[\"BM_STREAM\"]\n        )\n    )\n\n# Check device is ready using IsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    assert_pico_ok(\n        picosdk.pl1000.pl1000.pl1000Ready(handle, ctypes.byref(ready))\n        )\n\n# start download loop:\nfor iteration_idx in range(9):\n    time.sleep(0.1) # wait to part fill the buffer (never let it fill up!!)\n\n    read_sample_count = ctypes.c_uint32((int)(read_buffer_size // n_channels))\n\n    assert_pico_ok(\n        picosdk.pl1000.pl1000.pl1000GetValues(\n            handle,\n            ctypes.byref(read_buffer),\n            ctypes.byref(read_sample_count),    # gets modified on return (per channel)\n            ctypes.byref(overflow),             # Channel voltage over range bit flags (LSB is Ch0)\n            ctypes.byref(triggerIndex)\n        )\n    )\n    # check how many samples have actually been captured:\n\n    print(f\"iteration {iteration_idx}: readout {read_sample_count.value} samples across {n_channels} channels\")\n\n    read_samples_numpy_varsized = numpy.array(read_buffer[:read_sample_count.value * n_channels]) # get only the valid samples out of the read_buffer\n    print(f'  - read_samples_numpy_varsized.shape: {read_samples_numpy_varsized.shape}')\n\n    # now, we can reshape the running buffer, which is now well sized, to a 2D array:\n    channelized_samples = read_samples_numpy_varsized.reshape((-1,n_channels))\n    # Append to final Array\n    captured_samples = numpy.vstack((captured_samples,channelized_samples))\n\n    # Debug - list array sizes\n    # print(f'  - channelized_samples.shape: {channelized_samples.shape}')\n    # print(f'  - captured_samples.shape: {captured_samples.shape}')\n    # print('---')\n\n# Close unit                           \nassert_pico_ok(picosdk.pl1000.pl1000.pl1000CloseUnit(handle))        \n\n# Display data\nprint(f'Final captured_samples (Samples, NoOfChannels): {captured_samples.shape}')\nprint(f'Channel_list: {channel_list}')\nsamples_per_s = (ideal_no_of_samples * us_for_block.value / 1_000_000)\ninterval = 1 / samples_per_s\nprint(f\" { interval }s Sample Interval = { samples_per_s }Samples/sec \")\n\ntime_s = numpy.linspace(0, (len(captured_samples[:,0]) -1) * interval, len(captured_samples[:,0]))\nplt.plot(time_s, captured_samples[:,0])\nplt.plot(time_s, captured_samples[:,1])\nplt.plot(time_s, captured_samples[:,2]) # 3 channels\nplt.plot(time_s, captured_samples[:,3])\nplt.plot(time_s, captured_samples[:,4])\nplt.plot(time_s, captured_samples[:,5]) # 6 channels\nplt.plot(time_s, captured_samples[:,6])\nplt.plot(time_s, captured_samples[:,7])\nplt.plot(time_s, captured_samples[:,8]) # 9 channels\nplt.plot(time_s, captured_samples[:,9])\nplt.plot(time_s, captured_samples[:,10])\nplt.plot(time_s, captured_samples[:,11]) # 12 Max channels (1012)\n#plt.plot(time_s, captured_samples[:,12])\n#plt.plot(time_s, captured_samples[:,13])\n#plt.plot(time_s, captured_samples[:,14])\n#plt.plot(time_s, captured_samples[:,15]) # 16 Max channels (1216)\n\nplt.xlabel('Time (s)')\nplt.ylabel('ADC counts')\nplt.show()"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_dropout.py",
    "content": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nSAMPLES = 2000\nOVERSAMPLING = 1\nPRESAMPLE = 80.0\nADC_THRESHOLD = 1000\n\nTHRESHOLD_DIRECTION = {\n    'PS2000_ABOVE': 0,\n    'PS2000_BELOW': 1,\n    'PS2000_ADV_RISING': 2,\n    'PS2000_ADV_FALLING': 3,\n    'PS2000_ADV_RISING_OR_FALLING': 4,\n    'PS2000_INSIDE': 0,\n    'PS2000_OUTSIDE': 1,\n    'PS2000_ENTER': 2,\n    'PS2000_EXIT': 3,\n    'PS2000_ENTER_OR_EXIT': 4,\n    'PS2000_ADV_NONE': 2,\n}\n\n\nclass TriggerConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n        ('pulseWidthQualifier', c_int32),\n    ]\n\n\nclass PwqConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n    ]\n\n\nclass TriggerChannelProperties(Structure):\n    _fields_ = [\n        (\"thresholdMajor\", c_int16),\n        (\"thresholdMinor\", c_int16),\n        (\"hysteresis\", c_uint16),\n        (\"channel\", c_int16),\n        (\"thresholdMode\", c_int16),\n    ]\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        SAMPLES,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_500MV']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_conditions = TriggerConditions(0, 0, 0, 0, 0, 1)\n\n    res = ps2000.ps2000SetAdvTriggerChannelConditions(\n        device.handle,\n        byref(trigger_conditions),\n        1\n    )\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerDelay(device.handle, 0, -PRESAMPLE)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerChannelDirections(\n        device.handle,\n        THRESHOLD_DIRECTION['PS2000_ADV_RISING_OR_FALLING'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_properties = TriggerChannelProperties(\n        ADC_THRESHOLD,\n        -ADC_THRESHOLD,\n        0,\n        ps2000.PS2000_CHANNEL['PS2000_CHANNEL_A'],\n        picoEnum.PICO_THRESHOLD_MODE['PICO_WINDOW']\n    )\n\n    res = ps2000.ps2000SetAdvTriggerChannelProperties(device.handle, byref(trigger_properties), 1, 0)\n    assert_pico2000_ok(res)\n\n    pwq_conditions = PwqConditions(1, 0, 0, 0, 0)\n\n    res = ps2000.ps2000SetPulseWidthQualifier(\n        device.handle,\n        byref(pwq_conditions),\n        1,\n        THRESHOLD_DIRECTION['PS2000_ENTER'],\n        200,\n        0,\n        picoEnum.PICO_PULSE_WIDTH_TYPE['PICO_PW_TYPE_GREATER_THAN']\n    )\n    assert_pico2000_ok(res)\n\n    # calculate timebase\n    timebase_a, interval = get_timebase(device, 20_000)\n\n    collection_time = c_int32()\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('ADC counts')\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    # wait for ready signal\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        None,\n        None,\n        None,\n        None,\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), buffer_a[:])\n    ax.axvline(np.percentile(list(map(lambda x: x * 1e-6, times[:])), PRESAMPLE), color='red', linestyle='dotted')\n\n    ps2000.ps2000_stop(device.handle)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_interval.py",
    "content": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nSAMPLES = 2000\nOVERSAMPLING = 1\nPRESAMPLE = 80.0\n\nTHRESHOLD_DIRECTION = {\n    'PS2000_ABOVE': 0,\n    'PS2000_BELOW': 1,\n    'PS2000_ADV_RISING': 2,\n    'PS2000_ADV_FALLING': 3,\n    'PS2000_ADV_RISING_OR_FALLING': 4,\n    'PS2000_INSIDE': 0,\n    'PS2000_OUTSIDE': 1,\n    'PS2000_ENTER': 2,\n    'PS2000_EXIT': 3,\n    'PS2000_ENTER_OR_EXIT': 4,\n    'PS2000_ADV_NONE': 2,\n}\n\n\nclass TriggerConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n        ('pulseWidthQualifier', c_int32),\n    ]\n\n\nclass PwqConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n    ]\n\n\nclass TriggerChannelProperties(Structure):\n    _fields_ = [\n        (\"thresholdMajor\", c_int16),\n        (\"thresholdMinor\", c_int16),\n        (\"hysteresis\", c_uint16),\n        (\"channel\", c_int16),\n        (\"thresholdMode\", c_int16),\n    ]\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        SAMPLES,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_500MV']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_conditions = TriggerConditions(1, 0, 0, 0, 0, 1)\n\n    res = ps2000.ps2000SetAdvTriggerChannelConditions(device.handle, byref(trigger_conditions), 1)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerDelay(device.handle, 0, -PRESAMPLE)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerChannelDirections(\n        device.handle,\n        THRESHOLD_DIRECTION['PS2000_ADV_RISING_OR_FALLING'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_properties = TriggerChannelProperties(\n        32000,\n        2048,\n        328,\n        ps2000.PS2000_CHANNEL['PS2000_CHANNEL_A'],\n        picoEnum.PICO_THRESHOLD_MODE['PICO_WINDOW']\n    )\n\n    res = ps2000.ps2000SetAdvTriggerChannelProperties(device.handle, byref(trigger_properties), 1, 0)\n    assert_pico2000_ok(res)\n\n    pwq_conditions = PwqConditions(1, 0, 0, 0, 0)\n\n    res = ps2000.ps2000SetPulseWidthQualifier(\n        device.handle,\n        byref(pwq_conditions),\n        1,\n        THRESHOLD_DIRECTION['PS2000_ENTER_OR_EXIT'],\n        600,\n        0,\n        picoEnum.PICO_PULSE_WIDTH_TYPE['PICO_PW_TYPE_GREATER_THAN']\n    )\n    assert_pico2000_ok(res)\n\n    timebase_a, interval = get_timebase(device, 4_000)\n\n    collection_time = c_int32()\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('ADC counts')\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        None,\n        None,\n        None,\n        None,\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), buffer_a[:])\n    ax.axvline(np.percentile(list(map(lambda x: x * 1e-6, times[:])), PRESAMPLE), color='red', linestyle='dotted')\n\n    ps2000.ps2000_stop(device.handle)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_pwq.py",
    "content": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nSAMPLES = 2000\nOVERSAMPLING = 1\nPRESAMPLE = 10.0\nADC_THRESHOLD = 8192\n\nTHRESHOLD_DIRECTION = {\n    'PS2000_ABOVE': 0,\n    'PS2000_BELOW': 1,\n    'PS2000_ADV_RISING': 2,\n    'PS2000_ADV_FALLING': 3,\n    'PS2000_ADV_RISING_OR_FALLING': 4,\n    'PS2000_INSIDE': 0,\n    'PS2000_OUTSIDE': 1,\n    'PS2000_ENTER': 2,\n    'PS2000_EXIT': 3,\n    'PS2000_ENTER_OR_EXIT': 4,\n    'PS2000_ADV_NONE': 2,\n}\n\n\nclass TriggerConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n        ('pulseWidthQualifier', c_int32),\n    ]\n\n\nclass PwqConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n    ]\n\n\nclass TriggerChannelProperties(Structure):\n    _fields_ = [\n        (\"thresholdMajor\", c_int16),\n        (\"thresholdMinor\", c_int16),\n        (\"hysteresis\", c_uint16),\n        (\"channel\", c_int16),\n        (\"thresholdMode\", c_int16),\n    ]\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        SAMPLES,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_conditions = TriggerConditions(1, 0, 0, 0, 0, 1)\n\n    res = ps2000.ps2000SetAdvTriggerChannelConditions(device.handle, byref(trigger_conditions), 1)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerDelay(device.handle, 0, -PRESAMPLE)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerChannelDirections(\n        device.handle,\n        THRESHOLD_DIRECTION['PS2000_ADV_RISING_OR_FALLING'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_properties = TriggerChannelProperties(\n        ADC_THRESHOLD,\n        ADC_THRESHOLD,\n        328,\n        ps2000.PS2000_CHANNEL['PS2000_CHANNEL_A'],\n        picoEnum.PICO_THRESHOLD_MODE['PICO_LEVEL']\n    )\n\n    res = ps2000.ps2000SetAdvTriggerChannelProperties(device.handle, byref(trigger_properties), 1, 0)\n    assert_pico2000_ok(res)\n\n    pwq_conditions = PwqConditions(1, 0, 0, 0, 0)\n\n    res = ps2000.ps2000SetPulseWidthQualifier(\n        device.handle,\n        byref(pwq_conditions),\n        1,\n        THRESHOLD_DIRECTION['PS2000_ADV_RISING_OR_FALLING'],\n        1000,\n        0,\n        picoEnum.PICO_PULSE_WIDTH_TYPE['PICO_PW_TYPE_GREATER_THAN']\n    )\n    assert_pico2000_ok(res)\n\n    timebase_a, interval = get_timebase(device, 20_000)\n\n    collection_time = c_int32()\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('ADC counts')\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        None,\n        None,\n        None,\n        None,\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), buffer_a[:])\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), [ADC_THRESHOLD for _ in times[:]], color='red')\n    ax.axvline(np.percentile(list(map(lambda x: x * 1e-6, times[:])), PRESAMPLE), color='red', linestyle='dotted')\n\n    ps2000.ps2000_stop(device.handle)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_runt.py",
    "content": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nSAMPLES = 2000\nOVERSAMPLING = 1\nPRESAMPLE = 80.0\nADC_THRESHOLDS = (12000, 2048)\n\nTHRESHOLD_DIRECTION = {\n    'PS2000_ABOVE': 0,\n    'PS2000_BELOW': 1,\n    'PS2000_ADV_RISING': 2,\n    'PS2000_ADV_FALLING': 3,\n    'PS2000_ADV_RISING_OR_FALLING': 4,\n    'PS2000_INSIDE': 0,\n    'PS2000_OUTSIDE': 1,\n    'PS2000_ENTER': 2,\n    'PS2000_EXIT': 3,\n    'PS2000_ENTER_OR_EXIT': 4,\n    'PS2000_ADV_NONE': 2,\n}\n\n\nclass TriggerConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n        ('pulseWidthQualifier', c_int32),\n    ]\n\n\nclass PwqConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n    ]\n\n\nclass TriggerChannelProperties(Structure):\n    _fields_ = [\n        (\"thresholdMajor\", c_int16),\n        (\"thresholdMinor\", c_int16),\n        (\"hysteresis\", c_uint16),\n        (\"channel\", c_int16),\n        (\"thresholdMode\", c_int16),\n    ]\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        SAMPLES,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_500MV']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_conditions = TriggerConditions(0, 0, 0, 0, 0, 1)\n\n    res = ps2000.ps2000SetAdvTriggerChannelConditions(device.handle, byref(trigger_conditions), 1)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerDelay(device.handle, 0, -PRESAMPLE)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerChannelDirections(\n        device.handle,\n        THRESHOLD_DIRECTION['PS2000_EXIT'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_properties = TriggerChannelProperties(\n        max(ADC_THRESHOLDS),\n        min(ADC_THRESHOLDS),\n        328,\n        ps2000.PS2000_CHANNEL['PS2000_CHANNEL_A'],\n        picoEnum.PICO_THRESHOLD_MODE['PICO_WINDOW']\n    )\n\n    res = ps2000.ps2000SetAdvTriggerChannelProperties(device.handle, byref(trigger_properties), 1, 0)\n    assert_pico2000_ok(res)\n\n    pwq_conditions = PwqConditions(1, 0, 0, 0, 0)\n\n    res = ps2000.ps2000SetPulseWidthQualifier(\n        device.handle,\n        byref(pwq_conditions),\n        1,\n        THRESHOLD_DIRECTION['PS2000_ENTER'],\n        100,\n        0,\n        picoEnum.PICO_PULSE_WIDTH_TYPE['PICO_PW_TYPE_GREATER_THAN']\n    )\n    assert_pico2000_ok(res)\n\n    timebase_a, interval = get_timebase(device, 4_000)\n\n    collection_time = c_int32()\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('ADC counts')\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        None,\n        None,\n        None,\n        None,\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), buffer_a[:])\n    for threshold in ADC_THRESHOLDS:\n        ax.plot(list(map(lambda x: x * 1e-6, times[:])), [threshold for _ in times[:]], color='red')\n\n    ax.axvline(np.percentile(list(map(lambda x: x * 1e-6, times[:])), PRESAMPLE), color='red', linestyle='dotted')\n\n    ps2000.ps2000_stop(device.handle)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_window.py",
    "content": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nSAMPLES = 2000\nOVERSAMPLING = 1\nPRESAMPLE = 25.0\nADC_THRESHOLD = 8192\n\nTHRESHOLD_DIRECTION = {\n    'PS2000_ABOVE': 0,\n    'PS2000_BELOW': 1,\n    'PS2000_ADV_RISING': 2,\n    'PS2000_ADV_FALLING': 3,\n    'PS2000_ADV_RISING_OR_FALLING': 4,\n    'PS2000_INSIDE': 0,\n    'PS2000_OUTSIDE': 1,\n    'PS2000_ENTER': 2,\n    'PS2000_EXIT': 3,\n    'PS2000_ENTER_OR_EXIT': 4,\n    'PS2000_ADV_NONE': 2,\n}\n\n\nclass TriggerConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n        ('pulseWidthQualifier', c_int32),\n    ]\n\n\nclass PwqConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n    ]\n\n\nclass TriggerChannelProperties(Structure):\n    _fields_ = [\n        (\"thresholdMajor\", c_int16),\n        (\"thresholdMinor\", c_int16),\n        (\"hysteresis\", c_uint16),\n        (\"channel\", c_int16),\n        (\"thresholdMode\", c_int16),\n    ]\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        SAMPLES,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_conditions = TriggerConditions(1, 0, 0, 0, 0, 0)\n\n    res = ps2000.ps2000SetAdvTriggerChannelConditions(device.handle, byref(trigger_conditions), 1)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerDelay(device.handle, 0, -PRESAMPLE)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerChannelDirections(\n        device.handle,\n        THRESHOLD_DIRECTION['PS2000_EXIT'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_properties = TriggerChannelProperties(\n        ADC_THRESHOLD,\n        -ADC_THRESHOLD,\n        2,\n        ps2000.PS2000_CHANNEL['PS2000_CHANNEL_A'],\n        picoEnum.PICO_THRESHOLD_MODE['PICO_WINDOW']\n    )\n\n    res = ps2000.ps2000SetAdvTriggerChannelProperties(device.handle, byref(trigger_properties), 1, 0)\n    assert_pico2000_ok(res)\n\n    timebase_a, interval = get_timebase(device, 20_000)\n\n    collection_time = c_int32()\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('ADC counts')\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        None,\n        None,\n        None,\n        None,\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), buffer_a[:])\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), [ADC_THRESHOLD for _ in times[:]], color='red')\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), [-ADC_THRESHOLD for _ in times[:]], color='red')\n    ax.axvline(np.percentile(list(map(lambda x: x * 1e-6, times[:])), PRESAMPLE), color='red', linestyle='dotted')\n\n    ps2000.ps2000_stop(device.handle)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_wpwq.py",
    "content": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nSAMPLES = 2000\nOVERSAMPLING = 1\nPRESAMPLE = 80.0\nADC_THRESHOLDS = (6553, 32000)\n\nTHRESHOLD_DIRECTION = {\n    'PS2000_ABOVE': 0,\n    'PS2000_BELOW': 1,\n    'PS2000_ADV_RISING': 2,\n    'PS2000_ADV_FALLING': 3,\n    'PS2000_ADV_RISING_OR_FALLING': 4,\n    'PS2000_INSIDE': 0,\n    'PS2000_OUTSIDE': 1,\n    'PS2000_ENTER': 2,\n    'PS2000_EXIT': 3,\n    'PS2000_ENTER_OR_EXIT': 4,\n    'PS2000_ADV_NONE': 2,\n}\n\n\nclass TriggerConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n        ('pulseWidthQualifier', c_int32),\n    ]\n\n\nclass PwqConditions(Structure):\n    _fields_ = [\n        ('channelA', c_int32),\n        ('channelB', c_int32),\n        ('channelC', c_int32),\n        ('channelD', c_int32),\n        ('external', c_int32),\n    ]\n\n\nclass TriggerChannelProperties(Structure):\n    _fields_ = [\n        (\"thresholdMajor\", c_int16),\n        (\"thresholdMinor\", c_int16),\n        (\"hysteresis\", c_uint16),\n        (\"channel\", c_int16),\n        (\"thresholdMode\", c_int16),\n    ]\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        SAMPLES,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_conditions = TriggerConditions(0, 0, 0, 0, 0, 1)\n\n    res = ps2000.ps2000SetAdvTriggerChannelConditions(device.handle, byref(trigger_conditions), 1)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerDelay(device.handle, 0, -PRESAMPLE)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000SetAdvTriggerChannelDirections(\n        device.handle,\n        THRESHOLD_DIRECTION['PS2000_ENTER'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE'],\n        THRESHOLD_DIRECTION['PS2000_ADV_NONE']\n    )\n    assert_pico2000_ok(res)\n\n    trigger_properties = TriggerChannelProperties(\n        max(ADC_THRESHOLDS),\n        min(ADC_THRESHOLDS),\n        328,\n        ps2000.PS2000_CHANNEL['PS2000_CHANNEL_A'],\n        picoEnum.PICO_THRESHOLD_MODE['PICO_WINDOW']\n    )\n\n    res = ps2000.ps2000SetAdvTriggerChannelProperties(device.handle, byref(trigger_properties), 1, 0)\n    assert_pico2000_ok(res)\n\n    pwq_conditions = PwqConditions(1, 0, 0, 0, 0)\n\n    res = ps2000.ps2000SetPulseWidthQualifier(\n        device.handle,\n        byref(pwq_conditions),\n        1,\n        THRESHOLD_DIRECTION['PS2000_ENTER'],\n        195,\n        0,\n        picoEnum.PICO_PULSE_WIDTH_TYPE['PICO_PW_TYPE_GREATER_THAN']\n    )\n    assert_pico2000_ok(res)\n\n    timebase_a, interval = get_timebase(device, 20_000)\n\n    collection_time = c_int32()\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('ADC counts')\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        None,\n        None,\n        None,\n        None,\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), buffer_a[:])\n    for threshold in ADC_THRESHOLDS:\n        ax.plot(list(map(lambda x: x * 1e-6, times[:])), [threshold for _ in times[:]], color='red')\n\n    ax.axvline(np.percentile(list(map(lambda x: x * 1e-6, times[:])), PRESAMPLE), color='red', linestyle='dotted')\n\n    ps2000.ps2000_stop(device.handle)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/block_read.py",
    "content": "from ctypes import byref, c_byte, c_int16, c_int32, sizeof\nfrom time import sleep\n\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\n\nSAMPLES = 2000\nOVERSAMPLING = 1\n\n\ndef get_timebase(device, wanted_time_interval):\n    current_timebase = 1\n\n    old_time_interval = None\n    time_interval = c_int32(0)\n    time_units = c_int16()\n    max_samples = c_int32()\n\n    while ps2000.ps2000_get_timebase(\n        device.handle,\n        current_timebase,\n        2000,\n        byref(time_interval),\n        byref(time_units),\n        1,\n        byref(max_samples)) == 0 \\\n        or time_interval.value < wanted_time_interval:\n\n        current_timebase += 1\n        old_time_interval = time_interval.value\n\n        if current_timebase.bit_length() > sizeof(c_int16) * 8:\n            raise Exception('No appropriate timebase was identifiable')\n\n    return current_timebase - 1, old_time_interval\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_500MV'],\n    )\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_B'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'],\n    )\n    assert_pico2000_ok(res)\n\n    timebase_a, interval = get_timebase(device, 4_000)\n\n    collection_time = c_int32()\n\n    res = ps2000.ps2000_run_block(\n        device.handle,\n        SAMPLES,\n        timebase_a,\n        OVERSAMPLING,\n        byref(collection_time)\n    )\n    assert_pico2000_ok(res)\n\n    while ps2000.ps2000_ready(device.handle) == 0:\n        sleep(0.1)\n\n    times = (c_int32 * SAMPLES)()\n\n    buffer_a = (c_int16 * SAMPLES)()\n    buffer_b = (c_int16 * SAMPLES)()\n\n    overflow = c_byte(0)\n\n    res = ps2000.ps2000_get_times_and_values(\n        device.handle,\n        byref(times),\n        byref(buffer_a),\n        byref(buffer_b),\n        None,\n        None,\n        byref(overflow),\n        2,\n        SAMPLES,\n    )\n    assert_pico2000_ok(res)\n\n    channel_a_overflow = (overflow.value & 0b0000_0001) != 0\n\n    ps2000.ps2000_stop(device.handle)\n\n    channel_a_mv = adc2mV(buffer_a, ps2000.PS2000_VOLTAGE_RANGE['PS2000_500MV'], c_int16(32767))\n    channel_b_mv = adc2mV(buffer_b, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'], c_int16(32767))\n\n    fig, ax = plt.subplots()\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('voltage/mV')\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), channel_a_mv[:])\n    ax.plot(list(map(lambda x: x * 1e-6, times[:])), channel_b_mv[:])\n\n    if channel_a_overflow:\n        ax.text(0.01, 0.01, 'Overflow present', color='red', transform=ax.transAxes)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/device_info.py",
    "content": "from picosdk.ps2000 import ps2000\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n"
  },
  {
    "path": "ps2000Examples/gen_sq_wave.py",
    "content": "import ctypes\nimport numpy as np\n\ndef gen_square(t, duty, low_thres):\n    t, w = np.asarray(t), np.asarray(duty)\n    w = np.asarray(w + (t - t))\n    t = np.asarray(t + (w - w))\n    if t.dtype.char in ['fFdD']:\n        ytype = t.dtype.char\n    else:\n        ytype = 'd'\n\n    y = np.zeros(t.shape, ytype)\n    # width must be between 0 and 1 inclusive\n    mask1 = (w > 1) | (w < 0)\n    np.place(y, mask1, np.nan)\n    # on the interval 0 to duty*2*pi the function is 1\n    tmod = np.mod(t, 2 * np.pi)\n    \n    mask2 = (32767-mask1)&(tmod<w*2*np.pi)\n    np.place(y, mask2, 32767)\n\t\n\t#mask2 = (32767 - mask1) & (tmod < w * 2 * np.pi)\n    #np.place(y, mask2, 32767)\t\n\t\n    # on the interval duty*2*pi to 2*pi function is  (pi*(w+1)-tmod) / (pi*(1-w))\n    mask3 = (1 - mask1) & (1 - mask2)\n    np.place(y, mask3, low_thres)\n    return y"
  },
  {
    "path": "ps2000Examples/ps2000BlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 BLOCK MODE EXAMPLE\n# This example opens a 2000 driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000 import ps2000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico2000_ok\n\n# Create status ready for use\nstatus = {}\n\n# Open 2000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openUnit\"] = ps.ps2000_open_unit()\nassert_pico2000_ok(status[\"openUnit\"])\n\n# Create chandle for use\nchandle = ctypes.c_int16(status[\"openUnit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000_DC = 1\n# range = PS2000_2V = 7\n# analogue offset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps2000_set_channel(chandle, 0, 1, 1, chARange)\nassert_pico2000_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000_DC = 1\n# range = PS2000_2V = 7\n# analogue offset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps2000_set_channel(chandle, 1, 1, 1, chBRange)\nassert_pico2000_ok(status[\"setChB\"])\n\n# Set up single trigger\n# handle = chandle\n# source = PS2000_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS2000_RISING = 0\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps2000_set_trigger(chandle, 0, 64, 0, 0, 1000)\nassert_pico2000_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 1000\npostTriggerSamples = 1000\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# no_of_samples = maxSamples\n# pointer to time_interval = ctypes.byref(timeInterval)\n# pointer to time_units = ctypes.byref(timeUnits)\n# oversample = 1 = oversample\n# pointer to max_samples = ctypes.byref(maxSamplesReturn)\ntimebase = 8\ntimeInterval = ctypes.c_int32()\ntimeUnits = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nmaxSamplesReturn = ctypes.c_int32()\nstatus[\"getTimebase\"] = ps.ps2000_get_timebase(chandle, timebase, maxSamples, ctypes.byref(timeInterval), ctypes.byref(timeUnits), oversample, ctypes.byref(maxSamplesReturn))\nassert_pico2000_ok(status[\"getTimebase\"])\n\n# Run block capture\n# handle = chandle\n# no_of_samples = maxSamples\n# timebase = timebase\n# oversample = oversample\n# pointer to time_indisposed_ms = ctypes.byref(timeIndisposedms)\ntimeIndisposedms = ctypes.c_int32()\nstatus[\"runBlock\"] = ps.ps2000_run_block(chandle, maxSamples, timebase, oversample, ctypes.byref(timeIndisposedms))\nassert_pico2000_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps2000_ready(chandle)\n    ready = ctypes.c_int16(status[\"isReady\"])\n\n# Create buffers ready for data\nbufferA = (ctypes.c_int16 * maxSamples)()\nbufferB = (ctypes.c_int16 * maxSamples)()\n\n# Get data from scope\n# handle = chandle\n# pointer to buffer_a = ctypes.byref(bufferA)\n# pointer to buffer_b = ctypes.byref(bufferB)\n# poiner to overflow = ctypes.byref(oversample)\n# no_of_values = cmaxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\nstatus[\"getValues\"] = ps.ps2000_get_values(chandle, ctypes.byref(bufferA), ctypes.byref(bufferB), None, None, ctypes.byref(oversample), cmaxSamples)\nassert_pico2000_ok(status[\"getValues\"])\n\n# find maximum ADC count value\nmaxADC = ctypes.c_int16(32767)\n\n# convert ADC counts data to mV\nadc2mVChA =  adc2mV(bufferA, chARange, maxADC)\nadc2mVChB =  adc2mV(bufferB, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value -1) * timeInterval.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChA[:])\nplt.plot(time, adc2mVChB[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000_stop(chandle)\nassert_pico2000_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000_close_unit(chandle)\nassert_pico2000_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps2000Examples/ps2000ETSBlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 ETS BLOCK MODE EXAMPLE\n# This example opens a 2000 driver device, sets up two channels and a trigger with ETS mode then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000 import ps2000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico2000_ok\n\n# Create status ready for use\nstatus = {}\n\n# Open 2000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openUnit\"] = ps.ps2000_open_unit()\nassert_pico2000_ok(status[\"openUnit\"])\n\n# Create chandle for use\nchandle = ctypes.c_int16(status[\"openUnit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000_DC = 1\n# range = PS2000_2V = 7\n# analogue offset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps2000_set_channel(chandle, 0, 1, 1, chARange)\nassert_pico2000_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000_DC = 1\n# range = PS2000_2V = 7\n# analogue offset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps2000_set_channel(chandle, 1, 1, 1, chBRange)\nassert_pico2000_ok(status[\"setChB\"])\n\n# Set up single trigger\n# handle = chandle\n# source = PS2000_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS2000_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps2000_set_trigger(chandle, 0, 64, 2, 0, 1000)\nassert_pico2000_ok(status[\"trigger\"])\n\n# Set up ets mode\n# handle = chandle\n# mode = PS2000_ETS_FAST = 1\n# ets_cycles = 5\n# ets_interleave = 5\nstatus[\"setETS\"] = ps.ps2000_set_ets(chandle, 1, 5, 5) \nassert_pico2000_ok(status[\"setETS\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 0\npostTriggerSamples = 500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# no_of_samples = maxSamples\n# pointer to time_interval = ctypes.byref(timeInterval)\n# pointer to time_units = ctypes.byref(timeUnits)\n# oversample = 1 = oversample\n# pointer to max_samples = ctypes.byref(maxSamplesReturn)\ntimebase = 8\ntimeInterval = ctypes.c_int32()\ntimeUnits = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nmaxSamplesReturn = ctypes.c_int32()\nstatus[\"getTimebase\"] = ps.ps2000_get_timebase(chandle, timebase, maxSamples, ctypes.byref(timeInterval), ctypes.byref(timeUnits), oversample, ctypes.byref(maxSamplesReturn))\nassert_pico2000_ok(status[\"getTimebase\"])\n\n# Run block capture\n# handle = chandle\n# no_of_samples = maxSamples\n# timebase = timebase\n# oversample = oversample\n# pointer to time_indisposed_ms = ctypes.byref(timeIndisposedms)\ntimeIndisposedms = ctypes.c_int32()\nstatus[\"runBlock\"] = ps.ps2000_run_block(chandle, maxSamples, timebase, oversample, ctypes.byref(timeIndisposedms))\nassert_pico2000_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps2000_ready(chandle)\n    ready = ctypes.c_int16(status[\"isReady\"])\n\n# Create buffers ready for data\ntimes = (ctypes.c_int16 * maxSamples)()\nbufferA = (ctypes.c_int16 * maxSamples)()\nbufferB = (ctypes.c_int16 * maxSamples)()\noverflow = ctypes.c_int16(0)\n\n\n# Get data from scope\n# handle = chandle\n# pointer to times = ctypes.byref(times)\n# pointer to buffer_a = ctypes.byref(bufferA)\n# pointer to buffer_b = ctypes.byref(bufferB)\n# pointer to buffer c = None\n# pointer to buffer d = None\n# poiner to overflow = ctypes.byref(overflow)\n# time_units = timeUnits.value\n# no_of_values = cmaxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\nstatus[\"getValues\"] = ps.ps2000_get_times_and_values(chandle, ctypes.byref(times), ctypes.byref(bufferA), ctypes.byref(bufferB), None, None, ctypes.byref(overflow), timeUnits.value, cmaxSamples)\nassert_pico2000_ok(status[\"getValues\"])\n\n# find maximum ADC count value\nmaxADC = ctypes.c_int16(32767)\n\n# convert ADC counts data to mV\nadc2mVChA =  adc2mV(bufferA, chARange, maxADC)\nadc2mVChB =  adc2mV(bufferB, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value -1) * timeInterval.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChA[:])\nplt.plot(time, adc2mVChB[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000_stop(chandle)\nassert_pico2000_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000_close_unit(chandle)\nassert_pico2000_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps2000Examples/ps2000SigGen.py",
    "content": "import ctypes\nimport numpy as np\nfrom time import sleep\nimport math\n\nfrom picosdk.ps2000 import ps2000 as ps\nfrom picosdk.functions import assert_pico2000_ok, adc2mV\nfrom picosdk.PicoDeviceEnums import picoEnum\n\nimport matplotlib.pyplot as plt\n\nimport gen_sq_wave as square\nimport os\n\n# Create status ready for use\nstatus = {}\n\n# Open 2000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openUnit\"] = ps.ps2000_open_unit()\nassert_pico2000_ok(status[\"openUnit\"])\n# Create chandle for use\nchandle = ctypes.c_int16(status[\"openUnit\"])\n\nt_sq = np.linspace(0,1,1024)\n# waveform = np.array(waveform)\nwaveform  = square.gen_square(2*np.pi*t_sq, 0.2, 0)\n\n# plot AWG waveform to output\nplt.plot(waveform[:])\nprint(\"Plotting waveform to output...\")\nplt.show()\n# Once user closes the plot Window the waveform will be output enabled\n\n# change the datatype to ctypes.c_uint8\narbitraryWaveform = waveform.astype('uint8')\narbitraryWaveformSize = ctypes.c_int32(len(waveform))\nWaveformSize = len(waveform)\n\nfrequecy = 1000 # Hz\nprint(\"Frquency is \", frequecy)\n\n# Code to calulate FrequencyToPhase for 2000 series AWG\n# deltaPhase=((f*s)/maxBuffer)*phaseAcc*(1/ddsFreq)\n# phase =((f*s)/4096)*(32^2)*(1/48000000)\nphaseCal = ((frequecy*WaveformSize)/4096)*math.pow(2,32)*(1/48000000)\nprint(\"Which converts to AWG Phase value of \", phaseCal)\n#Cast float value to interger\nphase = ctypes.c_uint32(int(phaseCal))\n\narbitraryWaveformPointer = arbitraryWaveform.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8))\n\nprint(\"AWG buffer_length is \", arbitraryWaveformSize)\npkToPk = ctypes.c_uint32(1500000)\noffsetVoltage = ctypes.c_int32(0)\nsweeps = ctypes.c_uint32(0)\nstartDeltaPhase = phase\nstopDeltaPhase = phase  # when frequency sweep is not required set it equal to startDeltaPhase\ndeltaPhaseIncrement = ctypes.c_uint32(0)  # when frequency sweep is not required set it to 0\ndwellCount = ctypes.c_uint32(0) # when frequency sweep isn't required set it equal to 0\n# PS2000_SWEEP_TYPE\n#  PS2000_UP 0\n#  PS2000_DOWN 1\n#  PS2000_UPDOWN 2\n#  PS2000_DOWNUP 3\nsweepType = 0 #ctypes.c_unt32(0)\n\nprint(\"Output AWG waveform\")\nstatus[\"ps2000_set_sig_gen_arbitrary\"] = ps.ps2000_set_sig_gen_arbitrary(chandle, offsetVoltage,\n                                                                                pkToPk,\n                                                                                startDeltaPhase,\n                                                                                stopDeltaPhase,\n                                                                                deltaPhaseIncrement,\n                                                                                dwellCount,\n                                                                                arbitraryWaveformPointer,\n                                                                                arbitraryWaveformSize,\n                                                                                sweepType,\n                                                                                sweeps)\nassert_pico2000_ok(status[\"ps2000_set_sig_gen_arbitrary\"])\n\n\nprint(\"Delay for 10 seconds...\")\nsleep(10)\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000_close_unit(chandle)\nassert_pico2000_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n\n\n\n"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode.py",
    "content": "from ctypes import POINTER, c_int16, c_uint32\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok\nfrom picosdk.PicoDeviceEnums import picoEnum\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\n\nimport time\n\nCALLBACK = C_CALLBACK_FUNCTION_FACTORY(\n    None,\n    POINTER(POINTER(c_int16)),\n    c_int16,\n    c_uint32,\n    c_int16,\n    c_int16,\n    c_uint32\n)\n\nadc_values = []\n\n\ndef get_overview_buffers(buffers, _overflow, _triggered_at, _triggered, _auto_stop, n_values):\n    adc_values.extend(buffers[0][0:n_values])\n\n\ncallback = CALLBACK(get_overview_buffers)\n\n\ndef adc_to_mv(values, range_, bitness=16):\n    v_ranges = [10, 20, 50, 100, 200, 500, 1_000, 2_000, 5_000, 10_000, 20_000]\n\n    return [(x * v_ranges[range_]) / (2**(bitness - 1) - 1) for x in values]\n\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n\n    res = ps2000.ps2000_set_channel(\n        device.handle,\n        picoEnum.PICO_CHANNEL['PICO_CHANNEL_A'],\n        True,\n        picoEnum.PICO_COUPLING['PICO_DC'],\n        ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'],\n    )\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000_run_streaming_ns(\n        device.handle,\n        500,\n        2,\n        100_000,\n        False,\n        1,\n        50_000\n    )\n    assert_pico2000_ok(res)\n\n    start_time = time.time_ns()\n\n    while time.time_ns() - start_time < 60_000_000:\n        ps2000.ps2000_get_streaming_last_values(\n            device.handle,\n            callback\n        )\n\n    end_time = time.time_ns()\n\n    ps2000.ps2000_stop(device.handle)\n\n    mv_values = adc_to_mv(adc_values, ps2000.PS2000_VOLTAGE_RANGE['PS2000_50MV'])\n\n    fig, ax = plt.subplots()\n\n    ax.set_xlabel('time/ms')\n    ax.set_ylabel('voltage/mV')\n    ax.plot(np.linspace(0, (end_time - start_time) * 1e-6, len(mv_values)), mv_values)\n\n    plt.show()\n"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode_gathering.py",
    "content": "from time import time_ns\nfrom ctypes import POINTER, c_int16, c_uint32\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\n\nfrom enum import IntEnum\n\n\nclass Channel(IntEnum):\n    PS2000_CHANNEL_A = 0\n    PS2000_CHANNEL_B = 1\n\n\nclass PotentialRange(IntEnum):\n    PS2000_10MV = 0\n    PS2000_20MV = 1\n    PS2000_50MV = 2\n    PS2000_100MV = 3\n    PS2000_200MV = 4\n    PS2000_500MV = 5\n    PS2000_1V = 6\n    PS2000_2V = 7\n    PS2000_5V = 8\n    PS2000_10V = 9\n    PS2000_20V = 10\n\n\nclass TimeUnit(IntEnum):\n    FEMTOSECOND = 0\n    PICOSECOND = 1\n    NANOSECOND = 2\n    MICROSECOND = 3\n    MILLISECOND = 4\n    SECOND = 5\n\n\nCALLBACK = C_CALLBACK_FUNCTION_FACTORY(None, POINTER(POINTER(c_int16)), c_int16, c_uint32, c_int16, c_int16, c_uint32)\n\n\n# reimplement this because the other one only takes ctypes\ndef adc_to_mv(values, range_, bitness=16):\n    v_ranges = [10, 20, 50, 100, 200, 500, 1_000, 2_000, 5_000, 10_000, 20_000]\n\n    return [(x * v_ranges[range_]) / (2**(bitness - 1) - 1) for x in values]\n\n\ndef determine_time_unit(interval_ns):\n    unit = 0\n    units = ['ns', 'us', 'ms', 's']\n\n    while interval_ns > 5_000:\n        interval_ns /= 1000\n        unit += 1\n\n    return interval_ns, units[unit]\n\n\nclass StreamingDevice:\n    def __init__(self, gather_values, potential_range=PotentialRange.PS2000_50MV):\n        self.device = ps2000.open_unit()\n        self.potential_range = potential_range\n\n        self.gather_values = gather_values\n\n        res = ps2000.ps2000_set_channel(self.device.handle, Channel.PS2000_CHANNEL_A, True, True, potential_range)\n        assert_pico2000_ok(res)\n\n        # start 'fast-streaming' mode\n        res = ps2000.ps2000_run_streaming_ns(\n            self.device.handle,\n            500,\n            TimeUnit.NANOSECOND,\n            100_000,\n            False,\n            1,\n            50_000\n        )\n        assert_pico2000_ok(res)\n\n        self.start_time = time_ns()\n        self.end_time = time_ns()\n\n    def close(self):\n        ps2000.ps2000_stop(self.device.handle)\n        self.device.close()\n\n    def gather(self):\n        adc_values = []\n\n        def get_overview_buffers(buffers, _overflow, _triggered_at, _triggered, _auto_stop, n_values):\n            adc_values.extend(buffers[0][0:n_values])\n\n        callback = CALLBACK(get_overview_buffers)\n\n        while len(adc_values) < self.gather_values:\n            ps2000.ps2000_get_streaming_last_values(\n                self.device.handle,\n                callback\n            )\n\n        self.end_time = time_ns()\n\n        return adc_to_mv(adc_values, self.potential_range)\n\n\nstream = StreamingDevice(6_000_000)\nvalues = stream.gather()\nstream.close()\n\nprint('Values gathered: {}'.format(len(values)))\n\nfig, ax = plt.subplots()\ninterval, units = determine_time_unit(stream.end_time - stream.start_time)\n\nax.set_xlabel('time/{}'.format(units))\nax.set_ylabel('voltage/mV')\nax.plot(np.linspace(0, interval, len(values)), values)\n\nplt.show()\n"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode_polling.py",
    "content": "import asyncio\nimport concurrent.futures\nimport functools\n\nfrom ctypes import POINTER, c_int16, c_uint32\n\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\n\nfrom enum import IntEnum\n\n\nclass Channel(IntEnum):\n    PS2000_CHANNEL_A = 0\n    PS2000_CHANNEL_B = 1\n\n\nclass PotentialRange(IntEnum):\n    PS2000_20MV = 1\n    PS2000_50MV = 2\n    PS2000_100MV = 3\n    PS2000_200MV = 4\n    PS2000_500MV = 5\n    PS2000_1V = 6\n    PS2000_2V = 7\n    PS2000_5V = 8\n    PS2000_10V = 9\n    PS2000_20V = 10\n\n\nCALLBACK = C_CALLBACK_FUNCTION_FACTORY(None, POINTER(POINTER(c_int16)), c_int16, c_uint32, c_int16, c_int16, c_uint32)\n\n\n# reimplement this because the other one only takes ctypes\ndef adc_to_mv(values, range_, bitness=16):\n    v_ranges = [10, 20, 50, 100, 200, 500, 1_000, 2_000, 5_000, 10_000, 20_000]\n\n    return [(x * v_ranges[range_]) / (2**(bitness - 1) - 1) for x in values]\n\n\nclass StreamingDevice:\n    def __init__(self, potential_range=PotentialRange.PS2000_50MV):\n        self.device = ps2000.open_unit()\n        self.potential_range = potential_range\n        # create an event loop\n        self.loop = asyncio.new_event_loop()\n        # create a thread-pool executor\n        self.executor = concurrent.futures.ThreadPoolExecutor()\n\n        self.waiting_blocks = {}\n\n        res = ps2000.ps2000_set_channel(self.device.handle, Channel.PS2000_CHANNEL_A, True, True, potential_range)\n        assert_pico2000_ok(res)\n\n        # start 'fast-streaming' mode\n        res = ps2000.ps2000_run_streaming_ns(\n            self.device.handle,\n            100,\n            3,\n            30_000,\n            False,\n            1,\n            15_000\n        )\n        assert_pico2000_ok(res)\n\n    async def process_value(self, mv_value):\n        # overload\n        pass\n\n    def get_streamed_values(self, block_id):\n        def get_overview_buffers(buffers, _overflow, _triggered_at, _triggered, _auto_stop, n_values):\n            adc_values = buffers[0][0:n_values]\n\n            mv_values = adc_to_mv(adc_values, self.potential_range)\n\n            self.waiting_blocks[block_id] = mv_values\n\n        callback = CALLBACK(get_overview_buffers)\n\n        res = ps2000.ps2000_get_streaming_last_values(\n            self.device.handle,\n            callback\n        )\n        assert_pico2000_ok(res)\n\n    def start(self):\n        async def gather_values():\n            block_id = 0\n            while True:\n                await asyncio.sleep(0.5)\n\n                await self.loop.run_in_executor(self.executor, functools.partial(self.get_streamed_values, block_id))\n\n                block_id += 1\n\n        async def poll_waiting():\n            next_block = 0\n            while True:\n                if block := self.waiting_blocks.get(next_block):\n                    next_block += 1\n                    for n in block:\n                        await self.process_value(n)\n\n                await asyncio.sleep(0.25)\n\n        try:\n            self.loop.create_task(gather_values())\n            self.loop.run_until_complete(poll_waiting())\n        finally:\n            self.loop.close()\n            ps2000.ps2000_stop(self.device.handle)\n            ps2000.ps2000_close(self.device.handle)\n\n\nstream = StreamingDevice()\nstream.start()\n"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode_threaded.py",
    "content": "from ctypes import POINTER, c_int16, c_uint32\n\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pico2000_ok\nfrom picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY\n\nfrom enum import IntEnum\nfrom concurrent.futures import ThreadPoolExecutor\n\nimport functools\nimport time\nimport os\n\nCALLBACK = C_CALLBACK_FUNCTION_FACTORY(None, POINTER(POINTER(c_int16)), c_int16, c_uint32, c_int16, c_int16, c_uint32)\n\nTHREADPOOL = ThreadPoolExecutor()\n\npast_mv_values = []\n\nterm_width = os.get_terminal_size()\n\n\ndef process_values(adc_values):\n    mv_values = adc_to_mv(adc_values, PotentialRange.PS2000_50MV)\n\n    for value in mv_values:\n        pre = (value + 500) / 500 * term_width\n        print('{}|'.format(' ' * pre))\n\n    past_mv_values.extend(mv_values)\n\n\ndef get_overview_buffers(buffers, _overflow, _triggered_at, _triggered, _auto_stop, n_values):\n    adc_values = buffers[0][0:n_values]\n\n    THREADPOOL.submit(functools.partial(process_values, adc_values))\n\n\ncallback = CALLBACK(get_overview_buffers)\n\n\ndef adc_to_mv(values, range_, bitness=16):\n    v_ranges = [10, 20, 50, 100, 200, 500, 1_000, 2_000, 5_000, 10_000, 20_000]\n\n    return [(x * v_ranges[range_]) / (2**(bitness - 1) - 1) for x in values]\n\n\nclass Channel(IntEnum):\n    PS2000_CHANNEL_A = 0\n    PS2000_CHANNEL_B = 1\n\n\nclass PotentialRange(IntEnum):\n    PS2000_20MV = 1\n    PS2000_50MV = 2\n    PS2000_100MV = 3\n    PS2000_200MV = 4\n    PS2000_500MV = 5\n    PS2000_1V = 6\n    PS2000_2V = 7\n    PS2000_5V = 8\n    PS2000_10V = 9\n    PS2000_20V = 10\n\n\nwith ps2000.open_unit() as device:\n    res = ps2000.ps2000_set_channel(device.handle, Channel.PS2000_CHANNEL_A, True, True, PotentialRange.PS2000_50MV)\n    assert_pico2000_ok(res)\n\n    res = ps2000.ps2000_run_streaming_ns(\n        device.handle,\n        500,\n        2,\n        100_000,\n        False,\n        1,\n        50_000\n    )\n    assert_pico2000_ok(res)\n\n    target_samples = 1_000_000\n\n    while True:\n        ps2000.ps2000_get_streaming_last_values(\n            device.handle,\n            callback\n        )\n\n        time.sleep(0.01)\n"
  },
  {
    "path": "ps2000aExamples/ps2000aBlockAdvancedEdgeExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000A BLOCK MODE EXAMPLE\n# This example opens a 2000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000a import ps2000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 2000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps2000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps2000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up advanced edge trigger\nadcTriggerLevel = mV2adc(500, chARange, maxADC)\nhysteresisPercentage = 0.05\n\nconditions = ps.PS2000A_TRIGGER_CONDITION(ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_TRUE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"],\n                                            ps.PS2000A_TRIGGER_STATE[\"PS2000A_CONDITION_DONT_CARE\"])\nstatus[\"setConditions\"] = ps.ps2000aSetTriggerChannelConditions(chandle, ctypes.byref(conditions), 1)\nassert_pico_ok(status[\"setConditions\"])\n\nproperties = ps.PS2000A_TRIGGER_CHANNEL_PROPERTIES(adcTriggerLevel,\n                                                   (adcTriggerLevel * hysteresisPercentage),\n                                                   (adcTriggerLevel * -1),\n                                                   (adcTriggerLevel * hysteresisPercentage),\n                                                   ps.PS2000A_CHANNEL[\"PS2000A_CHANNEL_A\"],\n                                                   ps.PS2000A_THRESHOLD_MODE[\"PS2000A_LEVEL\"])\n\nstatus[\"setProperties\"] = ps.ps2000aSetTriggerChannelProperties(chandle, ctypes.byref(properties),1,0,1000)\nassert_pico_ok(status[\"setProperties\"])\n\nstatus[\"setDirections\"] = ps.ps2000aSetTriggerChannelDirections(chandle, ps.PS2000A_THRESHOLD_DIRECTION[\"PS2000A_RISING\"],\n                                                                        ps.PS2000A_THRESHOLD_DIRECTION[\"PS2000A_NONE\"],\n                                                                        ps.PS2000A_THRESHOLD_DIRECTION[\"PS2000A_NONE\"], \n                                                                        ps.PS2000A_THRESHOLD_DIRECTION[\"PS2000A_NONE\"], \n                                                                        ps.PS2000A_THRESHOLD_DIRECTION[\"PS2000A_NONE\"], \n                                                                        ps.PS2000A_THRESHOLD_DIRECTION[\"PS2000A_NONE\"])\nassert_pico_ok(status[\"setDirections\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = totalSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# pointer to totalSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(0)\nstatus[\"getTimebase2\"] = ps.ps2000aGetTimebase2(chandle,\n                                                timebase,\n                                                totalSamples,\n                                                ctypes.byref(timeIntervalns),\n                                                oversample,\n                                                ctypes.byref(returnedMaxSamples),\n                                                0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# oversample = 0 = oversample\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps2000aIsReady rather than ps2000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps2000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        oversample,\n                                        None,\n                                        0,\n                                        None,\n                                        None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps2000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps2000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * totalSamples)()\nbufferAMin = (ctypes.c_int16 * totalSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * totalSamples)()\nbufferBMin = (ctypes.c_int16 * totalSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS2000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferDPort0Max)\n# pointer to buffer min = ctypes.byref(bufferDPort0Min)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     0,\n                                                     ctypes.byref(bufferAMax),\n                                                     ctypes.byref(bufferAMin),\n                                                     totalSamples,\n                                                     0,\n                                                     0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS2000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     1,\n                                                     ctypes.byref(bufferBMax),\n                                                     ctypes.byref(bufferBMin),\n                                                     totalSamples,\n                                                     0,\n                                                     0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Create overflow location\noverflow = ctypes.c_int16()\n# create converted type totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cTotalSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS2000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps2000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps2000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, ((cTotalSamples.value)-1) * timeIntervalns.value, cTotalSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps2000aExamples/ps2000aBlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000A BLOCK MODE EXAMPLE\n# This example opens a 2000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000a import ps2000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 2000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps2000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps2000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\n# source = PS2000A_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS2000A_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps2000aSetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = totalSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# pointer to totalSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(0)\nstatus[\"getTimebase2\"] = ps.ps2000aGetTimebase2(chandle,\n                                                timebase,\n                                                totalSamples,\n                                                ctypes.byref(timeIntervalns),\n                                                oversample,\n                                                ctypes.byref(returnedMaxSamples),\n                                                0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# oversample = 0 = oversample\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps2000aIsReady rather than ps2000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps2000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        oversample,\n                                        None,\n                                        0,\n                                        None,\n                                        None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps2000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps2000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * totalSamples)()\nbufferAMin = (ctypes.c_int16 * totalSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * totalSamples)()\nbufferBMin = (ctypes.c_int16 * totalSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS2000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferDPort0Max)\n# pointer to buffer min = ctypes.byref(bufferDPort0Min)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     0,\n                                                     ctypes.byref(bufferAMax),\n                                                     ctypes.byref(bufferAMin),\n                                                     totalSamples,\n                                                     0,\n                                                     0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS2000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     1,\n                                                     ctypes.byref(bufferBMax),\n                                                     ctypes.byref(bufferBMin),\n                                                     totalSamples,\n                                                     0,\n                                                     0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Create overflow location\noverflow = ctypes.c_int16()\n# create converted type totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cTotalSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS2000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps2000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps2000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, ((cTotalSamples.value)-1) * timeIntervalns.value, cTotalSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps2000aExamples/ps2000aBlockExampleCallbackMethod.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000A BLOCK MODE EXAMPLE\n# This example opens a 2000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000a import ps2000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 2000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps2000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps2000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\n# source = PS2000A_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS2000A_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps2000aSetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = totalSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# pointer to totalSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(0)\nstatus[\"getTimebase2\"] = ps.ps2000aGetTimebase2(chandle,\n                                                timebase,\n                                                totalSamples,\n                                                ctypes.byref(timeIntervalns),\n                                                oversample,\n                                                ctypes.byref(returnedMaxSamples),\n                                                0)\nassert_pico_ok(status[\"getTimebase2\"])\n\nwasCalledBack = False\n\ndef blockready_callback(handle, statusCode, param):\n    global wasCalledBack\n    wasCalledBack = True\n    \ncFuncPtr = ps.BlockReadyType(blockready_callback)\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# oversample = 0 = oversample\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps2000aIsReady rather than ps2000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps2000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        oversample,\n                                        None,\n                                        0,\n                                        cFuncPtr,\n                                        None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish and callback\nwhile wasCalledBack == False:\n    time.sleep(0.01)\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * totalSamples)()\nbufferAMin = (ctypes.c_int16 * totalSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * totalSamples)()\nbufferBMin = (ctypes.c_int16 * totalSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS2000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferDPort0Max)\n# pointer to buffer min = ctypes.byref(bufferDPort0Min)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     0,\n                                                     ctypes.byref(bufferAMax),\n                                                     ctypes.byref(bufferAMin),\n                                                     totalSamples,\n                                                     0,\n                                                     0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS2000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     1,\n                                                     ctypes.byref(bufferBMax),\n                                                     ctypes.byref(bufferBMin),\n                                                     totalSamples,\n                                                     0,\n                                                     0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Create overflow location\noverflow = ctypes.c_int16()\n# create converted type totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cTotalSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS2000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps2000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps2000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, ((cTotalSamples.value)-1) * timeIntervalns.value, cTotalSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps2000aExamples/ps2000aMSOBlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 2000 Series (A API) MSO Block Mode Example\n# This example demonstrates how to use the PicoScope 2000 Series (ps2000a) driver API functions in order to do the\n# following:\n#\n# Open a connection to a PicoScope 2000 Series MSO device\n# Setup input analog channels and a digital port\n# Setup a trigger on a digital channel\n# Collect a block of data\n# Plot data\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000a import ps2000a as ps, PS2000A_TRIGGER_CONDITIONS, PS2000A_DIGITAL_CHANNEL_DIRECTIONS\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, splitMSODataFast, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open a connection to a PicoScope 2000 Series device\n# Returns handle to chandle for use in future API functions\nstatus[\"openUnit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openUnit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\n\nchannelA = ps.PS2000A_CHANNEL['PS2000A_CHANNEL_A']\nchAEnabled = 1\nchACoupling = ps.PS2000A_COUPLING['PS2000A_DC']\nchARange = ps.PS2000A_RANGE['PS2000A_2V']\nchAAnalogOffset = 0\n\nstatus[\"setChA\"] = ps.ps2000aSetChannel(chandle,\n                                        channelA,\n                                        chAEnabled,\n                                        chACoupling,\n                                        chARange,\n                                        chAAnalogOffset)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\n\nchannelB = ps.PS2000A_CHANNEL['PS2000A_CHANNEL_B']\nchBEnabled = 1\nchBCoupling = ps.PS2000A_COUPLING['PS2000A_DC']\nchBRange = ps.PS2000A_RANGE['PS2000A_2V']\nchBAnalogOffset = 0\n\nstatus[\"setChB\"] = ps.ps2000aSetChannel(chandle,\n                                        channelB,\n                                        chBEnabled,\n                                        chBCoupling,\n                                        chBRange,\n                                        chBAnalogOffset)\nassert_pico_ok(status[\"setChB\"])\n\n# Set Digital Port 0\n# handle = chandle\n# port = PS2000A_DIGITAL_PORT0 = 0x80\n# enabled = 1\n# logicLevel = 9754 (1.5 V)\n\ndPort0 = ps.PS2000A_DIGITAL_PORT.get(\"PS2000A_DIGITAL_PORT0\")\nstatus[\"setDigitalPort0\"] = ps.ps2000aSetDigitalPort(chandle, dPort0, 1, 9754)\nassert_pico_ok(status[\"setDigitalPort0\"])\n\n# Set up trigger on digital channel\n# Device will trigger when there is a transition from low to high on digital channel 0\n\n# Set trigger conditions\n# handle = chandle\n# Trigger conditions:\n# channelA            = PS2000A_CONDITION_DONT_CARE = 0\n# channelB            = PS2000A_CONDITION_DONT_CARE = 0\n# channelC            = PS2000A_CONDITION_DONT_CARE = 0\n# channelD            = PS2000A_CONDITION_DONT_CARE = 0\n# external            = PS2000A_CONDITION_DONT_CARE = 0\n# aux                 = PS2000A_CONDITION_DONT_CARE = 0\n# pulseWidthQualifier = PS2000A_CONDITION_DONT_CARE = 0\n# digital             = PS2000A_CONDITION_TRUE = 1\n# nConditions = 1\n\ndont_care = ps.PS2000A_TRIGGER_STATE['PS2000A_CONDITION_DONT_CARE']\ntrigger_true = ps.PS2000A_TRIGGER_STATE['PS2000A_CONDITION_TRUE']\nnConditions = 1\n\ntriggerConditions = PS2000A_TRIGGER_CONDITIONS(dont_care,\n                                               dont_care,\n                                               dont_care,\n                                               dont_care,\n                                               dont_care,\n                                               dont_care,\n                                               dont_care,\n                                               trigger_true)\n\nstatus[\"setTriggerChannelConditions\"] = ps.ps2000aSetTriggerChannelConditions(chandle,\n                                                                              ctypes.byref(triggerConditions),\n                                                                              nConditions)\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\n\n# Set digital trigger directions\n\n# handle = chandle\n# Digital directions\n# channel = PS2000A_DIGITAL_CHANNEL_0 = 0\n# direction = PS2000A_DIGITAL_DIRECTION_RISING = 3\n# nDirections = 1\n\ndigitalChannel = ps.PS2000A_DIGITAL_CHANNEL['PS2000A_DIGITAL_CHANNEL_0']\ndigiTriggerDirection = ps.PS2000A_DIGITAL_DIRECTION['PS2000A_DIGITAL_DIRECTION_RISING']\n\ndigitalDirections = PS2000A_DIGITAL_CHANNEL_DIRECTIONS(digitalChannel, digiTriggerDirection)\nnDigitalDirections = 1\n\nstatus[\"setTriggerDigitalPortProperties\"] = ps.ps2000aSetTriggerDigitalPortProperties(chandle,\n                                                                                      ctypes.byref(digitalDirections),\n                                                                                      nDigitalDirections)\nassert_pico_ok(status[\"setTriggerDigitalPortProperties\"])\n\n# Set number of pre- and post-trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 1252 = 10000 ns = timebase (see Programmer's guide for more information on timebases)\n# noSamples = totalSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# pointer to totalSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 1252\ntimeIntervalNs = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(0)\n\n# Query this function in a loop in case the timebase index selected is invalid.\n\nstatus[\"getTimebase2\"] = ps.PICO_STATUS['PICO_INVALID_TIMEBASE']\n\nwhile status[\"getTimebase2\"] == ps.PICO_STATUS['PICO_INVALID_TIMEBASE']:\n\n    status[\"getTimebase2\"] = ps.ps2000aGetTimebase2(chandle,\n                                                    timebase,\n                                                    totalSamples,\n                                                    ctypes.byref(timeIntervalNs),\n                                                    oversample,\n                                                    ctypes.byref(returnedMaxSamples),\n                                                    0)\n\n    if status[\"getTimebase2\"] == ps.PICO_STATUS['PICO_OK']:\n        break\n    else:\n\n        timebase = timebase + 1\n\nassert_pico_ok(status[\"getTimebase2\"])\n\nprint \"Starting data collection - waiting for trigger on channel D0...\"\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 1252 = 10000 ns = timebase (see Programmer's guide for mre information on timebases)\n# oversample = 0\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps2000aIsReady() rather than ps2000aBlockReady())\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps2000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        oversample,\n                                        None,\n                                        0,\n                                        None,\n                                        None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps2000aIsReady()\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\n\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps2000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferA = (ctypes.c_int16 * totalSamples)()\nbufferB = (ctypes.c_int16 * totalSamples)()\nbufferDPort0 = (ctypes.c_int16 * totalSamples)()\n\nratio_mode_none = ps.PS2000A_RATIO_MODE['PS2000A_RATIO_MODE_NONE']\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS2000A_CHANNEL_A = 0\n# pointer to buffer = ctypes.byref(bufferA)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBufferA\"] = ps.ps2000aSetDataBuffer(chandle,\n                                                   channelA,\n                                                   ctypes.byref(bufferA),\n                                                   totalSamples,\n                                                   0,\n                                                   ratio_mode_none)\nassert_pico_ok(status[\"setDataBufferA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS2000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferB)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBufferB\"] = ps.ps2000aSetDataBuffer(chandle,\n                                                   channelB,\n                                                   ctypes.byref(bufferB),\n                                                   totalSamples,\n                                                   0,\n                                                   ratio_mode_none)\nassert_pico_ok(status[\"setDataBufferB\"])\n\n# Set data buffer location for data collection from digital port 0\n# handle = chandle\n# source = PS2000A_DIGITAL_PORT0 = 0x80\n# pointer to buffer max = ctypes.byref(bufferB)\n# buffer length = totalSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBufferDPort0\"] = ps.ps2000aSetDataBuffer(chandle,\n                                                        dPort0,\n                                                        ctypes.byref(bufferDPort0),\n                                                        totalSamples,\n                                                        0,\n                                                        ratio_mode_none)\nassert_pico_ok(status[\"setDataBufferDPort0\"])\n\n# create overflow location\noverflow = ctypes.c_int16()\n# create converted type totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cTotalSamples)\n# downsample ratio = 1\n# downsample ratio mode = PS2000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps2000aGetValues(chandle,\n                                          0,\n                                          ctypes.byref(cTotalSamples),\n                                          0,\n                                          1,\n                                          ratio_mode_none,\n                                          ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\nprint \"Data collection complete.\"\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps2000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Convert ADC counts data to millivolts\nadc2mVChA = adc2mV(bufferA, chARange, maxADC)\nadc2mVChB = adc2mV(bufferB, chBRange, maxADC)\n\n# Obtain binary for Digital Port 0\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\ndPort0BinaryData = splitMSODataFast(cTotalSamples, bufferDPort0)\n\n# Create time data\ntime = np.linspace(0, (cTotalSamples.value - 1) * timeIntervalNs.value, cTotalSamples.value)\n\n# Plot data from channels A, B and D0\n\nprint \"Plotting data...\"\n\nfig, axs = plt.subplots(2, 1, constrained_layout=True)\naxs[0].plot(time, adc2mVChA[:], time, adc2mVChB[:])\naxs[0].set_title('Analog data acquisition')\naxs[0].set_xlabel('Time (ns)')\naxs[0].set_ylabel('Voltage (mV)')\naxs[0].legend(('Ch. A', 'Ch. B'), loc=\"upper right\")\n\naxs[1].plot(time, dPort0BinaryData[7], label='D0')  # D0 is the last array in the tuple.\naxs[1].set_title('Digital data acquisition')\naxs[1].set_xlabel('Time (ns)')\naxs[1].set_ylabel('Logic Level')\naxs[1].legend(loc=\"upper right\")\n\nfig.canvas.set_window_title('PicoScope 2000 Series (A API) MSO Block Capture Example')\nplt.show()\n\nprint \"Close figure to stop the device and close the connection.\"\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close the connection to the device\n# handle = chandle\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps2000aExamples/ps2000aRapidBlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps2000a RAPID BLOCK MODE EXAMPLE\n# This example opens a 3000a driver device, sets up one channel and a trigger then collects 10 block of data in rapid succession.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps2000a import ps2000a as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = ps2000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = ps2000a_DC = 1\n# range = ps2000a_10V = 9\n# analogue offset = 0 V\nchARange = 9\nstatus[\"setChA\"] = ps.ps2000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Sets up single trigger\n# andle = chandle\n# Enable = 1\n# Source = ps2000a_channel_A = 0\n# Threshold = 1024 ADC counts\n# Direction = ps2000a_Falling = 3\n# Delay = 0\n# autoTrigger_ms = 1000\nstatus[\"trigger\"] = ps.ps2000aSetSimpleTrigger(chandle, 1, 0, 1024, 3, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 400\npostTriggerSamples = 400\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# Timebase = 2 = timebase\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 2\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps2000aGetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Handle = Chandle\n# nSegments = 10\n# nMaxSamples = ctypes.byref(cmaxSamples)\n\nstatus[\"MemorySegments\"] = ps.ps2000aMemorySegments(chandle, 10, ctypes.byref(cmaxSamples))\nassert_pico_ok(status[\"MemorySegments\"])\n\n# sets number of captures\nstatus[\"SetNoOfCaptures\"] = ps.ps2000aSetNoOfCaptures(chandle, 10)\nassert_pico_ok(status[\"SetNoOfCaptures\"])\n\n# Starts the block capture\n# handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps2000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 1, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\nbufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax1 = (ctypes.c_int16 * maxsamples)()\nbufferAMin1 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 1\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), maxsamples, 1, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax2 = (ctypes.c_int16 * maxsamples)()\nbufferAMin2 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 2\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), maxsamples, 2, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax3 = (ctypes.c_int16 * maxsamples)()\nbufferAMin3 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 3\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), maxsamples, 3, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax4 = (ctypes.c_int16 * maxsamples)()\nbufferAMin4 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 4\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), maxsamples, 4, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax5 = (ctypes.c_int16 * maxsamples)()\nbufferAMin5 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 5\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), maxsamples, 5, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax6 = (ctypes.c_int16 * maxsamples)()\nbufferAMin6 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 6\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), maxsamples, 6, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax7 = (ctypes.c_int16 * maxsamples)()\nbufferAMin7 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 7\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), maxsamples, 7, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax8 = (ctypes.c_int16 * maxsamples)()\nbufferAMin8 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 8\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), maxsamples, 8, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax9 = (ctypes.c_int16 * maxsamples)()\nbufferAMin9 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# handle = chandle\n# source = ps2000a_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 9\n# Ratio mode = ps2000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps2000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), maxsamples, 9, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps2000aIsReady(chandle, ctypes.byref(ready))\n\n# handle = chandle\n# noOfSamples = ctypes.byref(cmaxSamples)\n# fromSegmentIndex = 0\n# ToSegmentIndex = 9\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValuesBulk\"] = ps.ps2000aGetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValuesBulk\"])\n\n# handle = chandle\n# Times = Times = (ctypes.c_int16*10)() = ctypes.byref(Times)\n# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)\n# Fromsegmentindex = 0\n# Tosegementindex = 9\nTimes = (ctypes.c_int16*10)()\nTimeUnits = ctypes.c_char()\nstatus[\"GetValuesTriggerTimeOffsetBulk\"] = ps.ps2000aGetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)\nassert_pico_ok(status[\"GetValuesTriggerTimeOffsetBulk\"])\n\n# Finds the max ADC count\n# handle = chandle\n# Value = ctype.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps2000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Converts ADC from channel A to mV\nadc2mVChAMax = adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChAMax1 = adc2mV(bufferAMax1, chARange, maxADC)\nadc2mVChAMax2 = adc2mV(bufferAMax2, chARange, maxADC)\nadc2mVChAMax3 = adc2mV(bufferAMax3, chARange, maxADC)\nadc2mVChAMax4 = adc2mV(bufferAMax4, chARange, maxADC)\nadc2mVChAMax5 = adc2mV(bufferAMax5, chARange, maxADC)\nadc2mVChAMax6 = adc2mV(bufferAMax6, chARange, maxADC)\nadc2mVChAMax7 = adc2mV(bufferAMax7, chARange, maxADC)\nadc2mVChAMax8 = adc2mV(bufferAMax8, chARange, maxADC)\nadc2mVChAMax9 = adc2mV(bufferAMax9, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChAMax1[:])\nplt.plot(time, adc2mVChAMax2[:])\nplt.plot(time, adc2mVChAMax3[:])\nplt.plot(time, adc2mVChAMax4[:])\nplt.plot(time, adc2mVChAMax5[:])\nplt.plot(time, adc2mVChAMax6[:])\nplt.plot(time, adc2mVChAMax7[:])\nplt.plot(time, adc2mVChAMax8[:])\nplt.plot(time, adc2mVChAMax9[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps2000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\nprint(status)\n\n"
  },
  {
    "path": "ps2000aExamples/ps2000aSigGen.py",
    "content": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 2000 (A API) Series Signal Generator Example\r\n# This example demonstrates how to use the PicoScope 2000 Series (ps2000a) driver API functions to set up the signal generator to do the following:\r\n# \r\n# 1. Output a sine wave \r\n# 2. Output a square wave \r\n# 3. Output a sweep of a square wave signal\r\n\r\nimport ctypes\r\nfrom picosdk.ps2000a import ps2000a as ps\r\nimport time\r\nfrom picosdk.functions import assert_pico_ok\r\nimport numpy as np\r\nimport math\r\n\r\n\r\n\r\n\r\n# Gives the device a handle\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Opens the device/s\r\nstatus[\"openunit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\r\n\r\ntry:\r\n    assert_pico_ok(status[\"openunit\"])\r\nexcept:\r\n    # powerstate becomes the status number of openunit\r\n    powerstate = status[\"openunit\"]\r\n\r\n    # If powerstate is the same as 282 then it will run this if statement\r\n    if powerstate == 282:\r\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\r\n        status[\"ChangePowerSource\"] = ps.ps2000aChangePowerSource(chandle, 282)\r\n    # If the powerstate is the same as 286 then it will run this if statement\r\n    elif powerstate == 286:\r\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\r\n        status[\"ChangePowerSource\"] = ps.ps2000aChangePowerSource(chandle, 286)\r\n    else:\r\n        raise\r\n\r\n    assert_pico_ok(status[\"ChangePowerSource\"])\r\n\r\n# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(0) = PS2000A_SINE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS2000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS2000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS2000A_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(0)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps2000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS2000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS2000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS2000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS2000A_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(1)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps2000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output square wave with an up-down sweep, ranging from 10-100 kHz in 5 kHz increments every 1 second.\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS2000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 100 kHz\r\n# increment = 5 kHz\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS2000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS2000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS2000A_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(1)\r\nsweepType = ctypes.c_int32(2)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps2000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 100000, 5000, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(36)\r\n\r\n#max and min values and lengths\r\nminValue = ctypes.c_int16(0)\r\nmaxValue = ctypes.c_int16(0)\r\nminSize = ctypes.c_int16(0)\r\nmaxSize = ctypes.c_int16(0)\r\nstatus[\"sigGenArbMinMaxValues\"] = ps.ps2000aSigGenArbitraryMinMaxValues(chandle, ctypes.byref(minValue), ctypes.byref(maxValue), ctypes.byref(minSize),ctypes.byref(maxSize))\r\nassert_pico_ok(status[\"sigGenArbMinMaxValues\"])\r\na=maxValue\r\n\r\n# create a custom waveform\r\nawgBuffer = np.sin(np.linspace(0,2*math.pi,1024))\r\nawgbufferPointer = awgBuffer.ctypes.data_as(ctypes.POINTER(ctypes.c_int16))\r\n\r\nphase = ctypes.c_uint32(0)\r\n\r\nstatus[\"freq2phase\"] = ps.ps2000aSigGenFrequencyToPhase(chandle, 100, 0, 1024, ctypes.byref(phase))\r\nassert_pico_ok(status[\"freq2phase\"])\r\n\r\n# output custom waveform with peak-to-peak of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# startDeltaPhase = phase\r\n# stopDeltaPhase = phase\r\n# deltaPhaseIncrement = 0\r\n# dwellCount = 0\r\n# *arbitaryWaveform = awgbufferPointer\r\n# arbitaryWaveformSize = 1024\r\n# sweepType = ctypes.c_int32(1) = PS5000A_UP\r\n# operation = 0\r\n# indexMode = 0 = PS2000A_SINGLE\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\n\r\nstatus[\"setSigGenArbitrary\"] = ps.ps2000aSetSigGenArbitrary(chandle, 0, 2000000, phase, phase, 0, 0, awgbufferPointer, 1024, 0, 0, 0, 0, 0, 0, 0, 0)\r\nassert_pico_ok(status[\"setSigGenArbitrary\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(36)\r\n\r\n# output a custom binary sequence from the AWG \r\n# create a binary buffer for AWG\r\n# this buffer can be replaced with whatever binary sequence is wanted to be outputted\r\n# any 1s should use the a variable which is equal to the maximum value for the awg buffer\r\nbinaryBuffer = [0,a,a,a,0,0,a,a,0,0,0,0,a,a,a,a,a,a,a,a,0,0,a,a,0]  \r\ncBinaryBuffer = (ctypes.c_int16*len(binaryBuffer))(*binaryBuffer)\r\nbinarybufferPointer = ctypes.byref(cBinaryBuffer)\r\n\r\nphase2 = ctypes.c_uint32(0)\r\n\r\n# get the phase for 100 kHz \r\nstatus[\"freq2phase\"] = ps.ps2000aSigGenFrequencyToPhase(chandle, 100, 0, len(cBinaryBuffer), ctypes.byref(phase2))\r\nassert_pico_ok(status[\"freq2phase\"])\r\n\r\n\r\n# output custom waveform with peak-to-peak of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# startDeltaPhase = phase2\r\n# stopDeltaPhase = phase2\r\n# deltaPhaseIncrement = 0\r\n# dwellCount = 0\r\n# *arbitaryWaveform = binarybufferPointer\r\n# arbitaryWaveformSize = len(binarybufferPointer) \r\n# sweepType = ctypes.c_int32(1) = PS5000A_UP\r\n# operation = 0\r\n# indexMode = 0 = PS2000A_SINGLE\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\n\r\nstatus[\"setSigGenArbitrary\"] = ps.ps2000aSetSigGenArbitrary(chandle, 0, 2000000, phase2, phase2, 0, 0, binarybufferPointer, len(cBinaryBuffer), 0, 0, 0, 0, 0, 0, 0, 0)\r\nassert_pico_ok(status[\"setSigGenArbitrary\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(36)\r\n\r\n# Closes the unit\r\n# Handle = chandle\r\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Displays the status returns\r\nprint(status)"
  },
  {
    "path": "ps2000aExamples/ps2000aStreamingExample.py",
    "content": "#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 Series (A API) STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps2000a driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps2000a import ps2000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 2000 Series device\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n\nenabled = 1\ndisabled = 0\nanalogue_offset = 0.0\n\n# Set up channel A\n# handle = chandle\n# channel = PS2000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nchannel_range = ps.PS2000A_RANGE['PS2000A_2V']\nstatus[\"setChA\"] = ps.ps2000aSetChannel(chandle,\n                                        ps.PS2000A_CHANNEL['PS2000A_CHANNEL_A'],\n                                        enabled,\n                                        ps.PS2000A_COUPLING['PS2000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS2000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS2000A_DC = 1\n# range = PS2000A_2V = 7\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps2000aSetChannel(chandle,\n                                        ps.PS2000A_CHANNEL['PS2000A_CHANNEL_B'],\n                                        enabled,\n                                        ps.PS2000A_COUPLING['PS2000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 500\nnumBuffersToCapture = 10\n\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\nmemory_segment = 0\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS2000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     ps.PS2000A_CHANNEL['PS2000A_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS2000A_RATIO_MODE['PS2000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS2000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS2000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps2000aSetDataBuffers(chandle,\n                                                     ps.PS2000A_CHANNEL['PS2000A_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS2000A_RATIO_MODE['PS2000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(250)\nsampleUnits = ps.PS2000A_TIME_UNITS['PS2000A_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps2000aRunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                ps.PS2000A_RATIO_MODE['PS2000A_RATIO_MODE_NONE'],\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps2000aGetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps2000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples-1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps2000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps2000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)\n"
  },
  {
    "path": "ps3000EExamples/ps3000EBlockExample.py",
    "content": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PSOSPA BLOCK MODE EXAMPLE\r\n# This example opens a psospa driver device, sets up two channels and a trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.psospa import psospa as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as structs\r\n# from picosdk.PicoConnectProbes import picoConnectProbes as probes\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mVV2, mV2adcV2, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open a psospa driver device\r\n# returns handle for future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openUnit\"] = ps.psospaOpenUnit(ctypes.byref(chandle), None, resolution, None)\r\nassert_pico_ok(status[\"openUnit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC\"]\r\nrangeMax = 2000000000 #nV\r\nrangeMin = -rangeMax #nV\r\nrangeType = 0 #probes.PICO_PROBE_RANGE_INFO[\"PICO_PROBE_NONE_NV\"]\r\nanalogueOffset = 0\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.psospaSetChannelOn(chandle, channelA, coupling, rangeMin, rangeMax, rangeType, analogueOffset, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\n# set channel B-H off\r\nfor x in range (1, 3, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.psospaSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.psospaGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.psospaSetSimpleTrigger(chandle, 1, source, mV2adcV2(100,rangeMax,maxADC), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# Get fastest available timebase\r\n# handle = chandle\r\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\r\ntimebase = ctypes.c_uint32(0)\r\ntimeInterval = ctypes.c_double(0)\r\n# resolution = resolution\r\nstatus[\"getMinimumTimebaseStateless\"] = ps.psospaGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"s\")\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataBuffers\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffers\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.psospaRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using psospaIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.psospaIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.psospaGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n\r\n\r\n# # convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mVV2(bufferAMax, rangeMax, maxADC)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.plot(time, bufferAMax[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Close the psospa driver device\r\nstatus[\"closeUnit\"] = ps.psospaCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeUnit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps3000EExamples/ps3000ERapidBlockExample.py",
    "content": "#\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PSOSPA RAPID BLOCK MODE EXAMPLE\n# This example opens a psospa driver device, sets up two channels and a trigger then collects 10 blocks of data in rapid block mode.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.psospa import psospa as ps\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\nfrom picosdk.PicoDeviceStructs import picoStruct as structs\n# from picosdk.PicoConnectProbes import picoConnectProbes as probes\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mVV2, assert_pico_ok, mV2adcV2\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open a psospa driver device\n# returns handle for future API functions\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\nstatus[\"openUnit\"] = ps.psospaOpenUnit(ctypes.byref(chandle), None, resolution, None)\nassert_pico_ok(status[\"openUnit\"])\n\n# Set channel A on\n# handle = chandle\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\ncoupling = enums.PICO_COUPLING[\"PICO_DC\"]\nrangeMax = 2000000000 #nV\nrangeMin = -rangeMax #nV\nrangeType = 0 #probes.PICO_PROBE_RANGE_INFO[\"PICO_PROBE_NONE_NV\"]\nanalogueOffset = 0\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\nstatus[\"setChannelA\"] = ps.psospaSetChannelOn(chandle, channelA, coupling, rangeMin, rangeMax, rangeType, analogueOffset, bandwidth)\nassert_pico_ok(status[\"setChannelA\"])\n\nfor x in range (1, 3, 1):\n    channel = x\n    status[\"setChannel\",x] = ps.psospaSetChannelOff(chandle,channel)\n    assert_pico_ok(status[\"setChannel\",x])\n\n# get max ADC value\n# handle = chandle\nminADC = ctypes.c_int16()\nmaxADC = ctypes.c_int16()\nstatus[\"getAdcLimits\"] = ps.psospaGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\nassert_pico_ok(status[\"getAdcLimits\"])\n\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\n# handle = chandle\n# enable = 1\nsource = channelA\n# threshold = 100 mV\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\n# delay = 0 s\n# autoTriggerMicroSeconds = 1000000 us\nstatus[\"setSimpleTrigger\"] = ps.psospaSetSimpleTrigger(chandle, 1, source, mV2adcV2(100,rangeMax,maxADC), direction, 0, 1000000)\nassert_pico_ok(status[\"setSimpleTrigger\"])\n\n# Get fastest available timebase\n# handle = chandle\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\ntimebase = ctypes.c_uint32(0)\ntimeInterval = ctypes.c_double(0)\n# resolution = resolution\nstatus[\"getMinimumTimebaseStateless\"] = ps.psospaGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\nprint(\"timebase = \", timebase.value)\nprint(\"sample interval =\", timeInterval.value, \"s\")\n\n# Set number of samples to be collected\nnoOfPreTriggerSamples = 500000\nnoOfPostTriggerSamples = 1000000\nnSamples = (noOfPostTriggerSamples + noOfPreTriggerSamples)\n\n# Set number of memory segments\nnoOfCaptures = 20\nmaxSegments = ctypes.c_uint64(10)\nstatus[\"memorySegments\"] = ps.psospaMemorySegments(chandle, noOfCaptures, ctypes.byref(maxSegments))\nassert_pico_ok(status[\"memorySegments\"])\n\n# Set number of captures\nstatus[\"setNoOfCaptures\"] = ps.psospaSetNoOfCaptures(chandle, noOfCaptures)\nassert_pico_ok(status[\"setNoOfCaptures\"])\n\n# Create buffers\nbufferAMax = (ctypes.c_int16 * nSamples)()\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax1 = (ctypes.c_int16 * nSamples)()\nbufferAMin1 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax2 = (ctypes.c_int16 * nSamples)()\nbufferAMin2 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax3 = (ctypes.c_int16 * nSamples)()\nbufferAMin3 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax4 = (ctypes.c_int16 * nSamples)()\nbufferAMin4 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax5 = (ctypes.c_int16 * nSamples)()\nbufferAMin5 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax6 = (ctypes.c_int16 * nSamples)()\nbufferAMin6 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax7 = (ctypes.c_int16 * nSamples)()\nbufferAMin7 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax8 = (ctypes.c_int16 * nSamples)()\nbufferAMin8 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\nbufferAMax9 = (ctypes.c_int16 * nSamples)()\nbufferAMin9 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffers\n# handle = chandle\n# channel = channelA\n# bufferMax = bufferAMax\n# bufferMin = bufferAMin\n# nSamples = nSamples\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\nwaveform = 0\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \nstatus[\"setDataBuffers\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\nassert_pico_ok(status[\"setDataBuffers\"])\nwaveform1 = 1\nstatus[\"setDataBuffers1\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), nSamples, dataType, waveform1, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers1\"])\nwaveform2 = 2\nstatus[\"setDataBuffers2\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), nSamples, dataType, waveform2, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers2\"])\nwaveform3 = 3\nstatus[\"setDataBuffers3\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), nSamples, dataType, waveform3, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers3\"])\nwaveform4 = 4\nstatus[\"setDataBuffers4\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), nSamples, dataType, waveform4, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers4\"])\nwaveform5 = 5\nstatus[\"setDataBuffers5\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), nSamples, dataType, waveform5, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers5\"])\nwaveform6 = 6\nstatus[\"setDataBuffers6\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), nSamples, dataType, waveform6, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers6\"])\nwaveform7 = 7\nstatus[\"setDataBuffers7\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), nSamples, dataType, waveform7, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers7\"])\nwaveform8 = 8\nstatus[\"setDataBuffers8\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), nSamples, dataType, waveform8, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers8\"])\nwaveform9 = 9\nstatus[\"setDataBuffers9\"] = ps.psospaSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), nSamples, dataType, waveform9, downSampleMode, add)\nassert_pico_ok(status[\"setDataBuffers9\"])\n\n# Run block capture\n# handle = chandle\n# timebase = timebase\ntimeIndisposedMs = ctypes.c_double(0)\n# segmentIndex = 0\n# lpReady = None   Using IsReady rather than a callback\n# pParameter = None\nstatus[\"runBlock\"] = ps.psospaRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using psospaIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.psospaIsReady(chandle, ctypes.byref(ready))\n    \n# Get data from scope\n# handle = chandle\n# startIndex = 0\nnoOfSamples = ctypes.c_uint64(nSamples)\n# downSampleRatio = 1\n# segmentIndex = 0\n# Creates a overflow location for each segment\noverflow = (ctypes.c_int16 * 10)()\nstatus[\"getValues\"] = ps.psospaGetValuesBulk(chandle, 0, ctypes.byref(noOfSamples),0, 9, 1, downSampleMode, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mVV2(bufferAMax, rangeMax, maxADC)\nadc2mVChAMax1 =  adc2mVV2(bufferAMax1, rangeMax, maxADC)\nadc2mVChAMax2 =  adc2mVV2(bufferAMax2, rangeMax, maxADC)\nadc2mVChAMax3 =  adc2mVV2(bufferAMax3, rangeMax, maxADC)\nadc2mVChAMax4 =  adc2mVV2(bufferAMax4, rangeMax, maxADC)\nadc2mVChAMax5 =  adc2mVV2(bufferAMax5, rangeMax, maxADC)\nadc2mVChAMax6 =  adc2mVV2(bufferAMax6, rangeMax, maxADC)\nadc2mVChAMax7 =  adc2mVV2(bufferAMax7, rangeMax, maxADC)\nadc2mVChAMax8 =  adc2mVV2(bufferAMax8, rangeMax, maxADC)\nadc2mVChAMax9 =  adc2mVV2(bufferAMax9, rangeMax, maxADC)\n\n# Create time data\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChAMax1[:])\nplt.plot(time, adc2mVChAMax2[:])\nplt.plot(time, adc2mVChAMax3[:])\nplt.plot(time, adc2mVChAMax4[:])\nplt.plot(time, adc2mVChAMax5[:])\nplt.plot(time, adc2mVChAMax6[:])\nplt.plot(time, adc2mVChAMax7[:])\nplt.plot(time, adc2mVChAMax8[:])\nplt.plot(time, adc2mVChAMax9[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Close the scope\nstatus[\"closeunit\"] = ps.psospaCloseUnit(chandle)\nassert_pico_ok(status[\"closeunit\"])\n\nprint(status)"
  },
  {
    "path": "ps3000EExamples/ps3000EStreamingModeExample.py",
    "content": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PSOSPA STREAMING MODE EXAMPLE\r\n# This example opens a psospa driver device, sets up two channels then collects a streamed set of data.\r\n# The data from channel A is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.psospa import psospa as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as structs\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mVV2, assert_pico_ok, mV2adcV2\r\nfrom picosdk.constants import PICO_STATUS\r\nimport time\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open a psospa driver device\r\n# returns handle for future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openUnit\"] = ps.psospaOpenUnit(ctypes.byref(chandle), None, resolution, None)\r\nassert_pico_ok(status[\"openUnit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC\"]\r\nrangeMax = 2000000000 #nV\r\nrangeMin = -rangeMax #nV\r\nrangeType = 0 #probes.PICO_PROBE_RANGE_INFO[\"PICO_PROBE_NONE_NV\"]\r\nanalogueOffset = 0\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.psospaSetChannelOn(chandle, channelA, coupling, rangeMin, rangeMax, rangeType, analogueOffset, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\nchannelB = enums.PICO_CHANNEL[\"PICO_CHANNEL_B\"]\r\nstatus[\"setChannelB\"] = ps.psospaSetChannelOn(chandle, channelB, coupling, rangeMin, rangeMax, rangeType, analogueOffset, bandwidth)\r\nassert_pico_ok(status[\"setChannelB\"])\r\n\r\n# set channel C-D off\r\nfor x in range(2, 3, 1):\r\n    channel = x\r\n    status[\"setChannel\", x] = ps.psospaSetChannelOff(chandle, channel)\r\n    assert_pico_ok(status[\"setChannel\", x])\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 100000\r\nnoOfPostTriggerSamples = 900000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.psospaGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.psospaSetSimpleTrigger(chandle, 1, source, (mV2adcV2(100,rangeMax,maxADC)), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# create buffers\r\nmaxBuffers = 10\r\n\r\nbufferA = ((ctypes.c_int16 * nSamples) * 10)()\r\nbufferB = ((ctypes.c_int16 * nSamples) * 10)()\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear | add  # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]\r\nactionAdd = add\r\nstatus[\"setDataBuffersA\"] = ps.psospaSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[0]), nSamples, dataType,\r\n                                                   waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffersA\"])\r\nstatus[\"setDataBuffersB\"] = ps.psospaSetDataBuffer(chandle, channelB, ctypes.byref(bufferB[0]), nSamples, dataType,\r\n                                                   waveform, downSampleMode, actionAdd)\r\nassert_pico_ok(status[\"setDataBuffersB\"])\r\n\r\n# Run streaming\r\nsampleInterval = ctypes.c_double(1)\r\nsampleIntervalTimeUnits = enums.PICO_TIME_UNITS[\"PICO_US\"]\r\nautoStop = 0\r\ndownSampleRatio = 1\r\n\r\nstatus[\"runStreaming\"] = ps.psospaRunStreaming(chandle, ctypes.byref(sampleInterval), sampleIntervalTimeUnits,\r\n                                                noOfPreTriggerSamples, noOfPostTriggerSamples, autoStop,\r\n                                                downSampleRatio, downSampleMode)\r\nassert_pico_ok(status[\"runStreaming\"])\r\n\r\nstreamData = (structs.PICO_STREAMING_DATA_INFO * 2)()\r\nstreamData[0] = structs.PICO_STREAMING_DATA_INFO(channelA, downSampleMode, dataType, 0, 0, 0, 0)\r\nstreamData[1] = structs.PICO_STREAMING_DATA_INFO(channelB, downSampleMode, dataType, 0, 0, 0, 0)\r\n\r\nstreamTrigger = structs.PICO_STREAMING_DATA_TRIGGER_INFO(0, 0, 0)\r\n\r\ncount = 0\r\n\r\npicoOk = PICO_STATUS[\"PICO_OK\"]\r\n\r\ncollectedSamples = 0\r\n\r\nwhile collectedSamples < (maxBuffers*nSamples):\r\n\r\n    status[\"getStreamingLatestValues\"] = ps.psospaGetStreamingLatestValues(chandle, ctypes.byref(streamData), 1,\r\n                                                                            ctypes.byref(streamTrigger))\r\n\r\n    if status[\"getStreamingLatestValues\"] == picoOk:\r\n        # do nothing\r\n        time.sleep(0.01)\r\n    else:\r\n        count = count + 1\r\n        if count < maxBuffers:\r\n            status[\"setDataBufferA\"] = ps.psospaSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[count]),\r\n                                                              nSamples, dataType, waveform, downSampleMode, actionAdd)\r\n            assert_pico_ok(status[\"setDataBufferA\"])\r\n            status[\"setDataBufferB\"] = ps.psospaSetDataBuffer(chandle, channelB, ctypes.byref(bufferB[count]),\r\n                                                              nSamples, dataType, waveform, downSampleMode, actionAdd)\r\n            assert_pico_ok(status[\"setDataBufferB\"])\r\n            print(count)\r\n            \r\n    collectedSamples = collectedSamples + streamData[0].noOfSamples\r\n\r\n# stop scope streaming\r\nstatus[\"stop\"] = ps.psospaStop(chandle)\r\nassert_pico_ok(status[\"stop\"])\r\n\r\n# get total number of streamed data points\r\nnoOfStreamedSamples=ctypes.c_uint64()\r\nstatus[\"noOfStreamedSamples\"] = ps.psospaNoOfStreamingValues(chandle, ctypes.byref(noOfStreamedSamples))\r\nassert_pico_ok(status[\"noOfStreamedSamples\"])\r\n\r\nprint(\"streaming finished\")\r\nprint(\"Number of samples collected during streaming\")\r\nprint(noOfStreamedSamples.value)\r\n\r\n\r\n# convert ADC counts data to mV\r\nbufferAmV = []\r\nfor k in range (0, maxBuffers, 1):\r\n    mvValues =  adc2mVV2(bufferA[k], rangeMax, maxADC)\r\n    bufferAmV.append(mvValues)\r\n\r\ntime = np.linspace(0, ((nSamples -1)*maxBuffers) * sampleInterval.value * 1000000, (nSamples*maxBuffers))\r\nstartTime = 0\r\nendTime = nSamples\r\n# plot data\r\nfor h in range (0, maxBuffers, 1):\r\n    plt.plot(time[startTime:endTime],bufferAmV[h])\r\n    startTime += nSamples\r\n    endTime += nSamples\r\nplt.xlabel('Time (us)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.psospaCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)\r\n"
  },
  {
    "path": "ps3000aExamples/ps3000aBlockAdvancedTriggerExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000A BLOCK MODE EXAMPLE\n# This example opens a 3000a driver device, sets up one channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps3000a import ps3000a as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, mV2adc, assert_pico_ok\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    # powerstate becomes the status number of openunit\n    powerstate = status[\"openunit\"]\n\n    # If powerstate is the same as 282 then it will run this if statement\n    if powerstate == 282:\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 282)\n        # If the powerstate is the same as 286 then it will run this if statement\n    elif powerstate == 286:\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 286)\n    else:\n        raise\n\n    assert_pico_ok(status[\"ChangePowerSource\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS3000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS3000A_DC = 1\n# range = PS3000A_5V = 8\n# analogue offset = 0 V\nchARange = 8\nstatus[\"setChA\"] = ps.ps3000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Finds the max ADC count\n# Handle = chandle\n# Value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps3000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Set an advanced trigger\nadcTriggerLevel = mV2adc(500, chARange, maxADC)\n\n# set trigger channel properties\n# handle = chandle\nchannelProperties = ps.PS3000A_TRIGGER_CHANNEL_PROPERTIES(adcTriggerLevel,\n                                                          10,\n                                                          adcTriggerLevel,\n                                                          10,\n                                                          ps.PS3000A_CHANNEL[\"PS3000A_CHANNEL_A\"],\n                                                          ps.PS3000A_THRESHOLD_MODE[\"PS3000A_LEVEL\"])\nnChannelProperties = 1\n# auxOutputEnabled = 0\nautoTriggerMilliseconds = 10000\nstatus[\"setTrigProp\"] = ps.ps3000aSetTriggerChannelProperties(chandle, ctypes.byref(channelProperties), nChannelProperties, 0, autoTriggerMilliseconds)\nassert_pico_ok(status[\"setTrigProp\"])\n\n# set trigger conditions V2\n# chandle = handle\nconditions = ps.PS3000A_TRIGGER_CONDITIONS_V2(ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_TRUE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"],\n                                              ps.PS3000A_TRIGGER_STATE[\"PS3000A_CONDITION_DONT_CARE\"])\nnConditions = 1\nstatus[\"setTrigCond\"] = ps.ps3000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(conditions), nConditions)\nassert_pico_ok(status[\"setTrigCond\"])\n\n# set trigger directions\n# handle = chandle\nchannelADirection = ps.PS3000A_THRESHOLD_DIRECTION[\"PS3000A_RISING\"]\nchannelBDirection = ps.PS3000A_THRESHOLD_DIRECTION[\"PS3000A_NONE\"]\nchannelCDirection = ps.PS3000A_THRESHOLD_DIRECTION[\"PS3000A_NONE\"]\nchannelDDirection = ps.PS3000A_THRESHOLD_DIRECTION[\"PS3000A_NONE\"]\nextDirection = ps.PS3000A_THRESHOLD_DIRECTION[\"PS3000A_RISING\"]\nauxDirection = ps.PS3000A_THRESHOLD_DIRECTION[\"PS3000A_NONE\"]\nstatus[\"setTrigDir\"] = ps.ps3000aSetTriggerChannelDirections(chandle, channelADirection, channelBDirection, channelCDirection, channelDDirection, extDirection, auxDirection)\nassert_pico_ok(status[\"setTrigDir\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 00000\npostTriggerSamples = 50000\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\n# Timebase = 2 = timebase\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 2\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps3000aGetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps3000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 1, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\nbufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps3000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# start index = 0\n# noOfSamples = ctypes.byref(cmaxSamples)\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# SegmentIndex = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValues\"] = ps.ps3000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValues\"])\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps3000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps3000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\nprint(status)\n\n"
  },
  {
    "path": "ps3000aExamples/ps3000aBlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000A BLOCK MODE EXAMPLE\n# This example opens a 3000a driver device, sets up one channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps3000a import ps3000a as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    # powerstate becomes the status number of openunit\n    powerstate = status[\"openunit\"]\n\n    # If powerstate is the same as 282 then it will run this if statement\n    if powerstate == 282:\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 282)\n        # If the powerstate is the same as 286 then it will run this if statement\n    elif powerstate == 286:\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 286)\n    else:\n        raise\n\n    assert_pico_ok(status[\"ChangePowerSource\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS3000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS3000A_DC = 1\n# range = PS3000A_10V = 8\n# analogue offset = 0 V\nchARange = 8\nstatus[\"setChA\"] = ps.ps3000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Sets up single trigger\n# Handle = Chandle\n# Source = ps3000A_channel_B = 0\n# Enable = 0\n# Threshold = 1024 ADC counts\n# Direction = ps3000A_Falling = 3\n# Delay = 0\n# autoTrigger_ms = 1000\nstatus[\"trigger\"] = ps.ps3000aSetSimpleTrigger(chandle, 1, 0, 1024, 3, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 40000\npostTriggerSamples = 40000\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\n# Timebase = 2 = timebase\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 2\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps3000aGetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps3000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 1, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\nbufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps3000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# start index = 0\n# noOfSamples = ctypes.byref(cmaxSamples)\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# SegmentIndex = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValues\"] = ps.ps3000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValues\"])\n\n# Finds the max ADC count\n# Handle = chandle\n# Value = ctype.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps3000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps3000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps3000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\nprint(status)\n\n"
  },
  {
    "path": "ps3000aExamples/ps3000aBlockMSOExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 3000 Series (A API) MSO Block Mode Example\n# This example demonstrates how to use the PicoScope 3000 Series (ps3000a) driver API functions in order to do the\n# following:\n#\n# Open a connection to a PicoScope 3000 Series MSO device\n# Setup a digital port\n# Collect a block of data\n# Plot data\n\nimport ctypes\nfrom picosdk.ps3000a import ps3000a as ps\nfrom picosdk.functions import splitMSODataFast, assert_pico_ok\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Gives the device a handle\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)\ndigital_port0 = ps.PS3000A_DIGITAL_PORT[\"PS3000A_DIGITAL_PORT0\"]\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n    # powerstate becomes the status number of openunit\n    powerstate = status[\"openunit\"]\n\n    # If powerstate is the same as 282 then it will run this if statement\n    if powerstate == 282:\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 282)\n    # If the powerstate is the same as 286 then it will run this if statement\n    elif powerstate == 286:\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 286)\n    else:\n        raise\n\n    assert_pico_ok(status[\"ChangePowerSource\"])\n\n# Set up digital port\n# handle = chandle\n# channel = PS3000A_DIGITAL_PORT0 = 0x80\n# enabled = 1\n# logicLevel = 10000\nstatus[\"SetDigitalPort\"] = ps.ps3000aSetDigitalPort( chandle, digital_port0, 1, 10000)\nassert_pico_ok(status[\"SetDigitalPort\"])\n\n# Set the number of sample to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 1252\n# Nosample = totalSamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 1252\ntimeIntervalNs = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps3000aGetTimebase2(chandle,\n                                               timebase,\n                                               totalSamples,\n                                               ctypes.byref(timeIntervalNs),\n                                               1,\n                                               ctypes.byref(returnedMaxSamples),\n                                               0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferDPort0Max = (ctypes.c_int16 * totalSamples)()\nbufferDPort0Min = (ctypes.c_int16 * totalSamples)()\n\n# Set the data buffer location for data collection from PS3000A_DIGITAL_PORT0\n# handle = chandle\n# source = PS3000A_DIGITAL_PORT0 = 0x80\n# Buffer max = ctypes.byref(bufferDPort0Max)\n# Buffer min = ctypes.byref(bufferDPort0Min)\n# Buffer length = totalSamples\n# Segment index = 0\n# Ratio mode = PS3000A_RATIO_MODE_NONE = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle,\n                                                    digital_port0,\n                                                    ctypes.byref(bufferDPort0Max),\n                                                    ctypes.byref(bufferDPort0Min),\n                                                    totalSamples,\n                                                    0,\n                                                    0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\nprint (\"Starting data collection...\")\n\n# Starts the block capture\n# handle = chandle\n# Number of preTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 1252 = 10000 ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps3000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        1,\n                                        None,\n                                        0,\n                                        None,\n                                        None)\nassert_pico_ok(status[\"runblock\"])\n\n# Creates a overflow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\n\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps3000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# start index = 0\n# noOfSamples = ctypes.byref(cTotalSamples)\n# DownSampleRatio = 1\n# DownSampleRatioMode = 0\n# SegmentIndex = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValues\"] = ps.ps3000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 1, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValues\"])\n\nprint (\"Data collection complete.\")\n\n# Obtain binary for Digital Port 0\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\nbufferDPort0 = splitMSODataFast(cTotalSamples, bufferDPort0Max)\n\n# Creates the time data\ntime = np.linspace(0, (cTotalSamples.value - 1) * timeIntervalNs.value, cTotalSamples.value)\n\n# Plot the data from digital channels onto a graph\n\nprint (\"Plotting data...\")\n\nplt.figure(num='PicoScope 3000 Series (A API) MSO Block Capture Example')\nplt.title('Plot of Digital Port 0 digital channels vs. time')\nplt.plot(time, bufferDPort0[0], label='D7')  # D7 is the last array in the tuple.\nplt.plot(time, bufferDPort0[1], label='D6')\nplt.plot(time, bufferDPort0[2], label='D5')\nplt.plot(time, bufferDPort0[3], label='D4')\nplt.plot(time, bufferDPort0[4], label='D3')\nplt.plot(time, bufferDPort0[5], label='D2')\nplt.plot(time, bufferDPort0[6], label='D1')\nplt.plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\nplt.xlabel('Time (ns)')\nplt.ylabel('Logic Level')\nplt.legend(loc=\"upper right\")\nplt.show()\n\nprint (\"Close figure to stop the device and close the connection.\")\n\n# Stops the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps3000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# handle = chandle\nstatus[\"closeUnit\"] = ps.ps3000aCloseUnit(chandle)\nassert_pico_ok(status[\"closeUnit\"])\n\n# Displays the status returns\nprint(status)"
  },
  {
    "path": "ps3000aExamples/ps3000aRapidBlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000A RAPID BLOCK MODE EXAMPLE\n# This example opens a 3000a driver device, sets up one channel and a trigger then collects 10 block of data in rapid succession.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps3000a import ps3000a as ps\nimport numpy as np\nimport matplotlib\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    # powerstate becomes the status number of openunit\n    powerstate = status[\"openunit\"]\n\n    # If powerstate is the same as 282 then it will run this if statement\n    if powerstate == 282:\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 282)\n    # If the powerstate is the same as 286 then it will run this if statement\n    elif powerstate == 286:\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 286)\n    else:\n        raise\n\n    assert_pico_ok(status[\"ChangePowerSource\"])\n\n\n# Set up channel A\n# handle = chandle\n# channel = PS3000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS3000A_DC = 1\n# range = PS3000A_10V = 8\n# analogue offset = 0 V\nchARange = 8\nstatus[\"setChA\"] = ps.ps3000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Sets up single trigger\n# Handle = Chandle\n# Enable = 1\n# Source = ps3000A_channel_A = 0\n# Threshold = 1024 ADC counts\n# Direction = ps3000A_Falling = 3\n# Delay = 0\n# autoTrigger_ms = 1000\nstatus[\"trigger\"] = ps.ps3000aSetSimpleTrigger(chandle, 1, 0, 1024, 3, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 40000\npostTriggerSamples = 40000\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\n# Timebase = 2 = timebase\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 2\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps3000aGetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Handle = Chandle\n# nSegments = 10\n# nMaxSamples = ctypes.byref(cmaxSamples)\n\nstatus[\"MemorySegments\"] = ps.ps3000aMemorySegments(chandle, 10, ctypes.byref(cmaxSamples))\nassert_pico_ok(status[\"MemorySegments\"])\n\n# sets number of captures\nstatus[\"SetNoOfCaptures\"] = ps.ps3000aSetNoOfCaptures(chandle, 10)\nassert_pico_ok(status[\"SetNoOfCaptures\"])\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps3000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 1, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\n#bufferAMax = (ctypes.c_int16 * maxsamples)()\n#bufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\nbufferAMax = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax.ctypes.data, bufferAMin.ctypes.data, maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax1 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin1 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax1)\n# Buffer min = ctypes.byref(bufferAMin1)\n# Buffer length = maxsamples\n# Segment index = 1\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax1.ctypes.data, bufferAMin1.ctypes.data, maxsamples, 1, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax2 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin2 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 2\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax2.ctypes.data, bufferAMin2.ctypes.data, maxsamples, 2, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax3 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin3 =np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 3\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax3.ctypes.data, bufferAMin3.ctypes.data, maxsamples, 3, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax4 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin4 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 4\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax4.ctypes.data, bufferAMin4.ctypes.data, maxsamples, 4, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax5 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin5 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 5\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax5.ctypes.data, bufferAMin5.ctypes.data, maxsamples, 5, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax6 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin6 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 6\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax6.ctypes.data, bufferAMin6.ctypes.data, maxsamples, 6, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax7 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin7 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 7\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax7.ctypes.data, bufferAMin7.ctypes.data, maxsamples, 7, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax8 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin8 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 8\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax8.ctypes.data, bufferAMin8.ctypes.data, maxsamples, 8, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax9 = np.empty(maxsamples, dtype=np.dtype('int16'))\nbufferAMin9 = np.empty(maxsamples, dtype=np.dtype('int16')) # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps3000A_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 9\n# Ratio mode = ps3000A_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps3000aSetDataBuffers(chandle, 0, bufferAMax9.ctypes.data, bufferAMin9.ctypes.data, maxsamples, 9, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps3000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# noOfSamples = ctypes.byref(cmaxSamples)\n# fromSegmentIndex = 0\n# ToSegmentIndex = 9\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValuesBulk\"] = ps.ps3000aGetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, 1, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValuesBulk\"])\n\n# Handle = chandle\n# Times = Times = (ctypes.c_int16*10)() = ctypes.byref(Times)\n# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)\n# Fromsegmentindex = 0\n# Tosegementindex = 9\nTimes = (ctypes.c_int16*10)()\nTimeUnits = ctypes.c_char()\nstatus[\"GetValuesTriggerTimeOffsetBulk\"] = ps.ps3000aGetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)\n\nprint(Times[0:9])\nprint(TimeUnits)\n\n# Finds the max ADC count\n# Handle = chandle\n# Value = ctype.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps3000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChAMax1 =  adc2mV(bufferAMax1, chARange, maxADC)\nadc2mVChAMax2 =  adc2mV(bufferAMax2, chARange, maxADC)\nadc2mVChAMax3 =  adc2mV(bufferAMax3, chARange, maxADC)\nadc2mVChAMax4 =  adc2mV(bufferAMax4, chARange, maxADC)\nadc2mVChAMax5 =  adc2mV(bufferAMax5, chARange, maxADC)\nadc2mVChAMax6 =  adc2mV(bufferAMax6, chARange, maxADC)\nadc2mVChAMax7 =  adc2mV(bufferAMax7, chARange, maxADC)\nadc2mVChAMax8 =  adc2mV(bufferAMax8, chARange, maxADC)\nadc2mVChAMax9 =  adc2mV(bufferAMax9, chARange, maxADC)\nassert_pico_ok(status[\"GetValuesTriggerTimeOffsetBulk\"])\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\n\nplt.plot(time, adc2mVChAMax)\nprint('test')\nplt.plot(time, adc2mVChAMax1)\nplt.plot(time, adc2mVChAMax2)\nplt.plot(time, adc2mVChAMax3)\nplt.plot(time, adc2mVChAMax4)\nplt.plot(time, adc2mVChAMax5)\nplt.plot(time, adc2mVChAMax6)\nplt.plot(time, adc2mVChAMax7)\nplt.plot(time, adc2mVChAMax8)\nplt.plot(time, adc2mVChAMax9)\n\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps3000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps3000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\nprint(status)\n\n"
  },
  {
    "path": "ps3000aExamples/ps3000aSigGen.py",
    "content": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 3000 (A API) Series Signal Generator Example\r\n# This example demonstrates how to use the PicoScope 3000 Series (ps3000a) driver API functions to set up the signal generator to do the following:\r\n# \r\n# 1. Output a sine wave \r\n# 2. Output a square wave \r\n# 3. Output a sweep of a square wave signal\r\n\r\nimport ctypes\r\nfrom picosdk.ps3000a import ps3000a as ps\r\nimport time\r\nfrom picosdk.functions import assert_pico_ok\r\n\r\n\r\n# Gives the device a handle\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Opens the device/s\r\nstatus[\"openunit\"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)\r\n\r\ntry:\r\n    assert_pico_ok(status[\"openunit\"])\r\nexcept:\r\n\r\n    # powerstate becomes the status number of openunit\r\n    powerstate = status[\"openunit\"]\r\n\r\n    # If powerstate is the same as 282 then it will run this if statement\r\n    if powerstate == 282:\r\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\r\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 282)\r\n    # If the powerstate is the same as 286 then it will run this if statement\r\n    elif powerstate == 286:\r\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\r\n        status[\"ChangePowerSource\"] = ps.ps3000aChangePowerSource(chandle, 286)\r\n    else:\r\n        raise\r\n\r\n    assert_pico_ok(status[\"ChangePowerSource\"])\r\n\r\n# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(0) = PS3000A_SINE\r\n# startFrequency = 10000 Hz\r\n# stopFrequency = 10000 Hz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS3000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS3000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = P3000A_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(0)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps3000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS3000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS3000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS3000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = P3000A_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(1)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps3000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with an up-down sweep, 10-100 kHz in 5 kHz increments every 1 second.\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS3000A_Square\r\n# startFrequency = 100 kHz\r\n# stopFrequency = 100 kHz\r\n# increment = 5 kHz\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS3000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS3000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = P3000A_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(1)\r\nsweepType = ctypes.c_int32(2)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps3000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 100000, 5000, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(36)\r\n\r\n# Closes the unit\r\n# Handle = chandle\r\nstatus[\"close\"] = ps.ps3000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Displays the status returns\r\nprint(status)\r\n"
  },
  {
    "path": "ps3000aExamples/ps3000aStreamingExample.py",
    "content": "#\n# Copyright (C) 2018-2020 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000 Series (A API) STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps3000a driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps3000a import ps3000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 5000 Series device\nstatus[\"openunit\"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps3000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps3000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n\nenabled = 1\ndisabled = 0\nanalogue_offset = 0.0\n\n# Set up channel A\n# handle = chandle\n# channel = PS3000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS3000A_DC = 1\n# range = PS3000A_2V = 7\n# analogue offset = 0 V\nchannel_range = ps.PS3000A_RANGE['PS3000A_2V']\nstatus[\"setChA\"] = ps.ps3000aSetChannel(chandle,\n                                        ps.PS3000A_CHANNEL['PS3000A_CHANNEL_A'],\n                                        enabled,\n                                        ps.PS3000A_COUPLING['PS3000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS3000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS3000A_DC = 1\n# range = PS3000A_2V = 7\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps3000aSetChannel(chandle,\n                                        ps.PS3000A_CHANNEL['PS3000A_CHANNEL_B'],\n                                        enabled,\n                                        ps.PS3000A_COUPLING['PS3000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 500\nnumBuffersToCapture = 10\n\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\nmemory_segment = 0\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS3000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS3000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps3000aSetDataBuffers(chandle,\n                                                     ps.PS3000A_CHANNEL['PS3000A_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS3000A_RATIO_MODE['PS3000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS3000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS3000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps3000aSetDataBuffers(chandle,\n                                                     ps.PS3000A_CHANNEL['PS3000A_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS3000A_RATIO_MODE['PS3000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(250)\nsampleUnits = ps.PS3000A_TIME_UNITS['PS3000A_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps3000aRunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                ps.PS3000A_RATIO_MODE['PS3000A_RATIO_MODE_NONE'],\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps3000aGetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps3000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples - 1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps3000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps3000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000Examples/ps4000BlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4000 BLOCK MODE EXAMPLE\n# This example opens a 4000 driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000 import ps4000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000OpenUnit(ctypes.byref(chandle))\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000_DC = 1\n# range = PS4000_2V = 7\nchARange = 7\nstatus[\"setChA\"] = ps.ps4000SetChannel(chandle, 0, 1, 1, chARange)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000_DC = 1\n# range = PS4000_2V = 7\nchBRange = 7\nstatus[\"setChB\"] = ps.ps4000SetChannel(chandle, 1, 1, 1, chBRange)\nassert_pico_ok(status[\"setChB\"])\n\n# setbandwidth filter A\n\nstatus[\"setBW\"] = ps.ps4000SetBwFilter(chandle, 0, 1)\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\n# source = PS4000_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS4000_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps4000SetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000GetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), oversample, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000IsReady rather than ps4000BlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, oversample, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000IsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000IsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\nstatus[\"setDataBuffersA\"] = ps.ps4000SetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\nstatus[\"setDataBuffersB\"] = ps.ps4000SetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000GetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps4000Examples/ps4000StreamingExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4000 Series (A API) STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps4000 driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000 import ps4000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 4000 Series device\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000OpenUnit(ctypes.byref(chandle))\nassert_pico_ok(status[\"openunit\"])\n\n\nenabled = 1\ndisabled = 0\nanalogue_offset = 0.0\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000_DC = 1\n# range = PS4000_2V = 7\nchannel_range = ps.PS4000_RANGE['PS4000_2V']\nstatus[\"setChA\"] = ps.ps4000SetChannel(chandle,\n                                        ps.PS4000_CHANNEL['PS4000_CHANNEL_A'],\n                                        enabled,\n                                        1,\n                                        channel_range)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000_DC = 1\n# range = PS4000_2V = 7\nstatus[\"setChB\"] = ps.ps4000SetChannel(chandle,\n                                        ps.PS4000_CHANNEL['PS4000_CHANNEL_B'],\n                                        enabled,\n                                        1,\n                                        channel_range)\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 500\nnumBuffersToCapture = 10\n\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\nmemory_segment = 0\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS4000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000SetDataBuffers(chandle,\n                                                     ps.PS4000_CHANNEL['PS4000_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS4000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps4000SetDataBuffers(chandle,\n                                                     ps.PS4000_CHANNEL['PS4000_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(250)\nsampleUnits = ps.PS4000_TIME_UNITS['PS4000_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps4000RunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps4000GetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples - 1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4000 Ch4 AND logic triggering.py",
    "content": "import ctypes\nfrom ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV,mV2adc ,assert_pico_ok\nfrom picosdk.errors import PicoSDKCtypesError\nimport time\n\nnChannels = 4\n# Level triggers are limited to any 4 channels by the driver/device! ie (Above/Below \"THRESHOLD_DIRECTION\")\n# Use edge trigger for 5 Channels or more (Rising/falling \"THRESHOLD_DIRECTION\")\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\nmaxADC = ctypes.c_int16(0) # (32767)\nstatus[\"MaximumValue\"] = ps.ps4000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"MaximumValue\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\n##################chARange = 7\n#channel = ctypes.c_int32()\nchRange = ctypes.c_int32()\n#chARange = 7\n#ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"]\nchRange = ps.PICO_CONNECT_PROBE_RANGE[\"PICO_X1_PROBE_2V\"] # pico_x1_probe_2v (see ps4000a.py)\nfor channel in range(nChannels):   \n    status[\"setCh\"] = ps.ps4000aSetChannel(chandle, ctypes.c_int32(channel), ctypes.c_int16(1), ps.PS4000A_COUPLING[\"PS4000A_DC\"], chRange, ctypes.c_float(0))\n    assert_pico_ok(status[\"setCh\"])\n\n# Trigger CONDITIONS ####################################\nclear = ps.PS4000A_CONDITIONS_INFO[\"PS4000A_CLEAR\"]\nadd = ps.PS4000A_CONDITIONS_INFO[\"PS4000A_ADD\"] \naction = clear|add\n\nconditions = (ps.PS4000A_CONDITION * nChannels)()  # Array for each channel condition\nnConditions = nChannels\n\n######## LOOP #\nfor channel in range(nChannels):\n    conditions[channel].source = ctypes.c_int32(channel)\n    conditions[channel].condition = ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"]\n\nstatus[\"setTriggerChannelConditions\"] = ps.ps4000aSetTriggerChannelConditions(\nchandle,\nctypes.byref(conditions),   # Pass the array by reference\nctypes.c_int16(nConditions), # Pass the length of the array\naction                       # Pass the conditions info ##### USE (CLEAR | ADD) on frist call\n)\n#print(\"Channel is \", channel)\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\n###############\n\n# Trigger DIRECTIONS ####################################\ndirections = (ps.PS4000A_DIRECTION * nChannels)()  # Array for directions (ALL CHANNELS)\nnDirections = len(directions)\n\n######## LOOP #\nfor channel in range(nChannels):\n    directions[channel].channel = ctypes.c_int32(channel)\n    directions[channel].direction = ps.PS4000A_THRESHOLD_DIRECTION[\"PS4000A_BELOW\"]\n###############\n  \nstatus[\"setTriggerChannelDirections\"] = ps.ps4000aSetTriggerChannelDirections(\n    chandle,\n    ctypes.byref(directions),    # Pass the array by reference\n    ctypes.c_int16(nDirections), # Pass the length of the array (1 in this case)\n)\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n# Trigger PROPERTIES ####################################\nchannelProperties = (ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES * nChannels)() # Array for Properties (ALL CHANNELS)\nnChannelProperties = len(channelProperties)\n\n# set trigger properties for channels\n# thresholdUpper = mV2adc(300, chRange, maxADC) # Use to set Voltage value\nthresholdUpper = int(maxADC.value * 0.5) # (+50% of ADC range) Adjust threshold as needed\nthresholdLower = 0  # Adjust threshold as needed\n######## LOOP #\nfor channel in range(nChannels):\n    channelProperties[channel].thresholdUpper = ctypes.c_int16(thresholdUpper)\n    channelProperties[channel].thresholdUpperHysteresis = ctypes.c_uint16(16) # Adjust hysteresis as needed\n    channelProperties[channel].thresholdLower = ctypes.c_int16(thresholdLower)\n    channelProperties[channel].thresholdLowerHysteresis = ctypes.c_uint16(16) # Adjust hysteresis as needed\n    channelProperties[channel].channel = ctypes.c_int32(channel)\n    channelProperties[channel].thresholdMode = ps.PS4000A_THRESHOLD_MODE[\"PS4000A_LEVEL\"]\n###############\nautoTriggerMilliseconds = 0  # Set to 0 to wait indefinitely for a trigger\n\nstatus[\"setTriggerChannelProperties\"] = ps.ps4000aSetTriggerChannelProperties(\n    chandle,\n    ctypes.byref(channelProperties),  # Pass the array by reference\n    ctypes.c_int16(nChannelProperties),              # Pass the length of the array\n    ctypes.c_int16(0),                              # auxOutputEnable (not used)\n    ctypes.c_int32(autoTriggerMilliseconds),        # autoTriggerMilliseconds             ############## PASS as int32 was not working!\n)\nassert_pico_ok(status[\"setTriggerChannelProperties\"])\n\n#########################################################################\n\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\ntimebase = 32\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\nprint(status)\n\n##################################\ntriggerEnabled = ctypes.c_int16(0)\npulseWidthQualifierEnabled = ctypes.c_int16(0)\n\nstatus[\"isTriggerOrPulseWidthQualifierEnabled\"] = ps.ps4000aIsTriggerOrPulseWidthQualifierEnabled(\n    chandle, \n    ctypes.byref(triggerEnabled), \n    ctypes.byref(pulseWidthQualifierEnabled)\n)\n\nif status[\"isTriggerOrPulseWidthQualifierEnabled\"] == 0:\n    if triggerEnabled.value != 0:\n        print(\"Trigger is enabled.\")\n    else:\n        print(\"Trigger is disabled.\")\n\n    if pulseWidthQualifierEnabled.value != 0:\n        print(\"Pulse width qualifier is enabled.\")\n    else:\n        print(\"Pulse width qualifier is disabled.\")\nelse:\n    print(\"Error checking trigger/pulse width qualifier status.\")\n#-------------------------------------------------------------------------------------------\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\n\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\n#assert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\n'''ready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\nstatus[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))'''\nready = ctypes.c_int16(0)\ncheck = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\nwhile ready.value == 0:  \n    #time.sleep(0.01)  # Short delay to allow data capture \n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n    #assert_pico_ok(status[\"isReady\"])\n    ###########print(ready.value)\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\nbufferCMax = (ctypes.c_int16 * maxSamples)()\nbufferCMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\nbufferDMax = (ctypes.c_int16 * maxSamples)()\nbufferDMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\n\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\nstatus[\"setDataBuffersC\"] = ps.ps4000aSetDataBuffers(chandle, 2, ctypes.byref(bufferCMax), ctypes.byref(bufferCMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersC\"])\n\nstatus[\"setDataBuffersD\"] = ps.ps4000aSetDataBuffers(chandle, 3, ctypes.byref(bufferDMax), ctypes.byref(bufferDMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersD\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chRange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chRange, maxADC)\nadc2mVChCMax =  adc2mV(bufferCMax, chRange, maxADC)\nadc2mVChDMax =  adc2mV(bufferDMax, chRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\ntime = time/1000000\n#fig, (ax1, ax2) = plt.subplots(2, 1) #2 rows 1 column\nfig, (ax1) = plt.subplots(1, 1) #1 rows 1 column\n# plot data\nax1.plot(time, adc2mVChAMax[:])\nax1.plot(time, adc2mVChBMax[:])\nax1.plot(time, adc2mVChCMax[:])\nax1.plot(time, adc2mVChDMax[:])\nax1.set_xlabel('Time (ms)')\nax1.set_ylabel('Voltage (mV)')\nax1.set_title('Channels')\nplt.tight_layout()\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps4000aExamples/ps4000aBlockAdvancedEdgeTriggerExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\nfrom math import *\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchARange = 6\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000a_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchBRange = 6\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up dropout trigger\n# set trigger condtions for channel A\n\nchannelAConditions =  ps.PS4000A_CONDITION(ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"],ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"])\n#conditions.channelA.condition = ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"]\n\nnConditions = 1\nclear = ps.PS4000A_CONDITIONS_INFO[\"PS4000A_CLEAR\"]\nadd = ps.PS4000A_CONDITIONS_INFO[\"PS4000A_ADD\"] \ninfo = clear|add\nstatus[\"setTriggerChannelConditions\"] = ps.ps4000aSetTriggerChannelConditions(chandle, ctypes.byref(channelAConditions), nConditions, info)\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\n\n#set trigger directions for channel A\ndirections = ps.PS4000A_DIRECTION(ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"], ps.PS4000A_THRESHOLD_DIRECTION[\"PS4000A_RISING\"])\nnDirections = 1\nstatus[\"setTriggerChannelDirections\"] = ps.ps4000aSetTriggerChannelDirections(chandle, ctypes.byref(directions), nDirections)\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# set trigger properties for channel ADC\nthresholdUpper = mV2adc(300, chARange, maxADC)\nthresholdLower = mV2adc(200, chARange, maxADC)\nchannelProperties = ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES(thresholdUpper, floor(thresholdUpper * 0.01), thresholdLower, floor(thresholdLower * 0.01), ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"], ps.PS4000A_THRESHOLD_MODE[\"PS4000A_WINDOW\"])\nnChannelProperties = 1\nautoTriggerms = 10000\nstatus[\"setTriggerChannelProperties\"] = ps.ps4000aSetTriggerChannelProperties(chandle, ctypes.byref(channelProperties), nChannelProperties, 0, autoTriggerms)\nassert_pico_ok(status[\"setTriggerChannelProperties\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\ntriggerEnabled = ctypes.c_int16(0)\npulseWidthQualifierEnabled = ctypes.c_int16(0)\n\nstatus[\"isTriggerOrPulseWidthQualifierEnabled\"] = ps.ps4000aIsTriggerOrPulseWidthQualifierEnabled(\n    chandle, \n    ctypes.byref(triggerEnabled), \n    ctypes.byref(pulseWidthQualifierEnabled)\n)\n\nif status[\"isTriggerOrPulseWidthQualifierEnabled\"] == 0:\n    if triggerEnabled.value != 0:\n        print(\"Trigger is enabled.\")\n    else:\n        print(\"Trigger is disabled.\")\n\n    if pulseWidthQualifierEnabled.value != 0:\n        print(\"Pulse width qualifier is enabled.\")\n    else:\n        print(\"Pulse width qualifier is disabled.\")\nelse:\n    print(\"Error checking trigger/pulse width qualifier status.\")\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000a_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4000aBlockDropoutTriggerExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\nfrom math import *\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000a_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up dropout trigger\n# set trigger condtions for channel A and pulse width qualifier\nclass RECT(ctypes.Structure):\n     _fields_ = [(\"channelA\",ps.PS4000A_CONDITION),\n                 (\"pwq\",ps.PS4000A_CONDITION)]\n\n #conditions =[ps.PS4000A_CONDITION() for i in range (2)]\n\nchannelAConditions =  ps.PS4000A_CONDITION(ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"],ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"])\n#conditions.channelA.condition = ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"]\npulseWidthConditions =  ps.PS4000A_CONDITION(ps.PS4000A_CHANNEL[\"PS4000A_PULSE_WIDTH_SOURCE\"],ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"])\n#conditions.pwq.condition = ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"]\n\nconditions = RECT(channelAConditions,pulseWidthConditions)\n\n\nnConditions = 2\ninfo = ps.PS4000A_CONDITIONS_INFO[\"PS4000A_ADD\"]\nstatus[\"setTriggerChannelConditions\"] = ps.ps4000aSetTriggerChannelConditions(chandle, ctypes.byref(conditions), nConditions, info)\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\n\n#set trigger directions for channel A\ndirections = ps.PS4000A_DIRECTION(ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"], ps.PS4000A_THRESHOLD_DIRECTION[\"PS4000A_ENTER\"])\nnDirections = 1\nstatus[\"setTriggerChannelDirections\"] = ps.ps4000aSetTriggerChannelDirections(chandle, ctypes.byref(directions), nDirections)\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# set trigger properties for channel ADC\nthresholdUpper = mV2adc(500, 7, maxADC)\nchannelProperties = ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES(thresholdUpper, floor(thresholdUpper * 0.05), (thresholdUpper * -1), floor(thresholdUpper * 0.05), ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"], ps.PS4000A_THRESHOLD_MODE[\"PS4000A_WINDOW\"])\nnChannelProperties = 1\nautoTriggerms = 10000\nstatus[\"setTriggerChannelProperties\"] = ps.ps4000aSetTriggerChannelProperties(chandle, ctypes.byref(channelProperties), nChannelProperties, 0, autoTriggerms)\nassert_pico_ok(status[\"setTriggerChannelProperties\"])\n\n# set pulse width qualifier conditions\npwqNConditions = 1\nstatus[\"setPulseWidthQualifierConditions\"] = ps.ps4000aSetPulseWidthQualifierConditions(chandle, ctypes.byref(pulseWidthConditions), pwqNConditions, info)\nassert_pico_ok(status[\"setPulseWidthQualifierConditions\"])\n\n# set pulse width qualifier properties\ndirection = ps.PS4000A_THRESHOLD_DIRECTION[\"PS4000A_ENTER\"]\nlower = 15\nupper = 100\ntype = ps.PS4000A_PULSE_WIDTH_TYPE[\"PW_TYPE_IN_RANGE\"]\nstatus[\"setPulseWidthQualifierProperties\"] = ps.ps4000aSetPulseWidthQualifierProperties(chandle, direction, lower, upper, type)\nassert_pico_ok(status[\"setPulseWidthQualifierProperties\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000a_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4000aBlockFrequencyCounterExample.py",
    "content": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4000 BLOCK MODE FREQUENCY COUNTER EXAMPLE\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as Hz against time in ns.\n#\n# This example will only work with an automotive version of a 4000 series scope\n# such as 4225A and 4425A\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\nfrom math import *\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_5V = 8\n# analogOffset = 0 V\nchARange = 8\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_5V = 8\n# analogOffset = 0 V\nchARange = 8\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle, 1, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# set trigger properties for channel ADC\nthresholdMajor = mV2adc(300, chARange, maxADC)\nthresholdMinor = mV2adc(0, chARange, maxADC)\n\n# set up frequency counting\n# handle = chandle\n# channel - PS4000a_CHANNEL_A = 0\n# enabled = 1\n# frequency range = PS4000A_FC_200 = 0 - 200 Hz\n\nstatus[\"setFrequencyCounter\"] = ps.ps4000aSetFrequencyCounter(chandle, 0, 1, ps.PS4000A_FREQUENCY_COUNTER_RANGE[\"PS4000A_FC_200\"],thresholdMajor,thresholdMinor)\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 500000\npostTriggerSamples = 500000\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 52\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# # convert ADC counts data to mV\nadc2mVChBMax =  adc2mV(bufferBMax, chARange, maxADC)\n\n\n# convert ADC counts to Hz for channel A\nchAHzMax = [((x + 32767) * 200) / (2 * maxADC.value) for x in bufferAMax]\n\n# # Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A\nplt.plot(time, chAHzMax)\n# plt.plot(time, chAHzMin)\nplt.xlabel('Time (ns)')\nplt.ylabel('Frequency (Hz)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4000aRapidBlockExample.py",
    "content": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS4000A RAPID BLOCK MODE EXAMPLE\r\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects 10 blocks of data with additional driver calls.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps4000a import ps4000a as ps\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 4000 series PicoScope\r\n# Returns handle to chandle for use in future API functions\r\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\r\n\r\ntry:\r\n    assert_pico_ok(status[\"openunit\"])\r\nexcept: # PicoNotOkError:\r\n    powerStatus = status[\"openunit\"]\r\n\r\n    if powerStatus == 286:\r\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\r\n    elif powerStatus == 282:\r\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\r\n    else:\r\n        raise\r\n\r\n    assert_pico_ok(status[\"changePowerSource\"])\r\n\r\n# Set up channel A\r\n# handle = chandle\r\n# channel = PS4000a_CHANNEL_A = 0\r\n# enabled = 1\r\n# coupling type = PS4000a_DC = 1\r\n# range = PS4000a_2V = 7\r\n# analogOffset = 0 V\r\nchARange = 7\r\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chARange, 0)\r\nassert_pico_ok(status[\"setChA\"])\r\n\r\n# Set up channel B\r\n# handle = chandle\r\n# channel = PS4000a_CHANNEL_B = 1\r\n# enabled = 1\r\n# coupling type = PS4000a_DC = 1\r\n# range = PS4000a_2V = 7\r\n# analogOffset = 0 V\r\nchBRange = 7\r\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\r\nassert_pico_ok(status[\"setChB\"])\r\n\r\n# Set up single trigger\r\n# handle = chandle\r\n# enabled = 1\r\n# source = PS4000a_CHANNEL_A = 0\r\n# threshold = 1024 ADC counts\r\n# direction = PS4000a_RISING = 2\r\n# delay = 0 s\r\n# auto Trigger = 1000 ms\r\nstatus[\"trigger\"] = ps.ps4000aSetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 1000)\r\nassert_pico_ok(status[\"trigger\"])\r\n\r\n# Set number of pre and post trigger samples to be collected\r\npreTriggerSamples = 2500\r\npostTriggerSamples = 2500\r\nmaxSamples = preTriggerSamples + postTriggerSamples\r\n\r\n# Get timebase information\r\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \r\n# To access these Timebases, set any unused analogue channels to off.\r\n# handle = chandle\r\n# timebase = 8 = timebase\r\n# noSamples = maxSamples\r\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\r\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\r\n# segment index = 0\r\ntimebase = 8\r\ntimeIntervalns = ctypes.c_float()\r\nreturnedMaxSamples = ctypes.c_int32()\r\noversample = ctypes.c_int16(1)\r\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\r\nassert_pico_ok(status[\"getTimebase2\"])\r\n\r\n# Set memory segments\r\n# handle = chandle\r\n# nSegments = 10\r\nnMaxSamples = ctypes.c_int32(0)\r\nstatus[\"setMemorySegments\"] = ps.ps4000aMemorySegments(chandle, 10, ctypes.byref(nMaxSamples))\r\nassert_pico_ok(status[\"setMemorySegments\"])\r\n\r\n# Set number of captures\r\n# handle = chandle\r\n# nCaptures = 10\r\nstatus[\"SetNoOfCaptures\"] = ps.ps4000aSetNoOfCaptures(chandle, 10)\r\nassert_pico_ok(status[\"SetNoOfCaptures\"])\r\n\r\n# set up buffers\r\nbufferA0 = (ctypes.c_int16 * maxSamples)()\r\nbufferA1 = (ctypes.c_int16 * maxSamples)()\r\nbufferA2 = (ctypes.c_int16 * maxSamples)()\r\nbufferA3 = (ctypes.c_int16 * maxSamples)()\r\nbufferA4 = (ctypes.c_int16 * maxSamples)()\r\nbufferA5 = (ctypes.c_int16 * maxSamples)()\r\nbufferA6 = (ctypes.c_int16 * maxSamples)()\r\nbufferA7 = (ctypes.c_int16 * maxSamples)()\r\nbufferA8 = (ctypes.c_int16 * maxSamples)()\r\nbufferA9 = (ctypes.c_int16 * maxSamples)()\r\n\r\nbufferB0 = (ctypes.c_int16 * maxSamples)()\r\nbufferB1 = (ctypes.c_int16 * maxSamples)()\r\nbufferB2 = (ctypes.c_int16 * maxSamples)()\r\nbufferB3 = (ctypes.c_int16 * maxSamples)()\r\nbufferB4 = (ctypes.c_int16 * maxSamples)()\r\nbufferB5 = (ctypes.c_int16 * maxSamples)()\r\nbufferB6 = (ctypes.c_int16 * maxSamples)()\r\nbufferB7 = (ctypes.c_int16 * maxSamples)()\r\nbufferB8 = (ctypes.c_int16 * maxSamples)()\r\nbufferB9 = (ctypes.c_int16 * maxSamples)()\r\n\r\n# set data buffers\r\n# handle = chandle\r\n# channel = PS4000A_CHANNEL_A = 0\r\n# buffer = bufferAX (where X = segmentIndex)\r\n# bufferLength = maxSamples\r\n# segmentIndex = X\r\n# mode = PS4000A_RATIO_MODE_NONE = 0\r\n\r\nstatus[\"setDataBufferA0\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA0), maxSamples, 0, 0)\r\nstatus[\"setDataBufferA1\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA1), maxSamples, 1, 0)\r\nstatus[\"setDataBufferA2\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA2), maxSamples, 2, 0)\r\nstatus[\"setDataBufferA3\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA3), maxSamples, 3, 0)\r\nstatus[\"setDataBufferA4\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA4), maxSamples, 4, 0)\r\nstatus[\"setDataBufferA5\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA5), maxSamples, 5, 0)\r\nstatus[\"setDataBufferA6\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA6), maxSamples, 6, 0)\r\nstatus[\"setDataBufferA7\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA7), maxSamples, 7, 0)\r\nstatus[\"setDataBufferA8\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA8), maxSamples, 8, 0)\r\nstatus[\"setDataBufferA9\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferA9), maxSamples, 9, 0)\r\n\r\nstatus[\"setDataBufferB0\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB0), maxSamples, 0, 0)\r\nstatus[\"setDataBufferB1\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB1), maxSamples, 1, 0)\r\nstatus[\"setDataBufferB2\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB2), maxSamples, 2, 0)\r\nstatus[\"setDataBufferB3\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB3), maxSamples, 3, 0)\r\nstatus[\"setDataBufferB4\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB4), maxSamples, 4, 0)\r\nstatus[\"setDataBufferB5\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB5), maxSamples, 5, 0)\r\nstatus[\"setDataBufferB6\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB6), maxSamples, 6, 0)\r\nstatus[\"setDataBufferB7\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB7), maxSamples, 7, 0)\r\nstatus[\"setDataBufferB8\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB8), maxSamples, 8, 0)\r\nstatus[\"setDataBufferB9\"] = ps.ps4000aSetDataBuffer(chandle, 0, ctypes.byref(bufferB9), maxSamples, 9, 0)\r\n\r\n# run block capture\r\n# handle = chandle\r\n# number of pre-trigger samples = preTriggerSamples\r\n# number of post-trigger samples = PostTriggerSamples\r\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\r\n# time indisposed ms = None (not needed in the example)\r\n# segment index = 0\r\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# check for end of capture\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\r\n\r\n# Creates a overlow location for data\r\noverflow = (ctypes.c_int16 * 10)()\r\n# Creates converted types maxsamples\r\ncmaxSamples = ctypes.c_int32(maxSamples)\r\n\r\n# collect data \r\n# handle = chandle\r\n# noOfSamples = cmaxSamples\r\n# fromSegmentIndex = 0\r\n# toSegmentIndex = 9\r\n# downSampleRatio = 1\r\n# downSampleRatioMode = PS4000A_RATIO_MODE_NONE\r\nstatus[\"getValuesBulk\"] = ps.ps4000aGetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, 1, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValuesBulk\"])\r\n\r\n# find maximum ADC count value\r\n# handle = chandle\r\n# pointer to value = ctypes.byref(maxADC)\r\nmaxADC = ctypes.c_int16(32767)\r\n\r\n# convert from adc to mV\r\nadc2mVChA0 =  adc2mV(bufferA0, chARange, maxADC)\r\nadc2mVChA1 =  adc2mV(bufferA1, chARange, maxADC)\r\nadc2mVChA2 =  adc2mV(bufferA2, chARange, maxADC)\r\nadc2mVChA3 =  adc2mV(bufferA3, chARange, maxADC)\r\nadc2mVChA4 =  adc2mV(bufferA4, chARange, maxADC)\r\nadc2mVChA5 =  adc2mV(bufferA5, chARange, maxADC)\r\nadc2mVChA6 =  adc2mV(bufferA6, chARange, maxADC)\r\nadc2mVChA7 =  adc2mV(bufferA7, chARange, maxADC)\r\nadc2mVChA8 =  adc2mV(bufferA8, chARange, maxADC)\r\nadc2mVChA9 =  adc2mV(bufferA9, chARange, maxADC)\r\n\r\nadc2mVChB0 =  adc2mV(bufferB0, chARange, maxADC)\r\nadc2mVChB1 =  adc2mV(bufferB1, chARange, maxADC)\r\nadc2mVChB2 =  adc2mV(bufferB2, chARange, maxADC)\r\nadc2mVChB3 =  adc2mV(bufferB3, chARange, maxADC)\r\nadc2mVChB4 =  adc2mV(bufferB4, chARange, maxADC)\r\nadc2mVChB5 =  adc2mV(bufferB5, chARange, maxADC)\r\nadc2mVChB6 =  adc2mV(bufferB6, chARange, maxADC)\r\nadc2mVChB7 =  adc2mV(bufferB7, chARange, maxADC)\r\nadc2mVChB8 =  adc2mV(bufferB8, chARange, maxADC)\r\nadc2mVChB9 =  adc2mV(bufferB9, chARange, maxADC)\r\n\r\n# Create time data\r\ntime = np.linspace(0, ((cmaxSamples.value)-1) * timeIntervalns.value, cmaxSamples.value)\r\n\r\n# plot data\r\nplt.plot(time, adc2mVChA0)\r\nplt.plot(time, adc2mVChA1)\r\nplt.plot(time, adc2mVChA2)\r\nplt.plot(time, adc2mVChA3)\r\nplt.plot(time, adc2mVChA4)\r\nplt.plot(time, adc2mVChA5)\r\nplt.plot(time, adc2mVChA6)\r\nplt.plot(time, adc2mVChA7)\r\nplt.plot(time, adc2mVChA8)\r\nplt.plot(time, adc2mVChA9)\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Stop the scope\r\n# handle = chandle\r\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\r\nassert_pico_ok(status[\"stop\"])\r\n\r\n# Close unitDisconnect the scope\r\n# handle = chandle\r\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# display status returns\r\nprint(status)\r\n\r\n"
  },
  {
    "path": "ps4000aExamples/ps4000aRapidBlockWaveformAveragingExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS4000 A BLOCK MODE WAVEFORM AVERAGING EXAMPLE\r\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects blocks of data.\r\n# The blocks are then avraged together for each channel.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps4000a import ps4000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\r\nfrom picosdk.functionsExhibitions import *\r\nfrom math import ceil\r\n\r\n# Scope settings\r\nnoOfChannels = 1\r\nsamplingRate = 1 #Mhz \r\nsampleLength = 10000 #Samples\r\nnumberOfSegments = 10\r\n\r\ntimebase = ps4000aTimebase(samplingRate)\r\n\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\r\ntry:\r\n    assert_pico_ok(status[\"openunit\"])\r\nexcept: # PicoNotOkError:\r\n\r\n    powerStatus = status[\"openunit\"]\r\n\r\n    if powerStatus == 286:\r\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\r\n    elif powerStatus == 282:\r\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\r\n    else:\r\n        raise\r\n\r\n    assert_pico_ok(status[\"changePowerSource\"])\r\n\r\n# Set channels on\r\n# handle = chandle\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC\"]\r\nchannelRange = 7 # +-2 V range\r\n# analogueOffset = 0 V\r\n\r\nfor x in range(0, noOfChannels, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps4000aSetChannel(chandle, channel, 1, coupling, channelRange, 0)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# set channels off\r\nfor x in range (noOfChannels, 4, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps4000aSetChannel(chandle,channel, 0, coupling, channelRange, 0)\r\n    try:\r\n        assert_pico_ok(status[\"setChannel\",x])\r\n    except:\r\n        break\r\n    \r\n# get max ADC value\r\n# handle = chandle\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps4000aMaximumValue(chandle, ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = 0\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.ps4000aSetSimpleTrigger(chandle, 1, source, (mV2adc(500,channelRange,maxADC)), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = int(sampleLength/2)\r\nnoOfPostTriggerSamples = int(sampleLength/2)\r\nnSamples = int(noOfPostTriggerSamples + noOfPreTriggerSamples)\r\n\r\n# Get fastest available timebase\r\n# handle = chandle\r\n# enabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\r\n# timebase = ctypes.c_uint32(0)\r\ntimeInterval = ctypes.c_float(0)\r\n# # resolution = resolution\r\n# status[\"getMinimumTimebaseStateless\"] = ps.ps4000aGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\r\n# print(\"timebase = \", timebase.value)\r\n# print(\"sample interval =\", timeInterval.value, \"s\")\r\nmaxSamples = ctypes.c_uint32(0)\r\n\r\nstatus[\"getTimebase\"] = ps.ps4000aGetTimebase2(chandle, timebase, nSamples, ctypes.byref(timeInterval), ctypes.byref(maxSamples), 0)\r\nassert_pico_ok(status[\"getTimebase\"])\r\n\r\n# Set number of memory segments\r\nmaxSegments = ctypes.c_uint64(10)\r\nstatus[\"memorySegments\"] = ps.ps4000aMemorySegments(chandle, numberOfSegments, ctypes.byref(maxSegments))\r\nassert_pico_ok(status[\"memorySegments\"])\r\n\r\n# Set number of captures\r\nstatus[\"setNoOfCaptures\"] = ps.ps4000aSetNoOfCaptures(chandle, numberOfSegments)\r\nassert_pico_ok(status[\"setNoOfCaptures\"])\r\n\r\noneDBuffer = (ctypes.c_int16 * nSamples)\r\ntwoDbuffer = (oneDBuffer * numberOfSegments)\r\nthreeDBuffer = (twoDbuffer * noOfChannels)\r\nbuffer = (threeDBuffer)()\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndownSampleMode = ps.PS4000A_RATIO_MODE[\"PS4000A_RATIO_MODE_NONE\"]\r\n\r\n\r\nfor x in range(0, numberOfSegments, 1):\r\n    for y in range(0, noOfChannels, 1):\r\n        channel = y\r\n        status[\"setDataBuffers\",x,y] = ps.ps4000aSetDataBuffer(chandle, channel, ctypes.byref(buffer[y][x]), nSamples, x, downSampleMode)\r\n        assert_pico_ok(status[\"setDataBuffers\",x,y])\r\n\r\n\r\n# sign gen output\r\n# Set signal generator waveform\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\nwavetype = ctypes.c_int32(0) #PS4000a_SINE\r\nfrequencyHz = 1000\r\n# increment = 0\r\n# dwellTime = 1\r\nsweepType = ctypes.c_int32(0) #PS4000a_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\ntriggertype = ctypes.c_int32(0) #PS4000a_SIGGEN_RISING\r\ntriggerSource = ctypes.c_int32(0) #P4000a_SIGGEN_NONE\r\n# extInThreshold = 1\r\nstatus[\"setSigGenBuiltInV2\"] = ps.ps4000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, frequencyHz, frequencyHz, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 0)\r\nassert_pico_ok(status[\"setSigGenBuiltInV2\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps4000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\r\n\r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\n# Creates a overflow location for each segment\r\noverflow = (ctypes.c_int16 * numberOfSegments)()\r\nstatus[\"getValues\"] = ps.ps4000aGetValuesBulk(chandle, ctypes.byref(noOfSamples), 0, numberOfSegments-1, 1, downSampleMode, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\noneDBuffer = (ctypes.c_float * nSamples)\r\ntwoDbuffer = (oneDBuffer * numberOfSegments)\r\nthreeDBuffer = (twoDbuffer * noOfChannels)\r\nrapidBlockBuffers = (threeDBuffer)()\r\n\r\n# convert ADC counts data to mV\r\n# convert all active channels\r\nfor x in range (0, numberOfSegments,1):\r\n    for y in range (0, noOfChannels, 1):\r\n        A =  adc2mV(buffer[y][x], channelRange, maxADC)\r\n        for z in range(0, nSamples, 1):\r\n            rapidBlockBuffers[y][x][z] = ctypes.c_float(A[z]) \r\n\r\n# Average waveforms\r\naverageWaveform=np.zeros((noOfChannels,nSamples))\r\n\r\n# loop through each channel, each memory segment and each sample to sum together, then divides by the number of memory segment to get the mean waveform for each channel\r\nfor y in range (0, noOfChannels, 1):\r\n    for x in range (0, numberOfSegments,1):\r\n        for z in range (0, nSamples,1):\r\n            averageWaveform[y][z] = averageWaveform[y][z] + rapidBlockBuffers[y][x][z]\r\n    averageWaveform[y] = [x/numberOfSegments for x in averageWaveform[y]]\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot channel A from all blocks\r\n# for y in range (0, numberOfSegments, 1):\r\n    # segment = y\r\n    # plt.plot(time, rapidBlockBuffers[0][y])\r\n    \r\n# plot averaged waveform from channel A\r\nplt.plot(time, averageWaveform[0])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps4000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps4000aExamples/ps4000aSigGen.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 4000 (A API) Series Signal Generator Example\r\n# This example demonstrates how to use the PicoScope 4000 Series (ps4000a) driver API functions to set up the signal generator to do the following:\r\n# \r\n# 1. Output a sine wave \r\n# 2. Output a square wave \r\n# 3. Output a sweep of a square wave signal\r\n\r\nimport ctypes\r\nfrom picosdk.ps4000a import ps4000a as ps\r\nimport time\r\nfrom picosdk.functions import assert_pico_ok\r\n\r\n\r\n# Gives the device a handle\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Opens the device/s\r\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\r\n\r\ntry:\r\n    assert_pico_ok(status[\"openunit\"])\r\nexcept:\r\n    # powerstate becomes the status number of openunit\r\n    powerstate = status[\"openunit\"]\r\n\r\n    # If powerstate is the same as 282 then it will run this if statement\r\n    if powerstate == 282:\r\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\r\n        status[\"ChangePowerSource\"] = ps.ps4000aChangePowerSource(chandle, 282)\r\n    # If the powerstate is the same as 286 then it will run this if statement\r\n    elif powerstate == 286:\r\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\r\n        status[\"ChangePowerSource\"] = ps.ps4000aChangePowerSource(chandle, 286)\r\n    else:\r\n        raise\r\n\r\n    assert_pico_ok(status[\"ChangePowerSource\"])\r\n\r\n# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(0) = PS4000A_SINE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int32(0) = PS4000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS4000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS4000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\nwavetype = ps.PS4000A_WAVE_TYPE['PS4000A_SINE']\r\nsweepType = ps.PS4000A_SWEEP_TYPE['PS4000A_UP']\r\ntriggertype = ps.PS4000A_SIGGEN_TRIG_TYPE['PS4000A_SIGGEN_RISING']\r\ntriggerSource = ps.PS4000A_SIGGEN_TRIG_SOURCE['PS4000A_SIGGEN_NONE']\r\nextInThreshold = ctypes.c_int16(0)  #extInThreshold - Not used\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps4000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, extInThreshold)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(1) = PS4000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int32(0) = PS4000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS4000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS4000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\nwavetype = ps.PS4000A_WAVE_TYPE['PS4000A_SQUARE']\r\nsweepType = ps.PS4000A_SWEEP_TYPE['PS4000A_UP']\r\ntriggertype = ps.PS4000A_SIGGEN_TRIG_TYPE['PS4000A_SIGGEN_RISING']\r\ntriggerSource = ps.PS4000A_SIGGEN_TRIG_SOURCE['PS4000A_SIGGEN_NONE']\r\nextInThreshold = ctypes.c_int16(0) #extInThreshold - Not used\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps4000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, extInThreshold)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output square wave with an up-down sweep, ranging from 10-100 kHz in 5 kHz increments every 1 second.\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(1) = PS4000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 100 kHz\r\n# increment = 5 kHz\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int32(2) = PS4000A_UPDOWN\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS4000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS4000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\nwavetype = ps.PS4000A_WAVE_TYPE['PS4000A_SQUARE']\r\nsweepType = ps.PS4000A_SWEEP_TYPE['PS4000A_UPDOWN']\r\ntriggertype = ps.PS4000A_SIGGEN_TRIG_TYPE['PS4000A_SIGGEN_RISING']\r\ntriggerSource = ps.PS4000A_SIGGEN_TRIG_SOURCE['PS4000A_SIGGEN_NONE']\r\nextInThreshold = ctypes.c_int16(0) #extInThreshold - Not used\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps4000aSetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 100000, 5000, 1, sweepType, 0, 0, 0, triggertype, triggerSource, extInThreshold)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(36)\r\n\r\n# Closes the unit\r\n# Handle = chandle\r\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Displays the status returns\r\nprint(status)\r\n"
  },
  {
    "path": "ps4000aExamples/ps4000aStreamingExample.py",
    "content": "#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 Series (A API) STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps4000A driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 2000 Series device\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n\nenabled = 1\ndisabled = 0\nanalogue_offset = 0.0\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000A_DC = 1\n# range = PS4000A_2V = 7\n# analogue offset = 0 V\nchannel_range = 7\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle,\n                                        ps.PS4000A_CHANNEL['PS4000A_CHANNEL_A'],\n                                        enabled,\n                                        ps.PS4000A_COUPLING['PS4000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000A_DC = 1\n# range = PS4000A_2V = 7\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle,\n                                        ps.PS4000A_CHANNEL['PS4000A_CHANNEL_B'],\n                                        enabled,\n                                        ps.PS4000A_COUPLING['PS4000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 500\nnumBuffersToCapture = 100\n\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\nmemory_segment = 0\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle,\n                                                     ps.PS4000A_CHANNEL['PS4000A_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS4000A_RATIO_MODE['PS4000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle,\n                                                     ps.PS4000A_CHANNEL['PS4000A_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS4000A_RATIO_MODE['PS4000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(250)\nsampleUnits = ps.PS4000A_TIME_UNITS['PS4000A_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps4000aRunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                ps.PS4000A_RATIO_MODE['PS4000A_RATIO_MODE_NONE'],\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps4000aGetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps4000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples - 1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, bufferCompleteA[:])\nplt.plot(time, bufferCompleteB[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4000a_Runt_trigger.py",
    "content": "import ctypes\nfrom picosdk.ps4000a import ps4000a as ps\nfrom picosdk.functions import assert_pico_ok\nimport numpy as np\n\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV,mV2adc\n\ndef setup_runt_trigger(chandle, trigger_ch, channel_range_mv):\n    # Sets up a positive \"Runt\" trigger between levels 0v and 1.8V, autotrigger disabled.\n    # Assume chandle is already open and channels are set up\n\n    print(\"Configuring Runt trigger...\")\n    status = {}\n    # 1. Define Trigger Channel Conditions\n    # This specifies the Channelto be the source for the trigger logic.\n    # PS4000A_CONDITION(source, condition)\n    # condition: 0 = Ignore, 1 = True, 2 = False\n    cond_list = [\n        ps.PS4000A_CONDITION(\n            trigger_ch, # ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"],\n            ps.PS4000A_TRIGGER_STATE[\"PS4000A_TRUE\"]\n        )\n    ]\n    # Convert list to ctypes array\n    n_cond = len(cond_list)\n    conditions = (ps.PS4000A_CONDITION * n_cond)(*cond_list)\n\n    status[\"setTriggerChannelConditions\"] = ps.ps4000aSetTriggerChannelConditions(\n        chandle, \n        ctypes.byref(conditions), \n        ctypes.c_int16(n_cond),\n        ps.PS4000A_CONDITIONS_INFO[\"PS4000A_CLEAR\"] | ps.PS4000A_CONDITIONS_INFO[\"PS4000A_ADD\"]\n    )\n    assert_pico_ok(status[\"setTriggerChannelConditions\"])\n\n    # 2. Define Trigger Directions\n    # For a Runt trigger, we use \"POSITIVE_RUNT\" or \"NEGATIVE_RUNT\".\n    # PS4000A_DIRECTION(channel, direction)\n    dir_list = [\n        ps.PS4000A_DIRECTION(\n            trigger_ch, # ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"],\n            ps.PS4000A_THRESHOLD_DIRECTION[\"PS4000A_POSITIVE_RUNT\"]\n        )\n    ]\n    n_dirs = len(dir_list)\n    directions = (ps.PS4000A_DIRECTION * n_dirs)(*dir_list)\n\n    status[\"setTriggerChannelDirections\"] = ps.ps4000aSetTriggerChannelDirections(\n        chandle,\n        ctypes.byref(directions),\n        ctypes.c_int16(n_dirs)\n    )\n    assert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n    # 3. Define Trigger Channel Properties (Thresholds)\n    # A runt trigger requires two thresholds (Upper and Lower).\n    # Convert mV to ADC counts (helper function assumed or manual calc)\n    # For example, if max ADC is 32767:\n\n    lower_threshold_adc = mV2adc(0, channel_range_mv, maxADC)\n    print(\"Lower Threshold: \",lower_threshold_adc)\n    upper_threshold_adc = mV2adc(1800, channel_range_mv, maxADC)\n    print(\"Upper Threshold: \",upper_threshold_adc)\n\n    prop_list = [\n        ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES(\n            ctypes.c_int16(upper_threshold_adc),            # thresholdUpper\n            ctypes.c_uint16(256),                           # thresholdUpperHysteresis\n            ctypes.c_int16(lower_threshold_adc),            # thresholdLower\n            ctypes.c_uint16(256),                           # thresholdLowerHysteresis\n            trigger_ch, # ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"],\n            ps.PS4000A_THRESHOLD_MODE[\"PS4000A_WINDOW\"]     # Window type needed for Runt trigger\n        )\n    ]\n    n_props = len(prop_list)\n    properties = (ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES * n_props)(*prop_list)\n\n    status[\"setTriggerChannelProperties\"] = ps.ps4000aSetTriggerChannelProperties(\n        chandle,\n        ctypes.byref(properties),\n        ctypes.c_int16(n_props),\n        ctypes.c_int16(0),    # auxOutputEnable 0: Off\n        ctypes.c_int32(0)  # autoTriggerMilliseconds (0 to wait forever)\n    )\n    assert_pico_ok(status[\"setTriggerChannelProperties\"])\n\n    # Check with API if trigger is set...\n    triggerEnabled = ctypes.c_int16(0)\n    pulseWidthQualifierEnabled = ctypes.c_int16(0)\n\n    status[\"isTriggerOrPulseWidthQualifierEnabled\"] = ps.ps4000aIsTriggerOrPulseWidthQualifierEnabled(\n        chandle, \n        ctypes.byref(triggerEnabled), \n        ctypes.byref(pulseWidthQualifierEnabled)\n    )\n\n    if status[\"isTriggerOrPulseWidthQualifierEnabled\"] == 0:\n        if triggerEnabled.value != 0:\n            print(\"Trigger is enabled.\")\n        else:\n            print(\"Trigger is disabled.\")\n\n        if pulseWidthQualifierEnabled.value != 0:\n            print(\"Pulse width qualifier is enabled.\")\n        else:\n            print(\"Pulse width qualifier is disabled.\")\n    else:\n        print(\"Error checking trigger/pulse width qualifier status.\")\n    return status\n\n#-------------------------------------------------------------------------------------------\n############################################################\n# START MAIN CODE\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\nmaxADC = ctypes.c_int16(0) # (32767)\nstatus[\"MaximumValue\"] = ps.ps4000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"MaximumValue\"])\n\nchannel = ps.PS4000A_CHANNEL[\"PS4000A_CHANNEL_A\"]\nchRange = ps.PICO_CONNECT_PROBE_RANGE[\"PICO_X1_PROBE_5V\"] # (see ps4000a.py)\n\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, ctypes.c_int32(channel), ctypes.c_int16(1), ps.PS4000A_COUPLING[\"PS4000A_DC\"], chRange, ctypes.c_float(0))\nassert_pico_ok(status[\"setChA\"])\n\n#########################################################################\nsetup_runt_trigger(chandle, channel, chRange) # Setup a \"Runt \"Trigger \n#########################################################################\n\n# Setup number samples and trigger point, and sample interval\npreTriggerSamples = 50_000\npostTriggerSamples = 50_000\nmaxSamples = preTriggerSamples + postTriggerSamples\n\ntimebase = 400 # ~200kS/s \n# (see Programmer's guide for mre information on timebases)\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\nprint(status)\n\n#-------------------------------------------------------------------------------------------\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\n\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\n'''ready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\nstatus[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))'''\nready = ctypes.c_int16(0)\ncheck = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\nwhile ready.value == 0:  \n    #time.sleep(0.01)  # Short delay to allow data capture \n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n    #assert_pico_ok(status[\"isReady\"])\n    ###########print(ready.value)\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\n\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chRange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\ntime = time/1000000\n#fig, (ax1, ax2) = plt.subplots(2, 1) #2 rows 1 column\nfig, (ax1) = plt.subplots(1, 1) #1 rows 1 column\n# plot data\nax1.plot(time, adc2mVChAMax[:])\nax1.plot(time, adc2mVChBMax[:])\nax1.set_xlabel('Time (ms)')\nax1.set_ylabel('Voltage (mV)')\nax1.set_title('Channels')\nplt.tight_layout()\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps4000aExamples/ps4444BlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000a_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up channel C\n# handle = chandle\n# channel = PS4000a_CHANNEL_C = 2\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchCRange = 7\nstatus[\"setChC\"] = ps.ps4000aSetChannel(chandle, 2, 0, 1, chCRange, 0)\nassert_pico_ok(status[\"setChC\"])\n\n# Set up channel D\n# handle = chandle\n# channel = PS4000a_CHANNEL_D = 3\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchDRange = 7\nstatus[\"setChD\"] = ps.ps4000aSetChannel(chandle, 3, 0, 1, chDRange, 0)\nassert_pico_ok(status[\"setChD\"])\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\n# source = PS4000a_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS4000a_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps4000aSetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 100)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000a_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4444BlockPicoConnectProbesExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4444 PICOCONNECT PROBE, BLOCK MODE EXAMPLE\n# This example opens a 4444 device, and demos PicoConnectProbes events.\n\nimport ctypes\nfrom array import array\nimport time\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, adc2mVpl1000, mV2adcpl1000\nfrom pynput import keyboard\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\nprobes = (ps.PS4000A_USER_PROBE_INTERACTIONS * 4)()  #\n\n# Calback for PicoConnectProbes events\ndef PicoConnectProbe_callback(handle, pico_status, probes_ptr, nProbes):\n    global PicoConnectProbewasCalledBack\n    PicoConnectProbewasCalledBack = True\n    print(\"PicoConnectProbes pico_status \", pico_status)\n    print(\"Number of PicoConnectProbes events is \", nProbes)\n    #print(probes_ptr)\n\n    # If probes_ptr is an integer (raw address), cast it to a pointer\n    if isinstance(probes_ptr, int):\n        probes_ptr = ctypes.cast(probes_ptr, ctypes.POINTER( (ps.PS4000A_USER_PROBE_INTERACTIONS) ))\n\n    n_probes = nProbes\n    if n_probes > 0 and probes_ptr:\n        # Iterate over the pointer using the count provided by n_probes\n        for i in range(n_probes):\n            # Access the struct at index i\n            probes[(probes_ptr[i].channel)] = probes_ptr[i]\n    else:\n        print(\"No probe interactions recorded.\")\n\n###########################################################\n# Convert the python function into a C function pointer.\ncFuncPtr2 = ps.ps4000aProbeInteractions(PicoConnectProbe_callback)\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\nstatus[\"SetProbeInteractionCallback\"] = ps.ps4000aSetProbeInteractionCallback(chandle, cFuncPtr2)\nassert_pico_ok(status[\"SetProbeInteractionCallback\"])\n\ntime.sleep(1.0) # Delay for first Probe callback events to trigger \n\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, ps.PS4000A_COUPLING[\"PS4000A_DC\"], ps.PICO_CONNECT_PROBE_RANGE[\"PICO_X1_PROBE_1V\"], 0)\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 1, 1, ps.PS4000A_COUPLING[\"PS4000A_DC\"], ps.PICO_CONNECT_PROBE_RANGE[\"PICO_X1_PROBE_1V\"], 0)\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 2, 1, ps.PS4000A_COUPLING[\"PS4000A_DC\"], ps.PICO_CONNECT_PROBE_RANGE[\"PICO_X1_PROBE_1V\"], 0)\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 3, 1, ps.PS4000A_COUPLING[\"PS4000A_DC\"], ps.PICO_CONNECT_PROBE_RANGE[\"PICO_X1_PROBE_1V\"], 0)\n\n##################################################\n# Look in \\picosdk\\ps4000a.py for all \"PICO_CONNECT_PROBE_RANGE\" defines for your Probe.\n\n# The 4444 PicoConnect current clamps don't have auto zero offset.\n# You need to manually set an analog offset in both PicoScope 7 and when using the API.\n# If you measuring AC current you can just AC couple the channel to remove any offset.\n# You can find out the max. and min. analogoffset values that can be set for any probe range by calling-\n# ps4000aGetAnalogueOffset().\n\n##################################################\nprint(\"Press 'Enter' to exit the Probe update loop!\")\nkeep_going=keyboard.Listener(lambda key: False if key==keyboard.Key.enter else True)\nkeep_going.start()\nwhile keep_going.is_alive():\n    if (PicoConnectProbewasCalledBack == True):\n        PicoConnectProbewasCalledBack = False\n        print(\"DEBUG all probe status:\")\n\n        for i in range(4):\n            #probe = probes_ptr[i]  # index into the array\n            if (probes[i].connected):\n                status[\"setChannel\"] = ps.ps4000aSetChannel(chandle,\n                                                            i, # channel\n                                                            1, # enabled\n                                                            ps.PS4000A_COUPLING[\"PS4000A_DC\"], # coupling\n                                                            (probes[i].rangeLast_), # probes[i].rangeFirst_, # ps.PICO_CONNECT_PROBE_RANGE[probes[i].rangeFirst_],\n                                                            0) # offset\n            else:\n                status[\"setChannel\"] = ps.ps4000aSetChannel(chandle, i, 0, ps.PS4000A_COUPLING[\"PS4000A_DC\"], ps.PICO_CONNECT_PROBE_RANGE[\"PICO_CONNECT_PROBE_OFF\"], 0)\n            assert_pico_ok(status[\"setChannel\"])\n            \n            #for i in range(4):\n            print(f\"Channel {i}:\")\n            print(f\"  Connected: {probes[i].connected}\")\n            print(f\"  probeName: {probes[i].probeName}\")\n            #print(f\"  Status: {probes[i].status}\")\n            print(f\"  Coupling: {probes[i].couplingCurrent_}\")\n                # Add more fields as needed      \n    time.sleep(0.1)\n\n#status[\"trigger\"] = ps.ps4000aSetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 100)\n#assert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 25000\npostTriggerSamples = 25000\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 400\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferCMax = (ctypes.c_int16 * maxSamples)()\nbufferCMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferDMax = (ctypes.c_int16 * maxSamples)()\nbufferDMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\nstatus[\"setDataBuffersC\"] = ps.ps4000aSetDataBuffers(chandle, 2, ctypes.byref(bufferCMax), ctypes.byref(bufferCMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersC\"])\n\nstatus[\"setDataBuffersD\"] = ps.ps4000aSetDataBuffers(chandle, 3, ctypes.byref(bufferDMax), ctypes.byref(bufferDMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersD\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# Scale for ps.PICO_CONNECT_PROBE_RANGE[\"PICO_CURRENT_CLAMP_40A_5A\"] range -> scale to +/-5A\n# adc2ProbeRangeChAMax = [(float(x) * 5 ) / float(maxADC.value) for x in float(bufferAMax)]\n# Just use adc2mVpl1000() to do this, and pass the range value scale to.\n\n# Just scale to 100 for percentage, for this demo\nadc2ProbeRangeChAMax = adc2mVpl1000(bufferAMax, 100 , maxADC)\nadc2ProbeRangeChBMax = adc2mVpl1000(bufferBMax, 100 , maxADC)\nadc2ProbeRangeChCMax = adc2mVpl1000(bufferCMax, 100 , maxADC)\nadc2ProbeRangeChDMax = adc2mVpl1000(bufferDMax, 100 , maxADC)\n# NICE TO HAVE A FUNCTION AND LOOK TABLE/ARRAY TO TRANSLATE PROBE ENUMS TO SCALING VALUES, rather than passing in constant above.\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data\nplt.plot(time, adc2ProbeRangeChAMax[:])\nplt.plot(time, adc2ProbeRangeChBMax[:])\nplt.plot(time, adc2ProbeRangeChCMax[:])\nplt.plot(time, adc2ProbeRangeChDMax[:])\n\nplt.xlabel('Time (ns)')\nplt.ylabel('Channel range (+/-100%)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps4000aExamples/ps4824BlockExample.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example opens a 4000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps4000a import ps4000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 4000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps4000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS4000a_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchARange = 7\nstatus[\"setChA\"] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS4000a_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchBRange = 7\nstatus[\"setChB\"] = ps.ps4000aSetChannel(chandle, 1, 1, 1, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up channel C\n# handle = chandle\n# channel = PS4000a_CHANNEL_C = 2\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchCRange = 7\nstatus[\"setChC\"] = ps.ps4000aSetChannel(chandle, 2, 0, 1, chCRange, 0)\nassert_pico_ok(status[\"setChC\"])\n\n# Set up channel D\n# handle = chandle\n# channel = PS4000a_CHANNEL_D = 3\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchDRange = 7\nstatus[\"setChD\"] = ps.ps4000aSetChannel(chandle, 3, 0, 1, chDRange, 0)\nassert_pico_ok(status[\"setChD\"])\n\n# Set up channel E\n# handle = chandle\n# channel = PS4000a_CHANNEL_E = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchERange = 7\nstatus[\"setChE\"] = ps.ps4000aSetChannel(chandle, 4, 0, 1, chERange, 0)\nassert_pico_ok(status[\"setChE\"])\n\n# Set up channel F\n# handle = chandle\n# channel = PS4000a_CHANNEL_F = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchFRange = 7\nstatus[\"setChF\"] = ps.ps4000aSetChannel(chandle, 5, 0, 1, chFRange, 0)\nassert_pico_ok(status[\"setChF\"])\n\n# Set up channel G\n# handle = chandle\n# channel = PS4000a_CHANNEL_G = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchGRange = 7\nstatus[\"setChG\"] = ps.ps4000aSetChannel(chandle, 6, 0, 1, chGRange, 0)\nassert_pico_ok(status[\"setChG\"])\n\n# Set up channel H\n# handle = chandle\n# channel = PS4000a_CHANNEL_H = 1\n# enabled = 1\n# coupling type = PS4000a_DC = 1\n# range = PS4000a_2V = 7\n# analogOffset = 0 V\nchHRange = 7\nstatus[\"setChH\"] = ps.ps4000aSetChannel(chandle, 7, 0, 1, chHRange, 0)\nassert_pico_ok(status[\"setChH\"])\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\n# source = PS4000a_CHANNEL_A = 0\n# threshold = 1024 ADC counts\n# direction = PS4000a_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps4000aSetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 100)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# WARNING: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\noversample = ctypes.c_int16(1)\nstatus[\"getTimebase2\"] = ps.ps4000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 3 = 80 ns = timebase (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps4000aIsReady rather than ps4000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps4000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS4000a_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS4000a_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segementIndex = 0\n# mode = PS4000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps4000aSetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0 , 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS4000a_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps4000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps4000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps5000Examples/ps5000BlockExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000 BLOCK MODE EXAMPLE\n# This example opens a 5000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000 import ps5000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000OpenUnit(ctypes.byref(chandle))\nassert_pico_ok(status[\"openunit\"])\n\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = 1 # DC\nchARange = ps.PS5000_RANGE[\"PS5000_20V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000SetChannel(chandle, channel, 1, coupling_type, chARange)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\nchannel = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_B\"]\n# enabled = 1\n# coupling_type = ps.PS5000_COUPLING[\"PS5000_DC\"]\nchBRange = ps.PS5000_RANGE[\"PS5000_2V\"]\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000SetChannel(chandle, channel, 1, coupling_type, chBRange)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32512)\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\nsource = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_A\"]\nthreshold = int(mV2adc(500,chARange, maxADC))\n# direction = PS5000_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps5000SetSimpleTrigger(chandle, 1, source, threshold, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\ntimebase = 8\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\noversample = 1\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimeIntervalns = ctypes.c_long()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase\"] = ps.ps5000GetTimebase(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), oversample, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# oversample = 1\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps5000IsReady rather than ps5000BlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps5000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, oversample, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000IsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000IsReady(chandle, ctypes.byref(ready))\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\nsource = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_A\"]\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\nstatus[\"setDataBuffersA\"] = ps.ps5000SetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\nsource = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_B\"]\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000SetDataBuffers(chandle, source, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS5000_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps5000GetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"]=ps.ps5000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)\n"
  },
  {
    "path": "ps5000Examples/ps5000RapidBlockExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps5000 RAPID BLOCK MODE EXAMPLE\n# This example opens a 5000 driver device, sets up one channel and a trigger then collects 10 block of data in rapid succession.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps5000 import ps5000 as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps5000OpenUnit(ctypes.byref(chandle))\nassert_pico_ok(status[\"openunit\"])\n\n\n# Displays the serial number and handle\nprint(chandle.value)\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = 1 # DC\nchARange = ps.PS5000_RANGE[\"PS5000_5V\"]\nstatus[\"setChA\"] = ps.ps5000SetChannel(chandle, channel, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n\n# Finds the max ADC count\n# Handle = chandle\n# Value = ctype.byref(maxADC)\nmaxADC = ctypes.c_int16(32512)\n\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\nsource = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_A\"]\nthreshold = int(mV2adc(500,chARange, maxADC))\n# direction = PS5000_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps5000SetSimpleTrigger(chandle, 1, source, threshold, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 400\npostTriggerSamples = 400\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\ntimebase = 2\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimeIntervalns = ctypes.c_float()\noversample = 1\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps5000GetTimebase(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), oversample, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Handle = Chandle\n# nSegments = 10\n# nMaxSamples = ctypes.byref(cmaxSamples)\nstatus[\"MemorySegments\"] = ps.ps5000MemorySegments(chandle, 10, ctypes.byref(cmaxSamples))\nassert_pico_ok(status[\"MemorySegments\"])\n\n# sets number of captures\nstatus[\"SetNoOfCaptures\"] = ps.ps5000SetNoOfCaptures(chandle, 10)\nassert_pico_ok(status[\"SetNoOfCaptures\"])\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps5000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, oversample, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\nsource = ps.PS5000_CHANNEL[\"PS5000_CHANNEL_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax1 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 1\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), maxsamples, 1)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax2 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 2\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), maxsamples, 2)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax3 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 3\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), maxsamples, 3)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax4 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 4\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), maxsamples, 4)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax5 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 5\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), maxsamples, 5)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax6 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 6\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), maxsamples, 6)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax7 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 7\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), maxsamples, 7)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax8 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 8\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), maxsamples, 8)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax9 = (ctypes.c_int16 * maxsamples)()\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000_CHANNEL[\"ps5000_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer length = maxsamples\n# Segment index = 9\nstatus[\"SetDataBuffers\"] = ps.ps5000SetDataBufferBulk(chandle, source, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), maxsamples, 9)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000IsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# noOfSamples = ctypes.byref(cmaxSamples)\n# fromSegmentIndex = 0\n# ToSegmentIndex = 9\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValuesBulk\"] = ps.ps5000GetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValuesBulk\"])\n\n# Handle = chandle\n# Times = Times = (ctypes.c_int16*10)() = ctypes.byref(Times)\n# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)\n# Fromsegmentindex = 0\n# Tosegementindex = 9\nTimes = (ctypes.c_int16*10)()\nTimeUnits = ctypes.c_char()\nstatus[\"GetValuesTriggerTimeOffsetBulk\"] = ps.ps5000GetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)\nassert_pico_ok(status[\"GetValuesTriggerTimeOffsetBulk\"])\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChAMax1 =  adc2mV(bufferAMax1, chARange, maxADC)\nadc2mVChAMax2 =  adc2mV(bufferAMax2, chARange, maxADC)\nadc2mVChAMax3 =  adc2mV(bufferAMax3, chARange, maxADC)\nadc2mVChAMax4 =  adc2mV(bufferAMax4, chARange, maxADC)\nadc2mVChAMax5 =  adc2mV(bufferAMax5, chARange, maxADC)\nadc2mVChAMax6 =  adc2mV(bufferAMax6, chARange, maxADC)\nadc2mVChAMax7 =  adc2mV(bufferAMax7, chARange, maxADC)\nadc2mVChAMax8 =  adc2mV(bufferAMax8, chARange, maxADC)\nadc2mVChAMax9 =  adc2mV(bufferAMax9, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChAMax1[:])\nplt.plot(time, adc2mVChAMax2[:])\nplt.plot(time, adc2mVChAMax3[:])\nplt.plot(time, adc2mVChAMax4[:])\nplt.plot(time, adc2mVChAMax5[:])\nplt.plot(time, adc2mVChAMax6[:])\nplt.plot(time, adc2mVChAMax7[:])\nplt.plot(time, adc2mVChAMax8[:])\nplt.plot(time, adc2mVChAMax9[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps5000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps5000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\n#print(status)\n\n\n"
  },
  {
    "path": "ps5000Examples/ps5000StreamingExample.py",
    "content": "#\n# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000 Series STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps5000 driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000 import ps5000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 5000 Series device\nstatus[\"openunit\"] = ps.ps5000OpenUnit(ctypes.byref(chandle))\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000ChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000ChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\nenabled = 1\ndisabled = 0\ncoupling_type = 1\n\n# Set up channel A\n# handle = chandle\n# channel = PS5000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS5000A_DC = 1\n# range = PS5000A_2V = 7\nchannel_range = ps.PS5000_RANGE[\"PS5000_2V\"]\nstatus[\"setChA\"] = ps.ps5000SetChannel(chandle,\n                                        ps.PS5000_CHANNEL['PS5000_CHANNEL_A'],\n                                        enabled,\n                                        coupling_type,\n                                        channel_range)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS5000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS5000A_DC = 1\n# range = PS5000A_2V = 7\n\nstatus[\"setChB\"] = ps.ps5000SetChannel(chandle,\n                                        ps.PS5000_CHANNEL['PS5000_CHANNEL_B'],\n                                        enabled,\n                                        coupling_type,\n                                        channel_range)\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 10000\nnumBuffersToCapture = 10\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\nmemory_segment = 0\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS5000_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# buffer length = maxSamples\nstatus[\"setDataBuffersA\"] = ps.ps5000SetDataBuffers(chandle,\n                                                     ps.PS5000_CHANNEL['PS5000_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer\n                                                     )\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS5000_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# buffer length = maxSamples\nstatus[\"setDataBuffersB\"] = ps.ps5000SetDataBuffers(chandle,\n                                                     ps.PS5000_CHANNEL['PS5000_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(200)\nsampleUnits = ps.PS5000_TIME_UNITS['PS5000_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps5000RunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps5000GetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32767)\n#status[\"maximumValue\"] = ps.ps5000MaximumValue(chandle, ctypes.byref(maxADC))\n#assert_pico_ok(status[\"maximumValue\"])\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples - 1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps5000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockAdvancedTriggerExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This example opens a 5000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000a import ps5000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Resolution set to 12 Bit\nresolution =ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_12BIT\"]\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, resolution)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchARange = ps.PS5000A_RANGE[\"PS5000A_20V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# enabled = 1\n# coupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchBRange = ps.PS5000A_RANGE[\"PS5000A_2V\"]\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Set up an advanced trigger\nadcTriggerLevelA = mV2adc(500, chARange, maxADC)\nadcTriggerLevelB = mV2adc(500, chARange, maxADC)\nadcTriggerLevelC = mV2adc(500, chARange, maxADC)\nadcTriggerLevelD = mV2adc(500, chARange, maxADC)\n\ntriggerProperties = (ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 * 4)()\ntriggerProperties[0] = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevelA,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"])\n                                                            \ntriggerProperties[1] = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevelB,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"])\n                                                            \ntriggerProperties[2] = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevelC,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_C\"])\n                                                            \ntriggerProperties[3] = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevelD,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_D\"])\n                                                           \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\nstatus[\"setTriggerChannelPropertiesV2\"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, ctypes.byref(triggerProperties), 4, 0)\nassert_pico_ok(status[\"setTriggerChannelPropertiesV2\"])\n\ntriggerConditionsA = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"],\n                                                           ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\ntriggerConditionsB = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"],\n                                                           ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\ntriggerConditionsC = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_C\"],\n                                                           ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\ntriggerConditionsD = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_D\"],\n                                                           ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\nclear = 1\nadd = 2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \nstatus[\"setTriggerChannelConditionsV2_A\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditionsA), 1, (clear + add))\nassert_pico_ok(status[\"setTriggerChannelConditionsV2_A\"])\nstatus[\"setTriggerChannelConditionsV2_B\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditionsB), 1, (add))\nassert_pico_ok(status[\"setTriggerChannelConditionsV2_B\"])\nstatus[\"setTriggerChannelConditionsV2_C\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditionsC), 1, (add))\nassert_pico_ok(status[\"setTriggerChannelConditionsV2_C\"])\nstatus[\"setTriggerChannelConditionsV2_D\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditionsD), 1, (add))\nassert_pico_ok(status[\"setTriggerChannelConditionsV2_D\"])\n\n\ntriggerDirections = (ps.PS5000A_DIRECTION * 4)()\ntriggerDirections[0] = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"], \n                                                            ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_RISING\"], \n                                                            ps.PS5000A_THRESHOLD_MODE[\"PS5000A_LEVEL\"])\ntriggerDirections[1] = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"], \n                                                            ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_RISING\"], \n                                                            ps.PS5000A_THRESHOLD_MODE[\"PS5000A_LEVEL\"])\ntriggerDirections[2] = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_C\"], \n                                                            ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_RISING\"], \n                                                            ps.PS5000A_THRESHOLD_MODE[\"PS5000A_LEVEL\"])\ntriggerDirections[3] = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_D\"], \n                                                            ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_RISING\"], \n                                                            ps.PS5000A_THRESHOLD_MODE[\"PS5000A_LEVEL\"])\nstatus[\"setTriggerChannelDirections\"] = ps.ps5000aSetTriggerChannelDirectionsV2(chandle, ctypes.byref(triggerDirections), 4)\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\ntimebase = 8\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps5000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps5000aIsReady rather than ps5000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps5000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS5000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"]=ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockCallbackExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This example opens a 5000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000a import ps5000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\nfrom picosdk.constants import PICO_STATUS\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Resolution set to 12 Bit\nresolution =ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_12BIT\"]\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, resolution)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchARange = ps.PS5000A_RANGE[\"PS5000A_20V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# enabled = 1\n# coupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchBRange = ps.PS5000A_RANGE[\"PS5000A_2V\"]\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\nthreshold = int(mV2adc(500,chARange, maxADC))\n# direction = PS5000A_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps5000aSetSimpleTrigger(chandle, 1, source, threshold, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\ntimebase = 8\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps5000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# setup callback function\nready = False\n\ndef block_callback(handle, statusCallback, param):\n    global wasCalledBack, ready\n    wasCalledBack = True\n    if statusCallback != PICO_STATUS['PICO_CANCELLED']:\n       ready = True\n    \n# Convert the python function into a C function pointer.\ncFuncPtr = ps.BlockReadyType(block_callback)\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = cFuncPtr\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps5000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, cFuncPtr, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\ncheck = ctypes.c_int16(0)\nwhile ready == False:\n    time.sleep(0.01)\n    \nprint(\"Capture finished\")\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS5000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"]=ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This example opens a 5000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000a import ps5000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Resolution set to 12 Bit\nresolution =ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_12BIT\"]\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, resolution)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\nchannelA = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchARange = ps.PS5000A_RANGE[\"PS5000A_2V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle, channelA, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\nchannelB = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# enabled = 1\n# coupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchBRange = ps.PS5000A_RANGE[\"PS5000A_2V\"]\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000aSetChannel(chandle, channelB, 1, coupling_type, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Set up simple trigger\n# handle = chandle\n# enabled = 1\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\nthreshold = int(mV2adc(500,chARange, maxADC))\n# direction = PS5000A_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps5000aSetSimpleTrigger(chandle, 1, source, threshold, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\ntimebase = 8\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps5000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps5000aIsReady rather than ps5000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps5000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS5000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"]=ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockLevelPulseWidthAdvancedTriggerExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This example opens a 5000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000a import ps5000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\nimport math\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Resolution set to 12 Bit\nresolution =ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_12BIT\"]\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, resolution)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchARange = ps.PS5000A_RANGE[\"PS5000A_20V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# enabled = 1\n# coupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchBRange = ps.PS5000A_RANGE[\"PS5000A_2V\"]\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\ntimebase = 8\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\n\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps5000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Set up an advanced trigger\nadcTriggerLevel = mV2adc(500, chARange, maxADC)\n\ntriggerProperties = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"])\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\nstatus[\"setTriggerChannelPropertiesV2\"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, ctypes.byref(triggerProperties), 1, 0)\nassert_pico_ok(status[\"setTriggerChannelPropertiesV2\"])\n\ntriggerConditions = (ps.PS5000A_CONDITION * 2)()\n# triggerConditions[0] = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"],\n                                                           # ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\ntriggerConditions = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_PULSE_WIDTH_SOURCE\"],\n                                                           ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\n\nclear = 1\nadd = 2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \nstatus[\"setTriggerChannelConditionsV2\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditions), 1, (clear|add))\nassert_pico_ok(status[\"setTriggerChannelConditionsV2\"])\n\ntriggerDirections = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"], \n                                                            ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_RISING\"], \n                                                            ps.PS5000A_THRESHOLD_MODE[\"PS5000A_LEVEL\"])\n\nstatus[\"setTriggerChannelDirections\"] = ps.ps5000aSetTriggerChannelDirectionsV2(chandle, ctypes.byref(triggerDirections), 1)\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n# pulse width setup\n# pulse width conditions\nPWQConditions = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"], ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\n\nstatus[\"setPWQualifierConditions\"] = ps.ps5000aSetPulseWidthQualifierConditions(chandle, ctypes.byref(PWQConditions), 1, add)\nassert_pico_ok(status[\"setPWQualifierConditions\"])\n\n\n#set pulse width counter \ntimeWidthNs = 3000 \ncounterSamples = math.ceil(timeWidthNs / timeIntervalns.value)\n\n# pulse width properties\nPWtype = 2 #ps.PS5000A_PULSE_WIDTH_TYPE[\"PS5000A_PW_TYPE_GREATER_THAN\"]\nstatus[\"setPWQualifierProperties\"] = ps.ps5000aSetPulseWidthQualifierProperties(chandle, counterSamples, counterSamples, PWtype)\nassert_pico_ok(status[\"setPWQualifierProperties\"])\n\n#pulse width directions\nPWQDirections = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"], ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_FALLING\"], ps.PS5000A_THRESHOLD_MODE[\"PS5000A_LEVEL\"])\nstatus[\"setPWQualifierDirections\"] = ps.ps5000aSetPulseWidthQualifierDirections(chandle, ctypes.byref(PWQDirections), 1)\nassert_pico_ok(status[\"setPWQualifierDirections\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps5000aIsReady rather than ps5000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps5000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS5000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"]=ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockMSOExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 5000 Series (A API) MSO Block Mode Example\n# This example demonstrates how to use the PicoScope 5000 Series (ps5000a) driver API functions in order to do the\n# following:\n#\n# Open a connection to a PicoScope 5000 Series MSO device\n# Setup a digital port\n# Collect a block of data\n# Plot data\n\nimport ctypes\nfrom picosdk.ps5000a import ps5000a as ps\nfrom picosdk.functions import splitMSODataFast, assert_pico_ok\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Gives the device a handle\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_8BIT\"])\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n    # powerstate becomes the status number of openunit\n    powerstate = status[\"openunit\"]\n\n    # If powerstate is the same as 282 then it will run this if statement\n    if powerstate == 282:\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\n        status[\"ChangePowerSource\"] = ps.ps5000aChangePowerSource(chandle, 282)\n    # If the powerstate is the same as 286 then it will run this if statement\n    elif powerstate == 286:\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\n        status[\"ChangePowerSource\"] = ps.ps5000aChangePowerSource(chandle, 286)\n    else:\n        raise\n\n    assert_pico_ok(status[\"ChangePowerSource\"])\n\n\ndigital_port0 = ps.PS5000A_CHANNEL[\"PS5000A_DIGITAL_PORT0\"]\n# Set up digital port\n# handle = chandle\n# channel = ps5000a_DIGITAL_PORT0 = 0x80\n# enabled = 1\n# logicLevel = 10000\nstatus[\"SetDigitalPort\"] = ps.ps5000aSetDigitalPort( chandle, digital_port0, 1, 10000)\nassert_pico_ok(status[\"SetDigitalPort\"])\n\n#Set a trigger on digital channel\n\n\n# Set the number of sample to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase information\n# handle = chandle\n# timebase = 1252\n# Nosample = totalSamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 1252\ntimeIntervalNs = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps5000aGetTimebase2(chandle,\n                                               timebase,\n                                               totalSamples,\n                                               ctypes.byref(timeIntervalNs),                                             \n                                               ctypes.byref(returnedMaxSamples),\n                                               0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferDPort0Max = (ctypes.c_int16 * totalSamples)()\nbufferDPort0Min = (ctypes.c_int16 * totalSamples)()\n\n# Set the data buffer location for data collection from ps5000a_DIGITAL_PORT0\n# handle = chandle\n# source = ps5000a_DIGITAL_PORT0 = 0x80\n# Buffer max = ctypes.byref(bufferDPort0Max)\n# Buffer min = ctypes.byref(bufferDPort0Min)\n# Buffer length = totalSamples\n# Segment index = 0\n# Ratio mode = ps5000a_RATIO_MODE_NONE = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle,\n                                                    0x80,\n                                                    ctypes.byref(bufferDPort0Max),\n                                                    ctypes.byref(bufferDPort0Min),\n                                                    totalSamples,\n                                                    0,\n                                                    0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\nprint (\"Starting data collection...\")\n\n# Starts the block capture\n# handle = chandle\n# Number of preTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 1252 = 10000 ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps5000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        None,\n                                        0,\n                                        None,\n                                        None)\nassert_pico_ok(status[\"runblock\"])\n\n# Creates a overflow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\n\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# start index = 0\n# noOfSamples = ctypes.byref(cTotalSamples)\n# DownSampleRatio = 1\n# DownSampleRatioMode = 0\n# SegmentIndex = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 1, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValues\"])\n\nprint (\"Data collection complete.\")\n\n# Obtain binary for Digital Port 0\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\nbufferDPort0 = splitMSODataFast(cTotalSamples, bufferDPort0Max)\n\n# Creates the time data\ntime = np.linspace(0, (cTotalSamples.value - 1) * timeIntervalNs.value, cTotalSamples.value)\n\nprint (\"Plotting data...\")\n\n# Plot the data from digital channels onto a graph\n\nplt.figure(num='PicoScope 3000 Series (A API) MSO Block Capture Example')\nplt.title('Plot of Digital Port 0 digital channels vs. time')\nplt.plot(time, bufferDPort0[0], label='D7')  # D7 is the first array in the tuple.\nplt.plot(time, bufferDPort0[1], label='D6')\nplt.plot(time, bufferDPort0[2], label='D5')\nplt.plot(time, bufferDPort0[3], label='D4')\nplt.plot(time, bufferDPort0[4], label='D3')\nplt.plot(time, bufferDPort0[5], label='D2')\nplt.plot(time, bufferDPort0[6], label='D1')\nplt.plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\nplt.xlabel('Time (ns)')\nplt.ylabel('Logic Level')\nplt.legend(loc=\"upper right\")\nplt.show()\n\nprint (\"Close figure to stop the device and close the connection.\")\n\n# Stops the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# handle = chandle\nstatus[\"closeUnit\"] = ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"closeUnit\"])\n\n# Displays the status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockMSOTriggerExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 5000 Series (A API) MSO Block Mode Triggered Example\n# This example demonstrates how to use the PicoScope 5000 Series (ps5000a) driver API functions in order to do the\n# following:\n#\n# Open a connection to a PicoScope 5000 Series MSO device\n# Setup a digital port\n# Set up a digital trigger\n# Collect a block of data\n# Plot data\n\nimport ctypes\nfrom picosdk.ps5000a import ps5000a as ps\nfrom picosdk.functions import splitMSODataFast, assert_pico_ok\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Gives the device a handle\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_8BIT\"])\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept:\n    # powerstate becomes the status number of openunit\n    powerstate = status[\"openunit\"]\n\n    # If powerstate is the same as 282 then it will run this if statement\n    if powerstate == 282:\n        # Changes the power input to \"PICO_POWER_SUPPLY_NOT_CONNECTED\"\n        status[\"ChangePowerSource\"] = ps.ps5000aChangePowerSource(chandle, 282)\n    # If the powerstate is the same as 286 then it will run this if statement\n    elif powerstate == 286:\n        # Changes the power input to \"PICO_USB3_0_DEVICE_NON_USB3_0_PORT\"\n        status[\"ChangePowerSource\"] = ps.ps5000aChangePowerSource(chandle, 286)\n    else:\n        raise\n\n    assert_pico_ok(status[\"ChangePowerSource\"])\n\n\ndigital_port0 = ps.PS5000A_CHANNEL[\"PS5000A_DIGITAL_PORT0\"]\n# Set up digital port\n# handle = chandle\n# channel = ps5000a_DIGITAL_PORT0 = 0x80\n# enabled = 1\n# logicLevel = 10000\nstatus[\"SetDigitalPort\"] = ps.ps5000aSetDigitalPort( chandle, digital_port0, 1, 10000)\nassert_pico_ok(status[\"SetDigitalPort\"])\n\n#Set a trigger on digital channel\n\n\n# Set the number of sample to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\ntotalSamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 1252\n# Nosample = totalSamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalNs)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 1252\ntimeIntervalNs = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps5000aGetTimebase2(chandle,\n                                               timebase,\n                                               totalSamples,\n                                               ctypes.byref(timeIntervalNs),                                             \n                                               ctypes.byref(returnedMaxSamples),\n                                               0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferDPort0Max = (ctypes.c_int16 * totalSamples)()\nbufferDPort0Min = (ctypes.c_int16 * totalSamples)()\n\n# Set the data buffer location for data collection from ps5000a_DIGITAL_PORT0\n# handle = chandle\n# source = ps5000a_DIGITAL_PORT0 = 0x80\n# Buffer max = ctypes.byref(bufferDPort0Max)\n# Buffer min = ctypes.byref(bufferDPort0Min)\n# Buffer length = totalSamples\n# Segment index = 0\n# Ratio mode = ps5000a_RATIO_MODE_NONE = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle,\n                                                    0x80,\n                                                    ctypes.byref(bufferDPort0Max),\n                                                    ctypes.byref(bufferDPort0Min),\n                                                    totalSamples,\n                                                    0,\n                                                    0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# set the digital trigger for a high bit on digital channel 0\nconditions = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_DIGITAL_PORT0\"], ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\nnConditions = 1\nclear = 1\nadd = 2\ninfo = clear + add\nstatus[\"setTriggerChannelConditionsV2\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle,\n                                                                                  ctypes.byref(conditions),\n                                                                                  nConditions,\n                                                                                  info)\nassert_pico_ok(status[\"setTriggerChannelConditionsV2\"])\n\ndirections = ps.PS5000A_DIGITAL_CHANNEL_DIRECTIONS(ps.PS5000A_DIGITAL_CHANNEL[\"PS5000A_DIGITAL_CHANNEL_0\"], ps.PS5000A_DIGITAL_DIRECTION[\"PS5000A_DIGITAL_DIRECTION_HIGH\"])\nnDirections = 1\nstatus[\"setTriggerDigitalPortProperties\"] = ps.ps5000aSetTriggerDigitalPortProperties(chandle,\n                                                                                      ctypes.byref(directions),\n                                                                                      nDirections)\nassert_pico_ok(status[\"setTriggerDigitalPortProperties\"])\n\n# set autotrigger timeout value\nstatus[\"autoTriggerus\"] = ps.ps5000aSetAutoTriggerMicroSeconds(chandle, 10000)\nassert_pico_ok(status[\"autoTriggerus\"])\n\nprint (\"Starting data collection...\")\n\n# Starts the block capture\n# handle = chandle\n# Number of preTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 1252 = 10000 ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps5000aRunBlock(chandle,\n                                        preTriggerSamples,\n                                        postTriggerSamples,\n                                        timebase,\n                                        None,\n                                        0,\n                                        None,\n                                        None)\nassert_pico_ok(status[\"runblock\"])\n\n# Creates a overflow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types totalSamples\ncTotalSamples = ctypes.c_int32(totalSamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\n\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# start index = 0\n# noOfSamples = ctypes.byref(cTotalSamples)\n# DownSampleRatio = 1\n# DownSampleRatioMode = 0\n# SegmentIndex = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cTotalSamples), 1, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValues\"])\n\nprint (\"Data collection complete.\")\n\n# Obtain binary for Digital Port 0\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\nbufferDPort0 = splitMSODataFast(cTotalSamples, bufferDPort0Max)\n\n# Creates the time data\ntime = np.linspace(0, (cTotalSamples.value - 1) * timeIntervalNs.value, cTotalSamples.value)\n\nprint (\"Plotting data...\")\n\n# Plot the data from digital channels onto a graph\n\nplt.figure(num='PicoScope 3000 Series (A API) MSO Block Capture Example')\nplt.title('Plot of Digital Port 0 digital channels vs. time')\nplt.plot(time, bufferDPort0[0], label='D7')  # D7 is the first array in the tuple.\nplt.plot(time, bufferDPort0[1], label='D6')\nplt.plot(time, bufferDPort0[2], label='D5')\nplt.plot(time, bufferDPort0[3], label='D4')\nplt.plot(time, bufferDPort0[4], label='D3')\nplt.plot(time, bufferDPort0[5], label='D2')\nplt.plot(time, bufferDPort0[6], label='D1')\nplt.plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\nplt.xlabel('Time (ns)')\nplt.ylabel('Logic Level')\nplt.legend(loc=\"upper right\")\nplt.show()\n\nprint (\"Close figure to stop the device and close the connection.\")\n\n# Stops the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# handle = chandle\nstatus[\"closeUnit\"] = ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"closeUnit\"])\n\n# Displays the status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockWindowPulseWidthAdvancedTriggerExample.py",
    "content": "#\n# Copyright (C) 2018-2023 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE WINDOW PULSE WIDTH ADVANCED TRIGGER EXAMPLE\n# This example opens a 5000a driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000a import ps5000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\nimport math\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 5000 series PicoScope\n# Resolution set to 12 Bit\nresolution =ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_12BIT\"]\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, resolution)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchARange = ps.PS5000A_RANGE[\"PS5000A_20V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# enabled = 1\n# coupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchBRange = ps.PS5000A_RANGE[\"PS5000A_2V\"]\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chBRange, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\ntimebase = 8\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\n\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps5000aGetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Set up an advanced trigger\nadcTriggerLevel = mV2adc(500, chARange, maxADC)\n\ntriggerProperties = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"])\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\nstatus[\"setTriggerChannelPropertiesV2\"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, ctypes.byref(triggerProperties), 1, 0)\nassert_pico_ok(status[\"setTriggerChannelPropertiesV2\"])\n\ntriggerConditions = (ps.PS5000A_CONDITION * 2)()\n# triggerConditions[0] = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"],\n                                                           # ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\ntriggerConditions = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_PULSE_WIDTH_SOURCE\"],\n                                                           ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\n\nclear = 1\nadd = 2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \nstatus[\"setTriggerChannelConditionsV2\"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditions), 1, (clear|add))\nassert_pico_ok(status[\"setTriggerChannelConditionsV2\"])\n\ntriggerDirections = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"], \n                                                            ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_OUTSIDE\"], \n                                                            ps.PS5000A_THRESHOLD_MODE[\"PS5000A_WINDOW\"])\n\nstatus[\"setTriggerChannelDirections\"] = ps.ps5000aSetTriggerChannelDirectionsV2(chandle, ctypes.byref(triggerDirections), 1)\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\n# pulse width setup\n# pulse width conditions\nPWQConditions = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"], ps.PS5000A_TRIGGER_STATE[\"PS5000A_CONDITION_TRUE\"])\n\nstatus[\"setPWQualifierConditions\"] = ps.ps5000aSetPulseWidthQualifierConditions(chandle, ctypes.byref(PWQConditions), 1, add)\nassert_pico_ok(status[\"setPWQualifierConditions\"])\n\n\n#set pulse width counter \ntimeWidthNs = 3000 \ncounterSamples = math.ceil(timeWidthNs / timeIntervalns.value)\n\n# pulse width properties\nPWtype = 2 #ps.PS5000A_PULSE_WIDTH_TYPE[\"PS5000A_PW_TYPE_GREATER_THAN\"]\nstatus[\"setPWQualifierProperties\"] = ps.ps5000aSetPulseWidthQualifierProperties(chandle, counterSamples, counterSamples, PWtype)\nassert_pico_ok(status[\"setPWQualifierProperties\"])\n\n#pulse width directions\nPWQDirections = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL[\"PS5000A_PULSE_WIDTH_SOURCE\"], ps.PS5000A_THRESHOLD_DIRECTION[\"PS5000A_ENTER\"], ps.PS5000A_THRESHOLD_MODE[\"PS5000A_WINDOW\"])\nstatus[\"setPWQualifierDirections\"] = ps.ps5000aSetPulseWidthQualifierDirections(chandle, ctypes.byref(PWQDirections), 1)\nassert_pico_ok(status[\"setPWQualifierDirections\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps5000aIsReady rather than ps5000aBlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps5000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps5000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_B\"]\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0, 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 0\n# downsample ratio mode = PS5000A_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps5000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unit Disconnect the scope\n# handle = chandle\nstatus[\"close\"]=ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aRapidBlockExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps5000a RAPID BLOCK MODE EXAMPLE\n# This example opens a 5000a driver device, sets up one channel and a trigger then collects 10 block of data in rapid succession.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps5000a import ps5000a as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, 1)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n# Displays the serial number and handle\nprint(chandle.value)\n\n# Set up channel A\n# handle = chandle\nchannel = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# enabled = 1\ncoupling_type = ps.PS5000A_COUPLING[\"PS5000A_DC\"]\nchARange = ps.PS5000A_RANGE[\"PS5000A_20V\"]\n# analogue offset = 0 V\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chARange, 0)\nassert_pico_ok(status[\"setChA\"])\n\n\n# Finds the max ADC count\n# Handle = chandle\n# Value = ctype.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\n\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\nthreshold = int(mV2adc(500,chARange, maxADC))\n# direction = PS5000A_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps5000aSetSimpleTrigger(chandle, 1, source, threshold, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 400\npostTriggerSamples = 400\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\ntimebase = 2\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"GetTimebase\"] = ps.ps5000aGetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Handle = Chandle\n# nSegments = 10\n# nMaxSamples = ctypes.byref(cmaxSamples)\nstatus[\"MemorySegments\"] = ps.ps5000aMemorySegments(chandle, 10, ctypes.byref(cmaxSamples))\nassert_pico_ok(status[\"MemorySegments\"])\n\n# sets number of captures\nstatus[\"SetNoOfCaptures\"] = ps.ps5000aSetNoOfCaptures(chandle, 10)\nassert_pico_ok(status[\"SetNoOfCaptures\"])\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps5000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\nbufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\nsource = ps.PS5000A_CHANNEL[\"PS5000A_CHANNEL_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax1 = (ctypes.c_int16 * maxsamples)()\nbufferAMin1 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 1\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), maxsamples, 1, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax2 = (ctypes.c_int16 * maxsamples)()\nbufferAMin2 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 2\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), maxsamples, 2, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax3 = (ctypes.c_int16 * maxsamples)()\nbufferAMin3 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 3\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), maxsamples, 3, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax4 = (ctypes.c_int16 * maxsamples)()\nbufferAMin4 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 4\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), maxsamples, 4, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax5 = (ctypes.c_int16 * maxsamples)()\nbufferAMin5 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 5\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), maxsamples, 5, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax6 = (ctypes.c_int16 * maxsamples)()\nbufferAMin6 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 6\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), maxsamples, 6, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax7 = (ctypes.c_int16 * maxsamples)()\nbufferAMin7 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 7\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), maxsamples, 7, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax8 = (ctypes.c_int16 * maxsamples)()\nbufferAMin8 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 8\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), maxsamples, 8, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax9 = (ctypes.c_int16 * maxsamples)()\nbufferAMin9 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps.PS5000A_CHANNEL[\"ps5000a_channel_A\"]\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 9\n# Ratio mode = ps5000a_Ratio_Mode_None = 0\nstatus[\"SetDataBuffers\"] = ps.ps5000aSetDataBuffers(chandle, source, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), maxsamples, 9, 0)\nassert_pico_ok(status[\"SetDataBuffers\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps5000aIsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# noOfSamples = ctypes.byref(cmaxSamples)\n# fromSegmentIndex = 0\n# ToSegmentIndex = 9\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValuesBulk\"] = ps.ps5000aGetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValuesBulk\"])\n\n# Handle = chandle\n# Times = Times = (ctypes.c_int16*10)() = ctypes.byref(Times)\n# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)\n# Fromsegmentindex = 0\n# Tosegementindex = 9\nTimes = (ctypes.c_int64*10)()\nTimeUnits = ctypes.c_char()\nstatus[\"GetValuesTriggerTimeOffsetBulk\"] = ps.ps5000aGetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)\nassert_pico_ok(status[\"GetValuesTriggerTimeOffsetBulk\"])\n\n# Get and print TriggerInfo for memory segments\n# Create array of ps.PS5000A_TRIGGER_INFO for each memory segment\nTen_TriggerInfo = (ps.PS5000A_TRIGGER_INFO*10) ()\n\nstatus[\"GetTriggerInfoBulk\"] = ps.ps5000aGetTriggerInfoBulk(chandle, ctypes.byref(Ten_TriggerInfo), 0, 9)\nassert_pico_ok(status[\"GetTriggerInfoBulk\"])\n\nprint(\"Printing triggerInfo blocks\")\nfor i in Ten_TriggerInfo:\n    print(\"PICO_STATUS is \", i.status)\n    print(\"segmentIndex is \", i.segmentIndex)\n    print(\"triggerTime is \", i.triggerTime)\n    print(\"timeUnits is \", i.timeUnits)\n    print(\"timeStampCounter is \", i.timeStampCounter)\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChAMax1 =  adc2mV(bufferAMax1, chARange, maxADC)\nadc2mVChAMax2 =  adc2mV(bufferAMax2, chARange, maxADC)\nadc2mVChAMax3 =  adc2mV(bufferAMax3, chARange, maxADC)\nadc2mVChAMax4 =  adc2mV(bufferAMax4, chARange, maxADC)\nadc2mVChAMax5 =  adc2mV(bufferAMax5, chARange, maxADC)\nadc2mVChAMax6 =  adc2mV(bufferAMax6, chARange, maxADC)\nadc2mVChAMax7 =  adc2mV(bufferAMax7, chARange, maxADC)\nadc2mVChAMax8 =  adc2mV(bufferAMax8, chARange, maxADC)\nadc2mVChAMax9 =  adc2mV(bufferAMax9, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value - 1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChAMax1[:])\nplt.plot(time, adc2mVChAMax2[:])\nplt.plot(time, adc2mVChAMax3[:])\nplt.plot(time, adc2mVChAMax4[:])\nplt.plot(time, adc2mVChAMax5[:])\nplt.plot(time, adc2mVChAMax6[:])\nplt.plot(time, adc2mVChAMax7[:])\nplt.plot(time, adc2mVChAMax8[:])\nplt.plot(time, adc2mVChAMax9[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\n#print(status)\n\n\n"
  },
  {
    "path": "ps5000aExamples/ps5000aSigGen.py",
    "content": "#\r\n# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 5000 (A API) Signal Generator Example\r\n# This example demonstrates how to use the PicoScope 5000 Series (ps5000a) driver API functions to set up the signal generator to do the following:\r\n# \r\n# 1. Output a sine wave \r\n# 2. Output a square wave \r\n# 3. Output a sweep of a square wave signal\r\n\r\nimport ctypes\r\nfrom picosdk.ps5000a import ps5000a as ps\r\nimport time\r\nfrom picosdk.functions import assert_pico_ok\r\nimport numpy as np\r\nimport math\r\nimport matplotlib.pyplot as plt\r\n\r\n\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Open the device\r\nstatus[\"openUnit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, 1)\r\n\r\n\r\ntry:\r\n    assert_pico_ok(status[\"openUnit\"])\r\nexcept: # PicoNotOkError:\r\n\r\n    powerStatus = status[\"openUnit\"]\r\n\r\n    if powerStatus == 286:\r\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\r\n    elif powerStatus == 282:\r\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\r\n    else:\r\n        raise\r\n\r\n    assert_pico_ok(status[\"changePowerSource\"])\r\n\r\n# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(0) = PS5000A_SINE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS5000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS5000a_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = P5000a_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int32(0)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"setSigGenBuiltInV2\"] = ps.ps5000aSetSigGenBuiltInV2(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 0)\r\nassert_pico_ok(status[\"setSigGenBuiltInV2\"])\r\n\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS5000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS5000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\nwavetype = ctypes.c_int32(1)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"setSigGenBuiltInV2\"] = ps.ps5000aSetSigGenBuiltInV2(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 0)\r\nassert_pico_ok(status[\"setSigGenBuiltInV2\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with an up-down sweep, 10-100 kHz in 5 kHz increments every 1 second.\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS5000A_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 100 kHz\r\n# increment = 5 kHz\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS5000A_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\nwavetype = ctypes.c_int32(1)\r\nsweepType = ctypes.c_int32(2)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"setSigGenBuiltInV2\"] = ps.ps5000aSetSigGenBuiltInV2(chandle, 0, 2000000, wavetype, 10000, 100000, 5000, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 0)\r\nassert_pico_ok(status[\"setSigGenBuiltInV2\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(6)\r\n\r\n# create a custom waveform\r\nminValue = ctypes.c_int16(0)\r\nmaxValue = ctypes.c_int16(0)\r\nminSize = ctypes.c_int16(0)\r\nmaxSize = ctypes.c_int16(0)\r\nstatus[\"sigGenArbMinMax\"] = ps.ps5000aSigGenArbitraryMinMaxValues(chandle, ctypes.byref(minValue), ctypes.byref(maxValue),ctypes.byref(minSize),ctypes.byref(maxSize))\r\nassert_pico_ok(status[\"sigGenArbMinMax\"])\r\n\r\nawgBuffer = (np.sin(np.linspace(0,2*math.pi,10000)))*maxValue.value\r\nawgBuffer = awgBuffer.astype(ctypes.c_int16)\r\nawgbufferPointer = awgBuffer.ctypes.data_as(ctypes.POINTER(ctypes.c_int16))\r\n\r\n\r\n\r\n# convert 10 KHZ frequency to phase \r\nfreq = 10000\r\nindexMode = 0\r\nbufferLength = len(awgBuffer)\r\nphase = ctypes.c_int16(0)\r\nstatus[\"freqToPhase\"] = ps.ps5000aSigGenFrequencyToPhase(chandle, freq, indexMode, bufferLength, ctypes.byref(phase))\r\nassert_pico_ok(status[\"freqToPhase\"])\r\n\r\n# output custom waveform with peak-to-peak of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# startDeltaPhase = phase\r\n# stopDeltaPhase = phase\r\n# deltaPhaseIncrement = 0\r\n# dwellCount = 0\r\n# *arbitaryWaveform = awgbufferPointer\r\n# arbitaryWaveformSize = 1024\r\n# sweepType = ctypes.c_int32(0) \r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE\r\n# extInThreshold = 0\r\n\r\nstatus[\"setSigGenArbitrary\"] = ps.ps5000aSetSigGenArbitrary(chandle, 0, 3600000, phase.value, phase.value, 0, 0, awgbufferPointer, bufferLength, 0, 0, 0, 0, 0, 0, 0, 0)\r\nassert_pico_ok(status[\"setSigGenArbitrary\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Closes the unit\r\n# Handle = chandle\r\nstatus[\"close\"] = ps.ps5000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Displays the status returns\r\nprint(status)"
  },
  {
    "path": "ps5000aExamples/ps5000aStreamingExample.py",
    "content": "#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000 Series (A API) STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps5000a driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps5000a import ps5000a as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 5000 Series device\n# Resolution set to 12 Bit\nresolution =ps.PS5000A_DEVICE_RESOLUTION[\"PS5000A_DR_12BIT\"]\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, resolution)\n\ntry:\n    assert_pico_ok(status[\"openunit\"])\nexcept: # PicoNotOkError:\n\n    powerStatus = status[\"openunit\"]\n\n    if powerStatus == 286:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    elif powerStatus == 282:\n        status[\"changePowerSource\"] = ps.ps5000aChangePowerSource(chandle, powerStatus)\n    else:\n        raise\n\n    assert_pico_ok(status[\"changePowerSource\"])\n\n\nenabled = 1\ndisabled = 0\nanalogue_offset = 0.0\n\n# Set up channel A\n# handle = chandle\n# channel = PS5000A_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS5000A_DC = 1\n# range = PS5000A_2V = 7\n# analogue offset = 0 V\nchannel_range = ps.PS5000A_RANGE['PS5000A_2V']\nstatus[\"setChA\"] = ps.ps5000aSetChannel(chandle,\n                                        ps.PS5000A_CHANNEL['PS5000A_CHANNEL_A'],\n                                        enabled,\n                                        ps.PS5000A_COUPLING['PS5000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS5000A_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS5000A_DC = 1\n# range = PS5000A_2V = 7\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps5000aSetChannel(chandle,\n                                        ps.PS5000A_CHANNEL['PS5000A_CHANNEL_B'],\n                                        enabled,\n                                        ps.PS5000A_COUPLING['PS5000A_DC'],\n                                        channel_range,\n                                        analogue_offset)\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 500\nnumBuffersToCapture = 10\n\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\nmemory_segment = 0\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS5000A_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps5000aSetDataBuffers(chandle,\n                                                     ps.PS5000A_CHANNEL['PS5000A_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS5000A_RATIO_MODE['PS5000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS5000A_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS5000A_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps5000aSetDataBuffers(chandle,\n                                                     ps.PS5000A_CHANNEL['PS5000A_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     memory_segment,\n                                                     ps.PS5000A_RATIO_MODE['PS5000A_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(250)\nsampleUnits = ps.PS5000A_TIME_UNITS['PS5000A_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps5000aRunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                ps.PS5000A_RATIO_MODE['PS5000A_RATIO_MODE_NONE'],\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps5000aGetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16()\nstatus[\"maximumValue\"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC))\nassert_pico_ok(status[\"maximumValue\"])\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples - 1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps5000aStop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps5000aCloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)\n"
  },
  {
    "path": "ps6000Examples/ps6000BlockAdvancedTriggerExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 BLOCK MODE ADVANCED TRIGGER EXAMPLE\n# This example opens a 6000 driver device, sets up one channel and a window pulse width advanced trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps6000 import ps6000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 6000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS6000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS6000_DC = 1\n# range = PS6000_2V = 7\n# analogue offset = 0 V\n# bandwidth limiter = PS6000_BW_FULL = 0\nchARange = 7\nstatus[\"setChA\"] = ps.ps6000SetChannel(chandle, 0, 1, 1, chARange, 0, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up window pulse width trigger on A\ntriggerConditions = ps.PS6000_TRIGGER_CONDITIONS(ps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_TRUE\"],\n\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_TRUE\"])\nnTriggerConditions = 1\n\nstatus[\"setTriggerChannelConditions\"] = ps.ps6000SetTriggerChannelConditions(chandle, ctypes.byref(triggerConditions), nTriggerConditions)\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\n\nstatus[\"setTriggerChannelDirections\"] = ps.ps6000SetTriggerChannelDirections(chandle, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_DIRECTION[\"PS6000_INSIDE\"], \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_DIRECTION[\"PS6000_NONE\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_DIRECTION[\"PS6000_NONE\"], \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_DIRECTION[\"PS6000_NONE\"], \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_DIRECTION[\"PS6000_NONE\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_DIRECTION[\"PS6000_NONE\"])\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\n\nmaxADC = ctypes.c_int16(32512)\nthreshold = mV2adc(109.2, chARange, maxADC)\nhysteresis = mV2adc((109.2 * 0.015), chARange, maxADC)\nchannelProperties = ps.PS6000_TRIGGER_CHANNEL_PROPERTIES(threshold,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thysteresis,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(threshold * -1),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thysteresis,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_CHANNEL[\"PS6000_CHANNEL_A\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tps.PS6000_THRESHOLD_MODE[\"PS6000_WINDOW\"])\nnChannelProperties = 1\nauxOutputEnable = 0\nautoTriggerMilliseconds = 10000\nstatus[\"setTriggerChannelProperties\"] = ps.ps6000SetTriggerChannelProperties(chandle, ctypes.byref(channelProperties), nChannelProperties, auxOutputEnable, autoTriggerMilliseconds)\nassert_pico_ok(status[\"setTriggerChannelProperties\"])\n\npwqConditions = ps.PS6000_PWQ_CONDITIONS(ps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_TRUE\"],\n\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"],\n\t\t\t\t\t\t\t\t\t\tps.PS6000_TRIGGER_STATE[\"PS6000_CONDITION_DONT_CARE\"])\nnPwqConditions = 1\ndirection = ps.PS6000_THRESHOLD_DIRECTION[\"PS6000_RISING_OR_FALLING\"]\nupper = 390625 #samples at timebase 8 is 10 ms\nlower = upper\ntype = ps.PS6000_PULSE_WIDTH_TYPE[\"PS6000_PW_TYPE_GREATER_THAN\"]\nstatus[\"setPulseWidthQualifier\"] = ps.ps6000SetPulseWidthQualifier(chandle, ctypes.byref(pwqConditions), nPwqConditions, direction, lower, upper, type)\nassert_pico_ok(status[\"setPulseWidthQualifier\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 390625*2\npostTriggerSamples = 390625\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# oversample = 1\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps6000GetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# oversample = 0\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps6000IsReady rather than ps6000BlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps6000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 0, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps6000IsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps6000IsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS6000_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# ratio mode = PS6000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps6000SetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 1\n# downsample ratio mode = PS6000_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps6000GetValues(chandle, 0, ctypes.byref(cmaxSamples), 1, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# find maximum ADC count value\nmaxADC = ctypes.c_int16(32512)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value -1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A\nplt.plot(time, adc2mVChAMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\nstatus[\"stop\"] = ps.ps6000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nps.ps6000CloseUnit(chandle)\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps6000Examples/ps6000BlockExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 BLOCK MODE EXAMPLE\n# This example opens a 6000 driver device, sets up two channels and a trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps6000 import ps6000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 6000 series PicoScope\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Set up channel A\n# handle = chandle\n# channel = PS6000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS6000_DC = 1\n# range = PS6000_2V = 7\n# analogue offset = 0 V\n# bandwidth limiter = PS6000_BW_FULL = 0\nchARange = 7\nstatus[\"setChA\"] = ps.ps6000SetChannel(chandle, 0, 1, 1, chARange, 0, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS6000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS6000_DC = 1\n# range = PS6000_2V = 7\n# analogue offset = 0 V\n# bandwidth limiter = PS6000_BW_FULL = 0\nchBRange = 7\nstatus[\"setChB\"] = ps.ps6000SetChannel(chandle, 1, 1, 1, chBRange, 0, 0)\nassert_pico_ok(status[\"setChB\"])\n\n# Set up single trigger\n# handle = chandle\n# enabled = 1\n# source = PS6000_CHANNEL_A = 0\n# threshold = 64 ADC counts\n# direction = PS6000_RISING = 2\n# delay = 0 s\n# auto Trigger = 1000 ms\nstatus[\"trigger\"] = ps.ps6000SetSimpleTrigger(chandle, 1, 0, 64, 2, 0, 1000)\nassert_pico_ok(status[\"trigger\"])\n\n# Set number of pre and post trigger samples to be collected\npreTriggerSamples = 2500\npostTriggerSamples = 2500\nmaxSamples = preTriggerSamples + postTriggerSamples\n\n# Get timebase information\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# handle = chandle\n# timebase = 8 = timebase\n# noSamples = maxSamples\n# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# oversample = 1\n# pointer to maxSamples = ctypes.byref(returnedMaxSamples)\n# segment index = 0\ntimebase = 8\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int32()\nstatus[\"getTimebase2\"] = ps.ps6000GetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"getTimebase2\"])\n\n# Run block capture\n# handle = chandle\n# number of pre-trigger samples = preTriggerSamples\n# number of post-trigger samples = PostTriggerSamples\n# timebase = 8 = 80 ns (see Programmer's guide for mre information on timebases)\n# oversample = 0\n# time indisposed ms = None (not needed in the example)\n# segment index = 0\n# lpReady = None (using ps6000IsReady rather than ps6000BlockReady)\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps6000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 0, None, 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps6000IsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps6000IsReady(chandle, ctypes.byref(ready))\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxSamples)()\nbufferAMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\nbufferBMax = (ctypes.c_int16 * maxSamples)()\nbufferBMin = (ctypes.c_int16 * maxSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS6000_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# ratio mode = PS6000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps6000SetDataBuffers(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxSamples, 0)\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS6000_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# ratio mode = PS6000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps6000SetDataBuffers(chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), maxSamples, 0)\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# create overflow loaction\noverflow = ctypes.c_int16()\n# create converted type maxSamples\ncmaxSamples = ctypes.c_int32(maxSamples)\n\n# Retried data from scope to buffers assigned above\n# handle = chandle\n# start index = 0\n# pointer to number of samples = ctypes.byref(cmaxSamples)\n# downsample ratio = 1\n# downsample ratio mode = PS6000_RATIO_MODE_NONE\n# pointer to overflow = ctypes.byref(overflow))\nstatus[\"getValues\"] = ps.ps6000GetValues(chandle, 0, ctypes.byref(cmaxSamples), 1, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# find maximum ADC count value\nmaxADC = ctypes.c_int16(32512)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChBMax =  adc2mV(bufferBMax, chBRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (cmaxSamples.value -1) * timeIntervalns.value, cmaxSamples.value)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\nstatus[\"stop\"] = ps.ps6000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Close unitDisconnect the scope\n# handle = chandle\nps.ps6000CloseUnit(chandle)\n\n# display status returns\nprint(status)"
  },
  {
    "path": "ps6000Examples/ps6000GetInfoExample.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 GET INFO EXAMPLE\r\n# This example opens a 6000 driver device, gets the variant info and closes the scope.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000 import ps6000 as ps\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 series PicoScope\r\n# Returns handle to chandle for use in future API functions\r\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Get Info from scope\r\nstring = (ctypes.c_char * 40)()\r\nstringLength = ctypes.c_int16(40)\r\nrequiredSize = ctypes.c_int16(40)\r\ninfo = ps.PICO_INFO[\"PICO_VARIANT_INFO\"]\r\nstatus[\"getInfo\"] = ps.ps6000GetUnitInfo(chandle, ctypes.byref(string),stringLength, ctypes.byref(requiredSize), info)\r\nassert_pico_ok(status[\"getInfo\"])\r\n\r\nprint(string.value)\r\n\r\n# Close unitDisconnect the scope\r\n# handle = chandle\r\nps.ps6000CloseUnit(chandle)\r\n\r\n# display status returns\r\nprint(status)"
  },
  {
    "path": "ps6000Examples/ps6000RapidBlockExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps6000 RAPID BLOCK MODE EXAMPLE\n# This example opens a 6000 driver device, sets up one channel and a trigger then collects 10 block of data in rapid succession.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps6000 import ps6000 as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Displays the serial number and handle\nprint(chandle.value)\n\n# Set up channel A\n# handle = chandle\n# channel = ps6000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = ps6000_DC = 1\n# range = ps6000_10V = 8\n# analogue offset = 0 V\nchARange = 8\nstatus[\"setChA\"] = ps.ps6000SetChannel(chandle, 0, 1, 1, chARange, 0, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Sets up single trigger\n# Handle = Chandle\n# Enable = 1\n# Source = ps6000_channel_A = 0\n# Threshold = 1024 ADC counts\n# Direction = ps6000_Falling = 3\n# Delay = 0\n# autoTrigger_ms = 1000\nstatus[\"trigger\"] = ps.ps6000SetSimpleTrigger(chandle, 1, 0, 1024, 3, 0, 1000)\nassert_pico_ok(status[\"setChA\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 400\npostTriggerSamples = 400\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\n# Timebase = 2 = timebase\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 2\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps6000GetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Handle = Chandle\n# nSegments = 10\n# nMaxSamples = ctypes.byref(cmaxSamples)\n\nstatus[\"MemorySegments\"] = ps.ps6000MemorySegments(chandle, 10, ctypes.byref(cmaxSamples))\nassert_pico_ok(status[\"MemorySegments\"])\n\n# sets number of captures\nstatus[\"SetNoOfCaptures\"] = ps.ps6000SetNoOfCaptures(chandle, 10)\nassert_pico_ok(status[\"SetNoOfCaptures\"])\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps6000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 1, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\nbufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax1 = (ctypes.c_int16 * maxsamples)()\nbufferAMin1 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 1\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), maxsamples, 1, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax2 = (ctypes.c_int16 * maxsamples)()\nbufferAMin2 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 2\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), maxsamples, 2, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax3 = (ctypes.c_int16 * maxsamples)()\nbufferAMin3 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 3\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), maxsamples, 3, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax4 = (ctypes.c_int16 * maxsamples)()\nbufferAMin4 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 4\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), maxsamples, 4, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax5 = (ctypes.c_int16 * maxsamples)()\nbufferAMin5 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 5\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), maxsamples, 5, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax6 = (ctypes.c_int16 * maxsamples)()\nbufferAMin6 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 6\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), maxsamples, 6, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax7 = (ctypes.c_int16 * maxsamples)()\nbufferAMin7 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 7\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), maxsamples, 7, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax8 = (ctypes.c_int16 * maxsamples)()\nbufferAMin8 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 8\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), maxsamples, 8, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax9 = (ctypes.c_int16 * maxsamples)()\nbufferAMin9 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 9\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), maxsamples, 9, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps6000IsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# noOfSamples = ctypes.byref(cmaxSamples)\n# fromSegmentIndex = 0\n# ToSegmentIndex = 9\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValuesBulk\"] = ps.ps6000GetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValuesBulk\"])\n\n# Handle = chandle\n# Times = Times = (ctypes.c_int16*10)() = ctypes.byref(Times)\n# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)\n# Fromsegmentindex = 0\n# Tosegementindex = 9\nTimes = (ctypes.c_int16*10)()\nTimeUnits = ctypes.c_char()\nstatus[\"GetValuesTriggerTimeOffsetBulk\"] = ps.ps6000GetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)\nassert_pico_ok(status[\"GetValuesTriggerTimeOffsetBulk\"])\n\n# Finds the max ADC count\nmaxADC = ctypes.c_int16(32512)\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChAMax1 =  adc2mV(bufferAMax1, chARange, maxADC)\nadc2mVChAMax2 =  adc2mV(bufferAMax2, chARange, maxADC)\nadc2mVChAMax3 =  adc2mV(bufferAMax3, chARange, maxADC)\nadc2mVChAMax4 =  adc2mV(bufferAMax4, chARange, maxADC)\nadc2mVChAMax5 =  adc2mV(bufferAMax5, chARange, maxADC)\nadc2mVChAMax6 =  adc2mV(bufferAMax6, chARange, maxADC)\nadc2mVChAMax7 =  adc2mV(bufferAMax7, chARange, maxADC)\nadc2mVChAMax8 =  adc2mV(bufferAMax8, chARange, maxADC)\nadc2mVChAMax9 =  adc2mV(bufferAMax9, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value -1) * timeIntervalns.value, cmaxSamples.value)\n\n# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChAMax1[:])\nplt.plot(time, adc2mVChAMax2[:])\nplt.plot(time, adc2mVChAMax3[:])\nplt.plot(time, adc2mVChAMax4[:])\nplt.plot(time, adc2mVChAMax5[:])\nplt.plot(time, adc2mVChAMax6[:])\nplt.plot(time, adc2mVChAMax7[:])\nplt.plot(time, adc2mVChAMax8[:])\nplt.plot(time, adc2mVChAMax9[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps6000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps6000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\nprint(status)\n\n"
  },
  {
    "path": "ps6000Examples/ps6000RapidBlockTriggerTimestampExample.py",
    "content": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps6000 RAPID BLOCK MODE EXAMPLE\n# This example opens a 6000 driver device, sets up one channel and a trigger then collects 10 block of data in rapid succession.\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nfrom picosdk.ps6000 import ps6000 as ps\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\n\n# Create chandle and status ready for use\nstatus = {}\nchandle = ctypes.c_int16()\n\n# Opens the device/s\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n# Displays the serial number and handle\nprint(chandle.value)\n\n# Set up channel A\n# handle = chandle\n# channel = ps6000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = ps6000_DC = 1\n# range = ps6000_10V = 8\n# analogue offset = 0 V\nchARange = 8\nstatus[\"setChA\"] = ps.ps6000SetChannel(chandle, 0, 1, 1, chARange, 0, 0)\nassert_pico_ok(status[\"setChA\"])\n\n# Sets up single trigger\n# Handle = Chandle\n# Enable = 1\n# Source = ps6000_channel_A = 0\n# Threshold = 1024 ADC counts\n# Direction = ps6000_Falling = 3\n# Delay = 0\n# autoTrigger_ms = 1000\nstatus[\"trigger\"] = ps.ps6000SetSimpleTrigger(chandle, 1, 0, 1024, 3, 0, 1000)\nassert_pico_ok(status[\"setChA\"])\n\n# Setting the number of sample to be collected\npreTriggerSamples = 400\npostTriggerSamples = 400\nmaxsamples = preTriggerSamples + postTriggerSamples\n\n# Gets timebase innfomation\n# Warning: When using this example it may not be possible to access all Timebases as all channels are enabled by default when opening the scope.  \n# To access these Timebases, set any unused analogue channels to off.\n# Handle = chandle\n# Timebase = 2 = timebase\n# Nosample = maxsamples\n# TimeIntervalNanoseconds = ctypes.byref(timeIntervalns)\n# MaxSamples = ctypes.byref(returnedMaxSamples)\n# Segement index = 0\ntimebase = 2\ntimeIntervalns = ctypes.c_float()\nreturnedMaxSamples = ctypes.c_int16()\nstatus[\"GetTimebase\"] = ps.ps6000GetTimebase2(chandle, timebase, maxsamples, ctypes.byref(timeIntervalns), 1, ctypes.byref(returnedMaxSamples), 0)\nassert_pico_ok(status[\"GetTimebase\"])\n\n# Creates a overlow location for data\noverflow = ctypes.c_int16()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Handle = Chandle\n# nSegments = 10\n# nMaxSamples = ctypes.byref(cmaxSamples)\n\nstatus[\"MemorySegments\"] = ps.ps6000MemorySegments(chandle, 10, ctypes.byref(cmaxSamples))\nassert_pico_ok(status[\"MemorySegments\"])\n\n# sets number of captures\nstatus[\"SetNoOfCaptures\"] = ps.ps6000SetNoOfCaptures(chandle, 10)\nassert_pico_ok(status[\"SetNoOfCaptures\"])\n\n# Starts the block capture\n# Handle = chandle\n# Number of prTriggerSamples\n# Number of postTriggerSamples\n# Timebase = 2 = 4ns (see Programmer's guide for more information on timebases)\n# time indisposed ms = None (This is not needed within the example)\n# Segment index = 0\n# LpRead = None\n# pParameter = None\nstatus[\"runblock\"] = ps.ps6000RunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, 1, None, 0, None, None)\nassert_pico_ok(status[\"runblock\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = (ctypes.c_int16 * maxsamples)()\nbufferAMin = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 0\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), maxsamples, 0, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax1 = (ctypes.c_int16 * maxsamples)()\nbufferAMin1 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 1\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), maxsamples, 1, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax2 = (ctypes.c_int16 * maxsamples)()\nbufferAMin2 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 2\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), maxsamples, 2, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax3 = (ctypes.c_int16 * maxsamples)()\nbufferAMin3 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 3\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), maxsamples, 3, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax4 = (ctypes.c_int16 * maxsamples)()\nbufferAMin4 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 4\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), maxsamples, 4, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax5 = (ctypes.c_int16 * maxsamples)()\nbufferAMin5 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 5\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), maxsamples, 5, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax6 = (ctypes.c_int16 * maxsamples)()\nbufferAMin6 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 6\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), maxsamples, 6, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax7 = (ctypes.c_int16 * maxsamples)()\nbufferAMin7 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 7\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), maxsamples, 7, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax8 = (ctypes.c_int16 * maxsamples)()\nbufferAMin8 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 8\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), maxsamples, 8, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax9 = (ctypes.c_int16 * maxsamples)()\nbufferAMin9 = (ctypes.c_int16 * maxsamples)() # used for downsampling which isn't in the scope of this example\n\n# Setting the data buffer location for data collection from channel A\n# Handle = Chandle\n# source = ps6000_channel_A = 0\n# Buffer max = ctypes.byref(bufferAMax)\n# Buffer min = ctypes.byref(bufferAMin)\n# Buffer length = maxsamples\n# Segment index = 9\n# Ratio mode = ps6000_Ratio_Mode_None = 0\nstatus[\"SetDataBuffersBulk\"] = ps.ps6000SetDataBuffersBulk(chandle, 0, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), maxsamples, 9, 0)\nassert_pico_ok(status[\"SetDataBuffersBulk\"])\n\n# Creates a overlow location for data\noverflow = (ctypes.c_int16 * 10)()\n# Creates converted types maxsamples\ncmaxSamples = ctypes.c_int32(maxsamples)\n\n# Checks data collection to finish the capture\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps6000IsReady(chandle, ctypes.byref(ready))\n\n# Handle = chandle\n# noOfSamples = ctypes.byref(cmaxSamples)\n# fromSegmentIndex = 0\n# ToSegmentIndex = 9\n# DownSampleRatio = 0\n# DownSampleRatioMode = 0\n# Overflow = ctypes.byref(overflow)\n\nstatus[\"GetValuesBulk\"] = ps.ps6000GetValuesBulk(chandle, ctypes.byref(cmaxSamples), 0, 9, 0, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"GetValuesBulk\"])\n\n# Handle = chandle\n# Times = Times = (ctypes.c_int16*10)() = ctypes.byref(Times)\n# Timeunits = TimeUnits = ctypes.c_char() = ctypes.byref(TimeUnits)\n# Fromsegmentindex = 0\n# Tosegementindex = 9\nTimes = (ctypes.c_int16*10)()\nTimeUnits = ctypes.c_char()\nstatus[\"GetValuesTriggerTimeOffsetBulk\"] = ps.ps6000GetValuesTriggerTimeOffsetBulk64(chandle, ctypes.byref(Times), ctypes.byref(TimeUnits), 0, 9)\nassert_pico_ok(status[\"GetValuesTriggerTimeOffsetBulk\"])\n\n# Finds the max ADC count\nmaxADC = ctypes.c_int16(32512)\n\n# Converts ADC from channel A to mV\nadc2mVChAMax =  adc2mV(bufferAMax, chARange, maxADC)\nadc2mVChAMax1 =  adc2mV(bufferAMax1, chARange, maxADC)\nadc2mVChAMax2 =  adc2mV(bufferAMax2, chARange, maxADC)\nadc2mVChAMax3 =  adc2mV(bufferAMax3, chARange, maxADC)\nadc2mVChAMax4 =  adc2mV(bufferAMax4, chARange, maxADC)\nadc2mVChAMax5 =  adc2mV(bufferAMax5, chARange, maxADC)\nadc2mVChAMax6 =  adc2mV(bufferAMax6, chARange, maxADC)\nadc2mVChAMax7 =  adc2mV(bufferAMax7, chARange, maxADC)\nadc2mVChAMax8 =  adc2mV(bufferAMax8, chARange, maxADC)\nadc2mVChAMax9 =  adc2mV(bufferAMax9, chARange, maxADC)\n\n# Creates the time data\ntime = np.linspace(0, (cmaxSamples.value -1) * timeIntervalns.value, cmaxSamples.value)\n\n\"\"\"# Plots the data from channel A onto a graph\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChAMax1[:])\nplt.plot(time, adc2mVChAMax2[:])\nplt.plot(time, adc2mVChAMax3[:])\nplt.plot(time, adc2mVChAMax4[:])\nplt.plot(time, adc2mVChAMax5[:])\nplt.plot(time, adc2mVChAMax6[:])\nplt.plot(time, adc2mVChAMax7[:])\nplt.plot(time, adc2mVChAMax8[:])\nplt.plot(time, adc2mVChAMax9[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\"\"\"\n\n# Create the trigger timestamping structure\n\ntriggerInfo = (ps.PS6000_TRIGGER_INFO * 10)()\n\n# Collect time stamp information\nstatus[\"triggerTimes\"] = ps.ps6000GetTriggerInfoBulk(chandle, ctypes.byref(triggerInfo), 0, 9)\nassert_pico_ok(status[\"triggerTimes\"])\n\n# retrieve information from the structure\n\nprint(\"segmentIndex\")\nfor i in range(0,9):\n    print(triggerInfo[i].segmentIndex)\n    \nprint(\"status\")\nfor i in range(0,9):\n    print(triggerInfo[i].status)\n    \nprint(\"timeStampCounter\")\nfor i in range(0,9):\n    print(triggerInfo[i].timeStampCounter)\n\n# Stops the scope\n# Handle = chandle\nstatus[\"stop\"] = ps.ps6000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Closes the unit\n# Handle = chandle\nstatus[\"close\"] = ps.ps6000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Displays the staus returns\nprint(status)\n\n"
  },
  {
    "path": "ps6000Examples/ps6000SigGen.py",
    "content": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 6000 Series Signal Generator Example\r\n# This example demonstrates how to use the PicoScope 6000 Series (ps6000) driver API functions to to set up the signal generator to do the following:\r\n# \r\n# 1. Output a sine wave \r\n# 2. Output a square wave \r\n# 3. Output a sweep of a square wave signal\r\n\r\nimport ctypes\r\nfrom picosdk.ps6000 import ps6000 as ps\r\nimport time\r\nfrom picosdk.functions import assert_pico_ok\r\n\r\n\r\n# Gives the device a handle\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Opens the device/s\r\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = 0\r\n# pkToPk = 2000000\r\n# waveType = ctypes.c_int16(0) = PS6000_SINE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS6000_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS6000_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS6000_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(0)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps6000SetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with peak-to-peak voltage of 2 V and frequency of 10 kHz\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS6000_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 10 kHz\r\n# increment = 0\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS6000_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS6000_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS6000_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(1)\r\nsweepType = ctypes.c_int32(0)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps6000SetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 10000, 0, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(10)\r\n\r\n# Output a square wave with an up-down sweep, 10-100 kHz in 5 kHz increments every 1 second.\r\n# handle = chandle\r\n# offsetVoltage = -1000000\r\n# pkToPk = 1500000\r\n# waveType = ctypes.c_int16(1) = PS6000_SQUARE\r\n# startFrequency = 10 kHz\r\n# stopFrequency = 100 kHz\r\n# increment = 5 kHz\r\n# dwellTime = 1\r\n# sweepType = ctypes.c_int16(1) = PS6000_UP\r\n# operation = 0\r\n# shots = 0\r\n# sweeps = 0\r\n# triggerType = ctypes.c_int16(0) = PS6000_SIGGEN_RISING\r\n# triggerSource = ctypes.c_int16(0) = PS6000_SIGGEN_NONE\r\n# extInThreshold = 1\r\nwavetype = ctypes.c_int16(1)\r\nsweepType = ctypes.c_int32(2)\r\ntriggertype = ctypes.c_int32(0)\r\ntriggerSource = ctypes.c_int32(0)\r\n\r\nstatus[\"SetSigGenBuiltIn\"] = ps.ps6000SetSigGenBuiltIn(chandle, 0, 2000000, wavetype, 10000, 100000, 5000, 1, sweepType, 0, 0, 0, triggertype, triggerSource, 1)\r\nassert_pico_ok(status[\"SetSigGenBuiltIn\"])\r\n\r\n# Pauses the script to show signal\r\ntime.sleep(36)\r\n\r\n# Closes the unit\r\n# Handle = chandle\r\nstatus[\"close\"] = ps.ps6000CloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Displays the status returns\r\nprint(status)"
  },
  {
    "path": "ps6000Examples/ps6000StreamingExample.py",
    "content": "#\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 Series STREAMING MODE EXAMPLE\n# This example demonstrates how to call the ps6000 driver API functions in order to open a device, setup 2 channels and collects streamed data (1 buffer).\n# This data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps6000 import ps6000 as ps\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open PicoScope 6000 Series device\n# Returns handle to chandle for use in future API functions\nstatus[\"openunit\"] = ps.ps6000OpenUnit(ctypes.byref(chandle), None)\nassert_pico_ok(status[\"openunit\"])\n\n\n\nenabled = 1\ndisabled = 0\nanalogue_offset = 0.0\n\n# Set up channel A\n# handle = chandle\n# channel = PS6000_CHANNEL_A = 0\n# enabled = 1\n# coupling type = PS6000_DC = 1\n# range = PS6000_2V = 7\n# analogue offset = 0 V\nchannel_range = ps.PS6000_RANGE['PS6000_2V']\nstatus[\"setChA\"] = ps.ps6000SetChannel(chandle,\n                                        ps.PS6000_CHANNEL['PS6000_CHANNEL_A'],\n                                        enabled,\n                                        ps.PS6000_COUPLING['PS6000_DC_1M'],\n                                        channel_range,\n                                        analogue_offset,\n\t\t\t\t\t\t\t\t\t\tps.PS6000_BANDWIDTH_LIMITER['PS6000_BW_FULL'])\nassert_pico_ok(status[\"setChA\"])\n\n# Set up channel B\n# handle = chandle\n# channel = PS6000_CHANNEL_B = 1\n# enabled = 1\n# coupling type = PS6000_DC = 1\n# range = PS6000_2V = 7\n# analogue offset = 0 V\nstatus[\"setChB\"] = ps.ps6000SetChannel(chandle,\n                                        ps.PS6000_CHANNEL['PS6000_CHANNEL_B'],\n                                        enabled,\n                                        ps.PS6000_COUPLING['PS6000_DC_1M'],\n                                        channel_range,\n                                        analogue_offset,\n\t\t\t\t\t\t\t\t\t\tps.PS6000_BANDWIDTH_LIMITER['PS6000_BW_FULL'])\nassert_pico_ok(status[\"setChB\"])\n\n# Size of capture\nsizeOfOneBuffer = 500\nnumBuffersToCapture = 10\n\ntotalSamples = sizeOfOneBuffer * numBuffersToCapture\n\n# Create buffers ready for assigning pointers for data collection\nbufferAMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\nbufferBMax = np.zeros(shape=sizeOfOneBuffer, dtype=np.int16)\n\n# Set data buffer location for data collection from channel A\n# handle = chandle\n# source = PS6000_CHANNEL_A = 0\n# pointer to buffer max = ctypes.byref(bufferAMax)\n# pointer to buffer min = ctypes.byref(bufferAMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS6000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersA\"] = ps.ps6000SetDataBuffers(chandle,\n                                                     ps.PS6000_CHANNEL['PS6000_CHANNEL_A'],\n                                                     bufferAMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     ps.PS6000_RATIO_MODE['PS6000_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersA\"])\n\n# Set data buffer location for data collection from channel B\n# handle = chandle\n# source = PS6000_CHANNEL_B = 1\n# pointer to buffer max = ctypes.byref(bufferBMax)\n# pointer to buffer min = ctypes.byref(bufferBMin)\n# buffer length = maxSamples\n# segment index = 0\n# ratio mode = PS6000_RATIO_MODE_NONE = 0\nstatus[\"setDataBuffersB\"] = ps.ps6000SetDataBuffers(chandle,\n                                                     ps.PS6000_CHANNEL['PS6000_CHANNEL_B'],\n                                                     bufferBMax.ctypes.data_as(ctypes.POINTER(ctypes.c_int16)),\n                                                     None,\n                                                     sizeOfOneBuffer,\n                                                     ps.PS6000_RATIO_MODE['PS6000_RATIO_MODE_NONE'])\nassert_pico_ok(status[\"setDataBuffersB\"])\n\n# Begin streaming mode:\nsampleInterval = ctypes.c_int32(250)\nsampleUnits = ps.PS6000_TIME_UNITS['PS6000_US']\n# We are not triggering:\nmaxPreTriggerSamples = 0\nautoStopOn = 1\n# No downsampling:\ndownsampleRatio = 1\nstatus[\"runStreaming\"] = ps.ps6000RunStreaming(chandle,\n                                                ctypes.byref(sampleInterval),\n                                                sampleUnits,\n                                                maxPreTriggerSamples,\n                                                totalSamples,\n                                                autoStopOn,\n                                                downsampleRatio,\n                                                ps.PS6000_RATIO_MODE['PS6000_RATIO_MODE_NONE'],\n                                                sizeOfOneBuffer)\nassert_pico_ok(status[\"runStreaming\"])\n\nactualSampleInterval = sampleInterval.value\nactualSampleIntervalNs = actualSampleInterval * 1000\n\nprint(\"Capturing at sample interval %s ns\" % actualSampleIntervalNs)\n\n# We need a big buffer, not registered with the driver, to keep our complete capture in.\nbufferCompleteA = np.zeros(shape=totalSamples, dtype=np.int16)\nbufferCompleteB = np.zeros(shape=totalSamples, dtype=np.int16)\nnextSample = 0\nautoStopOuter = False\nwasCalledBack = False\n\n\ndef streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):\n    global nextSample, autoStopOuter, wasCalledBack\n    wasCalledBack = True\n    destEnd = nextSample + noOfSamples\n    sourceEnd = startIndex + noOfSamples\n    bufferCompleteA[nextSample:destEnd] = bufferAMax[startIndex:sourceEnd]\n    bufferCompleteB[nextSample:destEnd] = bufferBMax[startIndex:sourceEnd]\n    nextSample += noOfSamples\n    if autoStop:\n        autoStopOuter = True\n\n\n# Convert the python function into a C function pointer.\ncFuncPtr = ps.StreamingReadyType(streaming_callback)\n\n# Fetch data from the driver in a loop, copying it out of the registered buffers and into our complete one.\nwhile nextSample < totalSamples and not autoStopOuter:\n    wasCalledBack = False\n    status[\"getStreamingLastestValues\"] = ps.ps6000GetStreamingLatestValues(chandle, cFuncPtr, None)\n    if not wasCalledBack:\n        # If we weren't called back by the driver, this means no data is ready. Sleep for a short while before trying\n        # again.\n        time.sleep(0.01)\n\nprint(\"Done grabbing values.\")\n\n# Find maximum ADC count value\n# handle = chandle\n# pointer to value = ctypes.byref(maxADC)\nmaxADC = ctypes.c_int16(32512)\n\n# Convert ADC counts data to mV\nadc2mVChAMax = adc2mV(bufferCompleteA, channel_range, maxADC)\nadc2mVChBMax = adc2mV(bufferCompleteB, channel_range, maxADC)\n\n# Create time data\ntime = np.linspace(0, (totalSamples -1) * actualSampleIntervalNs, totalSamples)\n\n# Plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.plot(time, adc2mVChBMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Stop the scope\n# handle = chandle\nstatus[\"stop\"] = ps.ps6000Stop(chandle)\nassert_pico_ok(status[\"stop\"])\n\n# Disconnect the scope\n# handle = chandle\nstatus[\"close\"] = ps.ps6000CloseUnit(chandle)\nassert_pico_ok(status[\"close\"])\n\n# Display status returns\nprint(status)\n"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockAdvancedTriggerExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This example opens a 6000a driver device, sets up two channels and a trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as struct\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\r\nchannelRange = 5\r\n# analogueOffset = 0 V\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\nchannelB = enums.PICO_CHANNEL[\"PICO_CHANNEL_B\"]\r\nstatus[\"setChannelB\"] = ps.ps6000aSetChannelOn(chandle, channelB, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelB\"])\r\n\r\n# set channel C-H off\r\nfor x in range (2, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# use the trigger functions seperately\r\n# set up a simple edge trigger on channel A OR B with a 100 mV threshold\r\n\r\nconditions = (struct.PICO_CONDITION * 2)()\r\nconditions[0] = struct.PICO_CONDITION(channelA,enums.PICO_TRIGGER_STATE[\"PICO_CONDITION_TRUE\"])\r\nconditions[1] = struct.PICO_CONDITION(channelB, enums.PICO_TRIGGER_STATE[\"PICO_CONDITION_TRUE\"])\r\nnConditions = 2\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setTriggerChannelConditions\"] = ps.ps6000aSetTriggerChannelConditions(chandle, ctypes.byref(conditions), nConditions, action)\r\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\r\n\r\ndirections = (struct.PICO_DIRECTION * 2)()\r\ndirections[0]= struct.PICO_DIRECTION(channelA, enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"], enums.PICO_THRESHOLD_MODE[\"PICO_LEVEL\"])\r\ndirections[1]= struct.PICO_DIRECTION(channelB, enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"], enums.PICO_THRESHOLD_MODE[\"PICO_LEVEL\"])\r\nnDirections = 2\r\nstatus[\"setTriggerChannelDirections\"] = ps.ps6000aSetTriggerChannelDirections(chandle,ctypes.byref(directions),nDirections)\r\nassert_pico_ok(status[\"setTriggerChannelDirections\"])\r\n\r\nchannelProperties = (struct.PICO_TRIGGER_CHANNEL_PROPERTIES * 2)()\r\nchannelProperties[0] = struct.PICO_TRIGGER_CHANNEL_PROPERTIES(mV2adc(100,channelRange,maxADC), 0, 0, 0, channelA)\r\nchannelProperties[1] = struct.PICO_TRIGGER_CHANNEL_PROPERTIES(mV2adc(100,channelRange,maxADC), 0, 0, 0, channelB)\r\nnChannelProperties = 2\r\nautoTriggerMicroSeconds = 1000000\r\nstatus[\"setTriggerChannelProperties\"] = ps.ps6000aSetTriggerChannelProperties(chandle, ctypes.byref(channelProperties),nChannelProperties,0,autoTriggerMicroSeconds)\r\nassert_pico_ok(status[\"setTriggerChannelProperties\"])\r\n\r\n# Get fastest available timebase\r\n# handle = chandle\r\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"] + enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_B_FLAGS\"]\r\ntimebase = ctypes.c_uint32(0)\r\ntimeInterval = ctypes.c_double(0)\r\n# resolution = resolution\r\nstatus[\"getMinimumTimebaseStateless\"] = ps.ps6000aGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"s\")\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferBMax = (ctypes.c_int16 * nSamples)()\r\nbufferBMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffers\"])\r\nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelB, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin), nSamples, dataType, waveform, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps6000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n# convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\r\nadc2mVChBMax =  adc2mV(bufferBMax, channelRange, maxADC)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.plot(time, adc2mVChAMax[:])\r\nplt.plot(time, adc2mVChBMax[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This example opens a 6000a driver device, sets up two channels and a trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\r\nchannelRange = 5\r\n# analogueOffset = 0 V\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\n# set channel B-H off\r\nfor x in range (1, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.ps6000aSetSimpleTrigger(chandle, 1, source, (mV2adc(100,channelRange,maxADC)), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# Get fastest available timebase\r\n# handle = chandle\r\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\r\ntimebase = ctypes.c_uint32(0)\r\ntimeInterval = ctypes.c_double(0)\r\n# resolution = resolution\r\nstatus[\"getMinimumTimebaseStateless\"] = ps.ps6000aGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"s\")\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffers\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps6000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n\r\n\r\n# convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.plot(time, adc2mVChAMax[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockExampleExtClk.py",
    "content": "#\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000A Demonstrates external clock callback using block mode.\n# This example opens a 6000a driver device, sets up the External clock callback, and reports its status during a block capture.\n# Data is then plotted as mV against time in ns.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps6000a import ps6000a as ps\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, mV2adc, assert_pico_ok\nfrom picosdk.constants import PICO_STATUS\nimport time\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 6000 A series PicoScope\n# returns handle to chandle for use in future API functions\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\nassert_pico_ok(status[\"openunit\"])\n\n# setup External clock callback function\nwasCalledBack = False\nExtRefClk_PicoStatus = enums.PICO_STATUS[\"PICO_OK\"]\nExtRefClkReference = enums.PICO_CLOCK_REFERENCE[\"PICO_INTERNAL_REF\"]\n\ndef ExternalReferenceInteractions_callback(handle, statusCallback, reference):\n    global wasCalledBack, ExtRefClk_PicoStatus, ExtRefClkReference\n    wasCalledBack = True\n    ExtRefClkReference = reference\n    ExtRefClk_PicoStatus = statusCallback\n    \n# Convert the python function into a C function pointer.\ncFuncPtrExtClkCB = ps.ExternalReferenceInteractionsReadyType(ExternalReferenceInteractions_callback) \n# Register the External clock callback\nstatus[\"SetExternalReferenceInteractionCallback\"] = ps.ps6000aSetExternalReferenceInteractionCallback(chandle, cFuncPtrExtClkCB)\nassert_pico_ok(status[\"SetExternalReferenceInteractionCallback\"])\n\ntime.sleep(1)\n\nif wasCalledBack == True:\n    print(\"ExtRefClk_PicoStatus = \", ExtRefClk_PicoStatus)\n    print(\"ExtRefClk_Reference = \", ExtRefClkReference)\n    wasCalledBack = False\n\n# Set channel A on\n# handle = chandle\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\nchannelRange = 5\n\n# analogueOffset = 0 V\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\nassert_pico_ok(status[\"setChannelA\"])\n\n# set channel B-H off\nfor x in range (1, 7, 1):\n    channel = x\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\n    assert_pico_ok(status[\"setChannel\",x])\n    \n# get max ADC value\n# handle = chandle\nminADC = ctypes.c_int16()\nmaxADC = ctypes.c_int16()\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\nassert_pico_ok(status[\"getAdcLimits\"])\n\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\n# handle = chandle\n# enable = 1\nsource = channelA\n# threshold = 100 mV\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\n# delay = 0 s\n# autoTriggerMicroSeconds = 1000000 us\nstatus[\"setSimpleTrigger\"] = ps.ps6000aSetSimpleTrigger(chandle, 1, source, (mV2adc(100,channelRange,maxADC)), direction, 0, 1000000)\nassert_pico_ok(status[\"setSimpleTrigger\"])\n\n# Get fastest available timebase\n# handle = chandle\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\ntimebase = ctypes.c_uint32(0)\ntimeInterval = ctypes.c_double(0)\n\n# resolution = resolution\nstatus[\"getMinimumTimebaseStateless\"] = ps.ps6000aGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\ntimebase = ctypes.c_uint32(1000)\nprint(\"timebase = \", timebase.value)\nprint(\"sample interval =\", timeInterval.value, \"s\")\n\n# Set number of samples to be collected\nnoOfPreTriggerSamples = 500000\nnoOfPostTriggerSamples = 1000000\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\n\n# Create buffers\nbufferAMax = (ctypes.c_int16 * nSamples)()\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\n\n# Set data buffers\n# handle = chandle\n# channel = channelA\n# bufferMax = bufferAMax\n# bufferMin = bufferAMin\n# nSamples = nSamples\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\nwaveform = 0\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\nassert_pico_ok(status[\"setDataBuffers\"])\n\n# Run block capture\n# handle = chandle\n# timebase = timebase\ntimeIndisposedMs = ctypes.c_double(0)\n# segmentIndex = 0\n# lpReady = None   Using IsReady rather than a callback\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps6000aIsReady\n# Also print any change to the samaple clock source\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\n    if wasCalledBack == True:\n        print(\"ExtRefClk_Reference = \", ExtRefClkReference)\n        wasCalledBack = False\n\n# Get data from scope\n# handle = chandle\n# startIndex = 0\nnoOfSamples = ctypes.c_uint64(nSamples)\n# downSampleRatio = 1\n# segmentIndex = 0\noverflow = ctypes.c_int16(0)\nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\n\n# plot data from channel A and B\nplt.plot(time, adc2mVChAMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Close the scope\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\nassert_pico_ok(status[\"closeunit\"])\n\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockExampleTrigTimes.py",
    "content": "#\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 A BLOCK MODE EXAMPLE WITH ALL TRIGGER TIMES\n# This example opens a 6000a driver device, sets up a channel A and its trigger then collects a block of data.\n# This data is then plotted as mV against time in ns.\n# Also the trigger data is plotted as mV against time in ns. (optional)\n# Addition function calls so all trigger time values are returned correctly.\n\nimport ctypes\nimport numpy as np\nfrom picosdk.ps6000a import ps6000a as ps\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\nfrom picosdk.PicoDeviceStructs import picoStruct as struct\nimport matplotlib.pyplot as plt\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\n\n# Create chandle and status ready for use\nchandle = ctypes.c_int16()\nstatus = {}\n\n# Open 6000 A series PicoScope\n# returns handle to chandle for use in future API functions\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\nassert_pico_ok(status[\"openunit\"])\n\n# Set channel A on\n# handle = chandle\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\ncoupling = enums.PICO_COUPLING[\"PICO_DC\"]\nchannelRange = 5\n# analogueOffset = 0 V\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\nassert_pico_ok(status[\"setChannelA\"])\n\n# set channel B-H off\nfor x in range (1, 3, 1):\n    channel = x\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\n    assert_pico_ok(status[\"setChannel\",x])\n    \n# get max ADC value\n# handle = chandle\nminADC = ctypes.c_int16()\nmaxADC = ctypes.c_int16()\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\nassert_pico_ok(status[\"getAdcLimits\"])\n\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\n# handle = chandle\n# enable = 1\n# threshold = 100 mV\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\n# delay = 0 s\n# autoTriggerMicroSeconds = 1000000 us\nstatus[\"setSimpleTrigger\"] = ps.ps6000aSetSimpleTrigger(chandle, 1, channelA, mV2adc(0,channelRange,maxADC), direction, 0, 0)\nassert_pico_ok(status[\"setSimpleTrigger\"])\n\n# Get fastest available timebase\n# handle = chandle\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\ntimebase = ctypes.c_uint32(0)\ntimeInterval = ctypes.c_double(0)\n# resolution = resolution\nstatus[\"getMinimumTimebaseStateless\"] = ps.ps6000aGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\nprint(\"MinimumTimebase is-\")\nprint(\"timebase = \", timebase.value)\nprint(\"sample interval =\", timeInterval.value, \"s\")\n\n# Set number of samples to be collected\nnoOfPreTriggerSamples = 500000\nnoOfPostTriggerSamples = 500000\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\n\n# Create buffers\nbufferAMax = (ctypes.c_int16 * nSamples)()\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\n\ntriggerSamples = 40 # This is always 40 - 20 samples around the trigger point.\ntriggerBuffer = (ctypes.c_int16 * triggerSamples)()\n\n# Run block capture\n# handle = chandle\n# timebase = timebase\ntimeIndisposedMs = ctypes.c_double(0)\ntimebase = ctypes.c_uint32(50)\n\nprint(\"Setting Timebase of-\")\nprint(\"timebase = \", timebase.value)\n\n# segmentIndex = 0\n# lpReady = None   Using IsReady rather than a callback\n# pParameter = None\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\nassert_pico_ok(status[\"runBlock\"])\n\n# Check for data collection to finish using ps6000aIsReady\nready = ctypes.c_int16(0)\ncheck = ctypes.c_int16(0)\nwhile ready.value == check.value:\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\n    \n# Set data buffers\n# handle = chandle\n# channel = channelA\n# bufferMax = bufferAMax\n# bufferMin = bufferAMin\n# nSamples = nSamples\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\nwaveform = 0\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\n\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\naction = clear | add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"] \n\nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffers(chandle,\n                                                    channelA,\n                                                    ctypes.byref(bufferAMax),\n                                                    ctypes.byref(bufferAMin),\n                                                    nSamples,\n                                                    dataType,\n                                                    waveform,\n                                                    downSampleMode,\n                                                    action)\n\n# Setup triggerSamples to get \"trigger time offset\" values when calling \"GetTriggerInfo()\" and \"GetTriggerTimeOffset\" functions.\nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffer(chandle,\n                                                    channelA,\n                                                    ctypes.byref(triggerBuffer),\n                                                    ctypes.c_int32(triggerSamples),\n                                                    dataType, \n                                                   waveform,\n                                                    enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_TRIGGER\"],\n                                                    add)\n\nassert_pico_ok(status[\"setDataBuffers\"])\n\n# Get data from scope\n# handle = chandle\n# startIndex = 0\nnoOfSamples = ctypes.c_uint64(nSamples)\n# downSampleRatio = 1\n# segmentIndex = 0\noverflow = ctypes.c_int16(0)\nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\nassert_pico_ok(status[\"getValues\"])\n\n# Request triggerSamples to get \"trigger time offset\" values when calling \"GetTriggerInfo()\" and \"GetTriggerTimeOffset\" functions. \nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(ctypes.c_uint64(triggerSamples)), noOfSamples, enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_TRIGGER\"], 0, None)\nassert_pico_ok(status[\"getValues\"])\n\ntriggerInfo = (struct.PICO_TRIGGER_INFO * 1)()\n\nstatus[\"GetTriggerInfo\"] = ps.ps6000aGetTriggerInfo(chandle, ctypes.byref(triggerInfo), 0, 1)\nassert_pico_ok(status[\"GetTriggerInfo\"])\nprint(\"TimestampCounter values in samples (only relative timestamps one segment to the next)\")\n# print(\"Timestamp samples for 2nd segment (index 1, from segment 0 to 1) = \", triggerInfo(1).timeStampCounter)\nprint(\"Printing triggerInfo for segments-\")\nfor i in triggerInfo:\n    print(\"segmentIndex is \", i.segmentIndex)\n    print(\"PICO_STATUS is \", i.status)\n    print(\"triggerIndex is \", i.triggerIndex)\n    print(\"triggerTime (jitter) is \", i.triggerTime)\n    print(\"timeUnits is \", i.timeUnits)\n    print(\"MissedTriggers is \", i.missedTriggers)\n    print(\"timeStampCounter is \", i.timeStampCounter)\n    print(\"-------------------------------\")\n\ntimeGTO = ctypes.c_int64(0)\ntimeUnits = ctypes.c_uint32(0)\nsegmentIndex = ctypes.c_uint64(0)\n \nstatus[\"GetTriggerTimeOffset\"] = ps.ps6000aGetTriggerTimeOffset(chandle, ctypes.byref(timeGTO), ctypes.byref(timeUnits), segmentIndex)\nassert_pico_ok(status[\"GetTriggerTimeOffset\"])\nprint(\"Calling GetTriggerTimeOffset() -\")\nprint(\"triggerTime (jitter) is \", timeGTO)\nprint(\"timeUnits is \", timeUnits)\n\n# convert ADC counts data to mV\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\n\n# Create time data\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\n\n# plot data from channel A\nplt.plot(time, adc2mVChAMax[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# plot trigger area data\ntimetrigger = np.linspace(0, (triggerSamples -1) * timeInterval.value * 1000000000, triggerSamples)\nplt.plot(timetrigger, triggerBuffer[:])\nplt.xlabel('Time (ns)')\nplt.ylabel('Voltage (mV)')\nplt.show()\n\n# Close the scope\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\nassert_pico_ok(status[\"closeunit\"])\n\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockMSODigitalTriggerExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A MSO BLOCK MODE DIGITAL TRIGGER EXAMPLE\r\n# This example opens a 6000a driver device, sets up one analogue channel and one digital channel and a digital trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as struct\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, splitMSODataFast\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\r\nchannelRange = 5\r\n# analogueOffset = 0 V\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\n# set channel B-H off\r\nfor x in range (1, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# set MSO pod 1 on\r\n# handle = chandle\r\nport = enums.PICO_CHANNEL[\"PICO_PORT0\"]\r\n# logic level needs to be set individually for all digital channels/pins in the port\r\npins = 8\r\nlogicThresholdLevel = (ctypes.c_int16 * pins)(0)\r\nlogicThresholdLevel[0] = 1000\r\nlogicThresholdLevelLength = len(logicThresholdLevel)\r\nhysteresis = enums.PICO_DIGITAL_PORT_HYSTERESIS[\"PICO_LOW_50MV\"]\r\nstatus[\"setDigitalPortOn\"] = ps.ps6000aSetDigitalPortOn(chandle, port, ctypes.byref(logicThresholdLevel), logicThresholdLevelLength, hysteresis)\r\nassert_pico_ok(status[\"setDigitalPortOn\"])\r\n\r\n# Set MSO pod 2 off\r\nport2 = enums.PICO_CHANNEL[\"PICO_PORT1\"]\r\nstatus[\"setDigitalPortOff\"] = ps.ps6000aSetDigitalPortOff(chandle,port2)\r\nassert_pico_ok(status[\"setDigitalPortOff\"])\r\n\r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set trigger on digital channel 0 Port 1 for rising logic level transition \r\nconditions = (struct.PICO_CONDITION * 1)()\r\nconditions = struct.PICO_CONDITION(enums.PICO_CHANNEL[\"PICO_PORT0\"] , enums.PICO_TRIGGER_STATE[\"PICO_CONDITION_TRUE\"])\r\nnConditions = 1\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add\r\nstatus[\"setTriggerChannelConditions\"] = ps.ps6000aSetTriggerChannelConditions(chandle, ctypes.byref(conditions),nConditions,action)\r\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\r\n\r\ndirections = (struct.DIGITAL_CHANNEL_DIRECTIONS * 1)()\r\ndirections = struct.DIGITAL_CHANNEL_DIRECTIONS(enums.PICO_PORT_DIGITAL_CHANNEL[\"PICO_PORT_DIGITAL_CHANNEL0\"],enums.PICO_DIGITAL_DIRECTION[\"PICO_DIGITAL_DIRECTION_RISING\"])\r\nnDirections = 1\r\nstatus[\"setTriggerDigitalPortProperties\"] = ps.ps6000aSetTriggerDigitalPortProperties(chandle,port,ctypes.byref(directions),nDirections)\r\nassert_pico_ok(status[\"setTriggerDigitalPortProperties\"])\r\n\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Check timebase is valid\r\n# handle = chandle\r\ntimebase = ctypes.c_uint32(1)\r\ntimeInterval = ctypes.c_double(0)\r\nreturnedMaxSamples=ctypes.c_uint64()\r\n#segment = 0\r\nstatus[\"getTimebase\"] = ps.ps6000aGetTimebase(chandle, timebase, nSamples, ctypes.byref(timeInterval), ctypes.byref(returnedMaxSamples), 0)\r\nassert_pico_ok(status[\"getTimebase\"])\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"ns\")\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\nbufferDPort0Max = (ctypes.c_int16 * nSamples)()\r\nbufferDPort0Min = (ctypes.c_int16 * nSamples)()\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataChABuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataChABuffers\"])\r\n\r\nstatus[\"setDataDP0Buffers\"] = ps.ps6000aSetDataBuffers(chandle, port, ctypes.byref(bufferDPort0Max), ctypes.byref(bufferDPort0Min), nSamples, dataType, waveform, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataDP0Buffers\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps5000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n\r\n\r\n# convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\r\n\r\n# Obtain binary for Digital Port 0\r\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\r\nbufferDPort0 = splitMSODataFast(noOfSamples, bufferDPort0Max)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.figure(num='Channel A Data')\r\nplt.plot(time, adc2mVChAMax[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.title('Channel A data')\r\n#plt.show()\r\n\r\n# Plot the data from digital channels onto a graph\r\nplt.figure(num='Digital Port 0 Data')\r\nplt.title('Plot of Digital Port 0 digital channels vs. time')\r\nplt.plot(time, bufferDPort0[0], label='D7')  # D7 is the first array in the tuple.\r\nplt.plot(time, bufferDPort0[1], label='D6')\r\nplt.plot(time, bufferDPort0[2], label='D5')\r\nplt.plot(time, bufferDPort0[3], label='D4')\r\nplt.plot(time, bufferDPort0[4], label='D3')\r\nplt.plot(time, bufferDPort0[5], label='D2')\r\nplt.plot(time, bufferDPort0[6], label='D1')\r\nplt.plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Logic Level')\r\nplt.legend(loc=\"upper right\")\r\nplt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockMSOExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This example opens a 6000a driver device, sets up two channels and a trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, splitMSODataFast\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\r\nchannelRange = 5\r\n# analogueOffset = 0 V\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\n# set channel B-H off\r\nfor x in range (1, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# set MSO pod 1 on\r\n# handle = chandle\r\nport = enums.PICO_CHANNEL[\"PICO_PORT0\"]\r\n# logic level needs to be set individually for all digital channels/pins in the port\r\npins = 8\r\nlogicThresholdLevel = (ctypes.c_int16 * pins)(0)\r\nlogicThresholdLevel[0] = 1000\r\nlogicThresholdLevelLength = len(logicThresholdLevel)\r\nhysteresis = enums.PICO_DIGITAL_PORT_HYSTERESIS[\"PICO_LOW_50MV\"]\r\nstatus[\"setDigitalPortOn\"] = ps.ps6000aSetDigitalPortOn(chandle, port, ctypes.byref(logicThresholdLevel), logicThresholdLevelLength, hysteresis)\r\nassert_pico_ok(status[\"setDigitalPortOn\"])\r\n\r\n# Set MSO pod 2 off\r\nport2 = enums.PICO_CHANNEL[\"PICO_PORT1\"]\r\nstatus[\"setDigitalPortOff\"] = ps.ps6000aSetDigitalPortOff(chandle,port2)\r\nassert_pico_ok(status[\"setDigitalPortOff\"])\r\n\r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.ps6000aSetSimpleTrigger(chandle, 1, source, (mV2adc(100,channelRange,maxADC), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Check timebase is valid\r\n# handle = chandle\r\ntimebase = ctypes.c_uint32(1)\r\ntimeInterval = ctypes.c_double(0)\r\nreturnedMaxSamples=ctypes.c_uint64()\r\n#segment = 0\r\nstatus[\"getTimebase\"] = ps.ps6000aGetTimebase(chandle, timebase, nSamples, ctypes.byref(timeInterval), ctypes.byref(returnedMaxSamples), 0)\r\nassert_pico_ok(status[\"getTimebase\"])\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"ns\")\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\nbufferDPort0Max = (ctypes.c_int16 * nSamples)()\r\nbufferDPort0Min = (ctypes.c_int16 * nSamples)()\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataChABuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataChABuffers\"])\r\n\r\nstatus[\"setDataDP0Buffers\"] = ps.ps6000aSetDataBuffers(chandle, port, ctypes.byref(bufferDPort0Max), ctypes.byref(bufferDPort0Min), nSamples, dataType, waveform, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataDP0Buffers\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps5000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.ps6000aGetValues(chandle, 0, ctypes.byref(noOfSamples), 1, downSampleMode, 0, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n\r\n\r\n# convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\r\n\r\n# Obtain binary for Digital Port 0\r\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\r\nbufferDPort0 = splitMSODataFast(noOfSamples, bufferDPort0Max)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.figure(num='Channel A Data')\r\nplt.plot(time, adc2mVChAMax[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.title('Channel A data')\r\n#plt.show()\r\n\r\n# Plot the data from digital channels onto a graph\r\nplt.figure(num='Digital Port 0 Data')\r\nplt.title('Plot of Digital Port 0 digital channels vs. time')\r\nplt.plot(time, bufferDPort0[0], label='D7')  # D7 is the first array in the tuple.\r\nplt.plot(time, bufferDPort0[1], label='D6')\r\nplt.plot(time, bufferDPort0[2], label='D5')\r\nplt.plot(time, bufferDPort0[3], label='D4')\r\nplt.plot(time, bufferDPort0[4], label='D3')\r\nplt.plot(time, bufferDPort0[5], label='D2')\r\nplt.plot(time, bufferDPort0[6], label='D1')\r\nplt.plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Logic Level')\r\nplt.legend(loc=\"upper right\")\r\nplt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aBlock_both_MSOExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This example opens a 6000a driver device, sets up two channels and a trigger then collects a block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as struct\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, splitMSODataFast\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# set channel A-H off\r\nfor x in range (0, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# set MSO pod 1 on\r\n# handle = chandle\r\nport_0 = enums.PICO_CHANNEL[\"PICO_PORT0\"]\r\n# logic level needs to be set individually for all digital channels/pins in the port\r\npins = 8\r\nlogicThresholdLevel = (ctypes.c_int16 * pins)(0)\r\nlogicThresholdLevel[0] = 6400 # ~1.5v\r\nlogicThresholdLevelLength = len(logicThresholdLevel)\r\nhysteresis = enums.PICO_DIGITAL_PORT_HYSTERESIS[\"PICO_LOW_50MV\"]\r\nstatus[\"setDigitalPortOn\"] = ps.ps6000aSetDigitalPortOn(chandle, \r\n                                                        port_0, \r\n                                                        ctypes.byref(logicThresholdLevel), \r\n                                                        logicThresholdLevelLength, \r\n                                                        hysteresis)\r\nassert_pico_ok(status[\"setDigitalPortOn\"])\r\n\r\n# set MSO pod 2 on\r\n# handle = chandle\r\nport_1 = enums.PICO_CHANNEL[\"PICO_PORT1\"]\r\n# logic level needs to be set individually for all digital channels/pins in the port\r\npins = 8\r\nlogicThresholdLevel_upper = (ctypes.c_int16 * pins)(0)\r\nlogicThresholdLevel_upper[0] = 6400 #~1.5v\r\nlogicThresholdLevel_upperLength = len(logicThresholdLevel)\r\nhysteresis = enums.PICO_DIGITAL_PORT_HYSTERESIS[\"PICO_LOW_50MV\"]\r\nstatus[\"setDigitalPortOn\"] = ps.ps6000aSetDigitalPortOn(chandle, \r\n                                                        port_1, \r\n                                                        ctypes.byref(logicThresholdLevel_upper), \r\n                                                        logicThresholdLevel_upperLength, \r\n                                                        hysteresis)\r\nassert_pico_ok(status[\"setDigitalPortOn\"])\r\n\r\n# Set trigger on digital channel 0 Port 1 for rising logic level transition \r\nconditions = (struct.PICO_CONDITION * 1)()\r\nconditions = struct.PICO_CONDITION(enums.PICO_CHANNEL[\"PICO_PORT0\"] , enums.PICO_TRIGGER_STATE[\"PICO_CONDITION_TRUE\"])\r\nnConditions = 1\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add\r\naction_post = add\r\nstatus[\"setTriggerChannelConditions\"] = ps.ps6000aSetTriggerChannelConditions(chandle, ctypes.byref(conditions),nConditions,action)\r\nassert_pico_ok(status[\"setTriggerChannelConditions\"])\r\n\r\ndirections = (struct.DIGITAL_CHANNEL_DIRECTIONS * 1)()\r\ndirections = struct.DIGITAL_CHANNEL_DIRECTIONS(enums.PICO_PORT_DIGITAL_CHANNEL[\"PICO_PORT_DIGITAL_CHANNEL0\"],enums.PICO_DIGITAL_DIRECTION[\"PICO_DIGITAL_DIRECTION_RISING\"])\r\nnDirections = 1\r\nstatus[\"setTriggerDigitalPortProperties\"] = ps.ps6000aSetTriggerDigitalPortProperties(chandle,port_0,ctypes.byref(directions),nDirections)\r\nassert_pico_ok(status[\"setTriggerDigitalPortProperties\"])\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 25000\r\nnoOfPostTriggerSamples = 0\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Check timebase is valid\r\n# handle = chandle\r\ntimebase = ctypes.c_uint32(1)\r\ntimeInterval = ctypes.c_double(0)\r\nreturnedMaxSamples=ctypes.c_uint64()\r\n#segment = 0\r\nstatus[\"getTimebase\"] = ps.ps6000aGetTimebase(chandle, timebase, nSamples, ctypes.byref(timeInterval), ctypes.byref(returnedMaxSamples), 0)\r\nassert_pico_ok(status[\"getTimebase\"])\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"ns\")\r\n\r\n# Create buffers\r\nbufferDPort0 = (ctypes.c_int16 * nSamples)()\r\nbufferDPort0Max = (ctypes.c_int16 * nSamples)()\r\nbufferDPort0Min = (ctypes.c_int16 * nSamples)()\r\n\r\nbufferDPort1 = (ctypes.c_int16 * nSamples)()\r\nbufferDPort1Max = (ctypes.c_int16 * nSamples)()\r\nbufferDPort1Min = (ctypes.c_int16 * nSamples)()\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\n#dataType_MSO = enums.PICO_DATA_TYPE[\"PICO_INT8_T\"]\r\n\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\n\r\nstatus[\"setDataDP0Buffer\"] = ps.ps6000aSetDataBuffers(chandle, \r\n                                                     port_0, \r\n                                                     ctypes.byref(bufferDPort0Max), \r\n                                                     ctypes.byref(bufferDPort0Min),\r\n                                                     nSamples, \r\n                                                     dataType, \r\n                                                     waveform, \r\n                                                     downSampleMode, \r\n                                                     action)\r\nassert_pico_ok(status[\"setDataDP0Buffer\"])\r\n\r\nstatus[\"setDataDP1Buffer\"] = ps.ps6000aSetDataBuffers(\r\n                                                    chandle, \r\n                                                    port_1, \r\n                                                    ctypes.byref(bufferDPort1Max), \r\n                                                    ctypes.byref(bufferDPort1Min),\r\n                                                    nSamples, \r\n                                                    dataType, \r\n                                                    waveform, \r\n                                                    downSampleMode, \r\n                                                    action_post)\r\nassert_pico_ok(status[\"setDataDP1Buffer\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(\r\n                                        chandle, \r\n                                        noOfPreTriggerSamples, \r\n                                        noOfPostTriggerSamples, \r\n                                        timebase, \r\n                                        ctypes.byref(timeIndisposedMs), \r\n                                        0, \r\n                                        None, \r\n                                        None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps5000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\noverflow = ctypes.c_int16(0)\r\nstatus[\"getValues\"] = ps.ps6000aGetValues(\r\n                                            chandle, \r\n                                            0, \r\n                                            ctypes.byref(noOfSamples), \r\n                                            1, \r\n                                            downSampleMode, \r\n                                            0, \r\n                                            ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n# # Obtain binary for Digital Port 0\r\n# # The tuple returned contains the channels in order (D7, D6, D5, ... D0).\r\n# bufferDPort0 = splitMSODataFast(noOfSamples, bufferDPort0)\r\n# bufferDPort1 = splitMSODataFast(noOfSamples, bufferDPort1)\r\n\r\n# Obtain binary for Digital Port 0\r\n# The tuple returned contains the channels in order (D7, D6, D5, ... D0).\r\nbufferDPort0 = splitMSODataFast(noOfSamples, bufferDPort0Max)\r\nbufferDPort1 = splitMSODataFast(noOfSamples, bufferDPort1Max)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n#MinMax plot\r\nfig, axs = plt.subplots(2)\r\nfig.suptitle(\"MSO data\")\r\n\r\n# Plot the data from digital channels onto a graph\r\naxs[0].plot(time, bufferDPort0[0], label='D7')  # D7 is the first array in the tuple.\r\naxs[0].plot(time, bufferDPort0[1], label='D6')\r\naxs[0].plot(time, bufferDPort0[2], label='D5')\r\naxs[0].plot(time, bufferDPort0[3], label='D4')\r\naxs[0].plot(time, bufferDPort0[4], label='D3')\r\naxs[0].plot(time, bufferDPort0[5], label='D2')\r\naxs[0].plot(time, bufferDPort0[6], label='D1')\r\naxs[0].plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\r\naxs[0].legend(loc=\"upper right\")\r\n#plt.show()\r\n\r\n# Plot the data from digital channels onto a graph\r\naxs[1].plot(time, bufferDPort1[0], label='D15')  # D7 is the first array in the tuple.\r\naxs[1].plot(time, bufferDPort1[1], label='D14')\r\naxs[1].plot(time, bufferDPort1[2], label='D13')\r\naxs[1].plot(time, bufferDPort1[3], label='D12')\r\naxs[1].plot(time, bufferDPort1[4], label='D11')\r\naxs[1].plot(time, bufferDPort1[5], label='D10')\r\naxs[1].plot(time, bufferDPort1[6], label='D9')\r\naxs[1].plot(time, bufferDPort1[7], label='D8')  # D0 is the last array in the tuple.\r\naxs[1].legend(loc=\"upper right\")\r\n\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Logic Level')\r\nplt.show()\r\n\r\n\r\n# fig, axs = plt.subplots(2)\r\n# fig.suptitle(\"MSO data\")\r\n\r\n# # Plot the data from digital channels onto a graph\r\n# axs[0].plot(time, bufferDPort0[0], label='D7')  # D7 is the first array in the tuple.\r\n# axs[0].plot(time, bufferDPort0[1], label='D6')\r\n# axs[0].plot(time, bufferDPort0[2], label='D5')\r\n# axs[0].plot(time, bufferDPort0[3], label='D4')\r\n# axs[0].plot(time, bufferDPort0[4], label='D3')\r\n# axs[0].plot(time, bufferDPort0[5], label='D2')\r\n# axs[0].plot(time, bufferDPort0[6], label='D1')\r\n# axs[0].plot(time, bufferDPort0[7], label='D0')  # D0 is the last array in the tuple.\r\n# axs[0].legend(loc=\"upper right\")\r\n# #plt.show()\r\n\r\n# # Plot the data from digital channels onto a graph\r\n# axs[1].plot(time, bufferDPort1[0], label='D15')  # D7 is the first array in the tuple.\r\n# axs[1].plot(time, bufferDPort1[1], label='D14')\r\n# axs[1].plot(time, bufferDPort1[2], label='D13')\r\n# axs[1].plot(time, bufferDPort1[3], label='D12')\r\n# axs[1].plot(time, bufferDPort1[4], label='D11')\r\n# axs[1].plot(time, bufferDPort1[5], label='D10')\r\n# axs[1].plot(time, bufferDPort1[6], label='D9')\r\n# axs[1].plot(time, bufferDPort1[7], label='D8')  # D0 is the last array in the tuple.\r\n# axs[1].legend(loc=\"upper right\")\r\n\r\n# plt.xlabel('Time (ns)')\r\n# plt.ylabel('Logic Level')\r\n# plt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aGetUnitInfo.py",
    "content": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A GET UNIT INFO EXAMPLE\r\n# This example opens a 6000a driver device, collects the model and serial nubmber from the device and closes the device.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.functions import assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Get unit info\r\nmodelNum = ctypes.create_string_buffer(6)\r\nmodelNumString = ctypes.cast(modelNum,ctypes.c_char_p)\r\nstringLength = len(modelNum)\r\nrequiredSize = ctypes.c_int16(stringLength)\r\ninfoModel= 0x03\r\nstatus[\"getUnitInfo_Model\"] = ps.ps6000aGetUnitInfo(chandle, modelNumString,stringLength,ctypes.byref(requiredSize),infoModel)\r\nassert_pico_ok(status[\"getUnitInfo_Model\"])\r\nprint(modelNum.value)\r\n\r\nSN = ctypes.create_string_buffer(b\"AA000/0000\")\r\nSNString = ctypes.cast(SN,ctypes.c_char_p)\r\nstringLength = len(SN)\r\nrequiredSize = ctypes.c_int16(stringLength)\r\ninfoSN = 0x04\r\nstatus[\"getUnitInfo_SN\"] = ps.ps6000aGetUnitInfo(chandle, SNString,stringLength,ctypes.byref(requiredSize),infoSN)\r\nassert_pico_ok(status[\"getUnitInfo_SN\"])\r\nprint(SN.value)\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aRapidBlockExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This example opens a 6000a driver device, sets up two channels and a trigger then collects 10 blocks of data in rapid block mode.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as struct\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import mV2adc, adc2mV, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\r\nchannelRange = 5\r\n# analogueOffset = 0 V\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\n\r\n# set channel B-H off\r\nfor x in range (1, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\",x] = ps.ps6000aSetChannelOff(chandle,channel)\r\n    assert_pico_ok(status[\"setChannel\",x])\r\n    \r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.ps6000aSetSimpleTrigger(chandle, 1, source, mV2adc(100,channelRange,maxADC), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# Get fastest available timebase\r\n# handle = chandle\r\nenabledChannelFlags = enums.PICO_CHANNEL_FLAGS[\"PICO_CHANNEL_A_FLAGS\"]\r\ntimebase = ctypes.c_uint32(0)\r\ntimeInterval = ctypes.c_double(0)\r\n# resolution = resolution\r\nstatus[\"getMinimumTimebaseStateless\"] = ps.ps6000aGetMinimumTimebaseStateless(chandle, enabledChannelFlags, ctypes.byref(timebase), ctypes.byref(timeInterval), resolution)\r\nassert_pico_ok(status[\"getMinimumTimebaseStateless\"])\r\nprint(\"timebase = \", timebase.value)\r\nprint(\"sample interval =\", timeInterval.value, \"s\")\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 500000\r\nnoOfPostTriggerSamples = 1000000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# Set number of memory segments\r\nnoOfCaptures = 10\r\nmaxSegments = ctypes.c_uint64(10)\r\nstatus[\"memorySegments\"] = ps.ps6000aMemorySegments(chandle, noOfCaptures, ctypes.byref(maxSegments))\r\nassert_pico_ok(status[\"memorySegments\"])\r\n\r\n# Set number of captures\r\nstatus[\"setNoOfCaptures\"] = ps.ps6000aSetNoOfCaptures(chandle, noOfCaptures)\r\nassert_pico_ok(status[\"setNoOfCaptures\"])\r\n\r\n# Create buffers\r\nbufferAMax = (ctypes.c_int16 * nSamples)()\r\nbufferAMin = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax1 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin1 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax2 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin2 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax3 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin3 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax4 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin4 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax5 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin5 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax6 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin6 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax7 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin7 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax8 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin8 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\nbufferAMax9 = (ctypes.c_int16 * nSamples)()\r\nbufferAMin9 = (ctypes.c_int16 * nSamples)() # used for downsampling which isn't in the scope of this example\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear|add # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]  \r\nstatus[\"setDataBuffers\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffers\"])\r\nwaveform1 = 1\r\nstatus[\"setDataBuffers1\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax1), ctypes.byref(bufferAMin1), nSamples, dataType, waveform1, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers1\"])\r\nwaveform2 = 2\r\nstatus[\"setDataBuffers2\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax2), ctypes.byref(bufferAMin2), nSamples, dataType, waveform2, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers2\"])\r\nwaveform3 = 3\r\nstatus[\"setDataBuffers3\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax3), ctypes.byref(bufferAMin3), nSamples, dataType, waveform3, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers3\"])\r\nwaveform4 = 4\r\nstatus[\"setDataBuffers4\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax4), ctypes.byref(bufferAMin4), nSamples, dataType, waveform4, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers4\"])\r\nwaveform5 = 5\r\nstatus[\"setDataBuffers5\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax5), ctypes.byref(bufferAMin5), nSamples, dataType, waveform5, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers5\"])\r\nwaveform6 = 6\r\nstatus[\"setDataBuffers6\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax6), ctypes.byref(bufferAMin6), nSamples, dataType, waveform6, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers6\"])\r\nwaveform7 = 7\r\nstatus[\"setDataBuffers7\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax7), ctypes.byref(bufferAMin7), nSamples, dataType, waveform7, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers7\"])\r\nwaveform8 = 8\r\nstatus[\"setDataBuffers8\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax8), ctypes.byref(bufferAMin8), nSamples, dataType, waveform8, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers8\"])\r\nwaveform9 = 9\r\nstatus[\"setDataBuffers9\"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax9), ctypes.byref(bufferAMin9), nSamples, dataType, waveform9, downSampleMode, add)\r\nassert_pico_ok(status[\"setDataBuffers9\"])\r\n\r\n# Run block capture\r\n# handle = chandle\r\n# timebase = timebase\r\ntimeIndisposedMs = ctypes.c_double(0)\r\n# segmentIndex = 0\r\n# lpReady = None   Using IsReady rather than a callback\r\n# pParameter = None\r\nstatus[\"runBlock\"] = ps.ps6000aRunBlock(chandle, noOfPreTriggerSamples, noOfPostTriggerSamples, timebase, ctypes.byref(timeIndisposedMs), 0, None, None)\r\nassert_pico_ok(status[\"runBlock\"])\r\n\r\n# Check for data collection to finish using ps6000aIsReady\r\nready = ctypes.c_int16(0)\r\ncheck = ctypes.c_int16(0)\r\nwhile ready.value == check.value:\r\n    status[\"isReady\"] = ps.ps6000aIsReady(chandle, ctypes.byref(ready))\r\n    \r\n# Get data from scope\r\n# handle = chandle\r\n# startIndex = 0\r\nnoOfSamples = ctypes.c_uint64(nSamples)\r\n# downSampleRatio = 1\r\n# segmentIndex = 0\r\n# Creates a overflow location for each segment\r\noverflow = (ctypes.c_int16 * 10)()\r\nstatus[\"getValues\"] = ps.ps6000aGetValuesBulk(chandle, 0, ctypes.byref(noOfSamples),0, 9, 1, downSampleMode, ctypes.byref(overflow))\r\nassert_pico_ok(status[\"getValues\"])\r\n\r\n# Handle = chandle\r\n# triggerInfo = (struct.PICO_TRIGGER_INFO * 10)()\r\n# Fromsegmentindex = 0\r\n# Tosegementindex = 9\r\ntriggerInfo = (struct.PICO_TRIGGER_INFO * 10)()\r\n\r\nstatus[\"GetTriggerInfo\"] = ps.ps6000aGetTriggerInfo(chandle, ctypes.byref(triggerInfo), 0, 10)\r\nassert_pico_ok(status[\"GetTriggerInfo\"])\r\nprint(\"TimestampCounter values in samples (only relative timestamps one segment to the next)\")\r\n# print(\"Timestamp samples for 2nd segment (index 1, from segment 0 to 1) = \", triggerInfo(1).timeStampCounter)\r\nprint(\"Printing triggerInfo for segments-\")\r\nfor i in triggerInfo:\r\n    print(\"segmentIndex is \", i.segmentIndex)\r\n    print(\"PICO_STATUS is \", i.status)\r\n    # print(\"triggerIndex is \", i.triggerIndex)\r\n    # print(\"triggerTime is \", i.triggerTime)\r\n    # print(\"timeUnits is \", i.timeUnits)\r\n    print(\"timeStampCounter is \", i.timeStampCounter)\r\n    print(\"-------------------------------\")\r\n\r\n# convert ADC counts data to mV\r\nadc2mVChAMax =  adc2mV(bufferAMax, channelRange, maxADC)\r\nadc2mVChAMax1 =  adc2mV(bufferAMax1, channelRange, maxADC)\r\nadc2mVChAMax2 =  adc2mV(bufferAMax2, channelRange, maxADC)\r\nadc2mVChAMax3 =  adc2mV(bufferAMax3, channelRange, maxADC)\r\nadc2mVChAMax4 =  adc2mV(bufferAMax4, channelRange, maxADC)\r\nadc2mVChAMax5 =  adc2mV(bufferAMax5, channelRange, maxADC)\r\nadc2mVChAMax6 =  adc2mV(bufferAMax6, channelRange, maxADC)\r\nadc2mVChAMax7 =  adc2mV(bufferAMax7, channelRange, maxADC)\r\nadc2mVChAMax8 =  adc2mV(bufferAMax8, channelRange, maxADC)\r\nadc2mVChAMax9 =  adc2mV(bufferAMax9, channelRange, maxADC)\r\n\r\n# Create time data\r\ntime = np.linspace(0, (nSamples -1) * timeInterval.value * 1000000000, nSamples)\r\n\r\n# plot data from channel A and B\r\nplt.plot(time, adc2mVChAMax[:])\r\nplt.plot(time, adc2mVChAMax1[:])\r\nplt.plot(time, adc2mVChAMax2[:])\r\nplt.plot(time, adc2mVChAMax3[:])\r\nplt.plot(time, adc2mVChAMax4[:])\r\nplt.plot(time, adc2mVChAMax5[:])\r\nplt.plot(time, adc2mVChAMax6[:])\r\nplt.plot(time, adc2mVChAMax7[:])\r\nplt.plot(time, adc2mVChAMax8[:])\r\nplt.plot(time, adc2mVChAMax9[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)\r\n"
  },
  {
    "path": "ps6000aExamples/ps6000aSigGenExample.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A SIGNAL GENERATOR EXAMPLE\r\n# This example opens a 6000a driver device, sets up the signal generator to do the following:\r\n# \r\n# 1. Output a sine wave \r\n# 2. Output a square wave \r\n# 3. Output a sweep of a square wave signal\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.functions import adc2mV, assert_pico_ok\r\nimport time\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set signal generator waveform\r\n# handle = chandle\r\nwavetype = enums.PICO_WAVE_TYPE[\"PICO_SINE\"]\r\nbufferlength = 1000\r\nbuffer = (ctypes.c_int16 * bufferlength)()\r\nstatus[\"sigGenWaveform\"] = ps.ps6000aSigGenWaveform(chandle, wavetype, ctypes.byref(buffer), bufferlength)\r\nassert_pico_ok(status[\"sigGenWaveform\"])\r\n\r\n# Set signal generator range\r\n# handle = chandle\r\npeakToPeakVolts = 2\r\noffsetVolts = 0\r\nstatus[\"sigGenRange\"] = ps.ps6000aSigGenRange(chandle, peakToPeakVolts, offsetVolts)\r\nassert_pico_ok(status[\"sigGenRange\"])\r\n\r\n# Set signal generator duty cycle\r\n# handle = chandle\r\ndutyCyclePercent = 50\r\nstatus[\"sigGenDutyCycle\"] = ps.ps6000aSigGenWaveformDutyCycle(chandle, dutyCyclePercent)\r\nassert_pico_ok(status[\"sigGenDutyCycle\"])\r\n\r\n# Set signal generator frequency\r\n# handle = chandle\r\nfrequencyHz = 1000\r\nstatus[\"sigGenFreq\"] = ps.ps6000aSigGenFrequency(chandle, frequencyHz)\r\nassert_pico_ok(status[\"sigGenFreq\"])\r\n\r\n# Apply signal generator settings\r\n# handle = chandle\r\nsigGenEnabled = 1\r\nsweepEnabled = 0\r\ntriggerEnabled = 0\r\nautomaticClockOptimisationEnabled = 0\r\noverrideAutomaticClockAndPrescale = 0\r\nfrequency = ctypes.c_int16(frequencyHz)\r\n#stopFrequency = None\r\n#frequencyIncrement = None\r\n#dwellTime = None\r\nstatus[\"sigGenApply\"] = ps.ps6000aSigGenApply(chandle, \r\n                                              sigGenEnabled, \r\n                                              sweepEnabled, \r\n                                              triggerEnabled, \r\n                                              automaticClockOptimisationEnabled, \r\n                                              overrideAutomaticClockAndPrescale, \r\n                                              ctypes.byref(frequency), \r\n                                              None,\r\n                                              None,\r\n                                              None\r\n                                              )\r\nassert_pico_ok(status[\"sigGenApply\"])\r\n\r\ntime.sleep(5)\r\n\r\n# Pause signal generator\r\n# handle = chandle\r\nstatus[\"sigGenPause\"] = ps.ps6000aSigGenPause(chandle)\r\nassert_pico_ok(status[\"sigGenPause\"])\r\n\r\ntime.sleep(5)\r\n\r\n# Resume signal generator\r\n# handle = chandle\r\nstatus[\"sigGenRestart\"] = ps.ps6000aSigGenRestart(chandle)\r\nassert_pico_ok(status[\"sigGenRestart\"])\r\n\r\ntime.sleep(5)\r\n\r\n# Pause signal generator\r\n# handle = chandle\r\nstatus[\"sigGenPause\"] = ps.ps6000aSigGenPause(chandle)\r\nassert_pico_ok(status[\"sigGenPause\"])\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "ps6000aExamples/ps6000aStreamingModeExample.py",
    "content": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A STREAMING MODE EXAMPLE\r\n# This example opens a 6000a driver device, sets up one channel then collects a streamed set of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.ps6000a import ps6000a as ps\r\nfrom picosdk.PicoDeviceEnums import picoEnum as enums\r\nfrom picosdk.PicoDeviceStructs import picoStruct as structs\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok, mV2adc\r\nfrom picosdk.constants import PICO_STATUS\r\nimport time\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# Open 6000 A series PicoScope\r\n# returns handle to chandle for use in future API functions\r\nresolution = enums.PICO_DEVICE_RESOLUTION[\"PICO_DR_8BIT\"]\r\nstatus[\"openunit\"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set channel A on\r\n# handle = chandle\r\nchannelA = enums.PICO_CHANNEL[\"PICO_CHANNEL_A\"]\r\ncoupling = enums.PICO_COUPLING[\"PICO_DC_50OHM\"]\r\nchannelRange = 5\r\n# analogueOffset = 0 V\r\nbandwidth = enums.PICO_BANDWIDTH_LIMITER[\"PICO_BW_FULL\"]\r\nstatus[\"setChannelA\"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelA\"])\r\nchannelB = enums.PICO_CHANNEL[\"PICO_CHANNEL_B\"]\r\nstatus[\"setChannelB\"] = ps.ps6000aSetChannelOn(chandle, channelB, coupling, channelRange, 0, bandwidth)\r\nassert_pico_ok(status[\"setChannelB\"])\r\n\r\n# set channel C-H off\r\nfor x in range(2, 7, 1):\r\n    channel = x\r\n    status[\"setChannel\", x] = ps.ps6000aSetChannelOff(chandle, channel)\r\n    assert_pico_ok(status[\"setChannel\", x])\r\n\r\n# Set number of samples to be collected\r\nnoOfPreTriggerSamples = 100000\r\nnoOfPostTriggerSamples = 900000\r\nnSamples = noOfPostTriggerSamples + noOfPreTriggerSamples\r\n\r\n# get max ADC value\r\n# handle = chandle\r\nminADC = ctypes.c_int16()\r\nmaxADC = ctypes.c_int16()\r\nstatus[\"getAdcLimits\"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC))\r\nassert_pico_ok(status[\"getAdcLimits\"])\r\n\r\n# Set simple trigger on channel A, 1 V rising with 1 s autotrigger\r\n# handle = chandle\r\n# enable = 1\r\nsource = channelA\r\n# threshold = 100 mV\r\ndirection = enums.PICO_THRESHOLD_DIRECTION[\"PICO_RISING\"]\r\n# delay = 0 s\r\n# autoTriggerMicroSeconds = 1000000 us\r\nstatus[\"setSimpleTrigger\"] = ps.ps6000aSetSimpleTrigger(chandle, 1, source, (mV2adc(100,channelRange,maxADC)), direction, 0, 1000000)\r\nassert_pico_ok(status[\"setSimpleTrigger\"])\r\n\r\n# create buffers\r\nmaxBuffers = 10\r\n\r\nbufferA = ((ctypes.c_int16 * nSamples) * 10)()\r\nbufferB = ((ctypes.c_int16 * nSamples) * 10)()\r\n\r\n# Set data buffers\r\n# handle = chandle\r\n# channel = channelA\r\n# bufferMax = bufferAMax\r\n# bufferMin = bufferAMin\r\n# nSamples = nSamples\r\ndataType = enums.PICO_DATA_TYPE[\"PICO_INT16_T\"]\r\nwaveform = 0\r\ndownSampleMode = enums.PICO_RATIO_MODE[\"PICO_RATIO_MODE_RAW\"]\r\nclear = enums.PICO_ACTION[\"PICO_CLEAR_ALL\"]\r\nadd = enums.PICO_ACTION[\"PICO_ADD\"]\r\naction = clear | add  # PICO_ACTION[\"PICO_CLEAR_WAVEFORM_CLEAR_ALL\"] | PICO_ACTION[\"PICO_ADD\"]\r\nactionAdd = add\r\nstatus[\"setDataBuffersA\"] = ps.ps6000aSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[0]), nSamples, dataType,\r\n                                                   waveform, downSampleMode, action)\r\nassert_pico_ok(status[\"setDataBuffersA\"])\r\nstatus[\"setDataBuffersB\"] = ps.ps6000aSetDataBuffer(chandle, channelB, ctypes.byref(bufferB[0]), nSamples, dataType,\r\n                                                   waveform, downSampleMode, actionAdd)\r\nassert_pico_ok(status[\"setDataBuffersB\"])\r\n\r\n# Run streaming\r\nsampleInterval = ctypes.c_double(1)\r\nsampleIntervalTimeUnits = enums.PICO_TIME_UNITS[\"PICO_US\"]\r\nautoStop = 0\r\ndownSampleRatio = 1\r\n\r\nstatus[\"runStreaming\"] = ps.ps6000aRunStreaming(chandle, ctypes.byref(sampleInterval), sampleIntervalTimeUnits,\r\n                                                noOfPreTriggerSamples, noOfPostTriggerSamples, autoStop,\r\n                                                downSampleRatio, downSampleMode)\r\nassert_pico_ok(status[\"runStreaming\"])\r\n\r\nstreamData = (structs.PICO_STREAMING_DATA_INFO * 2)()\r\nstreamData[0] = structs.PICO_STREAMING_DATA_INFO(channelA, downSampleMode, dataType, 0, 0, 0, 0)\r\nstreamData[1] = structs.PICO_STREAMING_DATA_INFO(channelB, downSampleMode, dataType, 0, 0, 0, 0)\r\n\r\nstreamTrigger = structs.PICO_STREAMING_DATA_TRIGGER_INFO(0, 0, 0)\r\n\r\ncount = 0\r\n\r\npicoOk = PICO_STATUS[\"PICO_OK\"]\r\n\r\ncollectedSamples = 0\r\n\r\nwhile collectedSamples < (maxBuffers*nSamples):\r\n\r\n    status[\"getStreamingLatestValues\"] = ps.ps6000aGetStreamingLatestValues(chandle, ctypes.byref(streamData), 1,\r\n                                                                            ctypes.byref(streamTrigger))\r\n\r\n    if status[\"getStreamingLatestValues\"] == picoOk:\r\n        # do nothing\r\n        time.sleep(0.01)\r\n    else:\r\n        count = count + 1\r\n        if count < maxBuffers:\r\n            status[\"setDataBufferA\"] = ps.ps6000aSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[count]),\r\n                                                              nSamples, dataType, waveform, downSampleMode, actionAdd)\r\n            assert_pico_ok(status[\"setDataBufferA\"])\r\n            status[\"setDataBufferB\"] = ps.ps6000aSetDataBuffer(chandle, channelB, ctypes.byref(bufferB[count]),\r\n                                                              nSamples, dataType, waveform, downSampleMode, actionAdd)\r\n            assert_pico_ok(status[\"setDataBufferB\"])\r\n            print(count)\r\n            \r\n    collectedSamples = collectedSamples + streamData[0].noOfSamples\r\n\r\n# stop scope streaming\r\nstatus[\"stop\"] = ps.ps6000aStop(chandle)\r\nassert_pico_ok(status[\"stop\"])\r\n\r\n# get total number of streamed data points\r\nnoOfStreamedSamples=ctypes.c_uint64()\r\nstatus[\"noOfStreamedSamples\"] = ps.ps6000aNoOfStreamingValues(chandle, ctypes.byref(noOfStreamedSamples))\r\nassert_pico_ok(status[\"noOfStreamedSamples\"])\r\n\r\nprint(\"streaming finished\")\r\nprint(\"Number of samples collected during streaming\")\r\nprint(noOfStreamedSamples.value)\r\n\r\n\r\n# convert ADC counts data to mV\r\nbufferAmV = []\r\nfor k in range (0, maxBuffers, 1):\r\n    mvValues =  adc2mV(bufferA[k], channelRange, maxADC)\r\n    bufferAmV.append(mvValues)\r\n\r\ntime = np.linspace(0, ((nSamples -1)*maxBuffers) * sampleInterval.value * 1000000, (nSamples*maxBuffers))\r\nstartTime = 0\r\nendTime = nSamples\r\n# plot ADC data\r\nfor h in range (0, maxBuffers, 1):\r\n    plt.plot(time[startTime:endTime],bufferAmV[h])\r\n    startTime += nSamples\r\n    endTime += nSamples\r\n# plt.xlabel('Time (us)')\r\n# plt.ylabel('Voltage (mV)')\r\n# plt.show()\r\n\r\n\r\n\r\n# Close the scope\r\nstatus[\"closeunit\"] = ps.ps6000aCloseUnit(chandle)\r\nassert_pico_ok(status[\"closeunit\"])\r\n\r\nprint(status)\r\n"
  },
  {
    "path": "pt104Examples/pt104DirectEthernet.py",
    "content": "#\n# Copyright (C) 2026 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PT-104 DIRECT ETHERNET EXAMPLE (NO SDK)\n# ######################################################################\n\n\"\"\"\nPure‑Ethernet PT‑104 client – mode.\n\nAssumptions (as you confirmed):\n* The PT‑104 has already been configured (via usb with picolog app) to output\n  temperature directly.\n* The configuration is 4 channels with PT100 4 wires with average enabled.\n* No SDK/DLL is used – everything is done with raw UDP packets.\n\"\"\"\n\nimport socket\nimport struct\nimport time\nimport threading\nimport codecs\n\n# ----------------------------------------------------------------------\n# --------------------------- USER SETTINGS ----------------------------\n# ----------------------------------------------------------------------\nDEVICE_IP   = \"172.26.178.124\"   # ← change if needed\nDEVICE_PORT = 1                  # listening port reported by the PT‑104\nDEVICE_ADDR = (DEVICE_IP, DEVICE_PORT)\n\n# Lookup table for Resistance (Ohms) to Temperature (Celsius)\n# Format: (Temperature, Resistance)\nRESISTANCE_TEMP_LOOKUP = [\n    (-50, 80.306282), (-49, 80.703340), (-48, 81.100257), (-47, 81.497036), (-46, 81.893677),\n    (-45, 82.290179), (-44, 82.686545), (-43, 83.082774), (-42, 83.478868), (-41, 83.874827),\n    (-40, 84.270652), (-39, 84.666343), (-38, 85.061901), (-37, 85.457327), (-36, 85.852622),\n    (-35, 86.247785), (-34, 86.642818), (-33, 87.037721), (-32, 87.432495), (-31, 87.827140),\n    (-30, 88.221657), (-29, 88.616046), (-28, 89.010309), (-27, 89.404445), (-26, 89.798455),\n    (-25, 90.192339), (-24, 90.586099), (-23, 90.979734), (-22, 91.373246), (-21, 91.766634),\n    (-20, 92.159898), (-19, 92.553041), (-18, 92.946061), (-17, 93.338960), (-16, 93.731737),\n    (-15, 94.124394), (-14, 94.516930), (-13, 94.909346), (-12, 95.301643), (-11, 95.693820),\n    (-10, 96.085879), (-9, 96.477819), (-8, 96.869641), (-7, 97.261345), (-6, 97.652931),\n    (-5, 98.044401), (-4, 98.435753), (-3, 98.826989), (-2, 99.218109), (-1, 99.609112),\n    (0, 100.000000), (1, 100.390772), (2, 100.781429), (3, 101.171970), (4, 101.562396),\n    (5, 101.952706), (6, 102.342901), (7, 102.732980), (8, 103.122944), (9, 103.512792),\n    (10, 103.902525), (11, 104.292142), (12, 104.681644), (13, 105.071030), (14, 105.460301),\n    (15, 105.849456), (16, 106.238496), (17, 106.627420), (18, 107.016229), (19, 107.404922),\n    (20, 107.793500), (21, 108.181962), (22, 108.570309), (23, 108.958540), (24, 109.346656),\n    (25, 109.734656), (26, 110.122541), (27, 110.510310), (28, 110.897964), (29, 111.285502),\n    (30, 111.672925), (31, 112.060232), (32, 112.447424), (33, 112.834500), (34, 113.221461),\n    (35, 113.608306), (36, 113.995036), (37, 114.381650), (38, 114.768149), (39, 115.154532),\n    (40, 115.540800), (41, 115.926952), (42, 116.312989), (43, 116.698910), (44, 117.084716),\n    (45, 117.470406), (46, 117.855981), (47, 118.241440), (48, 118.626784), (49, 119.012012),\n    (50, 119.397125), (51, 119.782122), (52, 120.167004), (53, 120.551770), (54, 120.936421),\n    (55, 121.320956), (56, 121.705376), (57, 122.089680), (58, 122.473869), (59, 122.857942),\n    (60, 123.241900), (61, 123.625742), (62, 124.009469), (63, 124.393080), (64, 124.776576),\n    (65, 125.159956), (66, 125.543221), (67, 125.926370), (68, 126.309404), (69, 126.692322),\n    (70, 127.075125), (71, 127.457812), (72, 127.840384), (73, 128.222840), (74, 128.605181),\n    (75, 128.987406), (76, 129.369516), (77, 129.751510), (78, 130.133389), (79, 130.515152),\n    (80, 130.896800), (81, 131.278332), (82, 131.659749), (83, 132.041050), (84, 132.422236),\n    (85, 132.803306), (86, 133.184261), (87, 133.565100), (88, 133.945824), (89, 134.326432),\n    (90, 134.706925), (91, 135.087302), (92, 135.467564), (93, 135.847710), (94, 136.227741),\n    (95, 136.607656), (96, 136.987456), (97, 137.367140), (98, 137.746709), (99, 138.126162),\n    (100, 138.505500), (101, 138.884722), (102, 139.263829), (103, 139.642820), (104, 140.021696),\n    (105, 140.400456), (106, 140.779101), (107, 141.157630), (108, 141.536044), (109, 141.914342),\n    (110, 142.292525), (111, 142.670592), (112, 143.048544), (113, 143.426380), (114, 143.804101),\n    (115, 144.181706), (116, 144.559196), (117, 144.936570), (118, 145.313829), (119, 145.690972),\n    (120, 146.068000), (121, 146.444912), (122, 146.821709), (123, 147.198390), (124, 147.574956),\n    (125, 147.951406), (126, 148.327741), (127, 148.703960), (128, 149.080064), (129, 149.456052),\n    (130, 149.831925), (131, 150.207682), (132, 150.583324), (133, 150.958850), (134, 151.334261),\n    (135, 151.709556), (136, 152.084736), (137, 152.459800), (138, 152.834749), (139, 153.209582),\n    (140, 153.584300), (141, 153.958902), (142, 154.333389), (143, 154.707760), (144, 155.082016),\n    (145, 155.456156), (146, 155.830181), (147, 156.204090), (148, 156.577884), (149, 156.951562),\n    (150, 157.325125), (151, 157.698572), (152, 158.071904), (153, 158.445120), (154, 158.818221),\n    (155, 159.191206), (156, 159.564076), (157, 159.936830), (158, 160.309469), (159, 160.681992),\n    (160, 161.054400), (161, 161.426692), (162, 161.798869), (163, 162.170930), (164, 162.542876),\n    (165, 162.914706), (166, 163.286421), (167, 163.658020), (168, 164.029504), (169, 164.400872),\n    (170, 164.772125), (171, 165.143262), (172, 165.514284), (173, 165.885190), (174, 166.255981),\n    (175, 166.626656), (176, 166.997216), (177, 167.367660), (178, 167.737989), (179, 168.108202),\n    (180, 168.478300), (181, 168.848282), (182, 169.218149), (183, 169.587900), (184, 169.957536),\n    (185, 170.327056), (186, 170.696461), (187, 171.065750), (188, 171.434924), (189, 171.803982),\n    (190, 172.172925), (191, 172.541752), (192, 172.910464), (193, 173.279060), (194, 173.647541),\n    (195, 174.015906), (196, 174.384156), (197, 174.752290), (198, 175.120309), (199, 175.488212),\n    (200, 175.856000)\n]\n\n# Define a dictionary to hold the structured \"Data\" variables based on the memory map\ndata_variables = {\n    \"Reserved_1\": None,\n    \"Batch\": None,\n    \"Calibration_Date\": None,\n    \"Ch1_Calibration\": None,\n    \"Ch2_Calibration\": None,\n    \"Ch3_Calibration\": None,\n    \"Ch4_Calibration\": None,\n    \"MAC_Address\": None,\n    \"Reserved_2\": None,\n    \"Checksum\": None,\n    \"status\": \"empty\"\n}\n\n# Define a dictionary to hold measurement packet data\nmeasurement_data = {\n    \"Channel_1\": [0, 0, 0, 0],  # Indices 00-03\n    \"Channel_2\": [0, 0, 0, 0],  # Indices 04-07\n    \"Channel_3\": [0, 0, 0, 0],  # Indices 08-0B\n    \"Channel_4\": [0, 0, 0, 0]   # Indices 0C-0F\n}\n\n# ----------------------------------------------------------------------\ndef interpolate_temperature(resistance):\n    \"\"\"\n    Performs linear interpolation on the RESISTANCE_TEMP_LOOKUP table.\n    \"\"\"\n    if resistance is None or resistance == 0:\n        return None\n\n    # Sort the table just in case (though it is provided sorted by temp)\n    # We need it sorted by Resistance for searching\n    table = sorted(RESISTANCE_TEMP_LOOKUP, key=lambda x: x[1])\n    \n    # Handle cases outside the table range (extrapolation)\n    if resistance <= table[0][1]:\n        p1, p2 = table[0], table[1]\n    elif resistance >= table[-1][1]:\n        p1, p2 = table[-2], table[-1]\n    else:\n        # Find the two points to interpolate between\n        p1, p2 = None, None\n        for i in range(len(table) - 1):\n            if table[i][1] <= resistance <= table[i+1][1]:\n                p1, p2 = table[i], table[i+1]\n                break\n    \n    # Linear Interpolation Formula: y = y1 + (x - x1) * ((y2 - y1) / (x2 - x1))\n    # y = Temperature, x = Resistance\n    t1, r1 = p1\n    t2, r2 = p2\n    \n    temperature = t1 + (resistance - r1) * ((t2 - t1) / (r2 - r1))\n    return temperature\n\ndef get_channel_temperatures(resistances):\n    \"\"\"\n    Converts a dictionary of resistances to temperatures.\n    \"\"\"\n    temps = {}\n    for ch, res in resistances.items():\n        temps[ch] = interpolate_temperature(res)\n    return temps\n\ndef calculate_resistances(eeprom_vars, measurements):\n    \"\"\"\n    Calculates resistance (in MOhms) for each channel using the formula:\n    result = ((cal * (m3 - m2)) / (m1 - m0)) / 1,000,000\n    \"\"\"\n    results = {}\n    \n    # Mapping EEPROM calibration keys to measurement storage keys\n    channels = [\n        (\"Channel_1\", \"Ch1_Calibration\"),\n        (\"Channel_2\", \"Ch2_Calibration\"),\n        (\"Channel_3\", \"Ch3_Calibration\"),\n        (\"Channel_4\", \"Ch4_Calibration\")\n    ]\n    \n    for m_key, c_key in channels:\n        cal = eeprom_vars.get(c_key)\n        m = measurements.get(m_key)\n        \n        # Ensure we have the calibration and measurement data\n        if cal is None or m is None:\n            results[m_key] = None\n            continue\n            \n        try:\n            # Formula updated to divide by 1,000,000 for Ohms\n            numerator = cal * (m[3] - m[2])\n            denominator = (m[1] - m[0])\n            \n            if denominator == 0:\n                print(f\"Warning: Division by zero for {m_key} (m1 - m0 = 0).\")\n                results[m_key] = 0.0\n            else:\n                # Calculate and convert to Ohms\n                results[m_key] = (numerator / denominator) / 1_000_000.0\n        except Exception as e:\n            print(f\"Error calculating {m_key}: {e}\")\n            results[m_key] = None\n            \n    return results\n\ndef parse_pkt_data(pkt, storage):\n    \"\"\"\n    Parses a 'pkt' variable containing indexed 32-bit values.\n    Format: [Index Byte] [4 Bytes Data (MSB First)]\n    \"\"\"\n    if not isinstance(pkt, bytes):\n        print(\"Error: pkt must be of type 'bytes'\")\n        return\n\n    # Process packet in chunks of 5 bytes (1 index + 4 data)\n    for i in range(0, len(pkt), 5):\n        chunk = pkt[i:i+5]\n        if len(chunk) < 5:\n            break\n            \n        index = chunk[0]\n        # Convert 4 bytes to integer (Big Endian / MSB First as specified)\n        value = int.from_bytes(chunk[1:5], byteorder='big')\n        \n        # Map indices to the appropriate channel array\n        if 0x00 <= index <= 0x03:\n            storage[\"Channel_1\"][index] = value\n        elif 0x04 <= index <= 0x07:\n            storage[\"Channel_2\"][index - 4] = value\n        elif 0x08 <= index <= 0x0B:\n            storage[\"Channel_3\"][index - 8] = value\n        elif 0x0C <= index <= 0x0F:\n            storage[\"Channel_4\"][index - 12] = value\n\n    print(f\"Success: Parsed packet data into measurement storage.\")\n\ndef parse_and_store_data(raw_input, data_store):\n    \"\"\"\n    Parses a bytes object or string by stripping the command prefix \n    and correcting escape sequences to reach the 128-byte payload.\n    \"\"\"\n    #print(f\"DEBUG1:{raw_input!r}\")\n    \n    # 1. Convert input to bytes\n    if isinstance(raw_input, str):\n        # latin-1 preserves byte-value integrity for characters 0-255\n        raw_bytes = raw_input.encode('latin-1')\n    elif isinstance(raw_input, bytes):\n        raw_bytes = raw_input\n    else:\n        print(\"Error: Input must be a bytes object or string.\")\n        return       \n    #print(f\"DEBUG2:{raw_bytes!r}\")\n\n    # 2. Extract Data after the '=' prefix\n    if b'=' in raw_bytes:\n        data_payload = raw_bytes.split(b'=', 1)[1]\n    else:\n        data_payload = raw_bytes\n    \n    #print(f\"DEBUG3: {data_payload!r}\")\n\n    # 3. Fix literal escaping (e.g., b'\\\\x00' -> b'\\x00')\n    try:\n        if b'\\\\' in data_payload:\n            data_payload = codecs.escape_decode(data_payload)[0]\n    except Exception as e:\n        print(f\"Warning during unescape: {e}\")\n\n    # 4. Final Alignment and Validation\n    actual_len = len(data_payload)\n    if actual_len < 128:\n        data_payload = data_payload.ljust(128, b'\\x00')\n    elif actual_len > 128:\n        data_payload = data_payload[:128]\n    #print(f\"DEBUG4: {data_payload!r}\")\n    try:\n        # Helper to decode ASCII and strip null/whitespace\n        def decode_text(b_slice):\n            return b_slice.decode('ascii', errors='ignore').split('\\x00')[0].strip()\n\n        # Helper for LSB-first 4-byte integers (Little Endian)\n        def to_int_lsb(b_slice):\n            return int.from_bytes(b_slice, byteorder='little')\n\n        # --- Adjusted Parsing Alignment ---\n        \n        # 0 to 19: Reserved\n        data_store[\"Reserved_1\"] = data_payload[0:19].hex().upper()\n        \n        # 19 to 29: Batch (10 bytes)\n        data_store[\"Batch\"] = decode_text(data_payload[19:29])\n        \n        # 29 to 37: Calibration Date (8 bytes)\n        data_store[\"Calibration_Date\"] = decode_text(data_payload[29:37])\n        \n        # 37 to 53: 4 Channels @ 4 bytes each\n        data_store[\"Ch1_Calibration\"] = to_int_lsb(data_payload[37:41])\n        data_store[\"Ch2_Calibration\"] = to_int_lsb(data_payload[41:45])\n        data_store[\"Ch3_Calibration\"] = to_int_lsb(data_payload[45:49])\n        data_store[\"Ch4_Calibration\"] = to_int_lsb(data_payload[49:53])\n        \n        # 53 to 59: MAC Address (6 bytes)\n        mac_bytes = data_payload[53:59]\n        data_store[\"MAC_Address\"] = \":\".join(f\"{b:02x}\" for b in mac_bytes).upper()\n        \n        # 59 to 126: Reserved\n        data_store[\"Reserved_2\"] = data_payload[59:126].hex().upper()\n        \n        # 126 to 128: Checksum\n        data_store[\"Checksum\"] = data_payload[126:128].hex().upper()\n        \n        data_store[\"status\"] = \"parsed_successfully\"\n        print(f\"Success: Parsed {len(data_payload)} bytes using adjusted offsets.\")\n\n    except Exception as e:\n        data_store[\"status\"] = \"error_parsing\"\n        print(f\"Error during parsing: {e}\")\n\n# ----------------------------------------------------------------------\n# UDP helpers\n# ----------------------------------------------------------------------\ndef udp_send(sock: socket.socket, payload: bytes, addr):\n    \"\"\"Send a UDP packet.\"\"\"\n    sock.sendto(payload, addr)\n\n\ndef udp_recv(sock: socket.socket, timeout: float = 2.0) -> bytes:\n    \"\"\"Receive a UDP packet; return empty bytes on timeout.\"\"\"\n    sock.settimeout(timeout)\n    try:\n        data, _ = sock.recvfrom(4096)\n        return data\n    except socket.timeout:\n        return b\"\"\n\n# ----------------------------------------------------------------------\n# Keep‑alive thread (0x34) – required every ≤ 15 s\n# ----------------------------------------------------------------------\ndef start_keep_alive(sock: socket.socket, dest):\n    \"\"\"Continuously send 0x34 (keep‑alive) every ~9 s.\"\"\"\n    def loop():\n        while True:\n            udp_send(sock, b\"\\x34\", dest)   # 0x34 = Keep‑alive\n            time.sleep(9)                  # a little under 10 s\n    t = threading.Thread(target=loop, daemon=True)\n    t.start()\n    return t\n\n# ----------------------------------------------------------------------\n# Lock the device (ASCII \"lock\") and interpret the reply\n# ----------------------------------------------------------------------\ndef lock_device(sock: socket.socket, dest) -> bool:\n    LOCK_CMD = b\"lock\"                 # ASCII lock command per the manual\n    udp_send(sock, LOCK_CMD, dest)\n\n    reply = udp_recv(sock, timeout=2.0)\n    if not reply:\n        print(\"⚠️  No reply to lock request – proceeding anyway.\")\n        return False\n\n    txt = reply.decode(errors=\"ignore\").lower()\n    if \"lock success\" in txt:\n        if \"already locked\" in txt:\n            print(\"ℹ️  Device already locked to this machine.\")\n        else:\n            print(\"✅  Lock acquired successfully.\")\n        return True\n    else:\n        print(f\"⚠️  Lock request failed / unexpected reply: {reply!r}\")\n        return False\n\n# ----------------------------------------------------------------------\n# Send the “read_EEPROM” command (0x32 )\n# ----------------------------------------------------------------------\ndef read_EEPROM(sock: socket.socket, dest):\n    \"\"\"\n    0x32 = read_EEPROM\n    \"\"\"\n    START_CMD = b'\\x32'\n    udp_send(sock, START_CMD, dest)\n\n    # Optional diagnostic reply (usually “Converting”)\n    resp = udp_recv(sock, timeout=1.0)\n    if resp:\n        temp = resp.decode(errors=\"ignore\").lower()\n        # 2. Parse and store into our variables\n        \n        if \"eeprom=\" in temp:\n            print(\"✅  read_EEPROM started – done\")\n        else:\n            print(f\"ℹ️  Unexpected read_EEPROM reply: {resp!r}\")\n    else:\n        print(\"⚠️  No immediate reply to read_EEPROM command (still OK).\")\n\n    parse_and_store_data(resp, data_variables)\n    # 3. Display results\n    print(\"\\n--- Parsed EEPROM data ---\")\n    for key, value in data_variables.items():\n        if key != \"status\":\n            print(f\"{key.replace('_', ' '):<20}: {value}\")\n\n# ----------------------------------------------------------------------\n# Send the “mains rejection” command (0x30, 0x00 )\n# ----------------------------------------------------------------------\ndef mains_rejection(sock: socket.socket, dest):\n    \"\"\"\n    0x30 = mains_rejection command\n    0x00 = For 50Hz\n    \"\"\"\n    START_CMD = b'\\x30\\x00'\n    udp_send(sock, START_CMD, dest)\n\n    # Optional diagnostic reply (usually “Converting”)\n    resp = udp_recv(sock, timeout=1.0)\n    if resp:\n        txt = resp.decode(errors=\"ignore\").lower()\n        if \"\" in txt:\n            print(\"✅  mains rejection started OK\")\n        else:\n            print(f\"ℹ️  Unexpected mains rejection reply: {resp!r}\")\n    else:\n        print(\"⚠️  No immediate reply to mains rejection command (still OK).\")\n\n# ----------------------------------------------------------------------\n# Send the “start converting” command (0x31 0x0F)\n# ----------------------------------------------------------------------\ndef start_converting(sock: socket.socket, dest):\n    \"\"\"\n    0x31 = start converting\n    0x0F = enable channels 1‑4 (bits 0‑3 = 1) and gain ×1 (bits 4‑7 = 0)\n    \"\"\"\n    START_CMD = b'\\x31\\x0F'\n    udp_send(sock, START_CMD, dest)\n\n    # Optional diagnostic reply (usually “Converting”)\n    resp = udp_recv(sock, timeout=1.0)\n    if resp:\n        txt = resp.decode(errors=\"ignore\").lower()\n        if \"converting\" in txt:\n            print(\"✅  Converter started – data will now stream.\")\n        else:\n            print(f\"ℹ️  Unexpected start‑convert reply: {resp!r}\")\n    else:\n        print(\"⚠️  No immediate reply to start‑convert command (still OK).\")\n\n\n# ----------------------------------------------------------------------\n# Main routine – receive raw temperature packets and print °C\n# ----------------------------------------------------------------------\ndef main():\n\n    # --------------------------------------------------------------\n    # 0️⃣  Create a UDP socket (bind to any free local port)\n    # --------------------------------------------------------------\n    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n    sock.bind((\"\", 0))                     # OS picks a free local port\n\n    # --------------------------------------------------------------\n    # 1️⃣  Lock the device\n    # --------------------------------------------------------------\n    have_lock = lock_device(sock, DEVICE_ADDR)\n\n    # --------------------------------------------------------------\n    # 2️⃣  Set read_EEPROM\n    # --------------------------------------------------------------\n    read_EEPROM(sock, DEVICE_ADDR)\n\n    # --------------------------------------------------------------\n    # 2️⃣  Set mains_rejection\n    # --------------------------------------------------------------\n    mains_rejection(sock, DEVICE_ADDR)\n\n    # --------------------------------------------------------------\n    # 2️⃣  Tell the logger to start converting (stream data)\n    # --------------------------------------------------------------\n    start_converting(sock, DEVICE_ADDR)\n\n    # --------------------------------------------------------------\n    # 3️⃣  Start keep‑alive (required whether we own the lock or not)\n    # --------------------------------------------------------------\n    start_keep_alive(sock, DEVICE_ADDR)\n    print(f\"✅ Keep‑alive started (0x34 every ~9 s) → {DEVICE_IP}:{DEVICE_PORT}\")\n\n    print(\"\\nWaiting for streamed data… (Ctrl‑C to stop)\\n\")\n\n    # --------------------------------------------------------------\n    # 4️⃣  Receive and decode measurement packets\n    # --------------------------------------------------------------\n    try:\n        while True:\n            pkt = udp_recv(sock, timeout=3.0)\n            if not pkt:\n                continue\n\n            # --------------------------------------------------\n            # a) Discard any textual packets (Lock replies, Alive, etc.)\n            # --------------------------------------------------\n            if pkt.startswith(b'PT104') or pkt.startswith(b'Lock') or pkt.startswith(b'Alive'):\n                continue\n\n            # --------------------------------------------------\n            # b) Binary measurement data: 5 bytes per channel\n            # --------------------------------------------------\n            if len(pkt) < 20:          # 4 channels × 5 bytes = 20 bytes\n                # Incomplete packet – ignore it.\n                continue\n            \n            parse_pkt_data(pkt, measurement_data)  \n            # Display raw channel data\n            # print(\"\\n--- Measurement Packet Results ---\")\n            # for channel, vals in measurement_data.items():\n            #     print(f\"{channel:<20}: {vals}\")\n\n            # Calculate Results\n            res_results = calculate_resistances(data_variables, measurement_data)\n            print(\"\\n--- Calculated Resistances (Ohms) ---\")\n            for channel, res in res_results.items():\n                if res is not None:\n                    print(f\"{channel:<20}: {res:.6f} Ohms\")\n                else:\n                    print(f\"{channel:<20}: Data Missing\")\n\n            # Convert to Temperature\n            temperatures = get_channel_temperatures(res_results)\n            print(\"\\n--- Temperature Results (Celsius) ---\")\n            for ch, temp in temperatures.items():\n                if temp is not None:\n                    print(f\"{ch:<20}: {temp:.2f} °C\")\n                else:\n                    print(f\"{ch:<20}: Invalid Data\")\n            # The logger up dates\n            # roughly every 720 ms per active channel.\n            time.sleep(0.5)\n\n    except KeyboardInterrupt:\n        print(\"\\n🛑 Stopped by user.\")\n    finally:\n        # ----------------------------------------------------------\n        # Optional: cleanly unlock the device if we own the lock\n        # ----------------------------------------------------------\n        if have_lock:\n            udp_send(sock, b\"lock\", DEVICE_ADDR)   # sending “lock” again releases it\n            print(\"🔓 Unlock command sent.\")\n        sock.close()\n\nif __name__ == \"__main__\":\n    main()"
  },
  {
    "path": "pt104Examples/pt104EnumerateTestsExample.py",
    "content": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PT104 Example\n# This example opens a pt104, sets up a single channel and collects data before closing the pt104\n\nimport ctypes\nfrom picosdk.usbPT104 import usbPt104 as pt104\nimport numpy as np\nfrom picosdk.functions import assert_pico_ok\nfrom time import sleep\nimport matplotlib.pyplot as plt\n\n# Create status ready for use\nstatus = {}\n\n# Setup Enumerating function data types\nEnumerate_string = ctypes.create_string_buffer(b\"------------------------------------------------------------------\")\nEnumUnitString = ctypes.cast(Enumerate_string,ctypes.c_char_p)\nstringLength = len(Enumerate_string)\nrequiredSize = ctypes.c_uint32(stringLength)\n\nunit_connection_method = pt104.COMMUNICATION_TYPE[\"CT_USB\"]\n\nprint(\"Enumerating Unit(s)...\")\nstatus[\"EnumerateUnit\"] = pt104.UsbPt104Enumerate(EnumUnitString, ctypes.byref(requiredSize) , unit_connection_method )\nassert_pico_ok(status[\"EnumerateUnit\"])\nprint(\"serial number(s) are-\")\nprint(EnumUnitString.value)\n\n# Create variables for unit handles\nchandle = ctypes.c_int16()\nchandle2 = ctypes.c_int16()\n\n# Open the device\nprint(\"Opening device...\")\nstatus[\"openUnit\"] = pt104.UsbPt104OpenUnit(ctypes.byref(chandle),0)\nassert_pico_ok(status[\"openUnit\"])\nprint(\"handle is: \", chandle)\n\nSN = ctypes.create_string_buffer(b\"AA000/0000\")\nSNString = ctypes.cast(SN,ctypes.c_char_p)\nstringLength = len(SN)\nrequiredSize = ctypes.c_int16(stringLength)\ninfoSN = 0x04\n\nstatus[\"getUnitInfo_SN\"] = pt104.UsbPt104GetUnitInfo(chandle, SNString,stringLength,ctypes.byref(requiredSize),infoSN)\nassert_pico_ok(status[\"getUnitInfo_SN\"])\nprint(\"Serial number is...\")\nprint(SN.value)\n\n# Open the 2nd device\nprint(\"Opening the 2nd device...\")\nstatus[\"openUnit\"] = pt104.UsbPt104OpenUnit(ctypes.byref(chandle2),0)\nassert_pico_ok(status[\"openUnit\"])\nprint(\"handle is: \", chandle2)\n\nstatus[\"getUnitInfo_SN\"] = pt104.UsbPt104GetUnitInfo(chandle2, SNString,stringLength,ctypes.byref(requiredSize),infoSN)\nassert_pico_ok(status[\"getUnitInfo_SN\"])\nprint(\"Serial number is...\")\nprint(SN.value)\n\n# Close the unit(s)\nprint(\"Closing Unit(s)...\")\nstatus[\"closeUnit\"] = pt104.UsbPt104CloseUnit(chandle)\nassert_pico_ok(status[\"closeUnit\"])\nstatus[\"closeUnit\"] = pt104.UsbPt104CloseUnit(chandle2)\nassert_pico_ok(status[\"closeUnit\"])\n\nprint(status)\n"
  },
  {
    "path": "pt104Examples/pt104Example.py",
    "content": "#\r\n# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PT104 Example\r\n# This example opens a pt104, sets up a single channel and collects data before closing the pt104\r\n\r\nimport ctypes\r\nfrom picosdk.usbPT104 import usbPt104 as pt104\r\nimport numpy as np\r\nfrom picosdk.functions import assert_pico_ok\r\nfrom time import sleep\r\nimport matplotlib.pyplot as plt\r\n\r\n# Create chandle and status ready for use\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Open the device\r\nstatus[\"openUnit\"] = pt104.UsbPt104OpenUnit(ctypes.byref(chandle),0)\r\nassert_pico_ok(status[\"openUnit\"])\r\n\r\n# Set mains noise filtering\r\nsixty_hertz = 0 #50 Hz\r\nstatus[\"setMains\"] = pt104.UsbPt104SetMains(chandle, sixty_hertz)\r\nassert_pico_ok(status[\"setMains\"])\r\n\r\n# Setup channel 1\r\nchannel = pt104.PT104_CHANNELS[\"USBPT104_CHANNEL_1\"] #channel 1\r\ndatatype = pt104.PT104_DATA_TYPE[\"USBPT104_PT100\"] #pt100\r\nnoOfWires = 4 #wires\r\n\r\nstatus[\"setChannel1\"] = pt104.UsbPt104SetChannel(chandle, channel, datatype, noOfWires)\r\nassert_pico_ok(status[\"setChannel1\"])\r\n\r\n#collect data\r\nprint(\"collecting data\")\r\nnumSamples = 20\r\n\r\ndata = (ctypes.c_int32 * numSamples)()\r\n\r\nfor i in range(numSamples):\r\n\r\n    #pause\r\n    sleep(2)\r\n\r\n    # Get values\r\n    measurement = ctypes.c_int32()\r\n    filtered = 1 # true\r\n    status[\"getValue\"] = pt104.UsbPt104GetValue(chandle, channel, ctypes.byref(measurement), filtered)\r\n    assert_pico_ok(status[\"getValue\"])\r\n    \r\n    data[i] = measurement.value\r\n\r\nsamples = np.linspace(0, numSamples*2, numSamples)\r\ndataTemp = [x /1000 for x in data]   \r\n\r\nplt.plot(samples, dataTemp)\r\nplt.xlabel('Time (s)')\r\nplt.ylabel('Temperature ($^o$C)')\r\nplt.show()\r\n\r\n# Close the device\r\nstatus[\"closeUnit\"] = pt104.UsbPt104CloseUnit(chandle)\r\nassert_pico_ok(status[\"closeUnit\"])\r\n\r\nprint(status)"
  },
  {
    "path": "requirements-for-examples.txt",
    "content": "matplotlib>=1.5.3\r\ntoml>=0.10.2"
  },
  {
    "path": "requirements.txt",
    "content": "numpy>=1.12.1"
  },
  {
    "path": "setup.py",
    "content": "#\n# Copyright (C) 2017-2018 Pico Technology Ltd.\n#\nfrom __future__ import print_function\nfrom setuptools import setup\n\nimport ctypes\nfrom ctypes import *\nfrom ctypes.util import find_library\nimport sys\nimport os.path\n\n\nsignalfile = \".sdkwarning\"\natleast1dll = 0\nif not os.path.exists(signalfile):\n    for name in ['ps2000', 'ps3000', 'ps4000', 'ps5000', 'ps2000a', 'ps3000a', 'ps4000a', 'ps5000a', 'ps6000a', 'ps6000', 'psospa']:\n        try:\n            if sys.platform == 'win32':\n                result = ctypes.WinDLL(find_library(name))\n            else:\n                result = cdll.LoadLibrary(find_library(name))\n            atleast1dll = 1\n        except OSError:\n            print(f\"Warning: PicoSDK installation is missing {name}.dll\")\n    if not atleast1dll:\n        print(\"Please install the PicoSDK in order to use this wrapper.\"\n              \"Visit https://www.picotech.com/downloads\")\n        exit(1)\n    open(signalfile, 'a').close()\n\nwith open(\"README.md\") as f:\n    readme = f.read()\n    \nsetup(\n    name='picosdk',\n    packages=['picosdk'],\n    install_requires=[\"numpy>=1.12.1\"],\n    version='1.0',\n    description='PicoSDK Python wrapper',\n    long_description=readme,\n    author='Pico Technology Ltd',\n    author_email='support@picotech.com',\n    license=\"ISC\",\n    url='https://www.picotech.com',\n    classifiers=[\n        \"Development Status :: 5 - Production/Stable\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: ISC License (ISCL)\",\n        \"Natural Language :: English\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.6\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Topic :: Scientific/Engineering\",\n    ],\n)\n"
  },
  {
    "path": "setupPicosynth.py",
    "content": "#\n# Copyright (C) 2017-2018 Pico Technology Ltd.\n#\nfrom __future__ import print_function\nfrom distutils.core import setup\n\nimport ctypes\nfrom ctypes import *\nfrom ctypes.util import find_library\nimport sys\nimport os.path\n\n\nsignalfile = \".sdkwarning\"\nif not os.path.exists(signalfile):\n    name = 'picosynth'\n    try:\n        if sys.platform == 'win32':\n            result = ctypes.WinDLL(find_library(name))\n            print(result)\n        else:\n            result = cdll.LoadLibrary(find_library(name))\n    except OSError:\n        print(\"Please install PicoSynth software in order to use this wrapper.\"\n              \"Visit https://www.picotech.com/downloads\")\n        exit(1)\n    open(signalfile, 'a').close()\n\n\nsetup(name='PicoSDK',\n      version='1.0',\n      description='PicoSDK Python wrapper',\n      author='Pico Technology Ltd',\n      author_email='support@picotech.com',\n      url='https://www.picotech.com',\n      packages=['picosdk'])\n"
  },
  {
    "path": "test/__init__.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n"
  },
  {
    "path": "test/run_examples.sh",
    "content": "#! /bin/bash\n\ncd \"${BASH_SOURCE%/*}\" || exit\n\nFILE_ERRORS=\"\"\nNEWLINE=$'\\n'\n\nfor file in ../ps*Examples/*\ndo\n    if [[ -f $file ]]; then\n        echo $file\n        PYTHONPATH=`pwd`/.. python $file\n        if [ $? -ne 0 ]; then\n            FILE_ERRORS=\"$FILE_ERRORS$file$NEWLINE\"\n        fi\n    fi\ndone\n\necho $FILE_ERRORS\n\nif [ -z \"$FILE_ERRORS\" ]; then\n    exit 0\nfi\nexit 1\n"
  },
  {
    "path": "test/test_discover.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for discovering devices\n\"\"\"\n\nfrom __future__ import print_function\n\nfrom test.test_helpers import DriverTest, drivers_with_device_connected\nfrom picosdk.device import Device\nfrom picosdk.errors import DeviceNotFoundError\nimport picosdk.discover as dut\n\n\nclass OpenCloseTest(DriverTest):\n    def test_find_unit_success(self):\n        \"\"\"test_find_unit_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n\n        device = dut.find_unit()\n        try:\n            self.assertIsInstance(device, Device)\n            self.assertIn(device.driver.name, drivers_with_device_connected)\n        finally:\n            device.close()\n\n    def test_find_all_units_success(self):\n        \"\"\"test_find_all_units_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n\n        devices = dut.find_all_units()\n\n        try:\n            for device in devices:\n                self.assertIsInstance(device, Device)\n                self.assertIn(device.driver.name, drivers_with_device_connected)\n            self.assertEqual(set(device.driver.name for device in devices), set(drivers_with_device_connected))\n        finally:\n            for device in devices:\n                device.close()\n\n    def test_find_unit_failure(self):\n        devices = []\n        threw = False\n        try:\n            while len(devices) <= len(drivers_with_device_connected):\n                devices.append(dut.find_unit())\n        except DeviceNotFoundError:\n            threw = True\n        finally:\n            for device in devices:\n                device.close()\n        self.assertEqual(len(drivers_with_device_connected), len(devices))\n        self.assertTrue(threw)\n\n    def test_find_all_units_failure(self):\n        devices = []\n        threw = False\n        try:\n            devices = dut.find_all_units()\n            dut.find_all_units()\n        except DeviceNotFoundError:\n            threw = True\n        finally:\n            for device in devices:\n                device.close()\n        self.assertTrue(threw)\n"
  },
  {
    "path": "test/test_get_unit_info.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper function for retrieving device information.\n\"\"\"\n\nfrom __future__ import print_function\n\nfrom test.test_helpers import DriverTest, drivers_with_device_connected\nfrom picosdk.errors import DeviceNotFoundError, ArgumentOutOfRangeError\n\ntry:\n    STRING_TYPES = (str, unicode)\nexcept:\n    STRING_TYPES = (bytes, str)\n\n\nclass GetInfoTest(DriverTest):\n    def test_get_info_success(self):\n        \"\"\"test_get_info_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            devices = []\n            try:\n                devices.append(driver.open_unit())\n            except DeviceNotFoundError:\n                return \"no device found.\"\n\n            device = devices.pop()\n            info = driver.get_unit_info(device)\n            device.close()\n\n            self.assertEqual(info.driver, driver)\n            self.assertIsInstance(info.variant, STRING_TYPES)\n            self.assertIsInstance(info.serial, STRING_TYPES)\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_get_info_advanced_success(self):\n        \"\"\"test_get_info_advanced_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            devices = []\n            try:\n                devices.append(driver.open_unit())\n            except DeviceNotFoundError:\n                return \"no device found.\"\n\n            device = devices.pop()\n            # three keys present on ALL devices.\n            info = driver.get_unit_info(device,\n                                        \"PICO_DRIVER_VERSION\",\n                                        \"PICO_USB_VERSION\",\n                                        \"PICO_HARDWARE_VERSION\")\n            device.close()\n\n            self.assertEqual(len(info), 3)\n            self.assertIsInstance(info.PICO_DRIVER_VERSION, STRING_TYPES)\n            self.assertIsInstance(info.PICO_USB_VERSION, STRING_TYPES)\n            self.assertIsInstance(info.PICO_HARDWARE_VERSION, STRING_TYPES)\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_get_info_with_invalid_key_fails(self):\n        \"\"\"test_get_info_advanced_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            devices = []\n            try:\n                devices.append(driver.open_unit())\n            except DeviceNotFoundError:\n                return \"no device found.\"\n\n            device = devices.pop()\n            threw = False\n            try:\n                # some valid and some invalid keys. People may pass PICO_CAL_DATE to ps2000 etc.\n                info = driver.get_unit_info(device,\n                                            \"PICO_DRIVER_VERSION\",\n                                            \"aillk_jasgKLASDFG_Jlasdkgfj\",\n                                            \"PICO_HARDWARE_VERSION\")\n            except ArgumentOutOfRangeError:\n                threw = True\n            finally:\n                device.close()\n\n            if not threw:\n                return \"get_unit_info didn't throw exception on bad key.\"\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n"
  },
  {
    "path": "test/test_helpers.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nHelper methods for tests, and test configuration information.\n\"\"\"\n\nimport importlib as _importlib\nimport unittest as _unittest\n\ndrivers_to_load = [\n    'ps2000',\n    'ps2000a',\n    'ps3000',\n    'ps3000a',\n    'ps4000',\n    'ps4000a',\n    'ps5000a',\n    'ps6000',\n]\n\nmodules = {}\n\nfor _d in drivers_to_load:\n    modules[_d] = _importlib.import_module(\"picosdk.%s\" % _d)\n\n# PLEASE MODIFY this list before running, to indicate which drivers should\n# expect to find a device.\ndrivers_with_device_connected = [\n    # 'ps2000',\n    # 'ps2000a',\n    # 'ps3000',\n    # 'ps3000a',\n    # 'ps4000',\n    # 'ps4000a',\n    # 'ps5000a',\n    # 'ps6000',\n]\n\n\nclass TestFailAndError(Exception):\n    pass\n\n\nclass TestError(Exception):\n    pass\n\n\nclass DriverTest(_unittest.TestCase):\n    @staticmethod\n    def _find_driver(name):\n        # e.g. ps2000.ps2000\n        m = modules[name]\n        return getattr(m, name)\n\n    def run_snippet_and_count_problems(self, drivers_to_use, fn):\n        errors = []\n        failures = []\n        for d in drivers_to_use:\n            driver = self._find_driver(d)\n            try:\n                result = fn(driver)\n                if result is not None:\n                    failures.append((d, result))\n            except Exception as e:\n                errors.append((d, e))\n        # format the errors and failure messages for printing:\n        errors = \", \".join([\"%s (%r)\" % e for e in errors])\n        failures = \", \".join([\"%s (%s)\" % f for f in failures])\n        if failures and errors:\n            raise TestFailAndError(\"drivers error'd: %s\\nand drivers failed: %s\" % (errors, failures))\n        elif errors:\n            raise TestError(\"drivers error'd: %s\" % errors)\n        else:\n            self.assertEqual(len(failures), 0, \"Drivers failed: %s\" % failures)\n"
  },
  {
    "path": "test/test_open_close_unit.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for opening and closing devices.\n\"\"\"\n\nfrom __future__ import print_function\n\nfrom test.test_helpers import DriverTest, drivers_to_load, drivers_with_device_connected\nfrom picosdk.errors import DeviceNotFoundError\n\n\nclass OpenCloseTest(DriverTest):\n    def test_open_unit_failure(self):\n        \"\"\"test_open_unit_failure\n        note: test assumes that at maximum one device is attached for each driver.\"\"\"\n        drivers_to_use = drivers_to_load\n\n        def test(driver):\n            threw = False\n            devices = []\n            try:\n                devices.append(driver.open_unit())\n                devices.append(driver.open_unit())\n            except DeviceNotFoundError:\n                threw = True\n            finally:\n                for device in devices:\n                    device.close()\n            if not threw:\n                return \"didn't throw a DeviceNotFoundError.\"\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_open_unit_success(self):\n        \"\"\"test_open_unit_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected[:]\n\n        def test(driver):\n            threw = False\n            devices = []\n            try:\n                devices.append(driver.open_unit())\n            except DeviceNotFoundError as e:\n                threw = e\n            finally:\n                for device in devices:\n                    print(\"closing device %s\" % device.handle)\n                    device.close()\n            if threw is not False:\n                return \"no device found (%s).\" % threw\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_close_unit_success(self):\n        \"\"\"test_close_unit_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            devices = []\n            try:\n                devices.append(driver.open_unit())\n            except DeviceNotFoundError as e:\n                return \"no device found (%s).\" % e\n\n            device = devices.pop()\n            info = device.info\n            device.close()\n            # To test the success of close(), we try to re-open the device.\n            # If we fail, then we have not closed it correctly.\n            try:\n                devices.append(driver.open_unit(serial=info.serial))\n            except DeviceNotFoundError as e:\n                return \"Could not close and then re-open the device (%s).\" % e\n            finally:\n                for device in devices:\n                    device.close()\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_with_statement_open_close(self):\n        \"\"\"test_with_statement_open_close\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected[:]\n\n        def test(driver):\n            threw = False\n            was_open = False\n            was_closed = False\n            outer_scope_device = None\n            try:\n                with driver.open_unit() as device:\n                    was_open = device.is_open\n                    outer_scope_device = device\n                was_closed = not outer_scope_device.is_open\n            except DeviceNotFoundError as e:\n                threw = e\n            finally:\n                if outer_scope_device is not None and not was_closed:\n                    outer_scope_device.close()\n            if threw is not False:\n                return \"no device found (%s).\" % threw\n            elif not was_open:\n                return \"device was not opened correctly\"\n            elif not was_closed:\n                return \"device was not closed after exiting the scope\"\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n"
  },
  {
    "path": "test/test_set_channel.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for configuring channels\n\"\"\"\n\nfrom __future__ import print_function\n\nfrom test.test_helpers import DriverTest, drivers_with_device_connected\nfrom picosdk.errors import ArgumentOutOfRangeError\nfrom picosdk.device import ChannelConfig\n\n\nclass SetChannelTest(DriverTest):\n    # Both 3000a and 5000a define a 50V enum member, but neither actually has a device which\n    # supports that range.\n    max_volts_by_driver = {\n        \"ps2000\": 20,\n        \"ps2000a\": 20,\n        \"ps3000\": 400,\n        \"ps3000a\": 20,\n        \"ps4000\": 100,\n        \"ps4000a\": 50,\n        \"ps5000a\": 20,\n    }\n\n    def test_set_channel_success(self):\n        \"\"\"test_set_channel_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            expected_max_volts = self.max_volts_by_driver[driver.name]\n            with driver.open_unit() as device:\n                config = ChannelConfig(name='A', enabled=True, coupling='DC', range_peak=expected_max_volts)\n                actual_max_voltage = device.set_channel(config)\n\n            self.assertEqual(expected_max_volts, actual_max_voltage)\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_set_channel_very_small_peak(self):\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        # Some drivers specify more ranges than some of their devices actually support. Check that we handle this error\n        # at the lowest voltages (at the upper range, see the relevant test below, there's nothing we can do but raise.)\n        def test(driver):\n            five_millivolts = 0.005\n\n            with driver.open_unit() as device:\n                config = ChannelConfig(name='A', enabled=True, coupling='DC', range_peak=five_millivolts)\n                actual_max_voltage = device.set_channel(config)\n\n            self.assertGreaterEqual(actual_max_voltage, five_millivolts)\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_set_channel_range_too_large(self):\n        \"\"\"test_set_channel_range_too_large\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            with driver.open_unit() as device:\n                threw = False\n                try:\n                    driver.set_channel(device, range_peak=float('inf'))\n                except ArgumentOutOfRangeError:\n                    threw = True\n                if not threw:\n                    return \"didn't throw an ArgumentOutOfRangeError.\"\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n"
  },
  {
    "path": "test/test_timebase.py",
    "content": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for computing and validating timebases\n\"\"\"\n\nfrom __future__ import print_function\n\nfrom test.test_helpers import DriverTest, drivers_with_device_connected\nimport unittest\nfrom picosdk.library import TimebaseInfo\nfrom picosdk.errors import InvalidTimebaseError, NoValidTimebaseForOptionsError\nfrom picosdk.device import Device, TimebaseOptions\nimport math\n\n\nclass FindTimebaseTest(DriverTest):\n    def assertValidTimebases(self, input_config, output_info):\n        if input_config.max_time_interval is not None:\n            self.assertLessEqual(output_info.time_interval, input_config.max_time_interval)\n        if input_config.no_of_samples is not None:\n            self.assertGreaterEqual(output_info.max_samples, input_config.no_of_samples)\n        if input_config.min_collection_time is not None:\n            self.assertGreaterEqual(output_info.time_interval * output_info.max_samples,\n                                    input_config.min_collection_time)\n\n    def test_find_timebase_success(self):\n        \"\"\"test_find_timebase_success\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n\n            with driver.open_unit() as device:\n                five_milliseconds = 0.005\n                config = TimebaseOptions(max_time_interval=five_milliseconds,\n                                         no_of_samples=None,\n                                         min_collection_time=five_milliseconds * 30,\n                                         oversample=1)\n                timebase_info = device.find_timebase(config)\n\n            self.assertValidTimebases(config, timebase_info)\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_find_timebase_terrasample(self):\n        \"\"\"test_find_timebase_terrasample\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            with driver.open_unit() as device:\n                threw = False\n                try:\n                    # we ask for a config which requires 1TS (one terra-sample) of memory on device.\n                    smallest_timebase = 1.e-8\n                    one_terra_sample = 1.e12\n                    duration = smallest_timebase * one_terra_sample\n                    config = TimebaseOptions(max_time_interval=smallest_timebase,\n                                             no_of_samples=one_terra_sample,\n                                             min_collection_time=duration)\n                    timebase_info = device.find_timebase(config)\n                except NoValidTimebaseForOptionsError:\n                    threw = True\n                if not threw:\n                    return \"didn't throw an NoValidTimebaseForOptionsError.\"\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_find_timebase_impossible(self):\n        \"\"\"test_find_timebase_impossible\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            with driver.open_unit() as device:\n                threw = False\n                try:\n                    # we ask for a config which cannot be achieved (specifying all 3 variables can lead to invalid\n                    # configs.)\n                    no_of_samples = 150\n                    duration = 0.4\n                    computed_timebase = duration / no_of_samples\n                    max_timebase_requested = computed_timebase / 4\n                    config = TimebaseOptions(max_time_interval=max_timebase_requested,\n                                             no_of_samples=no_of_samples,\n                                             min_collection_time=duration)\n                    timebase_info = device.find_timebase(config)\n                except NoValidTimebaseForOptionsError:\n                    threw = True\n                if not threw:\n                    return \"didn't throw an NoValidTimebaseForOptionsError.\"\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n    def test_get_timebase_throws_on_bad_params(self):\n        \"\"\"test_get_timebase_impossible\n        note: test assumes you have set test_helpers.drivers_with_device_connected\"\"\"\n        if not drivers_with_device_connected:\n            return\n        drivers_to_use = drivers_with_device_connected\n\n        def test(driver):\n            with driver.open_unit() as device:\n                threw = False\n                try:\n                    # we ask for a config which cannot be achieved (specifying all 3 variables can lead to invalid\n                    # configs.)\n                    no_of_samples = 150\n                    duration = 0.4\n                    computed_timebase = duration / no_of_samples\n                    max_timebase_requested = computed_timebase / 4\n\n                    # we manually invoke the Library method, to check that if invalid options sneak through, we throw\n                    # a different error:\n                    timebase_info = device.driver.get_timebase(device, 1, no_of_samples)\n                except InvalidTimebaseError:\n                    threw = True\n                if not threw:\n                    return \"didn't throw an InvalidTimebaseError.\"\n\n        self.run_snippet_and_count_problems(drivers_to_use, test)\n\n\nclass TimebaseValidationTest(unittest.TestCase):\n    def test_valid_config(self):\n        request = TimebaseOptions(max_time_interval=0.005,\n                                  no_of_samples=None,\n                                  min_collection_time=1.)\n        actual_timebase = 0.004\n        required_max_samples = int(math.ceil(request.min_collection_time / actual_timebase))\n        response = TimebaseInfo(timebase_id=7,\n                                time_interval=0.004,\n                                time_units=None,\n                                max_samples=required_max_samples+1,\n                                segment_id=0)\n\n        self.assertTrue(Device._validate_timebase(request, response))\n\n    def test_invalid_config(self):\n        request = TimebaseOptions(max_time_interval=0.005,\n                                  no_of_samples=None,\n                                  min_collection_time=1.)\n        actual_timebase = 0.004\n        required_max_samples = int(math.ceil(request.min_collection_time / actual_timebase))\n        response = TimebaseInfo(timebase_id=7,\n                                time_interval=0.004,\n                                time_units=None,\n                                max_samples=required_max_samples-5,\n                                segment_id=0)\n\n        self.assertFalse(Device._validate_timebase(request, response))\n"
  },
  {
    "path": "usbdrdaqExamples/usbdrdaqPhBlockExample.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# USBDRDAQ SCOPE BLOCK MODE EXAMPLE\r\n# This example opens a UsbDrDaq driver device, sets up the scope channel and a trigger then collects a single block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport time\r\nfrom picosdk.usbDrDaq import usbDrDaq as drDaq\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Opens the device\r\nstatus[\"openunit\"] = drDaq.UsbDrDaqOpenUnit(ctypes.byref(chandle))\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set sample interval\r\nus_for_block = ctypes.c_int32(1000)\r\nideal_no_of_samples = 1000\r\nchannels = ctypes.c_int32(drDaq.USB_DRDAQ_INPUTS[\"USB_DRDAQ_CHANNEL_PH\"])\r\nno_of_channels = 1\r\nstatus[\"setInterval\"] = drDaq.UsbDrDaqSetInterval(chandle, ctypes.byref(us_for_block), ideal_no_of_samples, ctypes.byref(channels), no_of_channels)\r\nassert_pico_ok(status[\"setInterval\"])\r\n\r\n# Find scaling information\r\nchannel = drDaq.USB_DRDAQ_INPUTS[\"USB_DRDAQ_CHANNEL_PH\"]\r\nnScales = ctypes.c_int16(0)\r\ncurrentScale = ctypes.c_int16(0)\r\nnames = (ctypes.c_char*256)()\r\nnamesSize = 256\r\nstatus[\"getscalings\"] = drDaq.UsbDrDaqGetScalings(chandle, channel, ctypes.byref(nScales), ctypes.byref(currentScale), ctypes.byref(names), namesSize)\r\nassert_pico_ok(status[\"getscalings\"])\r\n\r\nprint(nScales.value)\r\nprint(currentScale.value)\r\nprint(names.value)\r\n\r\n# Set channel scaling \r\nscalingNumber = 0 # pH scaling\r\nstatus[\"setscaling\"] = drDaq.UsbDrDaqSetScalings(chandle, channel, scalingNumber)\r\nassert_pico_ok(status[\"setscaling\"])\r\n\r\n# Set temperature compenstation\r\nenabled = 1\r\nstatus[\"phTemperatureCompensation\"] = drDaq.UsbDrDaqPhTemperatureCompensation(chandle, enabled)\r\nassert_pico_ok(status[\"phTemperatureCompensation\"])\r\n\r\n# Run block capture\r\nmethod = drDaq.USB_DRDAQ_BLOCK_METHOD[\"BM_SINGLE\"]\r\nstatus[\"run\"] = drDaq.UsbDrDaqRun(chandle, ideal_no_of_samples, method)\r\nassert_pico_ok(status[\"run\"])\r\n\r\nready = ctypes.c_int16(0)\r\n\r\nwhile ready.value == 0:\r\n    status[\"ready\"] = drDaq.UsbDrDaqReady(chandle, ctypes.byref(ready))\r\n    print(ready.value)\r\n    time.sleep(0.1)\r\n\r\n# Retrieve data from device\r\nvalues = (ctypes.c_float * ideal_no_of_samples)()\r\nnoOfValues = ctypes.c_uint32(ideal_no_of_samples)\r\noverflow = ctypes.c_uint16(0)\r\ntriggerIndex = ctypes.c_uint32(0)\r\nstatus[\"getvaluesF\"] = drDaq.UsbDrDaqGetValuesF(chandle, ctypes.byref(values), ctypes.byref(noOfValues), ctypes.byref(overflow), ctypes.byref(triggerIndex))\r\nassert_pico_ok(status[\"getvaluesF\"])\r\n\r\n# generate time data\r\ntime = np.linspace(0, us_for_block, ideal_no_of_samples)\r\n\r\n# plot the data\r\nplt.plot(time, values[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('pH')\r\nplt.show()\r\n\r\n\r\n# Disconnect the scope\r\n# handle = chandle\r\nstatus[\"close\"] = drDaq.UsbDrDaqCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Display status returns\r\nprint(status)\r\n"
  },
  {
    "path": "usbdrdaqExamples/usbdrdaqScopeBlockExample.py",
    "content": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# USBDRDAQ SCOPE BLOCK MODE EXAMPLE\r\n# This example opens a UsbDrDaq driver device, sets up the scope channel and a trigger then collects a single block of data.\r\n# This data is then plotted as mV against time in ns.\r\n\r\nimport ctypes\r\nimport time\r\nfrom picosdk.usbDrDaq import usbDrDaq as drDaq\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom picosdk.functions import adc2mV, assert_pico_ok\r\n\r\n# Create chandle and status ready for use\r\nstatus = {}\r\nchandle = ctypes.c_int16()\r\n\r\n# Opens the device\r\nstatus[\"openunit\"] = drDaq.UsbDrDaqOpenUnit(ctypes.byref(chandle))\r\nassert_pico_ok(status[\"openunit\"])\r\n\r\n# Set sample interval\r\nus_for_block = ctypes.c_int32(1000)\r\nideal_no_of_samples = 1000\r\nchannels = ctypes.c_int32(drDaq.USB_DRDAQ_INPUTS[\"USB_DRDAQ_CHANNEL_SCOPE\"])\r\nno_of_channels = 1\r\nstatus[\"setInterval\"] = drDaq.UsbDrDaqSetInterval(chandle, ctypes.byref(us_for_block), ideal_no_of_samples, ctypes.byref(channels), no_of_channels)\r\nassert_pico_ok(status[\"setInterval\"])\r\n\r\n# Find scaling information\r\nchannel = drDaq.USB_DRDAQ_INPUTS[\"USB_DRDAQ_CHANNEL_SCOPE\"]\r\nnScales = ctypes.c_int16(0)\r\ncurrentScale = ctypes.c_int16(0)\r\nnames = (ctypes.c_char*256)()\r\nnamesSize = 256\r\nstatus[\"getscalings\"] = drDaq.UsbDrDaqGetScalings(chandle, channel, ctypes.byref(nScales), ctypes.byref(currentScale), ctypes.byref(names), namesSize)\r\nassert_pico_ok(status[\"getscalings\"])\r\n\r\nprint(nScales.value)\r\nprint(currentScale.value)\r\nprint(names.value)\r\n\r\n# Set channel scaling \r\nscalingNumber = drDaq.USB_DRDAQ_SCOPE_RANGE[\"USB_DRDAQ_2V5\"]\r\nstatus[\"setscaling\"] = drDaq.UsbDrDaqSetScalings(chandle, channel, scalingNumber)\r\nassert_pico_ok(status[\"setscaling\"])\r\n\r\n# Set trigger\r\nenabled = 1\r\nauto_trigger = 1\r\nauto_ms = 1000 # in ms\r\ndir = 0 # rising edge\r\nthreshold = 1000 # in mV\r\nhysteresis = 50 # in ADC counts\r\ndelay = -50 # trigger in centre of block\r\nstatus[\"settrigger\"] = drDaq.UsbDrDaqSetTrigger(chandle, enabled, auto_trigger, auto_ms, channel, dir, threshold, hysteresis, delay)\r\nassert_pico_ok(status[\"settrigger\"])\r\n\r\n# Run block capture\r\nmethod = drDaq.USB_DRDAQ_BLOCK_METHOD[\"BM_SINGLE\"]\r\nstatus[\"run\"] = drDaq.UsbDrDaqRun(chandle, ideal_no_of_samples, method)\r\nassert_pico_ok(status[\"run\"])\r\n\r\nready = ctypes.c_int16(0)\r\n\r\nwhile ready.value == 0:\r\n    status[\"ready\"] = drDaq.UsbDrDaqReady(chandle, ctypes.byref(ready))\r\n    print(ready.value)\r\n    time.sleep(0.1)\r\n\r\n# Retrieve data from device\r\nvalues = (ctypes.c_float * ideal_no_of_samples)()\r\nnoOfValues = ctypes.c_uint32(ideal_no_of_samples)\r\noverflow = ctypes.c_uint16(0)\r\ntriggerIndex = ctypes.c_uint32(0)\r\nstatus[\"getvaluesF\"] = drDaq.UsbDrDaqGetValuesF(chandle, ctypes.byref(values), ctypes.byref(noOfValues), ctypes.byref(overflow), ctypes.byref(triggerIndex))\r\nassert_pico_ok(status[\"getvaluesF\"])\r\n\r\n# generate time data\r\ntime = np.linspace(0, us_for_block, ideal_no_of_samples)\r\n\r\n# plot the data\r\nplt.plot(time, values[:])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Voltage (mV)')\r\nplt.show()\r\n\r\n\r\n# Disconnect the scope\r\n# handle = chandle\r\nstatus[\"close\"] = drDaq.UsbDrDaqCloseUnit(chandle)\r\nassert_pico_ok(status[\"close\"])\r\n\r\n# Display status returns\r\nprint(status)\r\n"
  },
  {
    "path": "usbtc08Examples/tc08SingleModeExample.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# TC-08 SINGLE MODE EXAMPLE\r\n\r\n\r\nimport ctypes\r\nimport numpy as np\r\nfrom picosdk.usbtc08 import usbtc08 as tc08\r\nfrom picosdk.functions import assert_pico2000_ok\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# open unit\r\nstatus[\"open_unit\"] = tc08.usb_tc08_open_unit()\r\nassert_pico2000_ok(status[\"open_unit\"])\r\nchandle = status[\"open_unit\"]\r\n\r\n# set mains rejection to 50 Hz\r\nstatus[\"set_mains\"] = tc08.usb_tc08_set_mains(chandle,0)\r\nassert_pico2000_ok(status[\"set_mains\"])\r\n\r\n# set up channel\r\n# therocouples types and int8 equivalent\r\n# B=66 , E=69 , J=74 , K=75 , N=78 , R=82 , S=83 , T=84 , ' '=32 , X=88 \r\ntypeK = ctypes.c_int8(75)\r\nstatus[\"set_channel\"] = tc08.usb_tc08_set_channel(chandle, 1, typeK)\r\nassert_pico2000_ok(status[\"set_channel\"])\r\n\r\n# get minimum sampling interval in ms\r\nstatus[\"get_minimum_interval_ms\"] = tc08.usb_tc08_get_minimum_interval_ms(chandle)\r\nassert_pico2000_ok(status[\"get_minimum_interval_ms\"])\r\n\r\n# get single temperature reading\r\ntemp = (ctypes.c_float * 9)()\r\noverflow = ctypes.c_int16(0)\r\nunits = tc08.USBTC08_UNITS[\"USBTC08_UNITS_CENTIGRADE\"]\r\nstatus[\"get_single\"] = tc08.usb_tc08_get_single(chandle,ctypes.byref(temp), ctypes.byref(overflow), units)\r\nassert_pico2000_ok(status[\"get_single\"])\r\n\r\n# print data\r\nprint(\"Cold Junction \", temp[0],\" Channel 1 \", temp[1])\r\n\r\n\r\n# close unit\r\nstatus[\"close_unit\"] = tc08.usb_tc08_close_unit(chandle)\r\nassert_pico2000_ok(status[\"close_unit\"])\r\n\r\n# display status returns\r\nprint(status)"
  },
  {
    "path": "usbtc08Examples/tc08StreamingModeExample.py",
    "content": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# TC-08 STREAMING MODE EXAMPLE\r\n\r\n\r\nimport ctypes\r\nimport numpy as np\r\nimport time\r\nfrom picosdk.usbtc08 import usbtc08 as tc08\r\nfrom picosdk.functions import assert_pico2000_ok\r\nimport matplotlib.pyplot as plt\r\n\r\n# Create chandle and status ready for use\r\nchandle = ctypes.c_int16()\r\nstatus = {}\r\n\r\n# open unit\r\nstatus[\"open_unit\"] = tc08.usb_tc08_open_unit()\r\nassert_pico2000_ok(status[\"open_unit\"])\r\nchandle = status[\"open_unit\"]\r\n\r\n# set mains rejection to 50 Hz\r\nstatus[\"set_mains\"] = tc08.usb_tc08_set_mains(chandle,0)\r\nassert_pico2000_ok(status[\"set_mains\"])\r\n\r\n# set up channel\r\n# therocouples types and int8 equivalent\r\n# B=66 , E=69 , J=74 , K=75 , N=78 , R=82 , S=83 , T=84 , ' '=32 , X=88 \r\ntypeK = ctypes.c_int8(75)\r\nstatus[\"set_channel\"] = tc08.usb_tc08_set_channel(chandle, 1, typeK)\r\nassert_pico2000_ok(status[\"set_channel\"])\r\n\r\n# get minimum sampling interval in ms\r\nstatus[\"get_minimum_interval_ms\"] = tc08.usb_tc08_get_minimum_interval_ms(chandle)\r\nassert_pico2000_ok(status[\"get_minimum_interval_ms\"])\r\n\r\n# set tc-08 running\r\nstatus[\"run\"] = tc08.usb_tc08_run(chandle, status[\"get_minimum_interval_ms\"])\r\nassert_pico2000_ok(status[\"run\"])\r\n\r\ntime.sleep(21)\r\n\r\n# collect data \r\ntemp_buffer = (ctypes.c_float * 2 * 100)()\r\ntimes_ms_buffer = (ctypes.c_int32 * 100)()\r\noverflow = ctypes.c_int16()\r\nstatus[\"get_temp\"] = tc08.usb_tc08_get_temp(chandle, ctypes.byref(temp_buffer), ctypes.byref(times_ms_buffer), 100, ctypes.byref(overflow), 1, 0, 1)\r\nassert_pico2000_ok(status[\"get_temp\"])\r\n\r\n# stop unit\r\nstatus[\"stop\"] = tc08.usb_tc08_stop(chandle)\r\nassert_pico2000_ok(status[\"stop\"])\r\n\r\n# close unit\r\nstatus[\"close_unit\"] = tc08.usb_tc08_close_unit(chandle)\r\nassert_pico2000_ok(status[\"close_unit\"])\r\n\r\n# plot data\r\nplt.plot(temp_buffer[0:status[\"get_temp\"]])\r\nplt.xlabel('Time (ns)')\r\nplt.ylabel('Temperature (oC)')\r\nplt.show()\r\n\r\n# display status returns\r\nprint(status)"
  },
  {
    "path": "usbtc08Examples/tc08StreamingModeMultiChExample.py",
    "content": "#\n# Copyright (C) 2026 Pico Technology Ltd. See LICENSE file for terms.\n#\n# TC-08 STREAMING MODE EXAMPLE\n\nimport ctypes\nimport time\nimport numpy as np\nfrom picosdk.usbtc08 import usbtc08 as tc08\nfrom picosdk.functions import assert_pico2000_ok\n\n# --- Configuration ---\nNUM_SAMPLES = 100\nRequested_No_Samples = 5 # per function call - sets the loop delay (min. value is 1)\n# Define which channels to enable (1-8). 0 is the Cold Junction.\nENABLED_CHANNELS = [1, 2, 8] \nTHERMOCOUPLE_TYPE = ord('K') # 'K' type. Use 32 (ASCII space) to disable.\n# ---------------------\n\n# Create status dictionary to track API calls\nstatus = {}\n\n# Open Unit\nstatus[\"open_unit\"] = tc08.usb_tc08_open_unit()\nassert_pico2000_ok(status[\"open_unit\"])\nchandle = status[\"open_unit\"]\n\ntry:\n    # Set Mains Rejection (50Hz = 0, 60Hz = 1)\n    status[\"set_mains\"] = tc08.usb_tc08_set_mains(chandle, 0)\n    assert_pico2000_ok(status[\"set_mains\"])\n\n    # Setup Channels\n    # Always set channel 0 (Cold Junction)\n    #tc08.usb_tc08_set_channel(chandle, 0, ord(' ')) \n    Enabled_chs = 0\n    for chan in ENABLED_CHANNELS:\n        status[f\"set_chan_{chan}\"] = tc08.usb_tc08_set_channel(chandle, chan, THERMOCOUPLE_TYPE)\n        assert_pico2000_ok(status[f\"set_chan_{chan}\"])\n        Enabled_chs = Enabled_chs + 1\n\n    # Get the minimum sampling interval\n    # This determines how fast the device can switch between enabled channels\n    min_interval_ms = tc08.usb_tc08_get_minimum_interval_ms(chandle)\n    status[\"get_temp_return\"] = min_interval_ms\n    assert_pico2000_ok(status[\"get_temp_return\"])\n    print(f\"Minimum sampling interval: {min_interval_ms} ms\")\n\n    # Prepare Data Storage\n    # We need a buffer for each channel's samples\n    # data_store[channel_index][sample_index]\n    #captured_samples=np.zeros(shape=(9, NUM_SAMPLES), dtype=ctypes.c_float)\n    rows, cols = 9, NUM_SAMPLES\n    RowType = ctypes.c_float * cols\n    Array2D = RowType * rows\n    captured_samples = Array2D()\n    \n    # Buffers required by usb_tc08_get_temp\n    # It returns up to 'buffer_length' samples per call\n    temp_buffer = (ctypes.c_float * 600)() # Buffer\n    times_ms_buffer = (ctypes.c_int32 * 600)() \n    overflow = ctypes.c_int16()\n\n    # set tc-08 running\n    status[\"run\"] = tc08.usb_tc08_run(chandle, min_interval_ms)\n    assert_pico2000_ok(status[\"run\"])\n\n    print(f\"Starting capture of {NUM_SAMPLES} samples...\")\n    current_num_samples = 0\n    # Collection Loop\n    while current_num_samples in range(NUM_SAMPLES):\n        # We call get_temp for each sample point\n        # The library fills the buffer with the most recent readings\n        # Store the data for our enabled channels\n        for chan in ENABLED_CHANNELS:\n            get_temp_return = tc08.usb_tc08_get_temp(\n                chandle, \n                ctypes.byref(temp_buffer), \n                ctypes.byref(times_ms_buffer), \n                len(temp_buffer),\n                ctypes.byref(overflow), # Chanel over range flag\n                chan, # channel\n                0, # units (0 = Centigrade)\n                1  # fill_missing samples\n            )\n            if(get_temp_return < 0):\n                status[\"get_temp_return\"] = get_temp_return\n                assert_pico2000_ok(status[\"get_temp_return\"])\n            \n            if(get_temp_return > 0): # If Samples\n                if((current_num_samples+get_temp_return) < NUM_SAMPLES): \n                    captured_samples[chan][current_num_samples:(current_num_samples+get_temp_return)] = temp_buffer[0:get_temp_return]\n\n        current_num_samples = current_num_samples + get_temp_return\n\n        # Print current values from channels-\n        if(get_temp_return > 0):\n            for chan in ENABLED_CHANNELS:\n                print(\"Channel: \", chan )\n                print(\"Channel Temps: \", captured_samples[chan][current_num_samples-get_temp_return])\n\n        # Delay by the minimum interval to ensure hardware is ready for next conversion\n        time.sleep(min_interval_ms * Requested_No_Samples / 1000.0)\n\n        if current_num_samples % 10 == 0:\n            print(f\"Captured {current_num_samples} samples...\")\n\n    print(\"Capture complete.\")\n\nfinally:\n    # Close Unit\n    status[\"close_unit\"] = tc08.usb_tc08_close_unit(chandle)\n    assert_pico2000_ok(status[\"close_unit\"])\n    print(\"Device closed.\")"
  }
]