Test and Measurement Forum

PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Post your Linux discussions here

PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby KrisHunt » Mon Mar 28, 2016 8:20 am

Hi, I'm having difficulty using the pl1000.SetInterval function when trying to get data from my Picolog 1216. I suspect the 'channel' array format is incorrect as it is giving a return code decimal 16. Can anyone help with this?
Thanks!

Code: Select all
import ctypes
from ctypes import *
from array import array

c_handle = c_int16()
maxvalue = c_int16()
reqd = c_int16()

zstr='abcdefghijklmnop'
testlib = ctypes.CDLL('/opt/picoscope/lib/libpl1000.so')
a=testlib.pl1000OpenUnit( byref(c_handle))
print a, c_handle

a=testlib.pl1000MaxValue(1,byref(maxvalue))
print maxvalue

dat1=c_uint * 16
channel = dat1(1, 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
print channel
b=testlib.pl1000GetUnitInfo(1,zstr,100,byref(reqd),1)
print b, zstr
b=testlib.pl1000GetUnitInfo(1,zstr,100,byref(reqd),2)
print b, zstr
b=testlib.pl1000GetUnitInfo(1,zstr,100,byref(reqd),3)
print b, zstr
b=testlib.pl1000GetUnitInfo(1,zstr,100,byref(reqd),4)
print b, zstr
b=testlib.pl1000GetUnitInfo(1,zstr,100,byref(reqd),5)
print b, zstr
b=testlib.pl1000GetUnitInfo(1,zstr,100,byref(reqd),6)
print b, zstr

b=testlib.pl1000SetInterval(1,10000,5,byref(channel),16)
print b, channel

a=testlib.pl1000CloseUnit( byref(c_handle))
print a


The output I'm getting is:
0 c_short(1)
c_short(4095)
<__main__.c_ulong_Array_16 object at 0x75abf850>
0 USB 1.1
0 1
0 PicoLog1216
0 AS920/025
0 17May13
0 PICOPP.SYS V1.0
16 <__main__.c_ulong_Array_16 object at 0x75abf850>
3
KrisHunt
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 7:45 am

Re: PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby Martyn » Mon Mar 28, 2016 9:22 am

I won't be able to check until I am in the office tomorrow but I would try 0 to 15 for the channels.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby KrisHunt » Mon Mar 28, 2016 9:34 am

Thank you,
I think you're right
but unfortunately the result code is the same.
:(
KrisHunt
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 7:45 am

Re: PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby Martyn » Tue Mar 29, 2016 7:04 am

Channel enumerations go from 1 to 16, so it is probaby your array that is the problem

You may wish to check out this topic using Python for the USB TC08. It uses numpy which may be the way to go.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby KrisHunt » Wed Mar 30, 2016 10:36 am

Thanks, but unfortunately the numpy code gives the same results.
:(

Code: Select all
import ctypes
import numpy as np
from ctypes import *
maxvalue = c_int16()
device = c_int16()
mydll = ctypes.CDLL('/opt/picoscope/lib/libpl1000.so')
a=mydll.pl1000OpenUnit( byref(device))
print a, device

a=mydll.pl1000MaxValue(device,byref(maxvalue))
print a, maxvalue

channel = np.zeros((4,), dtype=np.intc)

channel[0]=1
channel[1]=2
channel[2]=3
channel[3]=4
b=mydll.pl1000SetInterval(device,10000,20,channel.ctypes.data,4)
print b
print channel[0],channel[1],channel[2],channel[3]


The new output:
0 c_short(1)
0 c_short(4095)
16
1 2 3 4
KrisHunt
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 7:45 am

Re: PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby Martyn » Wed Mar 30, 2016 10:51 am

I don't have anything to test this on , but I think you will need
Code: Select all
us_for_block = c_int32()
us_for_block = 10000

b=mydll.pl1000SetInterval(device,byref(us_for_block),20,byref(channel.ctypes.data),4)

The driver will need to be able to write back into the two byref parameters
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: PL1000 library in Python2.7 on RaspberryPi (Raspbian)

Postby KrisHunt » Tue Apr 12, 2016 12:23 pm

Thanks for your help, but couldn't get block data configured properly, always the same channel error.
Did get the getsingle value working though so not a total loss. Thanks again!

Code: Select all
for i in range(1, 16):
    b=mydll.pl1000GetSingle(device,i,value.ctypes.data)
KrisHunt
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 7:45 am


Return to Linux

Who is online

Users browsing this forum: No registered users and 0 guests