Reset the board automatically

Is there a way to call a reset that does what manually pressing the reset button does?

I need to reset the board every time it starts up, cutting power wont work, my script demands pressing the reset button to work.

Thank you

fubbi

One of these may help...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222941939/all
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235780325/all

http://www.google.com/search?q=reset+watchdog+site%3Aarduino.cc
http://www.google.com/search?q=reset+site:arduino.cc

Good luck,
Brian

Thank you, will try that

any thoughts on why this is necessary. The arduino script is very simple and I dont understand why it requires the reset to work

the script:

/*
isadora triggering arduino
 in isadora the key watches will sent 1-4 to the arduino, and the arduino will blink accordingly
 
 
 created by r. holsopple
 http://31down.org
 2009
 */


int ledPin = 12; //the LED on the arduino board
byte incoming_byte;  // raw user input  


void setup()
{
  pinMode(ledPin, OUTPUT);

  Serial.begin(9600);  //set isadora serial out to this speed under communications, make sure serial port is enabled
  Serial.println("isadora control of arduino"); 
  Serial.println(" do it manually with the keyboard");   
  
  // blink twice on startup
   digitalWrite(ledPin, HIGH); // blink twice
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); 
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);


}

void loop()
{ 
  if (Serial.available() > 0) {  
    // read the incoming byte:  
    incoming_byte = Serial.read();  
    Serial.println(incoming_byte);

    switch (incoming_byte) {
    case 49://ascii 49 is the '1' key on the keyboard
      Serial.println(" received a '1'");   
      digitalWrite(ledPin, HIGH); // blink once
      delay(500); //pause for 100 milliseconds
      digitalWrite(ledPin, LOW);

      break;
      // break is optional
    case 50://ascii 50 is the '2' key on the keyboard 
      Serial.println(" received a '2'");   
      digitalWrite(ledPin, HIGH); // blink twice
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); 
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);


      break;
      //********for all dousers      
    case 51://ascii 51 is the '3' key on the keyboard
      Serial.println(" received a '3'");   
      digitalWrite(ledPin, HIGH); // blink three times
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); 
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); 
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);

      break;
      // break is optional
    case 52://ascii 52 is the '4' key on the keyboard
      Serial.println(" received a '4'");   
      digitalWrite(ledPin, HIGH); // blink four times
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); 
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); 
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, HIGH); \
       delay(500); //pause for 500 milliseconds
      digitalWrite(ledPin, LOW);
      break;





    default: 
      // if nothing else matches, do the default
      // default is optional
      Serial.println("not for arduino");



    }
  }


}

this seems to be what I am looking for

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

how would I implement that in the above code?

alternatively the manufacturer recommends this:
http://support.atmel.no/bin/customer?=&action=viewKbEntry&id=21

both solutions are a bit above my head...

thank you

alternatively the manufacturer recommends this:
http://support.atmel.no/bin/customer?=&action=viewKbEntry&id=21

DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog, and this leads to a loop where the arduino resets, starts the bootloader, and resets again before a sketch can be downloaded. Sometimes you can break the loop using power-on instead of reset to load a new sketch, but it isn't ... pleasant.

(I should say: "many versions of the arduino bootloader do not reset the watchdog." There are a couple that DO.)

The arduino script is very simple and I dont understand why it requires the reset to work

I agree. Please describe what you expect to happen and what does happen.

  • Brian

DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog

That's a bit strong given the fact that it's fairly easy to shut off the watchdog at the top of setup.

  • Brian

How about using a big cap + resistor on the reset line ?

5V
|
|
|
| |
| | 10k
| |
| |
|
|
+---------- reset pin
|
|
----- 47µF

|
|
|
GND

DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog

That's a bit strong given the fact that it's fairly easy to shut off the watchdog at the top of setup.

But it's not. Depending on the bootload, the arduino spends several seconds flashing the leds in a "healthy" sequence and/or checking for serial traffic to see whether it should upload a new sketch or start the existing one. If you've gotten it to reset by setting a short watchdog timeout and going into a loop, you might never get to the setup in your sketch before the next watchdog reset happens.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234876699
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234338562

DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog

That's a bit strong given the fact that it's fairly easy to shut off the watchdog at the top of setup.

But it's not.

Ah. Got it. I'm using an Arduino compatible board that doesn't have this problem. I assumed all boards behaved like mine.

It may be possible to avoid this problem by using the "Interrupt and System Reset Mode". It all depends on how the processor behaves if the watchdog is turned off in the ISR.

  • Brian

If I understand the reset correctly, the physical button resets it by bringing the RESET pin LOW. Is it possible to connect the reset pin to one of the digital IO pins and use a digitalWrite(connect_to_reset_pin, LOW) ?

If I understand the reset correctly, the physical button resets it by bringing the RESET pin LOW. Is it possible to connect the reset pin to one of the digital IO pins and use a digitalWrite(connect_to_reset_pin, LOW) ?

This will work but I would diode-or the output. I would configure the pin
as an output right before the digitalWrite command rather than in the setup
although it should not matter with the diode.

(* jcl *)

This sounds like a good solution.

Can you please explain in laymans terms?

Do I just hook up the reset pin to a digital pin and send it a low and then a high?

And I have diodes, what direction should they go?

thank you very much

fubbi

You should only set the pin low and then do a while(1) {};

Once you set the pin low the ATmega will reset and the default state of the pin will be an input (open circuit). If you set the pin low then high there is a chance that the reset pin will not be low long enough to reset the ATmega.

Connect the anode to the reset line and the cathode to the ATmega pin.

(* jcl *)

So I keep it HIGH (through the diode), and LOW it to reset?

Should I do that in the setup? or in the loop?

thank you

fubbi

When you want to reset the ATmega -- change the pin to an output and
then set the pin low.

Do you really want to reset the ATmega in the setup? It seems like you
would want to reset it somewhere in the loop after a specific condition
is met.

(* jcl *)

I'm not sure

the script listens to serial input from isadora and is basically a midi to light switch. It wont work unless I reset (press the little button).

I only need to do it once, is it ok to do it at the end of every loop?

does this apply?
http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

The trick will be figuring out how to only do the reset 'once per power cycle'. So the 'first' time the sketch runs, it sets some flag, then resets itself. The 'second' time it checks the flag state, and doesn't reset. Tricky.

Also you don't hold the pin HIGH using the diode, that is done with a pull-up resistor that is probably already on the board. What board are you using?

I am using a duemilanove, but I have a mega with me as well

Both of those have pull-up resistors for the RESET pin on the board then.

what does that mean, thats a good thing right?