Test and Measurement Forum

ps4000a+python+streaming mode problem

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

ps4000a+python+streaming mode problem

Postby hsun7 » Fri Jun 30, 2017 2:34 am

Hi,
I modified the python program( see http://ctrlpascal.com/picoscope.htm) for streaming mode. But severals problems exist. One is that the autostop sometimes work, somtimes not. Another problem is that the signal collection is not strictly continuous (see the picture, source is a sine function). Attachment is the python code (python 3).
signal.jpg
Attachments
ps4000aStreaming.py
(5.8 KiB) Downloaded 52 times
hsun7
Newbie
 
Posts: 0
Joined: Fri Jun 30, 2017 2:25 am

Re: ps4000a+python+streaming mode problem

Postby Hitesh » Mon Jul 03, 2017 3:16 pm

Hi hsun7,

Which version of the ps4000a.dll are you using?

In your code, are you copying the data from the driver buffers to a temporary application buffer in the streaming callback?

Have you tried the Python application from our GitHub repository?

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2514
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: ps4000a+python+streaming mode problem

Postby hsun7 » Tue Jul 04, 2017 1:43 am

Hitesh wrote:Hi hsun7,

Which version of the ps4000a.dll are you using?

In your code, are you copying the data from the driver buffers to a temporary application buffer in the streaming callback?

Have you tried the Python application from our GitHub repository?

Regards,


Hi Hitesh,
Thanks for your reply! I'm not sure the version of ps4000a.dll. I just installed a pico SDK. In my code, I copy the data from buffer to a list after each callback in the application level. I downloaded the Python application you suggested and I'm still working on it. It seems a little difficult for me.
Thanks,
Hongbin
hsun7
Newbie
 
Posts: 0
Joined: Fri Jun 30, 2017 2:25 am

Re: ps4000a+python+streaming mode problem

Postby Hitesh » Thu Jul 06, 2017 7:57 am

Hi Hongbin,

Please try the ps4000a.dll and picoipp.dll files from the latest PicoScope 6 release. These are 32-bit dlls.

Alternatively, please e-mail support@picotech.com and we can provide you with a set of 64-bit drivers if you are using a 64-bit Python environment.

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2514
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: ps4000a+python+streaming mode problem

Postby apos » Thu Jul 06, 2017 9:05 am

Hi,

this period I am also trying streaming mode with a PicoScope 4424 and experience troubles. I adopted the code provided by hsun7 for use on a 4424 and tried it with Python 3.5.2

I use ps4000.dll version 1.2.4.41 (dated: 8/6/2015). This is the dll that works correctly, since when using the newer version 1.5.0.6 (8/2/2017), function ps4000OpenUnit() fails when opening the device. (It returns "-1").

Anyway, I don't get the plot: after executing the callback the program jumps to the "finally" section, performs the CloseUnit() functionality and exits with a ValueError, as shown below:
Code: Select all
Traceback (most recent call last):
  File "F:\Picoscope\ctrlpascal_2\ps4000_Streaming_2.py", line 172, in <module>
    data1 = DoStreaming()
  File "F:\Picoscope\ctrlpascal_2\ps4000_Streaming_2.py", line 123, in DoStreaming
    status = DLL.ps4000GetStreamingLatestValues(handle, call_back, None)
ValueError: Procedure probably called with not enough arguments (20885764 bytes missing)


The callback indicates having acquired 9981 samples, but it seems that it cannot return properly.
Any ideas?

Thank you!
apos
Newbie
 
Posts: 0
Joined: Thu Jul 06, 2017 8:23 am

Re: ps4000a+python+streaming mode problem

Postby Hitesh » Fri Jul 07, 2017 8:59 am

Hi apos,

Have you tried our Python application from the GitHub repository?

Is the picoipp.dll with the ps4000.dll (presumanbly taken from the PicoScope 6 installation directory?) and have you tried the dlls from the PicoScope 6.12.9 release?

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2514
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: ps4000a+python+streaming mode problem

Postby apos » Fri Jul 07, 2017 11:54 am

Hi Hitesh,
I tried with the ps4000.dll from the latest picoscope version. This is v1.5.0.8 and still has the same issue: it returns -1 upon executing ps4000OpenUnit()
To ensure that I have control over the dlls used, I explicitly open them on my application:
Code: Select all
os.chdir("F:\\Picoscope\\ctrlpascal\\")
DLL = ctypes.WinDLL("ps4000_v1508.dll")

The only dll that opens the picoscope is version 1.2.4.41. Below are the details of the picoscope device, as returned when I run the C console example application
Code: Select all
Opening the device...
Handle: 16384
Device opened successfully, cycle 1

Driver Version: 1.2.4.41
USB Version: 2.0
Hardware Version: 1
Variant Info: 4424
Serial: ZMR94/293
Cal Date: 18Dec09
Kernel: 1.0


Thank you
apos
Newbie
 
Posts: 0
Joined: Thu Jul 06, 2017 8:23 am

Re: ps4000a+python+streaming mode problem

Postby Hitesh » Wed Jul 12, 2017 8:45 am

Hi apos,

We have just released a new PicoSDK version - could you please install the 32-bit/64-bit version as required and then try running the example?

It might be worth copying the ps4000 and picoipp dll files into the same folder as the exe file to ensure that they are being picked up.

Are there any other ps4000 and picoipp dlls on the PC apart from in the PicoScope and PicoSDK installation directories?

Does the PicoScope software detect the device without any issues?

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2514
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: ps4000a+python+streaming mode problem

Postby apos » Thu Jul 27, 2017 11:56 am

Hi Hitesh,

as I was a little bit behind schedule I resorted to C which worked without any problem. Therefore I will use C and perform some data post-processing in a seperate python application, which may be a better approach for my application after all.

Anyway, as I found some time to experiment, I tried once again with python and the latest SDK (32bit). However the dll files (ps4000, picoipp) included therein are the same to the ones that come with the latest version of the picoscope application that I had already installed. So no luck with these as well.

The code I used is in pastebin, https://pastebin.com/evJHiGXC
It still crashes upon exiting the callback.

Thanks & regards
apos
Newbie
 
Posts: 0
Joined: Thu Jul 06, 2017 8:23 am

Re: ps4000a+python+streaming mode problem

Postby jbentham » Thu Sep 28, 2017 9:59 am

It is possible to do 1 megasample/sec streaming in pure Python, see https://github.com/jbentham/picostream

Jeremy Bentham
jbentham
Newbie
 
Posts: 0
Joined: Thu Sep 21, 2017 9:30 pm


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests