ps4000GetValuesTriggerTimeOffsetBulk64 * timeUnits pointer

Post your MATLAB discussions here
Post Reply
hugiandreas
Newbie
Posts: 0
Joined: Fri May 17, 2013 3:04 pm

ps4000GetValuesTriggerTimeOffsetBulk64 * timeUnits pointer

Post by hugiandreas »

Hello,

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);
                [status,a,b]=calllib('PS4000','ps4000GetValuesTriggerTimeOffsetBulk64',obj.unitHandle,pointer,ptr_timeUnits,segment_low,segment_up)            
        end
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)
 ptr=lib.pointer(varargin{:});
On the website of MATLAB on passing arguments to functions I found this:
(http://www.mathworks.ch/ch/help/matlab/ ... tions.html)
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

Hitesh

Re: ps4000GetValuesTriggerTimeOffsetBulk64 * timeUnits point

Post by Hitesh »

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:

[The extension m has been deactivated and can no longer be displayed.]

Code: Select all

loadlibrary 'PS4000.dll' 'PS4000MFile'
I hope this helps.

Post Reply