universe
Offline
Sr. Member
Karma: 0
Posts: 258
I'm enjoying my Life
|
 |
« on: January 28, 2013, 08:34:53 pm » |
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
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #1 on: January 28, 2013, 08:43:50 pm » |
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
Faraday Member
Karma: 47
Posts: 2575
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #2 on: January 28, 2013, 08:45:09 pm » |
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
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #3 on: January 28, 2013, 08:51:04 pm » |
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
Tesla Member
Karma: 100
Posts: 6787
-
|
 |
« Reply #4 on: January 28, 2013, 11:00:55 pm » |
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
|
|
|
|
|
universe
Offline
Sr. Member
Karma: 0
Posts: 258
I'm enjoying my Life
|
 |
« Reply #5 on: January 28, 2013, 11:02:39 pm » |
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
Online
Brattain Member
Karma: 336
Posts: 36478
Seattle, WA USA
|
 |
« Reply #6 on: January 29, 2013, 07:22:38 am » |
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
Tesla Member
Karma: 100
Posts: 6787
-
|
 |
« Reply #7 on: January 29, 2013, 08:18:32 am » |
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
|
|
|
|
|
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)
|
 |
« Reply #8 on: January 29, 2013, 08:29:49 am » |
Maybe he's writing a reboot-count sketch ? 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #9 on: January 29, 2013, 08:33:38 am » |
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
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #10 on: January 29, 2013, 09:06:57 am » |
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
God Member
Karma: 15
Posts: 876
Arduino rocks
|
 |
« Reply #11 on: January 29, 2013, 10:16:04 am » |
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
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #12 on: January 29, 2013, 11:03:28 am » |
Lefty,
By upgraded bootloader are you referring to optiboot developed by westfw?
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #13 on: January 29, 2013, 11:09:22 am » |
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.htmlThanks. 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
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #14 on: January 29, 2013, 11:40:11 am » |
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
|
|
|
|
|
|