Test and Measurement Forum

ps4000GetValuesTriggerTimeOffsetBulk64 * timeUnits pointer

Post your MATLAB discussions here

ps4000GetValuesTriggerTimeOffsetBulk64 * timeUnits pointer

Postby hugiandreas » Fri May 17, 2013 3:25 pm


I have sucsefully implemented a rapid block mode aquisition in MATLAB for the picoscope 4227.
All the functions work very well, I just got stuck at the function to get all the TriggerTimeOffset values for the aquisitions.

The function to do this is as followed:

Code: Select all
function correct_trigger_jitter(obj)
            %Could not generate enPS4000TimeUnits pointer to an arry in
            %MATLAB, result Buffer Overflows
                segment_low = cast(0,'uint16');
                segment_up = cast(obj.Settings.NSegments-1,'uint16');
                pointer = libpointer('int64Ptr',zeros(obj.Settings.NSegments,1));
                ptr_timeUnits = libpointer('enPS4000TimeUnits',0);

In the variable a, I get the requested times as an array.
In b however, I only get one value and not an array.
If the aquisiton has more than one segment, MATLAB risks to crash. I assume this is due to the fact, that the function acutally assumes that the pointer points to a range of PS4000_TIME_UNITS, which it does not.

The problem I am facing is that I can not create an array to allocate the memory in MATLAB correctly of type enPS4000TimeUnits.
When I try something like this I constantly get an error that the function can only accept scalar values:

Code: Select all
>> ptr_timeUnits = libpointer('enPS4000TimeUnits',zeros(2,1))
Parameter must be scalar.

Error in libpointer (line 18)

On the website of MATLAB on passing arguments to functions I found this:

Guidelines for Passing Arguments

Nonscalar arguments must be declared as passed by reference in the library functions.

Has that been done in the function definition?

Does anybody have an idea how to solve this?

Thank you very much already in advance.

Andreas Hugi
Posts: 0
Joined: Fri May 17, 2013 3:04 pm

Re: ps4000GetValuesTriggerTimeOffsetBulk64 * timeUnits point

Postby Hitesh » Mon May 20, 2013 11:10 am

Hi Andreas,

MATLAB doesn't support an array of enumeration pointers.

The way around this is to treat them as an array of unsigned 32-bit integers.

I have generated a prototype file based on a modified header file which should work - you can substitute this file for the header file:

PicoScope 4000 Prototype file
(21.82 KiB) Downloaded 142 times

Code: Select all
loadlibrary 'PS4000.dll' 'PS4000MFile'

I hope this helps.

Technical Specialist
Pico Technology
Site Admin
Site Admin
Posts: 2112
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Return to MATLAB

Who is online

Users browsing this forum: No registered users and 0 guests