Pages: [1] 2   Go Down
Author Topic: SOftware RESET for arduino Demilanove  (Read 929 times)
0 Members and 1 Guest are viewing this topic.
DELHI
Offline Offline
God Member
*****
Karma: 0
Posts: 602
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HI,

I wanna know how can enable Hardware reset though software.

The program intention to track the sun direction from morning to evening.We have predefined calculation measure angle based on NREL code.

I have  code running on the arduino Deumilanove board( i cant share the code) . I ran program  for 2 to 3 days . It worked fine but @ end of day it struck @ particular point. So  i pressed reset button and getting started work.

i have watch dog timer program inside to take care of hang issue.i tested individually  for watch dog code. So i wanna know whether it possible to reset hardware reset pin through software . if yes can u share me pseudo code or  arduino program to reset it

Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, there is no simple way.
But there are plenty of threads on the subject and how close you can get, if you want to search for them.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

It's far better to fix the bug in your code than to try to work around it by resetting the Arduino.
Logged

DELHI
Offline Offline
God Member
*****
Karma: 0
Posts: 602
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i tried to debug the program. It worked fined for few days , again same issue has been raised.

I  Need  example how they take care of hardware pins like Reset pin
Logged

AMPS

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

Quote
I  Need  example how they take care of hardware pins like Reset pin
They who? International House Of Pancakes?
Logged

DELHI
Offline Offline
God Member
*****
Karma: 0
Posts: 602
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

understand question first.

assume that there is manual override option on board like reset switch on arduino uno. If i wanna avoid  manual override option how can we do it through software?

Is it possible to achieve in uno. deumilanove boards?
if yes ,how can we do that?
if no, why can't we do it?

You should satisfy me with technical reasons


eg:
pseudocode:

if a>b
 enable manual  reset switch( where we are working on manual switch)
else
enable automatic switch
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sorry, I don't understand what a manual override is in this context.
An override is not necessarily a reset.

Do you want me to move this to the International/India section?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

DELHI
Offline Offline
God Member
*****
Karma: 0
Posts: 602
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i given example dude.

First let me know why we use RESET switch.
Reset button when pressed RESET the process, And start execute from starting. Here person need to press this switch in order to restart the process.So i called it as manual override switch.

My question is : Instead of pressing RESET switch manually.IS there any way through software i can handle switch.
If yes , how can i do it??
if no, Why cant i do that??

Give the appropriate  technical reason. I hope its clear the question
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This subject has been debated here time and time again.
I'm not going over it one more time.

Do some searches.

A manual override switch temporarily suspends machine control, but doesn't normally (in my experience) reset the processor.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

DELHI
Offline Offline
God Member
*****
Karma: 0
Posts: 602
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ya it true..

Manual override  switch means when you want operate the operation in manual mode from automatic operation.

but to understand to you i named it like that

Logged

AMPS

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 188
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The fuse settings on the chip may be wrong which means the device doesn't start up after a watchdog timer reset.  Check it with an AVR Programmer
Logged

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

Quote
My question is : Instead of pressing RESET switch manually.IS there any way through software i can handle switch.
If yes , how can i do it??

The only way to generate a true chip reset with sketch software is to enable the watch dog timer, let it time out, and it will generate a reset.

Lefty
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Simplest way to do it:
Code:
void systemReset(void){
  WDTCR = _BV(WDCE) | _BV(WDE);
 
  WDTCR = _BV(WDE);
  while(1); //will reset in 16ms
}

More complex way (requires I/O pin):

Code:
void setup(void){
  digitalWrite(someIO,HIGH); //enable pullup-resistor
  pinMode(someIO,OUTPUT); //THEN set to output, by doing so, pin is already high when switching to output meaning reset is not tripped.
}

void systemReset(void){
  digitalWrite(someIO,LOW);
  while(1);
}
Just connect one of the Arduino digital pins to the reset pin, and then replace 'someIO' with the number for the pin you chose.
Logged

~Tom~

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

Simplest way to do it:
Code:
void systemReset(void){
  WDTCR = _BV(WDCE) | _BV(WDE);
 
  WDTCR = _BV(WDE);
  while(1); //will reset in 16ms
}

More complex way (requires I/O pin):

Code:
void setup(void){
  digitalWrite(someIO,HIGH); //enable pullup-resistor
  pinMode(someIO,OUTPUT); //THEN set to output, by doing so, pin is already high when switching to output meaning reset is not tripped.
}

void systemReset(void){
  digitalWrite(someIO,LOW);
  while(1);
}
Just connect one of the Arduino digital pins to the reset pin, and then replace 'someIO' with the number for the pin you chose.

Two points:

1. Your first method will work fine for chips with bootloaders that can handle WDT resets correctly, but if you were to do it in say a mega board with that short timeout period you would lock up the board in a endless WDT reset/bootloader starts to run/WDT resets again/ lather, rinse, repeat. I've run that on my mega board and the results is a 16 millisec blinking of pin 13 led and you can't recover or upload a new sketch, the only way out is to reburn the bootloader via ICSP which erases the sketch.

2. Atmel expressively says you can't generate a proper length reset pulse via a digital output pin wired to the reset pin, as the first step in the reset process is to make all I/O pins input pins, thus the reset pulse won't meet the minimum width required for a full proper reset.

Lefty
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

regarding point (2). I have used this method in several projects and it works fine from what I have seen.

Try this out:
Code:
#define someIO 2
void setup()
{
  // This code will only run once, after each powerup or reset of board
  pinMode(10,OUTPUT);
  digitalWrite(10,LOW);
  digitalWrite(someIO,HIGH); //enable pullup-resistor
  pinMode(someIO,OUTPUT); //THEN set to output, by doing so, pin is already high when switching to output meaning reset is not tripped.
}

void systemReset(void){
  digitalWrite(someIO,LOW);
  while(1);
}

void loop()
{
  // This code loops consecutively
  delay(1000);
  digitalWrite(10,HIGH);
  delay(1000);
  systemReset();
}

you will see an LED connected to pin10 blink on for a second then go off for a second (and the bootloader LED flashes in between). (This assumes pin 2 is connected to the reset pin).
Logged

~Tom~

Pages: [1] 2   Go Up
Jump to: