Pages: [1]   Go Down
Author Topic: bootloader delay  (Read 591 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i need a sketch on my arduino uno to start exactly five seconds after i turn on the power.
is there a way to see how long the bootloader waits to see if a sketch will be uploaded before starting the currently loaded sketch?
my plan is to add a delay at the very end of void setup that way the sketch start time would be
(bootloader) plus (delay) = 5 second delay before void loop
this way if i know the bootloader delay i can then do the math for the added delay

Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the easiest way is going to be to put delay(5000) at the first line of setup. You can of course tweak it for the bootloader delay, I can't remember where I saw it, but I think it's documented on the Arduino reference somewhere.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i need a sketch on my arduino uno to start exactly five seconds after i turn on the power.

The approach seems reasonable - the bootloader delay will depend what bootloader you're using but should be fixed as long as you don't burn a new bootloader. How exactly do you need to get the delay? As a starting point you could just write a sketch that writes a character to the serial port and see how much delay there is between releasing the reset button and that output appearing.

Alternatively try to track down which bootloader you are using (it should be possible to work it out), or simply get rid of the bootloader altogether - you'd need to upload using ICSP subsequently.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the easiest way is going to be to put delay(5000) at the first line of setup. You can of course tweak it for the bootloader delay, I can't remember where I saw it, but I think it's documented on the Arduino reference somewhere.

And this of course is the best method. Keep the 'customization' delay in the specific sketch that requires it rather then a custom bootloader that will effect every sketch ever run with it.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how can i find out what bootloader i am using and where do i find the delay for that boot loader.

i'm using an arduino uno rev3 with ATmega328
the boot loader was installed by arduino software version 1.0.4

(i have a programmer and i have removed and replaced the bootloader many times. but in my current project the arduino board is buried beneath a shield so i can't access the programming connector without major disassembly. i do have easy access to the regular usb port and that is the way i would like to program it in this case.)
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 116
Posts: 4317
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wouldn't bother messing with the bootloader.  As has been suggested, start with delay(5000) at the end of setup(), turn on an LED at the end of the delay() and tweak the value to make the total startup delay exactly what you want.  How accurate does the 5 second delay have to be ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 1
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

as accurate as possible.
i'm competing in a sumo bot competition and there is a five second delay before starting.
if i start too early i'm disqualified.
if i start a second late the other bot has a jump on me.
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To find the delay accurately, get a second Arduino, make a sketch on the one you want to measure the delay for to set a pin high in the first line of setup, then on the other Arduino make a sketch that will reset the first one, pull the rst pin low, and have it measure the time until it pin goes high. If you do it this way you could probably get the boot time accurate to micro seconds
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 116
Posts: 4317
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

as accurate as possible.
i'm competing in a sumo bot competition and there is a five second delay before starting.
if i start too early i'm disqualified.
if i start a second late the other bot has a jump on me.
How accurately, and by what method, is the delay being measured in the competition ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6782
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The bootloader delay is about 1.6 seconds, from a RESET.  It might or might not be different from a powerup (it's supposed to be zero, from powerup, but that doesn't seem to always work.)
The 1.6s is approximately 0.6 seconds of making the LED flash, and 1s of timeout waiting for upload-like serial activity.
Logged

Pages: [1]   Go Up
Jump to: