Go Down

Topic: [SOLVED] Map all Arduino's to same COM port? (Read 3428 times) previous topic - next topic

chriskner

Sep 13, 2013, 03:22 pm Last Edit: Sep 13, 2013, 10:57 pm by chriskner Reason: 1
Windows / Arduino DUE and Mega's

Every time I plug in a new Arduino PCB via USB, windows assigns a new COM port to it.

Is there a way to set any Arduino to use the same COM port (say when you'd like to program a stack of pcb's)?

** My apologies if this has already been answered... The search terms that I could come up with are so common, the that the results are hard to sift through. **

Regards,

Chris

chriskner

#1
Sep 13, 2013, 03:47 pm Last Edit: Sep 13, 2013, 04:34 pm by chriskner Reason: 1
-- Just found this:
"Ignore Hardware Serial Number Registry Editor Utility"
at:
http://www.ftdichip.com/Support/Utilities.htm

Has anyone attempted to use this?

The description notes:
Quote
Enter the device type and VID/PID that you want to ignore the serial number on and press WRITE to apply.


Any hints on discovering the 'device type' and 'VID/PID'?

I see the DUE does not use a FTDI chip...  No joy here...

-Chris

K5CZ

You may change COM port in the Device Manager and set to same number. Of course, ignoring all warnings.

Tip to show/delete/manage non present devices:
http://support.microsoft.com/kb/241257

chriskner

Thanks K5CZ,

I realized that changing the port assignment via the windows gui is a possibility, (as well as viewing ghosted devices).

However, imagine you have a stack of new Arduino's that you'd like to program, and then perhaps reprogram N times.  Followed by another batch...

It seems inefficient for the driver to assign a new Com port each time a new board is plugged in (especially when the other boards are not connected).

There must be a known work around for programming a pile of Arduino's...

I hope.

-Chris

K5CZ

#4
Sep 13, 2013, 08:58 pm Last Edit: Sep 13, 2013, 11:37 pm by K5CZ Reason: 1
Your problem is challenge to my scripting skills. So, Last hour I wrote next script:

Code: [Select]

@ECHO OFF
CLS
SET "DESIREDPORT=COM3"
SET /A COUNTER=0
FOR /F "tokens=1,2,3" %%A IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Enum\USB" /s /v "PortName" /f "COM" /c /t "REG_SZ"') DO CALL :_parse "%%A" "%%B" "%%C"
SET /A NUMBER=%COUNTER%
SET /A COUNTER=0
SET "ROW="
:loop
SET /A COUNTER=%COUNTER% + 1
IF %NUMBER% LSS %COUNTER% GOTO endloop
SET "ROW=%ROW% %COUNTER%"
GOTO loop
:endloop
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO COM ports found:
ECHO ================
FOR %%A IN (%ROW%) DO CALL :_process "%%A"
SET /A COUNTER=0
FOR /F "tokens=1,2,3" %%A IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Enum\USB" /s /v "PortName" /f "COM" /c /t "REG_SZ"') DO CALL :_parse "%%A" "%%B" "%%C"
ECHO.
ECHO COM ports changed to:
ECHO =====================
FOR %%A IN (%ROW%) DO (ECHO !KEYNAME%%A!&ECHO PortName=!COMPORT%%A!&ECHO.)
ENDLOCAL
PAUSE
GOTO :EOF
REM ***************************************************************************
:_process
ECHO !KEYNAME%~1!
ECHO PortName=!COMPORT%~1!
REG ADD "!KEYNAME%~1!" /v "PortName" /t "REG_SZ" /d "%DESIREDPORT%" /f > NUL
ECHO.
GOTO :EOF
REM ***************************************************************************
:_parse
ECHO "%~1"|FIND "HKEY_LOCAL_MACHINE">NUL
IF %ErrorLevel% EQU 0 goto keyname
IF "%~1" == "PortName" goto value
GOTO :EOF
:keyname
SET /A COUNTER=%COUNTER% + 1
set "KEYNAME%COUNTER%=%~1 %~2"
GOTO :EOF
:value
set "COMPORT%COUNTER%=%~3"
GOTO :EOF
REM ***************************************************************************


The script is not perfect, the Port descriptions are not changed (old port numbers are shown), but COM port numbers yes. Set IDE to COM3 and it works!

PS: I try to improve script later
PS2: second version requires subinacl.exe to set access rights in the registry

chriskner

#5
Sep 13, 2013, 10:56 pm Last Edit: Sep 13, 2013, 11:01 pm by chriskner Reason: 1
Works on Windows XP (Other Windows?)

Found a solution for me - inspired by by:
http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf

The key is to set 'IgnoreHWSerNum' in the registry for the Arduino DUE.

For reference the DUE's Vendor ID = 2341, the Product ID = 003d.


  • Follow Section 7.2 in the linked PDF to list all previously installed drivers.

  • Right-click on all existing Arduino serial ports listed in 'Ports', and select 'Uninstall'

  • Open Regedit, and add a new Binary entry as:



IgnoreHWSerNum2341003d to 1

(this is described in Section 7.1 in the PDF).  See attached image.

The next time an Arduino board is plugged in, allow the serial driver to install ('let Windows do it for me' worked).
Now, when that board is disconnected and a new board that is connected, the new board will use the same Com port number.

From now on, each new Arduino DUE will use the same Com port assignment.

Yes, this is an old XP box.  Not sure about Win7.

-Chris

K5CZ

The "IgnoreHWSerNumvendor" is good way for mass production.

Tip:
I also had a large number of USB COM ports (by present and non present devices), so I quickly delete all of them and rescan for present only devices by script

spycatcher2k

At work I program arduinos in batches , I use an ftdi board, mounted on a breadboard shield kit (from proto-pic.co.uk - http://proto-pic.co.uk/breadboard-shield-for-arduino-pack-of-3/), but if i'm programming stand alone chips for custom pcbs I use this - http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=271271691920&ssPageName=STRK:MESE:IT
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

Go Up