I noticed some delay in serial monitor.
Running a simple code like this , first message "Hello world"
appears after 10 secs (i think was much faster before) .
Is this normal?
H/w :Mega 2560, Serial port at 9600, PC runing Windows 7
Running a simple code like this , first message "Hello world"
appears after 10 secs
Describe what you mean by "running"
running=executing
When upload is done, i press serial monitor and message "Hello world" appears after 10 secs.
After reset , appears immediately, without delay !
If you "run" from the arduino IDE, it compiles and re-uploads every time, which does take several seconds. Then the program starts.
If pressing reset gives an immediate response, then it's working as it should.
Yes, serial monitor window appears immediately, but message appears after 10 sec.
After code upload , Led starts blinking (immediately after upload finish message), but if i press
Serial Monitor, Led Turns OFF for 10 sec, and Monitor doesn't show any message.
After 10 sec, everything is OK..
Serial.begin(9600) needs 10 sec to initialize port !!
My question is: Is this 'dead' time normal or too much ?
Try this code
void setup(){
Serial.begin(9600);
pinMode(8, OUTPUT); // Connect an Led at Dig Pin 8
}
void loop(){
digitalWrite(8, HIGH); // Turn ON Led for 0.5 sec
Serial.println("LED is ON"); //Serial Monitor: Led is ON
delay(500); // Keep it ON for 0.5 sec
digitalWrite(8, LOW); // Turn OFF Led
Serial.println("LED is OFF"); //Serial Monitor: Led is OFF
delay(500); // Keep it OFF for 0.5 sec
}
My question is: Is this 'dead' time normal or too much ?
No this is too much. However it sounds to me like a PC problem rather that an arduino problem.
When a port opens the arduino is reset, this triggers the boot loader to look to see if a program is being up loaded. It looks like your PC is doing something to to make the boot loader think something is being downloaded but when more fails to arrive it goes on and runs your sketch.
Nick, Mike and other friends , thank you for your quick response.
I already tryed with another Pc, but the problem is the same.
I noticed that, when i start serial monitor,board's yellow Led L (Dig pin 13) stays always on, and turns OFF only after reset.
Probably Something is wrong with DTR or Atmega 16U2.
I will try to see the waveforms with my oscilloscope.
Is it possible to burn the bootloader without any external hardware (using Usb-Serial port) ?
Sorry for all these questions but even i have more than 30 years of experience in electronics, i'm learning Arduino programming right now !!
Sometimes that LED stays on, I think that is an artifact of the bootloader.
You can't burn a new bootloader without some other hardware, for example an Arduino Uno. Or you can get a $10 ISP programmer from eBay or elsewhere.
It isn't necessarily the bootloader, it just sounds strange the way you describe it.
You have 9600 baud selected in the serial monitor, I take it? The only delay I can think of, though, is the bootloader is indeed holding up handing control over to the main sketch. Your scope might help. A logic analyzer might be better. One way or the other you should be able to see if the board is trying to communicate after the reset caused by the monitor being started up (or indeed if that even happens). Try monitoring the reset pin with your scope.
It's getting more and more mysterious!
Trying Serial.begin rates from 9600 to 115200, only at 57600 is Ok.
Yellow (L) Led blinks twice and messages appear immediately !
All other rates do what i described above!
So, the problem might be the timing during software reset.
Zeus:
It's getting more and more mysterious!
Trying Serial.begin rates from 9600 to 115200, only at 57600 is Ok.
Yellow (L) Led blinks twice and messages appear immediately !
All other rates do what i described above!
So, the problem might be the timing during software reset.
This has had me scratching my head for a while. It does seem to be a problem specific to the latest bootloader on the mega2560, and the way it interacts with the IDE (1.0.2 at least - I haven't tested with other versions). I can confirm your observation that execution being passed to the main program is delayed several seconds (~5 or 6 seconds in my case) except when the baud rate of the Serial monitor in the IDE is set to 57200.
No delay problem on Mega1280, Uno, Leo etc.
Two other things:
If you open the Serial monitor on the IDE at 57600, even if the Serial.begin on the board is set to a different baud rate (e.g., 115200), you still don't get the delay. (You get gibberish on the screen, of course, but you can see the sketch starts to execute without the delay).
If you open a Serial monitor outside the IDE (e.g., using Putty), you don't get the delay, even if you open it at 115200. Works normally without a start-up delay for Putty at all baud rates I've tested.
So the problem seems to be an interaction specific to the IDE and the Mega2560 bootloader when the IDE opens a Serial monitor at any baud rate I've tested, except for 57600. Clearly nothing to do with USB hardware and bootloader interaction at all,
Which is good to know, because until I came across this thread I thought the new Mega2560 bootloader had a 5 second delay built-in on reset. Now that I know it is just an artifact of interacting with the IDE, it sounds like a much less serious problem.
Pico, you describe very detailed, what really happens to my Arduino.
At a moment i thought that i had some hardware fault, but finally i know that this isn't only my problem.
Right now its more clear that has to do with communication between IDE and Mega 2560 .