Dear sdk developers,
I tried to use ps4000.dll for incorporating of PicoScope 4424 to the Matlab environment and was successful with the majority of the functions. However there some problems. Most important functions as for example ps4000RunBlock uses callback which is not supported by Matlab. Can such functions be rewritten for Matlab users so that callback routine would be excluded? For example I will ask manually if a record is done and than copy data via variable or memory pointer instead of using callback routine ps4000DataReady.
In the SDK there is a wrapper DLL that avoids the need to pass function pointers to run block. The source code (ps4000wrap.c) is also included in the SDK so you can see how to use it.
Thank you for the prompt reply.
We tried to use it but in such form it became more complicated. I need header file to load this wrap.dll to Matlab. Using two libraries rises some other questions. We try also to create our wrap file with partial success. Perhaps we can do it finally if you provide us header file or when we prepare our wrapper.
However it would be much easier if the wrapping functions would be simply in the primary dll and in primary header file. If it is not too complicate consider this, it would help as a lot.
Best regards,
Oleksiy.
I have a picoscope 4xxx and would like to get the dll libraries working in Matlab. I have never played with dlls in Matlab and it seems a little less straightforward than I had hoped, I have been modifying the ps2000 example, but haven't yet been able to get any data from the picoscope. I was wondering if anybody has some simple Matlab code they can provide which just uses the ps4000Api.h/ps4000.dll to get data from the picoscope.
Thanks!
Christopher
Here a files set prepared for three PicoScope 4424 units, perhaps it will help you. This program did not work properly but the problem was in communication with three units, with only one unit it could work. You should change the program for only one units mainly by deleting of unnecessary functions. It used ps4000sdk_r6_2_14_0 but may be will work with updated one. Start with Main file.
I am out of office and internet next month and can answer any questions in the end of august.
Good luck!
I am finding it difficult to emulate the callback function in ps6000_RunBlock using Matlab.
ps3000_run_block used to work perfectly with Matlab, a similar function would be most appreciated, or if anybody has a workaround it would save me a lot of headaches.
I have added library and header file from ps4000sdk to the previous set, thus it is functioning set now.
Just to summarize: there is set of files to run three units Picoscope
4424 in Matlab environment. It is functioning, however troubles with memory management lead to occasional errors mainly in Enumerate units function. You can significantly simplify program to operate only one unit and the errors must disappear. Or just use it like an inspiration.
Once you make functioning program publish it here for others users and the topic will be solved. Good luck.
Hi,
I need to use picoscope 4424 in my work place for data aquisition with the help of matlab. To say honestly, I have only learned how to use matlab(I have used C before so I knw the basics of programming) but I don't think I have advanced enough knowledge to write a program that can control the drivers and allow data aquisition from the picoscope 4424.
Can someone help me/ guide me on how to transfer data from picoscope 4424(I just need to use one channel) to my pc with the help of matlab? I have dowloaded PS4000sdk_r10_4_3_1 and also downloaded PicoMatlab.zip(from this forum), but how can I integrate both of this?
I have given below, the codes and errors which are given after I tried to start the program:
SamplePeriod=1e-007s
TimeMeasured=0.026214s
Warning: Message from C preprocessor:
lcc preprocessor warning: c:\SDKnew\ps4000Api.h:921 No newline at end of file
> In loadlibrary at 371
In PicoMatlabStartSetup at 5
In PicoMatlabMain at 3
1
AV706/069
OpenUnit=0
GetUnitInfo=0
AV706/069
PicoSerial=AV706/069
??? Undefined function or method 'UnitHandle' for input arguments of type 'double'.
Error in ==> PicoMatlabRunMeas at 15
Status =
calllib('ps4000','ps4000SetChannel',UnitHandle(k),Channel,Enabled,Coupling,VRange);
Error in ==> PicoMatlabMain at 4
PicoMatlabRunMeas
The example that this Customer provided is for 3 units. I would suggest that you need to simplify this or create a new script that will open the script.
Thanks for the quick reply and tips
I have tried to modify the code to make it for a single unit instead of 3.I am attaching the program I am working on.
The problems are that:
1. even after I plug in the picoscope it still shows “open unit = 0”
2. When I tried to run the program without plugging in picoscope then it shows open unit =3
3. I have given the new error which is given by the program below:
SamplePeriod=1e-007s
TimeMeasured=0.026214s
Warning: Message from C preprocessor:
lcc preprocessor warning: C:\SDKpico\ps4000Api.h:831 No newline at end of file
> In loadlibrary at 371
In PicoMatlabStartSetupS at 2
In PicoMatlabMain at 4
OpenUnit=0
GetUnitInfo=0
PicoSerial=AV706/069
Closing0
??? Error using ==> calllib
Library was not found
Error in ==> PicoMatlabRunMeas at 15
Status =
calllib('ps4000','ps4000SetChannel',UnitHandle(k),Channel,Enabled,Coupling,VRange);
Error in ==> PicoMatlabMain at 5
PicoMatlabRunMeas
I am trying to capture streaming data, sample interval can be 1Mb/s to 10Mb/s and voltage range is in the range of mV. And the trigger is a sudden change in voltage.
Your script is successfully opening and closing the scope - the '0' returned for open unit indicates that the function has returned successfully. If you examine the UnitHandle parameter after calling the ps4000OpenUnit function, you will find that it should have a positive non-zero value. This 'handle' value is then used when calling the various functions to acquire data.
The serial number returned gives away the fact the unit was opened
If no unit is connected then an error code of 3 (PICO_NOT_FOUND) is expected.
The example script that you downloaded captures data in rapid block mode. For streaming data capture, please refer to the PicoScope 4000 Series Programmer's Guide as this will help with your script:
The Programmer's Guide contains details of the API functions, enumerations to use and error codes. In the attached zip file, there are some prototype files which you can use to when calling the loadlibrary function i.e.
The examples above would work with the new PS4000.dll from the current SDK - note the capitalised 'PS' (This is probably why you could not call the ps4000SetChannel function). The current SDK is missing the ps4000wrap.dll so I have included it in the zip file. The wrapper dll is needed to be able to capture streaming data without the use of C-style callback functions.
The forum post that I referred to previously shows how to access the enumerations and structures from the prototype file.
The PS4000MFile.m contains details of the enumerations.
You can use the C console example from the SDK to help with structuring your code and for referring to the enumerations.
Section 4.6.4.1 (Using streaming mode) shows the functions you need to call in order to capture data. There is one exception - instead of step 6, you will need to use the following functions from the wrapper dll to be able to collect data:
GetStreamingLatestValues
IsReady
IsTriggerReady
AvailableData
AutoStopped
After calling ps4000RunStreaming this would be the order of function calls as pseudo-code:
Loop
GetStreamingLatestValues
Sub loop (while ready == 0)
ready = IsReady
End Sub loop
IsTriggerReady
AvailableData
Check if AutoStopped (if so, break out of loop)
End loop
In the zip file there are functions to help with converting the ADC counts returned from the driver into voltage values as well as vice-versa.