Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: cappy2112 on Feb 08, 2012, 12:50 am

Title: Arduinos and Windows COM ports
Post by: cappy2112 on Feb 08, 2012, 12:50 am

I've created an Arduino-based piece of test equipment where I work.
We are building 20 of these for use throughout the lab.

I've noticed that whenever I plug an Arduino "fresh out of the box" into the USB port a different COM port gets used each time.
This is quite annoying,but I'm sure it's more of a Windows issue than an Arduino issue.

Since I'm building 20 testers does this mean I may see up to 20 different COM ports in the Arduino IDE under the Tools/Serial Port menu?
Is there a straightforward way of forcing all Arduinos to use the same COM port each time it's plugged in?
Title: Re: Arduinos and Windows COM ports
Post by: pwillard on Feb 08, 2012, 01:57 am
sadly... you would have to play with the windows registry... as each USB device attached inserts it's unique ID in the registry.
Title: Re: Arduinos and Windows COM ports
Post by: retrolefty on Feb 08, 2012, 02:34 am
Since I'm building 20 testers does this mean I may see up to 20 different COM ports in the Arduino IDE under the Tools/Serial Port menu?

Not nessesarly, when you first open up the arduino IDE it searches via OS request for all active and attached serial comm ports. If there are no arduinos plugged in you won't see them listed as avalible in the port pull down menu. For instance, in my windows XP systems if I have no arduinos plugged into any usb ports and then open the arduino IDE, the port menu only shows COM1 and COM2 avalible as these are my two legacy RS232 ports I had built with my PC. I must have half a dozen usb arduinos and usb serial cables around and each was given a new com port number when first plugged into the PC, but it's not a problem as normally only have one or sometimes two arduinos plugged in at any given session.

Is there a straightforward way of forcing all Arduinos to use the same COM port each time it's plugged in?

I don't know how straight forward it might be but I do seem to recall sometime ago that there was a way to change windows settings (registry and or driver settings?) to do that, but as I explained it really doesn't seem to be an issue in reality. Possibly just put a small sticker on each arduino board with it's com port number written on it?

Lefty
Title: Re: Arduinos and Windows COM ports
Post by: zoomkat on Feb 08, 2012, 02:53 am
In the past with some usb serial adapters, I've had windows assign an ever increasing com port number each time the device was plugged in. It appeared that windows somehow thought something was still assigned to the previous ports or saw the adapter as something new each time it was plugged in.  To fix the problem I went into the comport setup and assigned the usb device to a previous comport I knew wasn't being used (like com port 5). Windows complained, but accepted the assigned number. From then on the usb serial adapter was assigned that comport when plugged in. 
Title: Re: Arduinos and Windows COM ports
Post by: Texy on Feb 08, 2012, 02:22 pm
You need to educate the staff/end user how to set the correct comm port. You are unlikely to get anywhere near 20 different comm ports reported, but this is down to how many USB devices are been seen in the past or that are correctly connected.
Out of interest, what does the test kit do?

Texy
Title: Re: Arduinos and Windows COM ports
Post by: cappy2112 on Feb 09, 2012, 03:12 am

You need to educate the staff/end user how to set the correct comm port. You are unlikely to get anywhere near 20 different comm ports reported, but this is down to how many USB devices are been seen in the past or that are correctly connected.
Out of interest, what does the test kit do?

Texy


What is a test kit?
Title: Re: Arduinos and Windows COM ports
Post by: Texy on Feb 09, 2012, 08:48 am
The test equipment the arduino is part of.
Texy
Title: Re: Arduinos and Windows COM ports
Post by: cappy2112 on Feb 09, 2012, 09:33 am

The test equipment the arduino is part of.
Texy


The arduino is used to control 5V power to a device which we are testing.
Power is turned on/off several times a minute. The arduino simply monitors a digital signal from this device in order
to know if it comes ready- after cycling power.

Since we are building 20+ of these testers, I need to verify that each one works by downloading a sketch.

I need to plug in each Arduino into my computer and make sure the sketch turns
one of the I/O lines on/off.

If each USB device writes a unique ID to the windows registry, it's possible that each Arduino will have a different COM port #.
This isn't really a problem, just inconvenient. I'm sure there is some upper limit to the COM port numbers.

What would happen if we were building 300 of these testers?
At some point I would expect the COM ports to be used over, or Windows would display a warning or error message.
Title: Re: Arduinos and Windows COM ports
Post by: Daanii on Feb 10, 2012, 08:05 am
You can use the Device Manager to hard-code the COM port you want to use.

If you plug in a new Arduino and Windows assigns it to COM port 10, for example, you can find the COM port in the "Ports (COM & LPT)" listing in Device Manager. Click on COM port 10 and choose the "Port Settings" tab. Click on "Advanced" and change the "COM Port Number" to whatever you want. If another device has that COM port number already, you can override that and assign it anyway.

I'm not sure what will happen, though, when a user plugs the Arduino into a different Windows machine. I suspect the new Windows machine will assign a new COM port number to the Arduino.
Title: Re: Arduinos and Windows COM ports
Post by: zoomkat on Feb 10, 2012, 08:22 am
Quote
What would happen if we were building 300 of these testers?
At some point I would expect the COM ports to be used over, or Windows would display a warning or error message.


You probably need to use an arduino using a known windows USB serial driver. The FTDI chip based arduinos seem to have fewer issues than the drivers used with the UNO.
Title: Re: Arduinos and Windows COM ports
Post by: cappy2112 on Feb 10, 2012, 08:49 pm

Quote
What would happen if we were building 300 of these testers?
At some point I would expect the COM ports to be used over, or Windows would display a warning or error message.


You probably need to use an arduino using a known windows USB serial driver. The FTDI chip based arduinos seem to have fewer issues than the drivers used with the UNO.


