def __init__(self):
        # Create chandle and status ready for use
        self.status = {}
        self.chandle = ctypes.c_int16()

        # Opens the device/s
        self.status["openunit"] = ps.ps3000aOpenUnit(
            ctypes.byref(self.chandle), None)

        try:
            assert_pico_ok(self.status["openunit"])
        except:

            # powerstate becomes the status number of openunit
            powerstate = self.status["openunit"]

            # If powerstate is the same as 282 then it will run this if statement
            if powerstate == 282:
                # Changes the power input to "PICO_POWER_SUPPLY_NOT_CONNECTED"
                self.status["ChangePowerSource"] = ps.ps3000aChangePowerSource(
                    self.chandle, 282)
                # If the powerstate is the same as 286 then it will run this if statement
            elif powerstate == 286:
                # Changes the power input to "PICO_USB3_0_DEVICE_NON_USB3_0_PORT"
                self.status["ChangePowerSource"] = ps.ps3000aChangePowerSource(
                    self.chandle, 286)
            else:
                raise

            assert_pico_ok(self.status["ChangePowerSource"])
Exemple #2
0
    def open(self, serial=None):
        """Open the device.

        :param serial: (optional) Serial number of the device
        :param resolution_bits: vertical resolution in number of bits
        """
        handle = ctypes.c_int16()
        status = ps.ps3000aOpenUnit(ctypes.byref(handle), serial)
        status_msg = PICO_STATUS_LOOKUP[status]

        if status_msg == "PICO_OK":
            self._handle = handle
        elif status_msg == 'PICO_NOT_FOUND':
            raise DeviceNotFoundError()
        else:
            raise PicoSDKError(f"PicoSDK returned {status_msg}")

        self.set_channel('A', is_enabled=False)
        self.set_channel('B', is_enabled=False)
Exemple #3
0
# Setup a digital port
# Collect a block of data
# Plot data

import ctypes
from picosdk.ps3000a import ps3000a as ps
from picosdk.functions import splitMSODataFast, assert_pico_ok
import numpy as np
import matplotlib.pyplot as plt

# Gives the device a handle
status = {}
chandle = ctypes.c_int16()

# Opens the device/s
status["openunit"] = ps.ps3000aOpenUnit(ctypes.byref(chandle), None)

try:
    assert_pico_ok(status["openunit"])
except:
    # powerstate becomes the status number of openunit
    powerstate = status["openunit"]

    # If powerstate is the same as 282 then it will run this if statement
    if powerstate == 282:
        # Changes the power input to "PICO_POWER_SUPPLY_NOT_CONNECTED"
        status["ChangePowerSource"] = ps.ps3000aChangePowerSource(chandle, 282)
    # If the powerstate is the same as 286 then it will run this if statement
    elif powerstate == 286:
        # Changes the power input to "PICO_USB3_0_DEVICE_NON_USB3_0_PORT"
        status["ChangePowerSource"] = ps.ps3000aChangePowerSource(chandle, 286)