Beispiel #1
0
    def setup(self):
        """
        Setup channel.

        Returns:
            Channel setup status
        """
        return ps.ps2000aSetChannel(self.chandle, self.channel, self.enabled,
                                    self.coupling, self.range, self.offset)
Beispiel #2
0
status = {}

# Open 2000 series PicoScope
# Returns handle to chandle for use in future API functions
status["openunit"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)
assert_pico_ok(status["openunit"])

# Set up channel A
# handle = chandle
# channel = PS2000A_CHANNEL_A = 0
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V
chARange = 7
status["setChA"] = ps.ps2000aSetChannel(chandle, 0, 1, 1, chARange, 0)
assert_pico_ok(status["setChA"])

# Set up channel C
# handle = chandle
# channel = PS2000A_CHANNEL_C = 2
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V
chCRange = 7
status["setChC"] = ps.ps2000aSetChannel(chandle, 2, 1, 1, chCRange, 0)
assert_pico_ok(status["setChC"])

# Set up single trigger
# handle = chandle
Beispiel #3
0
def naberDataA():
    # Create chandle and status ready for use
    chandle = ctypes.c_int16()
    status = {}

    # Open 2000 series PicoScope
    # Returns handle to chandle for use in future API functions
    status["openunit"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)
    assert_pico_ok(status["openunit"])

    # Set up channel A
    # handle = chandle
    # channel = PS2000A_CHANNEL_A = 0
    # enabled = 1
    # coupling type = PS2000A_DC = 1
    # range = PS2000A_2V = 7
    # analogue offset = 0 V
    chARange = 5
    status["setChA"] = ps.ps2000aSetChannel(chandle, 0, 1, 0, chARange, 0)
    assert_pico_ok(status["setChA"])

    # Set up channel B
    # handle = chandle
    # channel = PS2000A_CHANNEL_B = 1
    # enabled = 1
    # coupling type = PS2000A_DC = 1
    # range = PS2000A_2V = 7
    # analogue offset = 0 V
    chBRange = 7
    status["setChB"] = ps.ps2000aSetChannel(chandle, 1, 1, 1, chBRange, 0)
    assert_pico_ok(status["setChB"])

    # Set up single trigger
    # handle = chandle
    # enabled = 1
    # source = PS2000A_CHANNEL_A = 0
    # threshold = 1024 ADC counts
    # direction = PS2000A_RISING = 2 (falling = 3)
    # delay = 0 s
    # auto Trigger = 1000 ms
    maxADC = ctypes.c_int16()
    status["maximumValue"] = ps.ps2000aMaximumValue(chandle,
                                                    ctypes.byref(maxADC))
    vRange = 500
    mvTrigger = -100
    adcTrigger = int(mvTrigger / vRange * maxADC.value)
    #    print(maxADC.value,adcTrigger)
    status["trigger"] = ps.ps2000aSetSimpleTrigger(chandle, 1, 0, adcTrigger,
                                                   3, 0, 0)
    assert_pico_ok(status["trigger"])

    # Set number of pre and post trigger samples to be collected
    #preTriggerSamples = 2500
    #postTriggerSamples = 2500
    preTriggerSamples = 300
    postTriggerSamples = 2150
    totalSamples = preTriggerSamples + postTriggerSamples

    # Get timebase information
    # handle = chandle
    # timebase = 8 = timebase
    # noSamples = totalSamples
    # pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalNs)
    # pointer to totalSamples = ctypes.byref(returnedMaxSamples)
    # segment index = 0
    timebase = 8
    timeIntervalns = ctypes.c_float()
    returnedMaxSamples = ctypes.c_int32()
    oversample = ctypes.c_int16(0)
    status["getTimebase2"] = ps.ps2000aGetTimebase2(
        chandle, timebase, totalSamples, ctypes.byref(timeIntervalns),
        oversample, ctypes.byref(returnedMaxSamples), 0)
    assert_pico_ok(status["getTimebase2"])

    # Run block capture
    # handle = chandle
    # number of pre-trigger samples = preTriggerSamples
    # number of post-trigger samples = PostTriggerSamples
    # timebase = 8 = 80 ns = timebase (see Programmer's guide for mre information on timebases)
    # oversample = 0 = oversample
    # time indisposed ms = None (not needed in the example)
    # segment index = 0
    # lpReady = None (using ps2000aIsReady rather than ps2000aBlockReady)
    # pParameter = None
    status["runBlock"] = ps.ps2000aRunBlock(chandle, preTriggerSamples,
                                            postTriggerSamples, timebase,
                                            oversample, None, 0, None, None)
    assert_pico_ok(status["runBlock"])

    # Check for data collection to finish using ps2000aIsReady
    ready = ctypes.c_int16(0)
    check = ctypes.c_int16(0)
    while ready.value == check.value:
        status["isReady"] = ps.ps2000aIsReady(chandle, ctypes.byref(ready))

    # Create buffers ready for assigning pointers for data collection
    bufferAMax = (ctypes.c_int16 * totalSamples)()
    bufferAMin = (ctypes.c_int16 * totalSamples)(
    )  # used for downsampling which isn't in the scope of this example
    bufferBMax = (ctypes.c_int16 * totalSamples)()
    bufferBMin = (ctypes.c_int16 * totalSamples)(
    )  # used for downsampling which isn't in the scope of this example

    # Set data buffer location for data collection from channel A
    # handle = chandle
    # source = PS2000A_CHANNEL_A = 0
    # pointer to buffer max = ctypes.byref(bufferDPort0Max)
    # pointer to buffer min = ctypes.byref(bufferDPort0Min)
    # buffer length = totalSamples
    # segment index = 0
    # ratio mode = PS2000A_RATIO_MODE_NONE = 0
    status["setDataBuffersA"] = ps.ps2000aSetDataBuffers(
        chandle, 0, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin),
        totalSamples, 0, 0)
    assert_pico_ok(status["setDataBuffersA"])

    # Set data buffer location for data collection from channel B
    # handle = chandle
    # source = PS2000A_CHANNEL_B = 1
    # pointer to buffer max = ctypes.byref(bufferBMax)
    # pointer to buffer min = ctypes.byref(bufferBMin)
    # buffer length = totalSamples
    # segment index = 0
    # ratio mode = PS2000A_RATIO_MODE_NONE = 0
    status["setDataBuffersB"] = ps.ps2000aSetDataBuffers(
        chandle, 1, ctypes.byref(bufferBMax), ctypes.byref(bufferBMin),
        totalSamples, 0, 0)
    assert_pico_ok(status["setDataBuffersB"])

    # Create overflow location
    overflow = ctypes.c_int16()
    # create converted type totalSamples
    cTotalSamples = ctypes.c_int32(totalSamples)

    # Retried data from scope to buffers assigned above
    # handle = chandle
    # start index = 0
    # pointer to number of samples = ctypes.byref(cTotalSamples)
    # downsample ratio = 0
    # downsample ratio mode = PS2000A_RATIO_MODE_NONE
    # pointer to overflow = ctypes.byref(overflow))
    status["getValues"] = ps.ps2000aGetValues(chandle, 0,
                                              ctypes.byref(cTotalSamples), 0,
                                              0, 0, ctypes.byref(overflow))
    assert_pico_ok(status["getValues"])

    # find maximum ADC count value
    # handle = chandle
    # pointer to value = ctypes.byref(maxADC)
    maxADC = ctypes.c_int16()
    #    print(maxADC.value)
    status["maximumValue"] = ps.ps2000aMaximumValue(chandle,
                                                    ctypes.byref(maxADC))
    assert_pico_ok(status["maximumValue"])
    #    print(maxADC)
    # convert ADC counts data to mV
    adc2mVChAMax = adc2mV(bufferAMax, chARange, maxADC)
    adc2mVChBMax = adc2mV(bufferBMax, chBRange, maxADC)

    # Create time data
    time = np.linspace(0, (cTotalSamples.value) * timeIntervalns.value,
                       cTotalSamples.value)

    # Stop the scope
    # handle = chandle
    status["stop"] = ps.ps2000aStop(chandle)
    assert_pico_ok(status["stop"])

    # Close unitDisconnect the scope
    # handle = chandle
    status["close"] = ps.ps2000aCloseUnit(chandle)
    assert_pico_ok(status["close"])

    # display status returns
    #    print(status)

    casA = np.array(time)
    napetiA = np.array(adc2mVChAMax)

    return casA, napetiA
