Test and Measurement Forum

Need Pascal or Delphi code for ps5000a.dll

Post general discussions on using our drivers to write your own software here

Need Pascal or Delphi code for ps5000a.dll

Postby Paul Breneman » Thu Jun 19, 2014 4:29 pm

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
Paul Breneman
Newbie
 
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Hitesh » Mon Jun 23, 2014 3:28 pm

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/ps5000abpg.en-1.pdf

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

Some of the function calls will be similar.

I hope this helps.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Paul Breneman » Wed Jun 25, 2014 12:45 am

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

Postby Paul Breneman » Wed Jul 02, 2014 1:51 am

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! :)
Paul Breneman
Newbie
 
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Karunen » Wed Jul 02, 2014 10:07 am

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
Karunen
Zen Master
Zen Master
 
Posts: 194
Joined: Thu Nov 21, 2013 9:22 am

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Paul Breneman » Wed Jul 02, 2014 11:15 am

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

Postby Paul Breneman » Mon Jul 14, 2014 12:08 am

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?
Paul Breneman
Newbie
 
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Martyn » Mon Jul 14, 2014 9:32 am

You need to use SetDataBuffers as you have specified aggregation (1) as your down sample mode in your RunStreaming call.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Paul Breneman » Mon Jul 14, 2014 11:50 am

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);
Paul Breneman
Newbie
 
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Martyn » Mon Jul 14, 2014 12:21 pm

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 Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Paul Breneman » Mon Jul 14, 2014 2:50 pm

My last parameter "sizeof(ChannelA)" was wrong. It was 20000 but changing it to 10000 didn't get things working.
Paul Breneman
Newbie
 
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Martyn » Mon Jul 14, 2014 4:06 pm

Have you tried SetDataBuffers?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Need Pascal or Delphi code for ps5000a.dll

Postby Paul Breneman » Mon Jul 14, 2014 4:40 pm

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

Postby Paul Breneman » Tue Jul 15, 2014 3:24 pm

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

Postby Paul Breneman » Wed Jul 16, 2014 1:15 pm

With Python I get an exception after calling RunStreaming. Here is the example: http://ctrlpascal.com/ps5000acon3.zip
Paul Breneman
Newbie
 
Posts: 0
Joined: Thu Jun 19, 2014 4:15 pm

Next

Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests