Servo and AdvServo not working in matlab

Legacy support with Phidget21
canadakickass
Phidgetsian
Posts: 10
Joined: Fri Feb 13, 2009 8:55 pm
Location: canada
Contact:

Servo and AdvServo not working in matlab

Postby canadakickass » Wed Nov 28, 2012 9:23 pm

Hi everyone,

I tried changing the Phidget21Matlab.h file as described in the documentation but the examples will just not run. the program crashes at CPhidget_Open instruction. I noticed that ptr and handle both have a value of 0 for their pointers which is odd.

I'm running on windows 64 bit, matlab 2012a 64 bit with all 64bit phidgets files (drivers and libraries). Anyone knows a fix?

I also
function servo
%servo.m - sets servo motor position
% phidget20.h needs to be on the path
if ~libisloaded('phidget21')
loadlibrary('phidget21', 'phidget21Matlab.h');
end

%libfunctions('phidget21', '-full')

ptr = libpointer('int32Ptr', 0);

calllib('phidget21', 'CPhidgetServo_create', ptr);

%ptr points to a CPhidgetServoHandle sturcture but we use it's int value
%for control functions - handle

handle = get(ptr, 'Value');

calllib('phidget21', 'CPhidget_open', handle, -1); ( THE PROGRAM CRASH HERE, handle and ptr = 0... maby that's why? how do you fix that?).

------------------------------------------------------------------
I'm also getting these warnings when loading the library:
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 344
In servo at 5
Warning: The data type 'FcnPtr' used by function CPhidgetDictionary_set_OnKeyChange_Handler does not
exist.
> In loadlibrary at 403
In servo at 5
Warning: The data type 'voidPtrPtrPtr' used by function CPhidgetManager_getAttachedDevices does not
exist.
> In loadlibrary at 403
In servo at 5
Warning: The data type 'error' used by function CPhidget_log does not exist.
> In loadlibrary at 403
In servo at 5

User avatar
burley
Human-Cyborg Relations
Posts: 438
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: Servo and AdvServo not working in matlab

Postby burley » Thu Nov 29, 2012 9:33 am

Try this header file, I have been using this one on my machine (x64 Windows 7) for a while with no issues.
Attachments
phidget21Matlab.h
(146.78 KiB) Downloaded 429 times
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

canadakickass
Phidgetsian
Posts: 10
Joined: Fri Feb 13, 2009 8:55 pm
Location: canada
Contact:

Re: Servo and AdvServo not working in matlab

Postby canadakickass » Thu Nov 29, 2012 12:33 pm

Hi Burley,

Indeed, you version of Phidget21Matlab.h works correctly. Upon further inspection of the one I had, which is also the one provided in the programming section of the phidgets website, all that needed to be changed for it to work was to change all ''typedef void *abcdefg'' to ''typdef long abcdef. Once I made the change from void* to long, my programmed worked correctly. Note that the changes done as described above were not applied to function arguments. anyways I hope this provides direction and that phidgets will update their Phidget21Matlab.h file with a working one so no one else needs to pull their hair! =D

thanks again

Lois96
Fresh meat
Posts: 2
Joined: Sat Aug 31, 2013 1:42 am
Contact:

Re: Servo and AdvServo not working in matlab

Postby Lois96 » Sat Aug 31, 2013 1:48 am

No need to link a servo if it doesnt work you have a bad servo one note is the esc working and the servo dont if neither work you may need to re link your radio


Return to “Matlab”

Who is online

Users browsing this forum: No registered users and 2 guests