Left Coast, CA (USA)
Offline
Brattain Member
Karma: 282
Posts: 15443
Measurement changes behavior
|
 |
« Reply #15 on: January 16, 2013, 11:18:18 am » |
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.  Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #16 on: January 16, 2013, 11:30:07 am » |
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.
|
|
|
|
« Last Edit: January 16, 2013, 11:33:54 am by Tom Carpenter »
|
Logged
|
~Tom~
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 282
Posts: 15443
Measurement changes behavior
|
 |
« Reply #17 on: January 16, 2013, 11:33:26 am » |
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, else the autoreset function 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.  Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #18 on: January 16, 2013, 11:49:23 am » |
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.
|
|
|
|
« Last Edit: January 16, 2013, 11:50:54 am by Tom Carpenter »
|
Logged
|
~Tom~
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 282
Posts: 15443
Measurement changes behavior
|
 |
« Reply #19 on: January 16, 2013, 11:53:09 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 77
|
 |
« Reply #20 on: January 16, 2013, 01:20:40 pm » |
correct me if i am wrong please
pressing the reset button resets the hardware as well as software a WDT reset only resets the software and therefor if you have other devices such as ethernet, LCD etc those will not reset
I personally use the watchdog reset method to reset for the following purposes, these are some ways you can do a software reset but you must write your application to handle it. 1. i have a configuration change to a device attached to the UNO ie... a user had to change the card reader and the new reader reads track 2 instead of track 1. I send a command to the UNO through my software the uno recognize my command in the sketch , i then write that option change to the eeprom, and then force a WDT reset, the program restarts and now the new reader will work 2. i have many of the UNO in remote locations, i also have the TFTP bootloader installed, I do not want to go to each location to change the sketch. with the software on my PC with is constantly talking to the many UNO's I press a firmware update button. It sends a command to the uno to force WDT SOFTWARE reset, as uno is resetting bootloader will wait 5 seconds for a TFTP connection, once it recieves the connection the program on my pc tftp uploads a new sketch, resets uno again and then uno is running the new sketch
these are 2 examples i use, but you must write your sketch to do it, and write your pc based program or web site or whatever to take advantage of it there is no specific way that a software reset should be done. a software rest is not a hard reset, in fact even when uploading from the ide even though the reset is driven through the software it is still a hardware reset since it has the same effect as pushing the reset button
hope this helps explain
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 282
Posts: 15443
Measurement changes behavior
|
 |
« Reply #21 on: January 16, 2013, 01:39:15 pm » |
pressing the reset button resets the hardware as well as software a WDT reset only resets the software and therefor if you have other devices such as ethernet, LCD etc those will not reset The WDT resets the software and all the hardware registers on the AVR chip to their default condition, just as if you hit the reset switch or powered the chip down then on. But you are correct that the WDT does not do anything automatically to external stuff wired to the arduio, unless the arduino sketch performs some kind of 'reset' or start-up configuration stuff for the external stuff in the setup() function. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14099
Lua rocks!
|
 |
« Reply #22 on: January 16, 2013, 02:55:51 pm » |
i tried to debug the program. It worked fined for few days , again same issue has been raised.
Sounds like a bug. One worth fixing. Do you want it to be reliable or not? I have a program that opens my front door. It runs for something like a year at a time without needing resetting. We have had the issue before of needing to reset all hardware including attached boards. My suggestion was to use the watchdog timer to reset the Arduino, and then have the Arduino bring an output pin low, which is attached to the reset lines of other things (like Ethernet boards) to reset them as well. However if you were to post your code, we might spot the thing that is causing these problems.
|
|
|
|
|
Logged
|
|
|
|
|
DELHI
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #23 on: January 16, 2013, 11:03:50 pm » |
Here problem i found is this will keep on reseting the mcu every time. I wanted to RESET when watch dog timer cant take care of software RESET or program get struck @ particular point. 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).
|
|
|
|
|
Logged
|
AMPS
|
|
|
|
Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #24 on: January 17, 2013, 04:25:49 am » |
That was just an example. You would call the systemReset() function at any point in the program you want. Wrap it in an if statement, for example: #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.
Serial.begin(115200); }
void systemReset(void){ digitalWrite(someIO,LOW); while(1); }
void loop() { static unsigned long nextMillis = millis() + 1000; // This code loops consecutively if (millis() > nextMillis){ digitalWrite(10,!digitalRead(10)); nextMillis += 1000; } if (Serial.available() && (Serial.read() == 'K')){ systemReset(); //reset only when you send the uppercase letter 'K' (for kill?) through the serial port } }
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
|