DELHI
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« on: January 16, 2013, 05:41:37 am » |
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
|
|
|
|
|
Logged
|
AMPS
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19018
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: January 16, 2013, 06:11:13 am » |
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.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 311
Posts: 35474
Seattle, WA USA
|
 |
« Reply #2 on: January 16, 2013, 07:41:41 am » |
It's far better to fix the bug in your code than to try to work around it by resetting the Arduino.
|
|
|
|
|
Logged
|
|
|
|
|
DELHI
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #3 on: January 16, 2013, 07:49:05 am » |
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
|
|
|
|
|
Logged
|
AMPS
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 311
Posts: 35474
Seattle, WA USA
|
 |
« Reply #4 on: January 16, 2013, 08:05:24 am » |
I Need example how they take care of hardware pins like Reset pin They who? International House Of Pancakes?
|
|
|
|
|
Logged
|
|
|
|
|
DELHI
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #5 on: January 16, 2013, 08:24:57 am » |
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
|
|
|
|
|
Logged
|
AMPS
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19018
I don't think you connected the grounds, Dave.
|
 |
« Reply #6 on: January 16, 2013, 08:31:34 am » |
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?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
DELHI
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #7 on: January 16, 2013, 08:40:54 am » |
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
|
|
|
|
|
Logged
|
AMPS
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19018
I don't think you connected the grounds, Dave.
|
 |
« Reply #8 on: January 16, 2013, 08:47:49 am » |
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.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
DELHI
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #9 on: January 16, 2013, 08:51:48 am » |
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
|
|
|
|
|
Logged
|
AMPS
|
|
|
|
London, UK
Offline
Full Member
Karma: 4
Posts: 179
|
 |
« Reply #10 on: January 16, 2013, 08:59:24 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #11 on: January 16, 2013, 09:57:29 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
God Member
Karma: 35
Posts: 983
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #12 on: January 16, 2013, 10:14:43 am » |
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.
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #13 on: January 16, 2013, 10:29:36 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
God Member
Karma: 35
Posts: 983
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #14 on: January 16, 2013, 11:09:08 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).
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
|