0

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.

enter image description here

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

enter image description here

Thanks

asked Apr 19, 2017 at 8:23
5
  • 1
    Please include program code that performs search and connect a serial device and a screenshot of the device manager. Commented Apr 19, 2017 at 10:08
  • 1
    The 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. Commented 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) Commented 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) Commented Apr 20, 2017 at 4:53
  • 1
    CH340 is VID: 1A86, PID: 7523 Commented Apr 21, 2017 at 11:07

2 Answers 2

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.

answered Apr 20, 2017 at 20:32
1
  • Thank you very much @AltAir! I modified it an it worked! I hope this helps others as well. Commented Apr 24, 2017 at 3:54
1

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

Mine is the USB-SERIAL CH340

answered Apr 19, 2017 at 8:56
4
  • 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. Commented 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? Commented Apr 20, 2017 at 4:56
  • It just shows up as a com port in my IDE, I use STINO Commented 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. Commented Apr 25, 2017 at 3:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.