SOftware RESET for arduino Demilanove

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

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.

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

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

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

They who? International House Of Pancakes?

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

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?

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

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.

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

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

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

Simplest way to do it:

void systemReset(void){
  WDTCR = _BV(WDCE) | _BV(WDE);
  
  WDTCR = _BV(WDE);
  while(1); //will reset in 16ms
}

More complex way (requires I/O pin):

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

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

Try this out:

#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).

I am just summarizing what Atmel explicitly stated, that there is a minimum length reset pulse required to guarantee a proper hardware reset process, and that can't be met by wiring an output pin to the reset pin. That fact that it may appear to (or indeed) work, is no guarantee that it will always work with all AVR chips in all environments in all possible clock speeds. As they have published such a restriction it would seem to me to not be a method to hang one's hat on. You can find the minimum reset pulse length spec in any AVR datasheet. But of course it's just a hobby and it won't create a black hole and suck us all in, so go for it at your own risk. :smiley:

Lefty

It works because there is more in the circuit that just an I/O pin connected from an output to the reset pin.

Consider that there is also the "Auto-Reset" 100nF capacitor connected between the pin and GND (or +5v depending on how the DTR pin of the USB-Serial chip is set).

When the I/O pin goes low, it discharges (or charges if DTR=5v) that capcitor rapidly down to around 0v with respect to the GND at the reset pin end. When the chip then puts the I/O pins into a High-Z state, the 10k pullup has to charge (or discharge) that capacitor back up to +5v at the reset pin end which takes some time - sufficient time to reset the chip. If it wasn't sufficient time, the autoreset function itself wouldn't work.

Well then just measure the resulting reset pulse (low) duration with a scope and then compare that to the minimum reset pulse (low) width duration specified in the datasheet. If >= then you are gold, if not watch out for black holes. :wink:

Lefty

Hmm, its roughly half of the MAX reset period (1us). If you use a diode rather than a wire then the delay becomes 300x the reset period required (800us) - Cathode to digital pin, Anode to reset pin.

Cool, a diode is simpler then an external 555 one-shot pulse generator.

Lefty