Need Pascal or Delphi code for ps5000a.dll

Post general discussions on using our drivers to write your own software here
Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

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.

Regards,
Paul Breneman
http://www.TurboControl.com

Hitesh

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Hitesh »

Hello Paul,

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:

http://www.picotech.com/document/pdf/ps ... g.en-1.pdf

Note that the PicoScope 5244a uses the ps5000a.dll.

Some of the function calls will be similar.

I hope this helps.

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

Thanks Hitesh for the reply. There are utilities to convert h files to pascal that I will probably use.

My first step was to use the Tiny C Compiler as documented on this new (unpublished) web page:
http://ctrlpascal.com/picoscope.htm

I also spent a day trying to come up with a simple Python example. Pascal and Delphi are next. :)

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

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! :)

Karunen
Advanced User
Advanced User
Posts: 194
Joined: Thu Nov 21, 2013 9:22 am

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Karunen »

Hi Paul,

First I would like to thank you for sharing your code.

Unfortunately we do not provide Python Code.
But the good news is that other customers have posted their code on the forum.

for example http://www.picotech.com/support/post38949.html

This should hopefully help you create your own code.

Kind Regards,
Karunen

Technical Specialist
Pico Technology

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

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!

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

I hope someone can help me get a simple streaming example working in Python. Then maybe I can port that to Pascal?

If you check this page you'll see I'm using 32-bit Python 3.4.1 http://ctrlpascal.com/picoscope.htm and the simple example there works.

Here is an example where I'm trying to do streaming: http://ctrlpascal.com/ps5000acon2.zip

When I call ps5000aRunStreaming I get a 0x37 error (invalid buffer). Any idea what I'm doing wrong?

Martyn
Site Admin
Site Admin
Posts: 4483
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Martyn »

You need to use SetDataBuffers as you have specified aggregation (1) as your down sample mode in your RunStreaming call.
Martyn
Technical Support Manager

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

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);

Martyn
Site Admin
Site Admin
Posts: 4483
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Martyn »

You are correct, I misread your code.

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.
Martyn
Technical Support Manager

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

My last parameter "sizeof(ChannelA)" was wrong. It was 20000 but changing it to 10000 didn't get things working.

Martyn
Site Admin
Site Admin
Posts: 4483
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Martyn »

Have you tried SetDataBuffers?
Martyn
Technical Support Manager

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

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.

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

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?

Paul Breneman
Newbie
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Post by Paul Breneman »

With Python I get an exception after calling RunStreaming. Here is the example: http://ctrlpascal.com/ps5000acon3.zip

Post Reply