- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have USB-based EEG hardware, with an FX2LP controller. I am trying to read the data into MATLAB using the following code.
Note: there are only two endpoints one control and one interrupt
CODE 1: for interrupt endpoint
try
CyUSBdll = NET.addAssembly('C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin\CyUSB.dll');
catch error
error.message
if(isa(error,'NET.
e.ExceptionObject
else
disp('CyUSB.dll already loaded');
return;
end
end
%%USB Device Select
% Create a list of USB devices
usbDevices = CyUSB.USBDeviceList(CyUSB.
device=usbDevices.Item(0);
%For Interrupt Endpoint
len=1024;
buf = zeros(1,len,'uint8');
a=device.InterruptInEndPt.
OUTPUT:
a=1
- But the Buf has all zeros, I don't know where the data is, if the transfer is successful where will the data be?
CODE 2: for control endpoint
try
CyUSBdll = NET.addAssembly('C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin\CyUSB.dll');
catch error
error.message
if(isa(error,'NET.
e.ExceptionObject
else
disp('CyUSB.dll already loaded');
return;
end
end
%%USB Device Select
% Create a list of USB devices
usbDevices = CyUSB.USBDeviceList(CyUSB.
device=usbDevices.Item(0);
CEP=device.ControlEndPt;
CEP.Target=CyUSB.CyConst.TGT_
CEP.ReqType=CyUSB.CyConst.
CEP.Direction=CyUSB.CyConst.
CEP.ReqCode=0xB0;
CEP.Value=0;
CEP.Index=0;
len=64;
buf = zeros(1,len,'uint8');
CEP.XferData( buf, len );
RESULT:
- Execution doesn't end, the program keeps on running I do not know if data is coming or it is stuck, I had to use task manager to close the MatLab because even Ctrl+C was not able to stop execution.
I also think that it might be that the byte type used in .net/C# to make the buffer is not working here and hence CODE1 and 2 both are not working. I do not know what to do after this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Did you import the .dll into MATLAB?
Please also check the CyUSB.NET document attached along with my response.
Apologies but we do not have any example of using FX2LP in MATLAB.
Regards,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
May I know what interface are you using? Are you implementing serial communication?
Regards,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@MallikaK_22 wrote:
Hi,
May I know what interface are you using? Are you implementing serial communication?
Regards,
Mallika
Hi mallika,
I am simply connecting the the usb to the CPU and running the above code on matlab. Nothing else, hope that answers your question.
Regards
Vishwas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please let me know which version of .NET framework and Cyusb.dll are you using? Did you face any issue while compiling the two?
Regards,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey,
I downloaded the latest Cyusb.dll i.e, 1.3, and the .net framework was asked to be installed during the installation of 1.3, so I am assuming it is the latest one. There were no issues while compiling the two.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Malika,
Yes, I got the CyUSB.dll into MATLAB, problem is that the transfer status is 1 but the data is not in the buffer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
This is my code yes, do you have any idea how can I get the data?