Intermittent USB comport freeze Arduino Mega 2560

Hi all,

I have a simpel program that measures pulses on different pins and returns the count in using Serial.Print so nothing fancy there. At the receiving end I have developed a C#.Net application. The project that has been running flawlessly for months at my desk. So therefor I was certain that it was stable enough to deploy to another location.

But after I have installed the Arduino in another location I now have intermittent comport freeze situations. So to find out if it was my program (Arduino or C#) that somehow misbehaved I modified the Ascii example to the following:

void setup() { 
 //Initialize serial and wait for port to open:
  Serial.begin(115200); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("ASCII Table ~ Character Map"); 
} 

int thisByte = 33; 
void loop() { 
  Serial.write(thisByte);    
  Serial.print(", dec: "); 
  Serial.print(thisByte);      
  Serial.print(", hex: "); 
  Serial.print(thisByte, HEX);     
  Serial.print(", oct: "); 
  Serial.print(thisByte, OCT);     
  Serial.print(", bin: "); 
  Serial.println(thisByte, BIN);   
  if(thisByte == 126)      
    thisByte = 33;
  thisByte++;  
}

And using the Serial Monitor from the Arduino IDE to completly filter out any wrong doings from my side.

Yet I still experiences intermittent freeze of the comport. The problem sometimes occurs almost instantly, othertimes it may show up after several minutes.

What I meen by comport freeze is that the reception of caracters suddenly stops. But as far as Windows/Arduino IDE nothing is wrong with the comport. I can open and close the comport. But nothing is received.

I have by trial and error found the following solutions to unfreeze the comport: 1. Close the Arduino IDE and disconnecting the Arduino Mega 2560. Reconnect the Arduino and restart the Arduino IDE. 2. Close the Arduino IDE and then deactivate the Arduino comport in Windows control panel/device manager. Activate the arduino again and restart the Ardino IDE.

I am currently realy desperate because I need to have it running by next monday. So I am thinking of having my C# application do solution 2 automatically. But that would be a very ugly fix.

My best guess is that it is a Windows driver problem when the Arduino is used in a electronical noisy environment. But how to fix that ?

Any suggestions on how to find the real cause and a sollution would be greatly appreciated.

MadsRavnJensen: Hi all,

I have a simpel program that measures pulses on different pins and returns the count in using Serial.Print so nothing fancy there. At the receiving end I have developed a C#.Net application. The project that has been running flawlessly for months at my desk. So therefor I was certain that it was stable enough to deploy to another location.

But after I have installed the Arduino in another location I now have intermittent comport freeze situations. So to find out if it was my program (Arduino or C#) that somehow misbehaved I modified the Ascii example to the following:

void setup() { 
 //Initialize serial and wait for port to open:
  Serial.begin(115200); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("ASCII Table ~ Character Map"); 
} 

int thisByte = 33; void loop() {   Serial.write(thisByte);      Serial.print(", dec: ");   Serial.print(thisByte);        Serial.print(", hex: ");   Serial.print(thisByte, HEX);        Serial.print(", oct: ");   Serial.print(thisByte, OCT);        Serial.print(", bin: ");   Serial.println(thisByte, BIN);      if(thisByte == 126)          thisByte = 33;   thisByte++;  }




And using the Serial Monitor from the Arduino IDE to completly filter out any wrong doings from my side.

Yet I still experiences intermittent freeze of the comport. The problem sometimes occurs almost instantly, othertimes it may show up after several minutes.

What I meen by comport freeze is that the reception of caracters suddenly stops. But as far as Windows/Arduino IDE nothing is wrong with the comport. I can open and close the comport. But nothing is received.

I have by trial and error found the following solutions to unfreeze the comport:
1. Close the Arduino IDE and disconnecting the Arduino Mega 2560. Reconnect the Arduino and restart the Arduino IDE.
2. Close the Arduino IDE and then deactivate the Arduino comport in Windows control panel/device manager. Activate the arduino again and restart the Ardino IDE.

I am currently realy desperate because I need to have it running by next monday. So I am thinking of having my C# application do solution 2 automatically. But that would be a very ugly fix.

My best guess is that it is a Windows driver problem when the Arduino is used in a electronical noisy environment. But how to fix that ?

Any suggestions on how to find the real cause and a sollution would be greatly appreciated.

Update: I have just tested with a LCD shield that the Arduino continues running uninterupted when deactivating/activating the Arduino in device manager.