KRZ3 Newbie
 Joined: 31/12/2014 Location: United StatesPosts: 38 |
Posted: 02:30am 12 Oct 2016 |
Copy link to clipboard |
 Print this post |
|
I have a situation were I can't use a watchdog timer because of the way the power circuit is created. If the micromite resets it will kill the power to PCB board. Is there another way to continue a program running without it hanging up in a loop or whatever error happens while the program is running? Say I'm moving a servo back-n-forth and if a glitch happens and the program stalls, is there another way to keep the program running? I'm not sure if the on error ignore would work for this situation or if that is just ignoring an error in the code, or if the continue command would work, or if you can prevent a reset on a watchdog timeout and you can direct it to a new location in the program. |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9588 |
Posted: 02:52am 12 Oct 2016 |
Copy link to clipboard |
 Print this post |
|
...so the MM is controlling a relay or something like that, which controls power to the rest of the board or something?
So resetting the MM causes the power to the other circuit to drop off, because the I/O pins revert to high-impedance state, and everything switches off when that happens, yes?
One way to get around that, would be to have an external pin setup as an interrupt, and use an EXTERNAL watchdog circuit. The external watchdog is "Reset" by occasional pulses from the main MM as it does various things in the code, but if it gets stuck in a loop or something, that pulse will never come, the external watchdog would time-out, and would pulse a 2nd pin on the MM setup as an interrupt.
When the external watchdog pulses THAT pin, the interrupt could execute the CPU RESTART command.
All this assumes that the code has not crashed, in which case, the external watchdog could pulse the interrupt pin all night long, but nothing would happen.
If you are talking about a way to get the program going again WITHOUT resetting the MM, if it crashes in a loop, then no - if the code has crashed, that normally can only be fixed by a soft or hard reset.
If you are talking about a way to get the code to restart if it DOES NOT crash, but just gets stuck in a loop forever, then that is easy to do with a tick-timer, and a timeout figure. Have the SETTICK add one to a variable every second(for example), and while in your loop you are worried about, check that variable(which will always be increasing in value via the settick interrupt), and if >= to what you want, it will set a flag, then EXIT DO. First thing you check once outside the loop, is that flag, and if set, it goes back to the start of the program.
The beauty of the SETTICK approach, is you can reset that anytime you like in the code: X=0 kind of thing.Edited by Grogster 2016-10-13 Smoke makes things work. When the smoke gets out, it stops! |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9588 |
Posted: 03:07pm 12 Oct 2016 |
Copy link to clipboard |
 Print this post |
|
Yes, you can have up to four tick timers all running at the same time. They are really useful little timers I have found. See standard manual, page 70 for more info on them.
GOOD LUCK! Smoke makes things work. When the smoke gets out, it stops! |