comedi2py

18 views
Skip to first unread message

Bernd Porr

unread,
Apr 25, 2012, 2:49:22 PM4/25/12
to comed...@googlegroups.com
Hi all,

I've written a small program which completely hides the complexity of
the async acquisition of COMEDI and just calls a python function at the
sampling rate of the DAQ cards. The argument contains all the channel
values.

The source is here:
https://github.com/berndporr/comedi2py

My goal is to do plotting (Qwt) and number crunching in python. I've
tried to get a Qwt window created but haven't managed so far. Probably
the reason is that I'm creating already an QT application in the C
program and then the python call conficts with it. I guess instead of an
application I need to create another QT window object or I just need to
drop any QT functionality in the C part. Python experts: can you help
here out? Also, do you see any memory leaks generated by the repetitive
calls to to comedidata(a) in the C part?

compilation:
qmake
make

running:
bp1@bp1-x61:~/sandbox/comedi2py$ ./comedi2py Simple
Sampling rate is:
1000.0
0.113277323544 [0.11327732354402542, 0.11198132485151291,
0.11560995876789093, 0.11265372484922409, 0.11204055696725845,
0.12523999810218811, 0.11184453219175339, 0.11200643330812454,
0.11126832664012909, 0.1104205921292305, 0.10909569263458252,
0.11126042902469635, 0.11187833547592163, 0.11530795693397522,
0.11249371618032455, 0.11253778636455536]
0.22568179667 [0.1124044731259346, 0.11157491058111191,
0.11534318327903748, 0.11226090043783188, 0.11177456378936768,
0.12535355985164642, 0.11163603514432907, 0.11155769228935242,
0.11094483733177185, 0.11094009876251221, 0.1086660623550415,
0.11077156662940979, 0.11119914054870605, 0.11519912630319595,
0.11176903545856476, 0.11152341961860657]

/Bernd
--
www: http://www.berndporr.me.uk/
http://www.linux-usb-daq.co.uk/
http://www.imdb.com/name/nm3293421/
Mobile: +44 (0)7840 340069
Work: +44 (0)141 330 5237
University of Glasgow
School of Engineering
72 Oakfield Avenue (Rankine Building for deliveries)
Glasgow, G12 8LT

Bernd Porr

unread,
Apr 25, 2012, 3:05:41 PM4/25/12
to comed...@googlegroups.com, Nicholas Bailey
Update: Can now create a QWT window alongside the main window. Could any
of our python experts feed the data into that plot window? I'm still a
beginner with python.

/Bernd

W. Trevor King

unread,
Apr 25, 2012, 8:25:32 PM4/25/12
to comed...@googlegroups.com
On Wed, Apr 25, 2012 at 07:49:22PM +0100, Bernd Porr wrote:
> My goal is to do plotting (Qwt) and number crunching in python. I've
> tried to get a Qwt window created but haven't managed so far. Probably
> the reason is that I'm creating already an QT application in the C
> program and then the python call conficts with it. I guess instead of an
> application I need to create another QT window object or I just need to
> drop any QT functionality in the C part. Python experts: can you help
> here out? Also, do you see any memory leaks generated by the repetitive
> calls to to comedidata(a) in the C part?
>
> compilation:
> qmake
> make

I blindly updated to python2.7 in comedi2py.pro, but make died with
`cannot find -liir`. I compiled the IIR library you've mentioned in a
recent thread, and linked against that. I'll try and run some tests
when I'm in at work tomorrow, but I probably won't be able to help
much as I have very little experience with CPython's C interface and
none with Qt.

Cheers,
Trevor

--
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
signature.asc

Bernd Porr

unread,
Apr 26, 2012, 2:52:21 AM4/26/12
to comed...@googlegroups.com
Hi Trevor,

thanks. The IIR library has no python bindings yet so could be just
removed for now.

Have a look at QWTtest.py. It works now but probably the worst python
program you've ever seen. I'm still learning it and numpy is again not
really python but somehow a mix of Matlab syntax with python thrown in.
Taken me 2 hours to understand their array class.

/Bernd

W. Trevor King wrote:
> On Wed, Apr 25, 2012 at 07:49:22PM +0100, Bernd Porr wrote:
>> My goal is to do plotting (Qwt) and number crunching in python. I've
>> tried to get a Qwt window created but haven't managed so far. Probably
>> the reason is that I'm creating already an QT application in the C
>> program and then the python call conficts with it. I guess instead of an
>> application I need to create another QT window object or I just need to
>> drop any QT functionality in the C part. Python experts: can you help
>> here out? Also, do you see any memory leaks generated by the repetitive
>> calls to to comedidata(a) in the C part?
>>
>> compilation:
>> qmake
>> make
>
> I blindly updated to python2.7 in comedi2py.pro, but make died with
> `cannot find -liir`. I compiled the IIR library you've mentioned in a
> recent thread, and linked against that. I'll try and run some tests
> when I'm in at work tomorrow, but I probably won't be able to help
> much as I have very little experience with CPython's C interface and
> none with Qt.
>
> Cheers,
> Trevor
>

--

Bernd Porr

unread,
Apr 26, 2012, 1:18:26 PM4/26/12
to comed...@googlegroups.com, Nicholas Bailey
Hi all,

now "COMEDI 2 Python" is nicely running and I've also added a
"Thermometer" from the QWT library within 2 mins of coding. After having
spent recently half a day to create the thermometer application in C++
I'm now really thrilled of doing more Python coding.

Here's the page with a link to the source code:

http://www.linux-usb-daq.co.uk/software2/comedi2py/

It's obviously not for high speed stuff (I've set the default sampling
rate to 10Hz perhaps max is 1kHz) but for anything that's reasonably
slow and needs number-crunching of the input data that makes it
amazingly quick and easy. Basically in the true Python spirit.

/Bernd
http://www.linux-usb-daq.co.uk/


W. Trevor King wrote:
> On Wed, Apr 25, 2012 at 07:49:22PM +0100, Bernd Porr wrote:
>> My goal is to do plotting (Qwt) and number crunching in python. I've
>> tried to get a Qwt window created but haven't managed so far. Probably
>> the reason is that I'm creating already an QT application in the C
>> program and then the python call conficts with it. I guess instead of an
>> application I need to create another QT window object or I just need to
>> drop any QT functionality in the C part. Python experts: can you help
>> here out? Also, do you see any memory leaks generated by the repetitive
>> calls to to comedidata(a) in the C part?
>>
>> compilation:
>> qmake
>> make
>
> I blindly updated to python2.7 in comedi2py.pro, but make died with
> `cannot find -liir`. I compiled the IIR library you've mentioned in a
> recent thread, and linked against that. I'll try and run some tests
> when I'm in at work tomorrow, but I probably won't be able to help
> much as I have very little experience with CPython's C interface and
> none with Qt.
>
> Cheers,
> Trevor
>

--
Reply all
Reply to author
Forward
0 new messages