Beispiel #4
0
offsetA = 0  # analogue offset
"""
The pico 2206B ranges
0 = PS2000A_20MV:  ±20 mV
1 = PS2000A_50MV:  ±50 mV
2 = PS2000A_100MV: ±100 mV
3 = PS2000A_200MV: ±200 mV
4 = PS2000A_500MV: ±500 mV
5 = PS2000A_1V
6 = PS2000A_2V
7 = PS2000A_5V
8 = PS2000A_10V
9 = PS2000A_20V
"""

status["setChA"] = ps.ps2000aSetChannel(handle, channelA, enableA, couplingA,
                                        rangeA, offsetA)
assert_pico_ok(status["setChA"])

# B
enableB = 1  # Turn on (1) or off (0)
channelB = 1  # PS2000A_CHANNEL_B
couplingB = 1  # coupling type: PS2000A_DC = 1
rangeB = 7
offsetB = 0  # analogue offset

status["setChB"] = ps.ps2000aSetChannel(handle, channelB, enableB, couplingB,
                                        rangeB, offsetB)
assert_pico_ok(status["setChB"])

# Set the trigger
adcTriggerLevel = mV2adc(triggerVoltage, rangeA, maxADC)
Beispiel #5
0
# Returns handle to chandle for use in future API functions
# First argument: number that uniquely identifies the scope (address of chandle)
# Second argument:  first scope found (None)
status["openunit"] = ps.ps2000aOpenUnit(ctypes.byref(chandle), None)
# If any error, the following line will raise one.
assert_pico_ok(status["openunit"])

