Phidgets on Ubuntu + Matlab?

Supporting 2.6 and up
mrbts

Phidgets on Ubuntu + Matlab?

Postby mrbts » Wed Jun 17, 2009 10:05 am

Has anyone succesfully used phidgets with Matlab on Ubuntu? Supposedly the set up for Matlab only works on Windows. I was thinking of using C to get through to Matlab. The reason I need Matlab is that all my other code is developed in Matlab. If anyone could tell me how they did it, that would help me a lot!

User avatar
Patrick
Lead Developer
Posts: 3165
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets on Ubuntu + Matlab?

Postby Patrick » Wed Jun 17, 2009 2:27 pm

It should work, you would need to use the linux phidget21.h file, and open the linux library in the matlab files.

-Patrick

mrbts

Re: Phidgets on Ubuntu + Matlab?

Postby mrbts » Thu Jun 18, 2009 9:38 am

In running the analogin.m file after installing linux phidget libaries, etc., these errors appeared:

Warning: The library class 'libphidget21' already exists. Use a classname alias.
> In loadlibrary at 180
In analogin at 4
??? Error using ==> calllib
Library was not found

Error in ==> analogin at 8
calllib('phidget21', 'CPhidgetInterfaceKit_create', ptr);


I decided to try changing 'phidget21' to 'libphidget21' every time I saw it in analogin.m, but then that ended up crashing Matlab... Any ideas?

edward23

Re: Phidgets on Ubuntu + Matlab?

Postby edward23 » Thu Jun 25, 2009 7:34 pm

patrick wrote:It should work, you would need to use the linux phidget21.h file, and open the linux library in the matlab files.

-Patrick

I Agree With Patrick:)

JPereira

Re: Phidgets on Ubuntu + Matlab?

Postby JPereira » Tue Jun 29, 2010 11:24 pm

I am also having some problems with running phidgets from Matlab in ubuntu.

Here is what Matlab returns when I try to run AdvServo.m unmodified:



Warning: Warnings messages were produced while parsing. Check the functions you
intend to use for correctness. Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 394
In AdvServo at 4
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********

Failed to parse type '...' original input ' ...'
Found on line 532 of input from line 699 of file /projects/Matlab/phidget21Matlab.h
Error parsing argument for function CPhidget_log function may be invalid.
*********
??? Error using ==> loadlibrary at 422
Building phidget21_thunk_glnxa64 failed. Compiler output is:
In file included from phidget21_thunk_glnxa64.c:39:
/projects/Matlab/phidget21Matlab.h: In function ‘__declspec’:
/projects/Matlab/phidget21Matlab.h:174: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before
‘CPhidget_open’
/projects/Matlab/phidget21Matlab.h:179: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:185: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:193: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:201: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:209: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:217: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:225: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:232: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:239: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:246: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:253: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:259: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:266: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:273: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:280: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:287: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:294: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:301: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:309: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:316: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:323: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:330: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:349: error: storage class specified for parameter
‘CPhidgetDictionary_keyChangeReason’
/projects/Matlab/phidget21Matlab.h:354: error: storage class specified for parameter
‘CPhidgetDictionaryHandle’
/projects/Matlab/phidget21Matlab.h:358: error: storage class specified for parameter
‘CPhidgetDictionaryListenerHandle’
/projects/Matlab/phidget21Matlab.h:364: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:370: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:376: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:384: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:394: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:401: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:411: error: expected ‘)’ before ‘*’ token
/projects/Matlab/phidget21Matlab.h:421: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:428: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:437: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:445: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:453: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:460: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:468: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:475: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:488: error: storage class specified for parameter
‘CPhidgetManagerHandle’
/projects/Matlab/phidget21Matlab.h:494: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:500: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:506: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:512: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:520: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:528: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:536: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:543: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:551: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:560: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:568: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:575: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:583: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:590: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:605: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:615: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:628: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:637: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:650: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:659: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:678: error: storage class specified for parameter ‘CPhidgetLog_level’
/projects/Matlab/phidget21Matlab.h:685: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:690: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:698: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:709: error: storage class specified for parameter
‘CPhidgetAccelerometerHandle’
/projects/Matlab/phidget21Matlab.h:710: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:718: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:727: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:735: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:743: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:751: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:760: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:768: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:779: error: storage class specified for parameter
‘CPhidgetAdvancedServoHandle’
/projects/Matlab/phidget21Matlab.h:780: error: expected

Error in ==> AdvServo at 4
loadlibrary('phidget21', 'phidget21Matlab.h');

Warning: Warnings messages were produced while parsing. Check the functions you
intend to use for correctness. Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 394
In AdvServo at 4
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********

