I am trying to make some matlab code which will allow me to stream directly into my workspace however I am having a few issues with establishing a connection with the device.
When I call the enumeration to find the serials of the devices attached I see that the PT104 responds with USB:AT313/069 so I try to run the connect function with 'AT313/069' and tried with prefixing the 'USB:' but it always returns no device.
Here is a copy of the offending code.
- Code: Select all
if not(libisloaded('USBPT104'))
disp('Matlab: Load USBPT104.dll')
loadlibrary('USBPT104','UsbPt104Api.h')
disp('Matlab: dll loaded')
disp('')
else
disp('Matlab: dll already loaded')
disp('')
end
pause(0.5)
%%
serials = '';
serials_ptr = libpointer('cstring',serials);
seriallen = uint32(0);
seriallen_ptr = libpointer('uint32Ptr',seriallen);
[status, serials, seriallen] = calllib('USBPT104', 'UsbPt104Enumerate', serials_ptr, seriallen_ptr, 1);
pause(0.5);
disp(serials);
%%
handle = int16(0);
handle_ptr = libpointer('int16Ptr',handle);
serials = 'AT313/069';
%serials(end+1)=0;
[status, handle] = calllib('USBPT104', 'UsbPt104OpenUnit', handle_ptr, serials_ptr);
[status] = calllib('USBPT104','UsbPt104SetChannel', handle ,int16(1),int8(1),int16(4)); %setup a single channel
%-------------------------------------------------------------------------
y=int16(3);
yp = libpointer('voidPtr',y);
for loop =1:100
[status, y]=calllib('USBPT104','UsbPt104GetValue',handle, int16(1),yp, 0);
disp(y);
pause(1)
end
%-------------------------------------------------------------------------
%%
[status] = calllib('USBPT104', 'UsbPt104CloseUnit', handle);
Cart


