Pages: [1]   Go Down
Author Topic: Arduino Mega USB stopped working... all of a sudden  (Read 1053 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
I have been running an Arduino Mega in a particular project for about 2 months with no problem whatsoever.  Recently, I added an additional function to the my program, whereby there is now a computer connected to the Arduino's USB port.  That computer is connected to a bar code scanner, and when a scan is received, it passes some info to the Arduino via USB.  So the Arduino is now checking the USB connection for data all the time.

After running the system, for 1 week non-stop, at about day 6, the Arduino USB/serial just flat out stopped working altogether. The Arduino could not be seen by the Arduino IDE, Device Manager, Hyperterminal, nothing.  The rest of the Arduino functions like analog and digital IO are still working fine.  I swapped in another Arduino Mega, and voila it can be seen by the computer again.  Swapping in the old Arduino again, and it is invisible to any computer... and I tried a few computers.

This happened quite suddenly. What could have caused such a problem?  I do not believe it could be code related, but attached are a few snippets of code.
Code:

void setup()
{
  Serial.begin(115200);           //  debug and computer usb is on Serial0
  Serial3.begin(9600);          //  controls serial stepper motor drive

.... a bunch of other stuff
}

void loop()
{

  catchTechTag();

... a bunch of other stuff

}

void catchTechTag()
{

  if( Serial.available())
  {
    char ch = Serial.read();
    if( ch == '!')  // is this the terminating carriage return
    {
      buffer[ bufferIndex ] = 0; // terminate the string with a 0     
      bufferIndex = 0;  // reset the index ready for another string
      // do something with the string
      number = atoi(buffer);

      if (number == 99)
      { 

        if(lockoutTimer.isRunning())
        {
          lockoutTimer.stop();
          activityTimer.stop();
          Serial.print("N");
          Serial.print(activityTimer.elapsed()/1000);
          Serial.println("!");
          lockoutTimer.reset();
          lockoutTimer.start();
          activityTimer.reset();
          activityTimer.start();
          Serial3.print("AC25\r");      //  Set acceleration rate
          delay(10);
          Serial3.print("DE0\r");      //  Set deceleration speed
          delay(10);
          Serial3.print("VE10\r");      //  Set velocity
          delay(10);
          Serial3.print("FL200000\r");      //  commence jog
          digitalWrite(outs[4], HIGH);  // blink for visual feedback
          delay(300);
          digitalWrite(outs[4], LOW);
          delay(300);
        }

        if(!lockoutTimer.isRunning())
        {
          Serial3.print("AC25\r");      //  Set acceleration rate
          delay(10);
          Serial3.print("DE0\r");      //  Set deceleration speed
          delay(10);
          Serial3.print("VE10\r");      //  Set velocity
          delay(10);
          Serial3.print("FL200000\r");      //  commence jog
          digitalWrite(outs[4], HIGH);  // blink for visual feedback
          delay(300);
          digitalWrite(outs[4], LOW);
          delay(300);
 
          lockoutTimer.reset();
          lockoutTimer.start();
          activityTimer.reset();
          activityTimer.start();
        } 
       

      }// end of if (number ==99)


    }// end of if( ch == '!')
   
    else
      buffer[ bufferIndex++ ] = ch; // add the character into the buffer
 
} // end of if Serial.Available()

  // stop and reset timer here when TIMEOUT_MAX is exceeded
  if (lockoutTimer.elapsed() > TIMEOUT_MAX)
  {
    lockoutTimer.reset();
    lockoutTimer.stop();
    Serial.print("T");
    Serial.print(activityTimer.elapsed()/1000);
    Serial.println("!");
    digitalWrite(outs[4], HIGH);  // blink for visual feedback
    delay(300);
    digitalWrite(outs[4], LOW);
    delay(300);
    digitalWrite(outs[4], HIGH);
    delay(300);
    digitalWrite(outs[4], LOW);
    activityTimer.reset();
    activityTimer.stop();
   
  } 

} //end of void catchTechTag()

Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Have you tried a different USB cable?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Have you tried a different USB cable?


Yup, definitely tried that for sure.
Also, the second Arduino that I tested with, works with either of the two cables I tried.  Definitely not the cable.

Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5833
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How were you powering the Mega before you connected the usb cable?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How were you powering the Mega before you connected the usb cable?


I am powering it via the Vin with an industrial 12V trimmed down to 10.5V. (trimmer pot built into psu itself, nothing weird)
http://www.automationdirect.com/adc/Shopping/Catalog/Power_Products_(Electrical)/DC_Power_Supplies/5VDC,_12VDC_DIN_Rail_Mount_(RHINO_PS,_PSB,_PSC,_PSM,_PSP_Series)/PSC-12-030

From what I've read on several different threads here, if Vin is connected, and also USB is plugged in, the Mega will choose Vin.

I am careful not to overload the board's 5V regulator.  Only (4) 100k pots connected to Analog Ins are powered off the Mega's 5V.  I am powering other devices, but only with external power.
« Last Edit: July 10, 2013, 08:39:30 am by anchan » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Have you tested the board with just a USB cable connected?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Have you tested the board with just a USB cable connected?


Yeah, actually when I figured out that it was the Arduino, I pulled it out of my circuit, and replaced with a new one.
Now, bad one removed and my in hand, I went around to a few different computers, and tried it out.  No computers could see it.  This was with a new USB cable as well.

Also, just to reiterate, that bad Arduino still works and performs its functions, except for the USB/Serial0.  I am using Serial1, Serial2, and Serial3 for other things, and that part still works fine.

BTW, the new Arduino that I replaced into my circuit, has been running continuously for a few days.  I'll keep you posted as to the status of that second Mega.

I guess still a mystery at this point.... keep the questions coming if you have them....
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


The next step is to try reprogramming the ATmega16U2 (the processor that interfaces with the computer and does USB-to-serial conversion).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The next step is to try reprogramming the ATmega16U2 (the processor that interfaces with the computer and does USB-to-serial conversion).


I have seen a few sites which explain how to do this.  However, I am not really interested in spending time salvaging this Arduino.  I've already plugged in a new one to replace it, and it seems to be doing fine (so far).

What I am most interested in is discovering if this was a one time fluke, if I did something wrong, or really what is the cause and likelihood of reoccurrence. I am wondering if perhaps the computer itself could have made the Arduino USB fail?  Or could the code be the culprit?  Right now, i am just polling the port non-stop, keeping on the lookout for new serial.  Anything wrong with that?  Is there any other hardware related, or wiring issue that could have caused the failure?  Maybe the USB/Serial chip on the Arduino is not cut out for 365/24/7 operation? 
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What I am most interested in is discovering if this was a one time fluke, if I did something wrong, or really what is the cause and likelihood of reoccurrence.

My suspicion is a minor bug in the ATmega16U2 bootloader / FLIP.  Reprogramming it would add a bit of anecdotal evidence to bolster my suspicion.

Quote
I am wondering if perhaps the computer itself could have made the Arduino USB fail?  Or could the code be the culprit?

That seems highly unlikely.

Quote
Right now, i am just polling the port non-stop, keeping on the lookout for new serial.  Anything wrong with that?

Not in my annoyingly vast experience dealing with serial ports.  (It is a waste of CPU time.)

Quote
Is there any other hardware related, or wiring issue that could have caused the failure?

Well, 12V applied directly to the ATmega16U2 would certainly cause it some distress.

Quote
Maybe the USB/Serial chip on the Arduino is not cut out for 365/24/7 operation?

If that were the case, Atmel would have long ago been out of business.  They guarantee that each processor will perform within specifications for 20 years (or more).

On a more local level, the forum would be flooded with unhappy customers.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My suspicion is a minor bug in the ATmega16U2 bootloader / FLIP.  Reprogramming it would add a bit of anecdotal evidence to bolster my suspicion.

Interesting.  I do not have the time to do this reprogramming at the moment, but I may look into this.  I'm going to continue testing on the replacement Arduino I swapped in.  So far, its been 7 days, operating 24hours, and no problems to report.

Quote
Is there any other hardware related, or wiring issue that could have caused the failure?.......

"Well, 12V applied directly to the ATmega16U2 would certainly cause it some distress."
I do not see how 12V could be applied to the 16U2.  I am supplying 12V (actually 10.5V) to Vin.  Are you suggesting that there may be a way that Vin could make its way to this chip?

Quote
Maybe the USB/Serial chip on the Arduino is not cut out for 365/24/7 operation?...............

"If that were the case, Atmel would have long ago been out of business.  They guarantee that each processor will perform within specifications for 20 years (or more).

On a more local level, the forum would be flooded with unhappy customers."

I'm not suggesting that the processor itself is at fault.  Rather, how the USB chip was integrated, or perhaps some low level code has a bug in it, as you mentioned.  For all intents and purposes, that might make someone pause before using them in a situation where they must run 365/24/7.  There are a few other threads reporting USB failure, all without definitive resolution.  Analog and digital IO, on the other hand, all seem to be pretty bulletproof.
« Last Edit: July 15, 2013, 10:43:25 am by anchan » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you suggesting that there may be a way that Vin could make its way to this chip?

Nope.

You wanted to know "[are] there any other hardware related, or wiring issue that could have caused the failure?"  A few folks have killed a processor by accidentally dropping a "high" voltage (typically 12V DC) live wire onto the board.  

Quote
For all intents and purposes, that might make someone pause before using them in a situation where they must run 365/24/7.  There are a few other threads reporting USB failure, all without definitive resolution.

There are at least as many cases of folks who have used various Arduino boards nonstop for years.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Codingbadly- thanks for your input. I'll keep this 2nd board running and see what happens. If it fails, I might try reprogramming the bootloader, but maybe it was just a fluke.... Hopefully, she'll keep going........
Logged

Pages: [1]   Go Up
Jump to: