Hi there,
I couldn't find a topic similar to this in the forum. Well, I found one or two, but both old and unanswered.
My Arduinos, the Uno version and also my standalone assemblies, all seem to have this "issue". I can't tell about other versions, because I don't own any 
Here's the deal. When I plug/unplug external power or the USB port (always leaving one of them plugged in, to keep the device always on), the Arduino may freeze. And I say "may" because it's kind of random, I can't seem to reproduce this in a sistematic fashion.
Also, I would be okay with this if the internal watchdog would kick in, but it doesn't. The microcontroller seems to be stuck in some kind of void. To get around this I can press the reset button or open Serial Monitor which will trigger a reset. Physical presence in this case is quite the difficult task.
It just seems strange. Could it be that the RESET pull-up method is inadequate for this kind of handling?
Thanks in advance.
Regards,
footswitch
footswitch:
Physical presence in this case is quite the difficult task.
But you don't unplug it if you are not physically present, do you?
Nick.
LOL you sort of got me there.
I'm testing the implementation before actually implementing it, as you may understand.
I forgot to point this out: the circuit has a battery that "kicks in" if power is lost.
And this causes, at times, the same effect.
The battery "switchover" is seamless, from what I can measure. It's a 3V drop in a voltage regulator, but again from what I can tell, there's no significant voltage change after the regulator (I was able to measure a 0.01V change once).
In the case of the Uno, it is powered by this regulator into the DC barrel (9V).
In the case of a standalone assembly, the regulator powers the Arduino directly (5V).
I'm really clueless here, and was hoping somebody had come across this in the past, and actually found the culprit. Hoping it's not myself, though 
footswitch:
I forgot to point this out: the circuit has a battery that "kicks in" if power is lost.
And this causes, at times, the same effect.
Ah, more details. 
I would put a scope on the 5V line. It may well only drop slightly in the long run, but maybe it drops below 5V for a millisecond or something.
So, since this also happens without that additional circuitry, do you believe this is the case when "switching" between USB power and the DC barrel in the Arduino?
I don't have a scope
Do you think that measuring the 5V pin with another arduino's analog pin in a tight loop will be enough?
do you believe this is the case when "switching" between USB power and the DC barrel in the Arduino?
Not really, no. I was doing just that yesterday in this thread:
I had no problems plugging the power cable in and out. I didn't pull out the USB because that was where the debugging was being printed.
Do you think that measuring the 5V pin with another arduino's analog pin in a tight loop will be enough?
I doubt it. It takes 104 uS to do one analogRead. The pulse may be much shorter than that.
See if adding a fairly large capacitor between 5V and Gnd helps (eg. 100 uF as a guess).
I see...
You're right. The analog readings are annoyingly steady.
Yes I've tried a capacitor and the results are the same.
At first, I thought I was discovering different behaviors between the Uno R2 and R3, but after some switching back and forth, it's all the same.
I don't have the knowledge to support my theory, but it seems this is related to grounding, or lack thereof.
Before I connect an Arduino to the laptop (since it's a macbook pro, it's metal all over), it feels sort of "rugous" when gently touching it.
After I connect the arduino, the laptop becomes smooth to the touch.
Now this is me guessing, that the effect caused by this "transition" / "ground shift" is somehow "confusing" the circuit (lots of quotes).
Because if I have an Arduino connected to the computer and the grounds are linked between the two Arduinos, I can plug and unplug the USB on the other one any number of times; I can't reproduce the issue that way.
Now, how would that relate to the same behavior, but with the battery circuit? Beats me.
This is frustrating, I'm giving up. We'll see how it performs on the field.
Nonetheless, thanks for having dedicated some of your time to this.
footswitch:
This is frustrating, I'm giving up. We'll see how it performs on the field.
Your theory may well be right. You want to test in the field or in such a way that you don't change grounds (eg. put a switch in line with a battery).