I'm working on an app using Matlab and it recieves data from an arduino. I've changed my board into an Arduino Nano (clone) recently. My program will automatically check for the device's name in the list of serial devices connected and it will connect to it directly once the user presses connect. The user doesn't have to input any Com port number or baud rate. This worked fine with my previous boards (UNO, Pro Micro, Leonardo). I just need to change the search string in my code and it'll automatically connect. My current board however is different, I'm using VMA102 (Arduino Nano clone). It uses FTDI drivers which I downloaded following this tutorial. I can upload the codes correctly to it but I just doesn't show a name with in the ports list in Arduino IDE as shown in the picture below.
Now when I looked it up in the device manager the name was 'USB Serial Port (COM5)' so I pasted 'USB Serial Port' as my search text in Matlab, it doesn't find it. I concluded that the correct name for it is not 'USB Serial Port' but rather the 'no name' as shown in Arduino IDE. Is there a way to find what is it called or how I can change it into a unique name so that my app can search for it?
Edit: here is the code, it works fine with all the other boards: devices = IDSerialComs();%gets all the avilabe com ports and thier names (name, com#) assignin('base','devices',devices);%save it to main workspace
i=1;index=0; tesst= zeros(length(devices),1);%saves the comparison results
while i<=length(devices)
tesst(i)= strcmp(devices{i,1},'USB Serial Port');%compare the received names with the board's name
% 'SparkFun Pro Micro''Arduino Uno'
if ( tesst(i)==1 )
index=i;%save the index
end
i=i+1;
end
if(isempty(find(tesst,1)))
msgbox({'Connection failed' ' plug the device, wait for 5 seconds then try again'} ,'Connection Failure','error');
else
msgbox('Connection successful, proceed to the next tabs', 'Connection success');
end
%get the COM# associated with the index and add COM before it to from the comport number as a string
COM_Num = strcat('COM',num2str(devices{index,2}));
comport= serial(COM_Num, 'BaudRate', 115200);
and here is a screenshot of my device manager
Thanks
-
1Please include program code that performs search and connect a serial device and a screenshot of the device manager.AltAir– AltAir2017年04月19日 10:08:50 +00:00Commented Apr 19, 2017 at 10:08
-
1The name shown in the Arduino IDE's Tools > Port menu is set in the Arduino boards.txt file (github.com/arduino/Arduino/blob/1.8.2/hardware/arduino/avr/…) so that is not relevant to Matlab. Can you search for VID/PID instead? FTDI FT232RL chips come with a default VID: 0403, PID: 6001 unless the purchaser specifies otherwise. That still won't help you if there are multiple FT232RL attached to the computer but it's an improvement at least.per1234– per12342017年04月20日 04:39:56 +00:00Commented Apr 20, 2017 at 4:39
-
Assuming that I only have 1 FTDI FT232RL (which is the plan), what should its typical name be "0403 6001"? and is this the same with CH430 drivers (in case I want to buy one)Isra– Isra2017年04月20日 04:47:37 +00:00Commented Apr 20, 2017 at 4:47
-
I've done some debugging, and I found out that the function that searches for all the serial devices returns an empty cell when my Nano is the only board connected. Could this be because it has no name (Arduino shown "no name" only a port number)Isra– Isra2017年04月20日 04:53:25 +00:00Commented Apr 20, 2017 at 4:53
-
1CH340 is VID: 1A86, PID: 7523per1234– per12342017年04月21日 11:07:32 +00:00Commented Apr 21, 2017 at 11:07
2 Answers 2
The IDSerialComs() function scans the Windows registry and associated active COM ports with their registered "Friendly Name". To scans using the following path:
'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\'
But driver FTDI uses another path:
'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\FTDIBUS\'
Try to modify the function so that it meets your needs.
-
Thank you very much @AltAir! I modified it an it worked! I hope this helps others as well.Isra– Isra2017年04月24日 03:54:14 +00:00Commented Apr 24, 2017 at 3:54
If you do a windows search for the device manager you will be able to see all the com devices currently connected to your computer. Unplug and replug your Arduino and it should be pretty easy to spot.
Mine is the USB-SERIAL CH340
-
Yes i've done that, my board is called "USB Serial Port" which is not found when searched for. From my research, I read that with this driver all connected devices that use this FTDI driver will have exact same name, even if connected at the same time.Isra– Isra2017年04月20日 04:15:48 +00:00Commented Apr 20, 2017 at 4:15
-
Does USB Serial CH340 appear when you look for your board in Arduino IDE? or does it only show the com port number?Isra– Isra2017年04月20日 04:56:27 +00:00Commented Apr 20, 2017 at 4:56
-
It just shows up as a com port in my IDE, I use STINOMatt– Matt2017年04月24日 09:25:10 +00:00Commented Apr 24, 2017 at 9:25
-
Matt, yes it will show as a com port only in the IDE, I realized that only the original boards will show up by their name in the IDE.Isra– Isra2017年04月25日 03:52:01 +00:00Commented Apr 25, 2017 at 3:52