Pages: [1] 2   Go Down
Author Topic: Reset the board automatically  (Read 1830 times)
0 Members and 1 Guest are viewing this topic.
berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
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:
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
« Last Edit: May 14, 2009, 05:36:43 pm by fubbi » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6632
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

• 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!

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6632
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 197
Posts: 12736
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

U of A, Tucson, AZ
Offline Offline
Full Member
***
Karma: 0
Posts: 164
Hello World
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Boston, MA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1024
wiblocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 *)
Logged


berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Boston, MA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1024
wiblocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You should only set the pin low and then do a
Code:
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 *)
Logged


berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Boston, MA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1024
wiblocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 *)
Logged


Pages: [1] 2   Go Up
Jump to: