What Causes "Serial port 'COM#" already in use"

Hello,

I have been building line following bots with my engineering 9-12 class for a few years. We are using a motor shield I developed. Previously 1 in 10 of the student made boards would have the "Serial port COM# already in use" issue and I put it off as student error. The current semester class is having the "Serial port COM# already in use" with almost every board and for the life of me I cannot figure it out.

The issue is as soon as you plug in the board to the uno the error comes up when you try to upload a new sketch. The uno will run the any previous sketches uploaded to it but it will not allow a new sketch to be uploaded. I know I can get around this by unplugging the boards uploading the sketch and putting them back together but that makes trouble shooting 30 student projects very time consuming.

My question is what could be feeding back to the arduino to cause the "Serial port COM# already in use" problem? And what could I do to stop it from happening?

Thank you,

Are the computers shut down between sessions? I find this happens when I shut down one Arduino Window when the Serial Monitor is open. Also sometimes turns up when I have reconnected the Arduino several times in close succession. I think the problem is in the Java side of things, that some internal variable gets stuck.

The problem occurs only with the motor shield on. when it is off and the Arduino is unpluged and pluged back in every thing is back to normal, untill the motor shield goes back on. I think it has to be some sort of feed back issue.

Operating system?

we are using windows xp

At a guess the motor shield is probably introducing electrical noise into the power system (very common) which is causing unexpected behavior...maybe causing the arduino to change one of the status pins...

What model Arduino and motor shield are you using? Is it being powered from the USB or from an external power supply?

@nobikes: You left out an important detail. The student attempts an upload, gets impatient because nothing happens, and then tries again. The error is because the first instance of avrdude is still trying to communicate with the board.

In other words, both @kf2qd and @wanderson are essentially correct. The problem is a combination of: motor shield with a serious problem (hardware), impatient students (user), bug in the IDE that allows a new upload to start before a pending one completes (software).

The issue is defiantly not impatient students, i try to do it with their boards and i get the same error. My money is on Wandersons conclusion of electrical noise. The question is what can be done to stop the electrical noise? and what pins would most likely cause the com port in use problem if they were exposed to the electrical noise?

Motor shield files

https://sites.google.com/a/theprojectinventory.com/envertech/enver-creek-engineering/scamatics/motorshieldarduino2.sch?attredirects=0&d=1

https://sites.google.com/a/theprojectinventory.com/envertech/enver-creek-engineering/scamatics/motorshieldarduino2.brd?attredirects=0&d=1

Ive had the same problem using a ping and sabertooth motorcontroller most of the time if you unplug, hold reset, plug back in, and let go of reset it uploads after that.

nobikes:
The issue is defiantly not impatient students, i try to do it with their boards and i get the same error. My money is on Wandersons conclusion of electrical noise. The question is what can be done to stop the electrical noise? and what pins would most likely cause the com port in use problem if they were exposed to the electrical noise?

Motor shield files

Server error

Server error

If your using a usb connection there are only four pins (2 data and power). The electrical noise generated by motors affects everything in the circuit.... The best solution is to isolate the motor shield in particular isolate the motors power supply. A separate regularltor works best but lc filters can help as well.

I have had this error frequently

It happens when you have several megas or unos with different com port designations

Usually you have to close the arduino window and restart the program -- it doesn't matter what is hooked to the arduino -- I get it with no shields hooked up -- just doing the blink program for example

Sometimes going into the tools/serial port and selecting the correct com will work

If the problem goes away when you remove the shield, that does point to it being an Arduino electrical problem rather than an IDE/USB configuration issue on the PC side. Does the shield do anything when the reset line is pulled down at the start of uploading? Does it do anything to the serial send/receive pins? If it has a separate power supply and/or external electrical connections to motors etc, does it make any difference if you disconnect all that and just leave the shield itself connected?

the shield is not using the serial pins. It plugs into 5 volts (l293d only), ground, and pins 6,9,10,11. On the shields with the error problem the error occurs when the shield is plugged in to the arduino and without the secondary power hooked up. Holding down reset at the start of the upload does not seem to do anything, but i will test that on some of the other boards during the class today.

I didn't really mean to suggest that you held the reset button down.

I was thinking more along the lines of the shield doing something when the PC triggers the reset at the start of uploading. Either by being connected to the reset line and affecting the timing of the reset somehow, or doing something internally because of the reset that might affect the Arduino. (I'm thinking of hardware initialisation leaving the inputs/outputs in an undefined state that causes a transient brown-out on the supply, something like that.)

I have been testing this shield with the Leonardo for a month now. i have never lost the COM port while using it. The UNO still has the problem and it boggles my mind, but with the Leonardo working i have a solution.