Pages: [1] 2   Go Down
Author Topic: How to reset Arduino UNO without pushing reset button?  (Read 1692 times)
0 Members and 1 Guest are viewing this topic.
universe
Offline Offline
Sr. Member
****
Karma: 0
Posts: 258
I'm enjoying my Life
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Anybody, I would like to reset my Arduino UNO just via sending serial command, is it possible and safe for the chip?
Could it be done without pushing reset button?

Thank you ..
Logged

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

Anybody, I would like to reset my Arduino UNO just via sending serial command, is it possible and safe for the chip?
Could it be done without pushing reset button?

Thank you ..

Sure, just learn about using the watch dog timer (WDT), your sketch upon receiving the magic serial command could just activate the WDT which will cause a reset and start you sketch from it's start.

Lefty


Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes and yes. When the command is recognized from the serial interface, set the watchdog timer for a short interval (I think 16ms is the shortest), and enter a spin loop. Search the forum for specifics, this gets discussed with fair regularity.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

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

Just be sure your arduino board is one that has a WDT friendly bootloader such as the current UNO, as older and current mega boards for example will 'brick' with short WDT interrupts, requiring you to reburn the bootloader to recover.


Lefty
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12534
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to reset my Arduino UNO

In most cases you can do it just by closing and reopening the serial port. But why do you want to reset it?
Logged

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

universe
Offline Offline
Sr. Member
****
Karma: 0
Posts: 258
I'm enjoying my Life
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to reset my Arduino UNO

In most cases you can do it just by closing and reopening the serial port. But why do you want to reset it?
I just would like to take control my Arduino without touching it, it's cool if I can reset from distant afar.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just would like to take control my Arduino without touching it, it's cool if I can reset from distant afar.
The question is why? Opening and closing the serial port resets the Arduino, unless you've modified. That seems sufficient to me.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12534
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it's cool if I can reset from distant afar.

If being 'cool' is your only reason then I don't see any point. It's not as if you will get to see those LEDs flash briefly as it resets. And what other reason would you have for wanting to reset it?
Logged

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

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe he's writing a reboot-count sketch ?  smiley-razz
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just be sure your arduino board is one that has a WDT friendly bootloader such as the current UNO, as older and current mega boards for example will 'brick' with short WDT interrupts, requiring you to reburn the bootloader to recover.


Lefty

So how to software reboot MEGA then?
Logged


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

Just be sure your arduino board is one that has a WDT friendly bootloader such as the current UNO, as older and current mega boards for example will 'brick' with short WDT interrupts, requiring you to reburn the bootloader to recover.


Lefty

So how to software reboot MEGA then?

Use external hardware components (555 pulse generator for example) to generate a reset pulse wired to the avr reset pin.

Or find a upgraded bootloader hex file that does handle WDT correctly for the mega board and burn that into the chip before using the WDT generated reset method.

Lefty
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 928
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So how to software reboot MEGA then?

Depending on exactly what you want to do, use a call to location zero as in:

void(* resetFunc) (void) = 0; //declare reset function @ address 0

Or, if you want something more watchdog 'timerish', use the code I worked out to do this.  I wanted to simulate a watchdog and not use up any of the other timers.  It's at: http://www.desert-home.com/2011/10/2560-board-is-not-so-stupid-anymore.html
« Last Edit: January 29, 2013, 10:27:16 am by draythomp » Logged

Trying to keep my house under control http://www.desert-home.com/

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Lefty,

By upgraded bootloader are you referring to optiboot developed by westfw?
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So how to software reboot MEGA then?

Depending on exactly what you want to do, use a call to location zero as in:

void(* resetFunc) (void) = 0; //declare reset function @ address 0

Or, if you want something more watchdog 'timerish', use the code I worked out to do this.  I wanted to simulate a watchdog and not use up any of the other timers.  It's at: http://www.desert-home.com/2011/10/2560-board-is-not-so-stupid-anymore.html

Thanks. I know of the location zero but also vaguely remember people mentioning that just the execution is reset and other things aren't. Could you give me some hint on what does and doesn't reset by calling zero?

BTW, your home page temperature scale is in DegF, right? Does it every go near 150F as the max scale is set there? Horrible heat.
Logged


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

Lefty,

By upgraded bootloader are you referring to optiboot developed by westfw?

Depends on the type of mega board you are talking about. There is a optiboot avalible for the mega1280 board but westfw already stated the optiboot will never work with a mega2560 board. However there is a upgraded/fixed mega2560 bootloader avalible that works with the WDT correctly, but at the moment I can't steer you to it's location as I don't own a mega2560 board I never bothered to download a fixed bootloader for it.
If you do want or need a mega1280 optiboot.hex file I would be glad to post it here for you?

PS: A simple jump to 0 to restart a sketch doesn't place any of the AVR hardware registers to their true default reset condition, which may or may not to a big deal, so is rarely recommended as a reliable method to use.

Lefty
« Last Edit: January 29, 2013, 11:42:19 am by retrolefty » Logged

Pages: [1] 2   Go Up
Jump to: