There is a ps5000.inc file in the Delphi example for the older ps5000.dll but I need a ps5000a.inc file for the newer ps5000a.dll so if you have any ideas I'd sure appreciate them. I have a ps5244a.
Unfortunately, we do longer provide Pascal or Delphi examples for new products.
You could try to create your own inc file using the ps5000.inc file as an example and referring to the PicoScope 5000 Series (A API) Programmer's Guide:
A 1.2 MB zip file has been added to the web page noted above. It has the Free Pascal compiler and source code for a simple console program. A source file for Delphi is also included.
I still hope to do something simple for Python, so any suggestions are welcomed!
Thanks Karunen for the suggestion. I have searched the forum and found a bit of Python code. It shouldn't be very difficult to port the simple Free Pascal and Delphi console programs to Python. The difficulty is finding a simple Python download that supports numpy so https://github.com/colinoflynn/pico-python can be used (later). http://pypy.org/ looks nice but numpy isn't yet fully supported. https://github.com/cwsoft/WSPPDE and http://winpython.sourceforge.net/ are the two (with numpy) I've found. Suggestions are welcome!
Thanks Martyn, but I think the "1" is there for AutoStop.
Here is my Python code:
status = windll.ps5000a.ps5000aRunStreaming( ps5000a_handle, byref(sampleInterval), 3, 0, 1000, 1, 10, 0, sizeof(ChannelA))
Here is your "C" code:
status = ps5000aRunStreaming(unit->handle, &sampleInterval, timeUnits, preTrigger, postTrigger, autostop, downsampleRatio, ratioMode, sampleCount);
As the error was InvalidBuffer it is still worth trying SetDataBuffers, otherwise check the buffer you have allocated is correct, possibly pre fill it with data.
I think I'd rather stick with the most simple DLL call for now.
This was my SetDataBuffer call:
status = windll.ps5000a.ps5000aSetDataBuffer( ps5000a_handle, 1, byref(ChannelA), sizeof(ChannelA), 0, 0)
I had two things wrong. The second parameter should be 0 for channel A. The fourth parameter was wrong (20000 instead of 10000 - same as the problem with RunStreaming).
This is my new call that works:
status = windll.ps5000a.ps5000aSetDataBuffer( ps5000a_handle, 0, byref(ChannelA), sampleCount, 0, 0)
Thanks for the help. Now I'll try to finish things. I'll let you know how it goes.
With Python I don't know how to write the Callback procedure so any tips in that regard would be appreciated.
With Delphi I modified your old ps5000 code and now all of the dll calls return OK but I get an exception (divide by zero) in the dll. Using SetDataBuffers doesn't help.
I noticed that your C code calls 5 dll functions in the SetTrigger function, whereas the old Delphi code just makes a single call to SetTrigger. The ps5000a.dll no longer has the SetTrigger call so my Delphi (and Python) code has a single SetSimpleTrigger call. Maybe some of those 5 dll functions are needed?