The UNOS DO use known Windows drivers. I think that's the only way they will work.

The installation for the FTDI driver is easier though. You just run the installer.

With the UNO, Windows XP pops up a dialog that tells you you need a CD for SP3, EVEN after you've already installed the USB driver
on the machine.

Haven't tried W7 yet, not sure I want to see what happens there, but eventually our company will be migrating to Windows 7 64-bit.


Title: Re: Arduinos and Windows COM ports
Post by: zoomkat on Feb 10, 2012, 08:59 pm
Hopefully the FTDI driver will be automatically identified by windows and installed. The UNO driver will probably always be unknown by windows and will require some type of manual install process.
Title: Re: Arduinos and Windows COM ports
Post by: oric_dan on Feb 10, 2012, 09:20 pm

Danii said:
--------
You can use the Device Manager to hard-code the COM port you want to use.

If you plug in a new Arduino and Windows assigns it to COM port 10, for example, you can find the COM port in the "Ports (COM & LPT)" listing in Device Manager. Click on COM port 10 and choose the "Port Settings" tab. Click on "Advanced" and change the "COM Port Number" to whatever you want. If another device has that COM port number already, you can override that and assign it anyway.

I'm not sure what will happen, though, when a user plugs the Arduino into a different Windows machine. I suspect the new Windows machine will assign a new COM port number to the Arduino.
------

When you're in the Device Manager, click on "View > Show Hidden Devices", and it will display
ALL the commports that have been redundantly assigned on your PC. The first time I did this, there
were about 50 installs, mostly the same vendor programs installed again and again and again.

Then, under "Ports (COM & LPT)", select the redundant installs, and right-click to uninstall. It shouldn't
hurt anything if you remove too much [I think], as they should re-install next time. Also, you can go in
and re-assign commport #s by right-clicking on "Properties > Port Settings > Advanced", as mentioned.


Title: Re: Arduinos and Windows COM ports
Post by: retrolefty on Feb 11, 2012, 01:31 am
Quote
I'm not sure what will happen, though, when a user plugs the Arduino into a different Windows machine. I suspect the new Windows machine will assign a new COM port number to the Arduino.


Correct, a given Windows machine will assign it the next available unassigned COM port number, for that machine only, when the board is first plugged into the machine. There is no way to automatically force a COM number assignment that will follow the board to whatever machine it plugs into.
Title: Re: Arduinos and Windows COM ports
Post by: cappy2112 on Feb 11, 2012, 07:38 am

Quote
I'm not sure what will happen, though, when a user plugs the Arduino into a different Windows machine. I suspect the new Windows machine will assign a new COM port number to the Arduino.


Correct, a given Windows machine will assign it the next available unassigned COM port number, for that machine only, when the board is first plugged into the machine. There is no way to automatically force a COM number assignment that will follow the board to whatever machine it plugs into.


Of course it won't follow it. It would be nice to be able to configure Windows to use the same com port on all machines though.

I've got to send some of the testers that I've made with the Arduino to our engineering group overseas. The documentation I write will be translated to another language. It would be great if I could document it using a known com port number, as opposed to "Whatever com port windows assigns to the Arduino". I don't know how that will come across to the recipient once it's translated into another language.

Title: Re: Arduinos and Windows COM ports
Post by: Louis Davis on Feb 11, 2012, 07:28 pm
Here is a little background on how Windows assigns COM port numbers:

The Arduino UNO has a unique serial number defined in it's USB descriptor. Windows uses the VID/PID and serial number to determine if it has already seen this device before. If it finds a match for this combination, then it will use the driver and settings it has already used for that device. If it does not find a match then it will create a new entry in the registry and assign a new COM port for that device.

Windows uses the following registry key to determine which COM ports have already been assigned and will assign the next available COM port number to each new device.

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/COM Name Arbiter

The data field COMDB contains a bit mask of the COM ports already assigned. For example, on a system that has only two COM ports assigned COM1 and COM2, the COMDB value will be 03 00 00 00 … The first two bits are set in the first byte and all the rest are not set.

You can edit this registry setting and set the value of COMDB to 0. After you reboot the system, Windows will automatically re-assign any built in COM ports; like COM1 and COM2 and then any new devices added will start at COM3 and increment from there.  Any devices that have already been assigned will still end up using the COM port that was assigned at the time it was added. The COM Name Arbiter key is only used to figure out what ports have already been assigned and what the next one should be.

If you want to remove entries of UNOs already added to the system, you will need to remove the  corresponding registry entries. All UNO devices will be under the following registry entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_2341&PID_0001

Under this key you will find entries for each unique serial number. You could remove any unwanted devices from the registry by deleting the keys you no longer want. If one of the removed devices was ever attached to the system again, you will need to go through the installation process again, as if it was the first time.

I am not sure any of this information will help you solve your problem, but hopefully it will help explain why Windows behaves the way it does when a new UNO is connected to the system.

Here are some links for further detail:
http://rtshiva.com/2009/05/19/usb-specification-and-windows-limitation-on-serial-numbers/ (http://rtshiva.com/2009/05/19/usb-specification-and-windows-limitation-on-serial-numbers/)
http://blogs.msdn.com/b/oldnewthing/archive/2004/11/10/255047.aspx (http://blogs.msdn.com/b/oldnewthing/archive/2004/11/10/255047.aspx)
Title: Re: Arduinos and Windows COM ports
Post by: Daanii on Feb 11, 2012, 09:06 pm


I am not sure any of this information will help you solve your problem, but hopefully it will help explain why Windows behaves the way it does when a new UNO is connected to the system.



I don't know if your post helped cappy2112, the original poster, but it did help me. Thanks for the information!