Go Down

Topic: Reset the board automatically (Read 2590 times) previous topic - next topic

fubbi

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

Coding Badly

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

fubbi

#2
May 15, 2009, 12:33 am Last Edit: May 15, 2009, 12:36 am by fubbi Reason: 1
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:

Code: [Select]
/*
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

Code: [Select]
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

westfw

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

Coding Badly

Quote
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

Coding Badly

Quote
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

madworm

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

       5V
        |
        |
        |
      |   |
      |   |  10k
      |   |
      |   |
        |
        |
        +---------- reset pin
        |
        |
      -----  47µF
      -----
        |
        |
        |
      GND
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

westfw

Quote
Quote
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

Coding Badly

Quote
DON'T do this one.  Neither the reset nor the arduino bootloader does not reset the watchdog
Quote
That's a bit strong given the fact that it's fairly easy to shut off the watchdog at the top of setup.
Quote
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

estranged

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) ?

jluciani

Quote
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 *)
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks

fubbi

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

jluciani

You should only set the pin low and then do a
Code: [Select]
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 *)
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks

fubbi

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

jluciani

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 *)
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks

Go Up