Go Down

Topic: SOftware RESET for arduino Demilanove (Read 1 time) previous topic - next topic

AMPS-N

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

AMPS

AWOL

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.
"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.

PaulS

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

AMPS-N

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
AMPS

PaulS

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

They who? International House Of Pancakes?

AMPS-N

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
AMPS

AWOL

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?
"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.

AMPS-N

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
AMPS

AWOL

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.
"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.

AMPS-N

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

AMPS

mrjonny2

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

retrolefty

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

Tom Carpenter

Simplest way to do it:
Code: [Select]
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: [Select]
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.
~Tom~

retrolefty


Simplest way to do it:
Code: [Select]
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: [Select]
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

Tom Carpenter

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

Try this out:
Code: [Select]
#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).
~Tom~

Go Up