Failed to parse type '...' original input ' ...'
Found on line 532 of input from line 699 of file /projects/Matlab/phidget21Matlab.h
Error parsing argument for function CPhidget_log function may be invalid.
*********
??? Error using ==> loadlibrary at 422
Building phidget21_thunk_glnxa64 failed. Compiler output is:
In file included from phidget21_thunk_glnxa64.c:39:
/projects/Matlab/phidget21Matlab.h: In function ‘__declspec’:
/projects/Matlab/phidget21Matlab.h:174: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘CPhidget_open’
/projects/Matlab/phidget21Matlab.h:179: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:185: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:193: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:201: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:209: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:217: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:225: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:232: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:239: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:246: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:253: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:259: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:266: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:273: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:280: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:287: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:294: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:301: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:309: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:316: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:323: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:330: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:349: error: storage class specified for parameter ‘CPhidgetDictionary_keyChangeReason’
/projects/Matlab/phidget21Matlab.h:354: error: storage class specified for parameter ‘CPhidgetDictionaryHandle’
/projects/Matlab/phidget21Matlab.h:358: error: storage class specified for parameter ‘CPhidgetDictionaryListenerHandle’
/projects/Matlab/phidget21Matlab.h:364: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:370: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:376: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:384: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:394: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:401: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:411: error: expected ‘)’ before ‘*’ token
/projects/Matlab/phidget21Matlab.h:421: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:428: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:437: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:445: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:453: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:460: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:468: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:475: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:488: error: storage class specified for parameter ‘CPhidgetManagerHandle’
/projects/Matlab/phidget21Matlab.h:494: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:500: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:506: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:512: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:520: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:528: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:536: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:543: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:551: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:560: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:568: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:575: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:583: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:590: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:605: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:615: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:628: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:637: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:650: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:659: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:678: error: storage class specified for parameter ‘CPhidgetLog_level’
/projects/Matlab/phidget21Matlab.h:685: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:690: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:698: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:709: error: storage class specified for parameter ‘CPhidgetAccelerometerHandle’
/projects/Matlab/phidget21Matlab.h:710: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:718: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:727: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:735: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:743: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:751: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:760: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:768: error: expected declaration specifiers before ‘__declspec’
/projects/Matlab/phidget21Matlab.h:779: error: storage class specified for parameter ‘CPhidgetAdvancedServoHandle’
/projects/Matlab/phidget21Matlab.h:780: error: expected

Error in ==> AdvServo at 4
loadlibrary('phidget21', 'phidget21Matlab.h');

>>


Can someone tell me what I have done wrong? What files are supposed to be where (ie: phidget21.h in /usr/local/include, although that one is for C, not for Matlab, i believe... ; any other files that need to be anywhere in the filesystem... )

I am running ubuntu 10.04 LTS Lucid on a x64 AMD Phenom 9500 with Gnome 2.30.0 if any of that helps...

Thank you,

JP

User avatar
Patrick
Lead Developer
Posts: 3165
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets on Ubuntu + Matlab?

Postby Patrick » Wed Jun 30, 2010 10:42 am

You're using the wrong phidget21matlab.h - the one that comes with the matlab examples is for Windows. You need to make your own - you do this by running make phidget21matlab.h in the linux source.

-Patrick

hgm110

Re: Phidgets on Ubuntu + Matlab?

Postby hgm110 » Tue Dec 21, 2010 10:29 pm

I am trying to run it in OS X, but I got exactly the same output as JPereira. Patrick, could you explain what you mean about running make phidget21matlab.h in the linux source? Could this apply to me as well?

dynamphorous

Re: Phidgets on Ubuntu + Matlab?

Postby dynamphorous » Tue Mar 22, 2011 1:50 pm

I just figured this out from patricks answer, so I will just shoot it out there for everyone else who may want to use Phidgets+Matlab+Linux.

What he means by compiling it is to goto the directory ${phidget drivers}/phidget21 then type:

Code: Select all

make phidget21Matlab.h
Copy your newly created phidget21Matlab.h file into the working directory you wish to run your Matlab program, and replace the example one included with the Matlab code sample. Now you should be all set to go!

One note however: I found that I had to reference libphidget21 instead of just phidget21 as in:

loadlibrary libphidget21 phidget21Matlab.h;

then you just have to change all the references in your code that attach to that library reference to libphidget21

Hope this helps someone else!

I just wish that I could use the "on change handlers" with matlab :( I realize that its a limitation of Matlab, but its still kinda disappointing for my applications. Would really save me some wasted processor time busy waiting for results.


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest