I'm using the polling method to read in sensor data into matlab and I don't think I understand where to place 'CPhidgetInterfaceKit_setDataRate' in order to change the datarate.
After I run:
Code: Select all
loadphidget21;
handles.phid = libpointer('int32Ptr');
calllib('phidget21', 'CPhidgetInterfaceKit_create', handles.phid);
calllib('phidget21', 'CPhidget_open', handles.phid, -1);The following function is used:
Code: Select all
function sensorvalue = analogin_mod(n,phid)
if calllib('phidget21', 'CPhidget_waitForAttachment', phid, 500) == 0
    calllib('phidget21','CPhidgetInterfaceKit_setDataRate',phid,n,8);
    dataptr = libpointer('int32Ptr', 0);
    if calllib('phidget21', 'CPhidgetInterfaceKit_getSensorValue', phid, n, dataptr) == 0
       sensorvalue = dataptr.Value;
    else
        % clean up
        calllib('phidget21', 'CPhidget_close', phid);
        calllib('phidget21', 'CPhidget_delete', phid);
        error('Error getting sensor data..');
    end
else
    % clean up
    calllib('phidget21', 'CPhidget_close', phid);
    calllib('phidget21', 'CPhidget_delete', phid);
    error('Could not open InterfaceKit')
endI don't run into any errors, but no matter what I change the DataRate to I'm only able to sample at 40 hz. Even if I remove that line from the code I am still sampling at 40 hz.
Any thoughts?
Thanks
