Cannot retrieve max samples from 4262

Post your C and C++ discussions here
Post Reply
justinis
Newbie
Posts: 0
Joined: Wed Oct 27, 2021 11:04 pm

Cannot retrieve max samples from 4262

Post by justinis »

I am trying to retrieve as many samples as possible from a picoscope 4262 in block mode. The datasheet says the buffer is 16MS. But when I try to retrieve that many samples (I'm using the C wrappers in python) the driver gives me a PICO_TOO_MANY_SAMPLES error. By trial and error I've discovered the maximum amount of samples it will let me retrieve is between 8.3 and 8.4M.

Any ideas? Here is my code:

Code: Select all

#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#
# PS4000 BLOCK MODE EXAMPLE
# This example opens a 4000 driver device, sets up two channels and a trigger then collects a block of data.
# This data is then plotted as mV against time in ns.

import ctypes
import numpy as np
from picosdk.ps4000 import ps4000 as ps
import matplotlib.pyplot as plt
from picosdk.functions import adc2mV, assert_pico_ok
import csv
import sys

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

print('Opening picoscope 4000 series')

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

print('Configuring channel A')

# Set up channel A
# handle = chandle
# channel = PS4000_CHANNEL_A = 0
# enabled = 1
# coupling type = PS4000_DC = 1
# range = PS4000_2V = 7
chARange = ps.PS4000_RANGE['PS4000_100MV']
status["setChA"] = ps.ps4000SetChannel(chandle, 
										ps.PS4000_CHANNEL['PS4000_CHANNEL_A'], 
										1, 
										1, 
										chARange)
assert_pico_ok(status["setChA"])

print('Setting trigger')

# Set up single trigger
# handle = chandle
# enabled = 1
# source = PS4000_CHANNEL_A = 0
# threshold = 1024 ADC counts
# direction = PS4000_RISING = 2
# delay = 0 s
# auto Trigger = 1000 ms
status["trigger"] = ps.ps4000SetSimpleTrigger(chandle, 1, 0, 1024, 2, 0, 1000)
assert_pico_ok(status["trigger"])

# Set number of pre and post trigger samples to be collected
preTriggerSamples = 8000000
postTriggerSamples = 8000000
maxSamples = preTriggerSamples + postTriggerSamples

print('Setting sample interval')

# Get timebase information
# handle = chandle
# timebase = 8 = timebase (timebase of 0 = 100 ns sampling interval)
# noSamples = maxSamples
# pointer to timeIntervalNanoseconds = ctypes.byref(timeIntervalns)
# pointer to maxSamples = ctypes.byref(returnedMaxSamples)
# segment index = 0
timebase = 0
timeIntervalns = ctypes.c_float()
returnedMaxSamples = ctypes.c_int32()
oversample = ctypes.c_int16(1)
status["getTimebase2"] = ps.ps4000GetTimebase2(chandle, timebase, maxSamples, ctypes.byref(timeIntervalns), oversample, ctypes.byref(returnedMaxSamples), 0)
assert_pico_ok(status["getTimebase2"])

print('Capturing data')

Martyn
Site Admin
Site Admin
Posts: 4183
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Cannot retrieve max samples from 4262

Post by Martyn »

Make sure that you disable Channel B

Code: Select all

status["disableChB"] = ps.ps4000SetChannel(chandle, 
										ps.PS4000_CHANNEL['PS4000_CHANNEL_B'], 
										0, 
										1, 
										chBRange)
assert_pico_ok(status["disableChB"])
Martyn
Technical Support Manager

justinis
Newbie
Posts: 0
Joined: Wed Oct 27, 2021 11:04 pm

Re: Cannot retrieve max samples from 4262

Post by justinis »

That did it! Thank you!

Post Reply