Test and Measurement Forum

Programming ps3000 with Python

Post your Linux discussions here

Programming ps3000 with Python

Postby riovandaino » Fri Oct 24, 2008 6:04 pm

Hi!
I'm an italian high school student and I and my classmates are using a ps3000 oscilloscope for a project about radioactivity.
In this moment we need to write our own code to run the oscilloscope; personally I'm a good python programmer and I'm thinking to write the code of the program in this scripting language. I've studied the documentation of the ps3000.dll library and also the various examples in C, C++ and VB6 and I would very pleased to know if I can use this library in python. The problem is that I've found that a lot of the ps3000's functions want pointers as parameter ( such as ps3000.get_timebases or ps3000.get_values ) and python doesn't have pointers.
So this is my question: can I program the oscilloscope using this language or is better to use another one?

p.s.: please excuse me if I've posted this in the wrong section, but I didn't a better place.
riovandaino
Newbie
 
Posts: 1
Joined: Tue Oct 07, 2008 1:11 pm
Location: Italy

Postby Robin » Tue Oct 28, 2008 9:23 am

Hi riovandaino

We don't have any Python examples, but other users out there might.

You might find it easier to choose one of the examples in another language and adapt it.

Sorry I can't be more help.

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Postby wayoda » Tue Oct 28, 2008 1:36 pm

Hi riovandaino ,

I once used swig
http://www.swig.org
to interface pythoncode with a library written in C that had methods with pointers as arguments in it.
I think you should at least give it a try !

Eberhard
wayoda
Active User
Active User
 
Posts: 11
Joined: Fri Aug 01, 2008 9:49 am
Location: Wuppertal/Germany

Postby fearick » Wed Nov 12, 2008 2:06 pm

It's quite easy to program in Python using ctypes to interface to the dll:

import ctypes as ct
ps3000=ct.windll.ps3000

#function interface to dll
ps_open_unit=ps3000.ps3000_open_unit
ps_open_unit.restype=ct.c_short

ps_set_channel=ps3000.ps3000_set_channel
ps_set_channel.restype=ct.c_short
ps_set_channel.argtypes=[ct.c_short,ct.c_short,ct.c_short,ct.c_short,ct.c_short]

... etc ...
#use:
handle=ps_open_unit() # p16
err=ps_set_channel(handle,PS_A,PS_ENABLE,ct.c_short(PS_DC), ct.c_short(PS_100mV)) # p19
...etc ...

I can provide a better example if requested, but I haven't yet
get a complete interface file at the moment, only what I have need for.

Roger.
Roger Fearick
fearick
Newbie
 
Posts: 1
Joined: Wed Nov 12, 2008 1:39 pm
Location: Cape Town


Return to Linux

Who is online

Users browsing this forum: No registered users and 0 guests