Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post general discussions on using our drivers to write your own software here
Post Reply
AlexAbr
Newbie
Posts: 0
Joined: Thu Mar 02, 2023 7:12 am

Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by AlexAbr »

Good day to everybody,

I am trying to write an application that runs acquisition for PicoScope 6405E in rapid block mode.
I am stuck on the function ps6000aGetValuesBulk returning a PICO_INVALID_PARAMETER. Does anybody know why that exact function returns this status? It seems that I pass arguments of the right type and with the right values.

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

Re: Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by Martyn »

Can you post the code showing how you have set everything up.
Martyn
Technical Support Manager

AlexAbr
Newbie
Posts: 0
Joined: Thu Mar 02, 2023 7:12 am

Re: Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by AlexAbr »

Here you go

Code: Select all

from picoscope6000 import PicoScope6000

import matplotlib.pyplot as plt


import ctypes
from picosdk.ps6000a import ps6000a as ps
from picosdk.PicoDeviceEnums import picoEnum as enums # constants used in the library above
from picosdk.functions import assert_pico_ok,adc2mV,mV2adc # function that throws an exception if the scope function returns an error

# open the scope instance
scope = PicoScope6000()

scope.configure_channel("PICO_CHANNEL_A",coupling="PICO_DC_50OHM",voltage_range="PICO_5V")# configure vertical scale
scope.configure_timebase(1e-7,500)# configure horizontal scale
scope.configure_trigger("PICO_CHANNEL_A",threshold=1000,position=0.5,auto_trig=2000000)# configure triggering

#data = scope.rbm()# capture data
# let's try it step by step
## create memory segments
Nframes = 10
status = ps.ps6000aMemorySegments(scope.handle,
                                    Nframes,
                                    None)
assert_pico_ok(status)
buffer = [(ctypes.c_int16 * scope.record_length)()] * Nframes

for i in range(Nframes):
    action = enums.PICO_ACTION["PICO_ADD"]|enums.PICO_ACTION["PICO_CLEAR_THIS_DATA_BUFFER"] if not i else enums.PICO_ACTION["PICO_ADD"]
    status = ps.ps6000aSetDataBuffer(scope.handle,
                                    enums.PICO_CHANNEL["PICO_CHANNEL_A"],
                                    ctypes.byref(buffer[i]),
                                    scope.record_length,
                                    enums.PICO_DATA_TYPE["PICO_INT16_T"],
                                    i,
                                    enums.PICO_RATIO_MODE["PICO_RATIO_MODE_RAW"],
                                    enums.PICO_ACTION["PICO_ADD"])
    assert_pico_ok(status)

status = ps.ps6000aSetNoOfCaptures(scope.handle,Nframes)
assert_pico_ok(status)

scope.run_block()
scope.wait_until_complete()
Ncaptures = ctypes.c_short()
status = ps.ps6000aGetNoOfCaptures(scope.handle, ctypes.byref(Ncaptures))
assert_pico_ok(status)
Ncaptures = Ncaptures.value
print(Ncaptures)
intdump = ctypes.c_uint64()
overflow = (ctypes.c_int16 * Nframes)()
status = ps.ps6000aGetValuesBulk(scope.handle,
                                    0,
                                    None,#ctypes.byref(intdump),
                                    0,
                                    Ncaptures-1,
                                    1,
                                    enums.PICO_RATIO_MODE['PICO_RATIO_MODE_RAW'],
                                    None)
print(status)
assert_pico_ok(status)
Now, PicoScope6000 here is a class that I wrote myself as a shortcut to PicoScope's Python wrappers to circumvent using ctypes. The three scope.configure_x() in the beginning just set up channel A, get the timebase and set up the trigger. I have tested them separately in block mode, and they work fine, and so do scope.run_block() and scope.wait_until_complete(). However, with the rapid block mode the ps6000aGetValuesBulk will throw a PICO_INVALID_PARAMETER. I have consulted the programmer's guide, but no parameters that I pass to this function actually seem invalid to me.

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

Re: Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by Martyn »

On a phone so difficult to check but

NCaptures should be ctypes.c_uint64() according to Programmer's Guide

will verify tomorrow when back at work.
Martyn
Technical Support Manager

AlexAbr
Newbie
Posts: 0
Joined: Thu Mar 02, 2023 7:12 am

Re: Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by AlexAbr »

Ncaptures returned by GetNoOfCaptures should be uint64 indeed, but I run this code with a low number of captures (10, to be specific), and thus short works just fine. As to GetValuesBulk, I pass Ncaptures-1 as Python's int, so it should not matter at all.

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

Re: Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by Martyn »

I can see that you have set channel A, have you turned all the other channels off as we do in the example here

https://github.com/picotech/picosdk-pyt ... Example.py
Martyn
Technical Support Manager

AlexAbr
Newbie
Posts: 0
Joined: Thu Mar 02, 2023 7:12 am

Re: Python ps6000aGetValuesBulk returns PICO_INVALID_PARAMETER

Post by AlexAbr »

The answer to your question is yes, but I just figured out what was causing the problems.
i initialized intdump as ctypes.c_uint64(); for the correct operation it needed to be associated with the oscilloscope frame length. As soon as I changed it to ctypes.c_uint64(Nsamples), everything worked out.

Post Reply