Simple tools and code to start programming for PicoScope

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

Simple tools and code to start programming for PicoScope

Post by Paul Breneman » Wed Jul 02, 2014 5:57 pm

We have free and open source C and Pascal tools and code (Python hopefully soon) to demonstrate how easy it is to get started programming for the PS5000 oscilloscope (other models hopefully soon) here:
http://ctrlpascal.com/picoscope.htm

If you are an experienced programmer then this probably doesn't apply to you. But if you or someone you know is just starting out, maybe our new page can be a valuable resource. These folks have been doing something similar (demonstrating simple tools) since 1998: http://software-carpentry.org/

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

Re: Simple tools and code to start programming for PicoScope

Post by Paul Breneman » Thu Jul 10, 2014 3:04 pm

A simple Python example has been added to the page noted in the previous message.

fabianuis17
Newbie
Posts: 0
Joined: Fri Jul 18, 2014 5:24 pm

Re: Simple tools and code to start programming for PicoScope

Post by fabianuis17 » Fri Jul 18, 2014 8:23 pm

Hi! I need to program a PicoScope 2206 with Python but I didn't find information about that. How can I start to program? Where can I search a guide blog or pdf?
Please help me, is very important and I don't know what's the first thing that I have to do!!!
Thanks!

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

Re: Simple tools and code to start programming for PicoScope

Post by Paul Breneman » Mon Jul 21, 2014 1:25 pm

Do you have the PicoScope software installed and working OK? If so, have you tried to download the software development kit for the 2206? Those would be the first two steps.

Have you done any programming with Python before? If so, do you have it installed on your PC (and what version)? I used version 3.4.1 for my example so I'm not sure if it would work with version 2.7 or other versions.

fabianuis17
Newbie
Posts: 0
Joined: Fri Jul 18, 2014 5:24 pm

Re: Simple tools and code to start programming for PicoScope

Post by fabianuis17 » Thu Jul 24, 2014 8:48 pm

Hello again!
Thanks for replying to my message. Regarding your questions, I have already downloaded the software and it works properly. In addition to this, I downloaded the SDK for the Picoscope 2208 (I had made a mistake becuase it wasn't a 2206) and checked the examples related to Labview, Excel , C, etc. but, actually, I need to program using Python. My computer has Python 2.7 and I have worked several times with it. I have a couple of questions: How can I switch on / off the Picoscope using Python?, Which libraries should I use?
I have used your code (Python 2.7) and I get this error:

<WinDLL 'ps5000a', handle 58300000 at 2bc1fb0>
doing OpenUnit
3
('OpenUnit failed, status=', 3, ' handle=', c_short(0))
doing CloseUnit
CloseUnit ok

Besides, I have read Programmer's Guide (PicoScope 2000 Series (A API)) and I do not understand which platform should I use to write the code, you suggest. For instance:
PICO_STATUS ps2000aOpenUnit (
short * handle,
char * serial
)

I would appreciate your help once more.
Thanks.

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

Re: Simple tools and code to start programming for PicoScope

Post by Paul Breneman » Thu Jul 24, 2014 9:57 pm

First, I would suggest that you use a text editor to change every "ps5000a" in the ps5000acon.py file to "ps2000a". You might want to save the (changed) file as ps2000acon.py as well. Let me know how things work after you do that.

I hope to change the file so just a single line could be changed, but I'm not yet sure how to do that. I'm not a Python expert but I hope to keep learning. :)

fabianuis17
Newbie
Posts: 0
Joined: Fri Jul 18, 2014 5:24 pm

Re: Simple tools and code to start programming for PicoScope

Post by fabianuis17 » Thu Aug 07, 2014 4:00 pm

Hi again!
I followed your recommendations and it shows an error:
status = windll.ps2000a.ps2000aOpenUnit( byref( ps2000a_handle), None, 4)
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
I decided to eliminate the number 4 that appears at the end of the command windll.ps2000a.ps.ps2000aOpenUnit to correct it. If I do this, the result is:

<WinDLL 'ps2000a', handle 5fad0000 at 2bd1fb0>
doing OpenUnit
0
('OpenUnit ok, handle=', c_short(16384))
doing TryGettingInfo
('GetUnitInfo ok, MyReturnStr=', '1.1.0.143')
('GetUnitInfo ok, MyReturnStr=', '2.0')
('GetUnitInfo ok, MyReturnStr=', '1')
('GetUnitInfo ok, MyReturnStr=', '2208')
('GetUnitInfo ok, MyReturnStr=', 'AV723/024')
('GetUnitInfo ok, MyReturnStr=', '28Mar12')
('GetUnitInfo ok, MyReturnStr=', '1.0')
('GetUnitInfo ok, MyReturnStr=', '1')
('GetUnitInfo ok, MyReturnStr=', '1')
('GetUnitInfo ok, MyReturnStr=', '1.3.3.0')
doing CloseUnit
CloseUnit ok

I’m not sure if it is the correct result but I don’t think so.

I also tried the other file on the page (ps5000astr.py). I changed what you recommended but it shows 2 errors: the first one is the same one that I already mentioned, so I decided to eliminate the number 4 again. The second one refers to a Syntax Error which is print( ChannelAmin[ i] , end= ‘ ’)
NameError: global name 'end' is not defined

´end´ isn’t defined ¿What does it refer to? The Syntax Error occurs because of ( … , end=’ ’), but that is not possible in Python 2.7.
Finally, I wanted to ask: is it possible to use Linux to control the Picoscope? If so, How can you do that?
Thanks!!

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

Re: Simple tools and code to start programming for PicoScope

Post by Paul Breneman » Thu Aug 07, 2014 10:41 pm

Yes, you did the right thing in eliminating the 4 as the last parameter of OpenUnit.

https://docs.python.org/3.0/whatsnew/3.0.html shows how in Python 2.7 you should use a trailing comma rather than the "end = ' '".

Sounds like you are making good progress!

I use Linux a lot but I haven't tried PicoScope there yet.

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

Re: Simple tools and code to start programming for PicoScope

Post by Paul Breneman » Thu Aug 28, 2014 7:22 pm

I just added a new Linux section at the bottom of this page: http://ctrlpascal.com/picoscope.htm

Post Reply