Hi Sunny,
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:
http://www.picotech.com/document/pdf/ps4000pg.en-7.pdfThe 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.
- Code: Select all
loadlibrary('PS4000', 'PS4000MFile');
loadlibrary('ps4000wrap.dll', 'ps4000WrapMFile');
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:
- Code: Select all
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.
I hope this helps.