def initScope(self):
        self.status["openunit"] = ps.ps5000aOpenUnit(ctypes.byref(
            self.chandle), None, self.resolution)  #sets the chandle

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

            powerStatus = self.status["openunit"]

            if powerStatus == 286:
                self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                    self.chandle, powerStatus)
            elif powerStatus == 282:
                self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                    self.chandle, powerStatus)
            else:
                raise

            assert_pico_ok(self.status["changePowerSource"])

        #find out the ADC range for this resolution
        self.status["maximumValue"] = ps.ps5000aMaximumValue(
            self.chandle, ctypes.byref(self.maxADC))
        assert_pico_ok(self.status["maximumValue"])
Esempio n. 2
0
 def change_powersupply(self, state):
     if state == 286:  # USB3_0_DEVICE_NON_USB3_0_PORT (Does this work?)
         self.status["changePowerSource"] = ps.ps5000aChangePowerSource(self.chandle, state)  # Change powersource to USB2
     elif state == 282:  # POWER_SUPPLY_NOT_CONNECTED
         self.status["changePowerSource"] = ps.ps5000aChangePowerSource(self.chandle, state)  # Change powersource to USB3
     else:
         self.status["changePowerSource"] = state
     assert_pico_ok(self.status["changePowerSource"])  # Check whether the powerchange was successful
 def __open__(self):
     # set resolution
     res = ps.PS5000A_DEVICE_RESOLUTION["PS5000A_DR_"+self.settings['resolution']]
     # Returns handle to chandle for use in future API functions
     self.status["openunit"] = ps.ps5000aOpenUnit(ctypes.byref(self.chandle), None, res)
     try:
         assert_pico_ok(self.status["openunit"])
     except: # PicoNotOkError:
         powerStatus = self.status["openunit"]
         if powerStatus == 286:
             self.status["changePowerSource"] = ps.ps5000aChangePowerSource(self.chandle, powerStatus)
         elif powerStatus == 282:
             self.status["changePowerSource"] = ps.ps5000aChangePowerSource(self.chandle, powerStatus)
         else:
             raise
         assert_pico_ok(self.status["changePowerSource"])
Esempio n. 4
0
    def makeConnection(self):
        self.status["openunit"] = ps.ps5000aOpenUnit(
            ctypes.byref(self.chandle), None, self.resolution)
        try:
            assert_pico_ok(self.status["openunit"])
        except:  # PicoNotOkError:

            self.powerStatus = self.status["openunit"]

            if self.powerStatus == 286:
                self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                    self.chandle, self.powerStatus)
            elif self.powerStatus == 282:
                self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                    self.chandle, self.powerStatus)
            else:
                raise

            assert_pico_ok(self.status["changePowerSource"])
Esempio n. 5
0
 def openDevice(self):
     self.resolution = '8BIT'
     _resolution = ps.PS5000A_DEVICE_RESOLUTION['PS5000A_DR_' +
                                                self.resolution.upper()]
     self.status['openunit'] = ps.ps5000aOpenUnit(
         ctypes.byref(self.chandle), None, _resolution)
     try:
         assert_pico_ok(self.status['openunit'])
         return 0
     except:
         powerStatus = self.status["openunit"]
         if powerStatus == 286:
             self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                 chandle, powerStatus)
         elif powerStatus == 282:
             self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                 chandle, powerStatus)
         else:
             # raise
             return -1
from picosdk.functions import assert_pico_ok

status = {}
chandle = ctypes.c_int16()

# Open the device
status["openUnit"] = ps.ps5000aOpenUnit(ctypes.byref(chandle), None, 1)

try:
    assert_pico_ok(status["openUnit"])
except:  # PicoNotOkError:

    powerStatus = status["openUnit"]

    if powerStatus == 286:
        status["changePowerSource"] = ps.ps5000aChangePowerSource(
            chandle, powerStatus)
    elif powerStatus == 282:
        status["changePowerSource"] = ps.ps5000aChangePowerSource(
            chandle, powerStatus)
    else:
        raise

    assert_pico_ok(status["changePowerSource"])

# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz
# handle = chandle
# offsetVoltage = 0
# pkToPk = 2000000
# waveType = ctypes.c_int16(0) = PS5000A_SINE
# startFrequency = 10 kHz
# stopFrequency = 10 kHz
Esempio n. 7
0
status = {}
chandle = ctypes.c_int16()

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

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.ps5000aChangePowerSource(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.ps5000aChangePowerSource(chandle, 286)
    else:
        raise

    assert_pico_ok(status["ChangePowerSource"])


digital_port0 = ps.PS5000A_CHANNEL["PS5000A_DIGITAL_PORT0"]
# Set up digital port
# handle = chandle
# channel = ps5000a_DIGITAL_PORT0 = 0x80
# enabled = 1
Esempio n. 8
0
    def __init__(self):

        self.status = {}  # Exmpty dictionary
        self.status['running'] = False
        self.status['status'] = {}  # Empty dictionary to hold status results
        self.chandle = ctypes.c_int16()  # Stores handle for the Picotech HW
        self.maxADC = ctypes.c_int16()  # Stores a reference to the max ADC
        self.resolution = None
        self.resolutionString = ''
        self.possibleResValues = {
            "8-bit": "PS5000A_DR_8BIT",
            "12-bit": "PS5000A_DR_12BIT",
            "14-bit": "PS5000A_DR_14BIT",
            "15-bit": "PS5000A_DR_15BIT",
            "16-bit": "PS5000A_DR_16BIT"
        }
        # MS (2020.10.22): set the possible sampling modes
        self.samplingMode = None
        self.possibleSamplingModes = {'Rapid Block Mode': 'rapid_block'}
        # MS (2020.10.22): set the possible voltage scale
        self.rangeScale = None
        self.possibleRanges = {
            '10 mV': {
                'psRANGE': 'PS5000A_10MV',
                'intRange': 10
            },
            '20 mV': {
                'psRANGE': 'PS5000A_20MV',
                'intRange': 20
            },
            '50 mV': {
                'psRANGE': 'PS5000A_50MV',
                'intRange': 50
            },
            '100 mV': {
                'psRANGE': 'PS5000A_100MV',
                'intRange': 100
            },
            '200 mV': {
                'psRANGE': 'PS5000A_200MV',
                'intRange': 200
            },
            '500 mV': {
                'psRANGE': 'PS5000A_500MV',
                'intRange': 500
            },
            '1 V': {
                'psRANGE': 'PS5000A_1V',
                'intRange': 1000
            },
            '2 V': {
                'psRANGE': 'PS5000A_2V',
                'intRange': 2000
            },
            '5 V': {
                'psRANGE': 'PS5000A_5V',
                'intRange': 5000
            },
            '10 V': {
                'psRANGE': 'PS5000A_10V',
                'intRange': 10000
            },
            '20 V': {
                'psRANGE': 'PS5000A_20V',
                'intRange': 20000
            },
        }
        self.possibleWaveforms = {
            '1': 1,
            '2': 2,
            '3': 3,
            '10': 10,
            '30': 30,
        }
        # channelInputRanges = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000]
        self.downsampling = False
        self.downsamplingRatio = 1

        # Create chandle and status ready for use

        self.status["openunit"] = ps.ps5000aOpenUnit(
            ctypes.byref(self.chandle), None, 1)

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

            powerStatus = self.status["openunit"]

            if self.powerStatus == 286:
                self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                    self.chandle, powerStatus)
            elif self.powerStatus == 282:
                self.status["changePowerSource"] = ps.ps5000aChangePowerSource(
                    self.chandle, powerStatus)
            else:
                raise

            assert_pico_ok(self.status["changePowerSource"])