# Set up channel A
# handle = chandle
# channel = PS2000A_CHANNEL_A = 0
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = -2 V = -2
chARange = 7
status["setChA"] = ps.ps2000aSetChannel(chandle, 0, 1, 1, chARange, 0)
assert_pico_ok(status["setChA"])
# Set up channel B
# handle = chandle
# channel = PS2000A_CHANNEL_B = 1
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V
chBRange = 7
status["setChB"] = ps.ps2000aSetChannel(chandle, 1, 1, 1, chBRange, 0)
assert_pico_ok(status["setChB"])

# Set up single trigger
# handle = chandle
# enabled = 1
Beispiel #6
0
# Set up channel A
# handle = chandle
# channel = PS2000A_CHANNEL_A = 0
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V

channelA = ps.PS2000A_CHANNEL['PS2000A_CHANNEL_A']
chAEnabled = 1
chACoupling = ps.PS2000A_COUPLING['PS2000A_DC']
chARange = ps.PS2000A_RANGE['PS2000A_2V']
chAAnalogOffset = 0

status["setChA"] = ps.ps2000aSetChannel(chandle, channelA, chAEnabled,
                                        chACoupling, chARange, chAAnalogOffset)
assert_pico_ok(status["setChA"])

# Set up channel B
# handle = chandle
# channel = PS2000A_CHANNEL_B = 1
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V

channelB = ps.PS2000A_CHANNEL['PS2000A_CHANNEL_B']
chBEnabled = 1
chBCoupling = ps.PS2000A_COUPLING['PS2000A_DC']
chBRange = ps.PS2000A_RANGE['PS2000A_2V']
chBAnalogOffset = 0
Beispiel #7
0
enabled = 1
disabled = 0
analogue_offset = 0.0

# Set up channel A
# handle = chandle
# channel = PS2000A_CHANNEL_A = 0
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V
channel_range = ps.PS2000A_RANGE['PS2000A_2V']
status["setChA"] = ps.ps2000aSetChannel(chandle,
                                        ps.PS2000A_CHANNEL['PS2000A_CHANNEL_A'],
                                        enabled,
                                        ps.PS2000A_COUPLING['PS2000A_DC'],
                                        channel_range,
                                        analogue_offset)
assert_pico_ok(status["setChA"])

# Set up channel B
# handle = chandle
# channel = PS2000A_CHANNEL_B = 1
# enabled = 1
# coupling type = PS2000A_DC = 1
# range = PS2000A_2V = 7
# analogue offset = 0 V
status["setChB"] = ps.ps2000aSetChannel(chandle,
                                        ps.PS2000A_CHANNEL['PS2000A_CHANNEL_B'],
                                        enabled,
                                        ps.PS2000A_COUPLING['PS2000A_DC'],