Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:32 05 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : WATCHDOG - exactly how to implement?

Author Message
Eloclegin
Newbie

Joined: 01/07/2012
Location: United Kingdom
Posts: 25
Posted: 01:01am 14 Nov 2014
Copy link to clipboard 
Print this post

Hi Guys,
Can anyone tell me what I am doing wrong here. I am trying to add WATCHDOG command to a very simple prog, running on MMBASIC4.5 (DM version) on a DuinoMiteMINI. so that if the prog crashes it will be re-started at timeout. According to GeoffG the command should work also on the DuinoMite.

My main prog is called DM500.bas, listed below, and is a simple test prog which deliberately crashes

' DM500
' simple program to test WATCHDOG
PRINT "PROGRAM IS RUNNING"
WATCHDOG 5000 'Set with 5 sec timer
PRINT "will now deliberately crash the prog and hope to see it Restart."
Gx45frgegeeg 'A deliberate error to crash prog


I create prog RESTART.bas which has just 1 line, namely. RUN "DM500.bas"
I then Save RESTART
I then load in my main prog DM500.bas in usual way (I am using MMEDIT).
I run the main prog and expect to see it crash and then restart after 5 secs.
It does not restart.

Is it enough to just have DM500 loaded into memory or do I also need to SAVE DM500 locally, since it still does not get restarted after a crash. I assume I had to SAVE DM500 too, so after LOADing,

I tried SAVE "DM500.bas".
I tried SAVE"A:DM500.bas"

Did I miss something? I must be really dumb?!!!


 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9588
Posted: 02:12am 14 Nov 2014
Copy link to clipboard 
Print this post

I used the WATCHDOG command in many of my programs, and your interpretation of how it works is correct, so it SHOULD be working. I guess some kind of incompatibility with the DM, would be my guess.

Looking at your example, I would expect the following to happen:

1) Message to get printed and watchdog timer set to 5 seconds.
2) Drop to command prompt with unknown command error
3) Once watchdog timer times-out, Maximite should auto-restart.

If RESTART.BAS is present in the root of A drive, it will be run.
If RESTART.BAS is not present, MMBASIC will look for it in the root of B drive.

If MMBASIC cannot find RESTART.BAS in either location, you should get a message on the screen at restart saying something along the lines of: "The watchdog timer has restarted the processor."

SIMPLE TEST:

At the command line, just type the following:

WATCHDOG 2000

Two seconds later, the MM should restart.
Smoke makes things work. When the smoke gets out, it stops!
 
jimbotron
Regular Member

Joined: 27/11/2013
Location: Australia
Posts: 50
Posted: 02:55am 14 Nov 2014
Copy link to clipboard 
Print this post

Hi Eloclegin,
Do you have autorun turn on?
OPTION AUTORUN ON

If not then the Micromite will reset but it won't run your program.

Jimmy
 
Eloclegin
Newbie

Joined: 01/07/2012
Location: United Kingdom
Posts: 25
Posted: 03:11am 14 Nov 2014
Copy link to clipboard 
Print this post

Not using micromite. I am using a DuinoMite with the Dm version of MMBASIC4.5

Jimbotron,
If I add your suggested OPTION AUTORUN ON at the top of the program, then when it runs it says ERROR Unrecognised option.
It also does not appear as one of the OPTION commands in the manual for this version of MMBASIC.


I can look on the SD card and I can confirm that I have RESTART.bas which if I open is a one line prog namely RUN "DM500.BAS"
I have also put my DM500.BAS onto the SD card (a:) and I can confirm it is there too.

I must be missing something obvious.
 
jimbotron
Regular Member

Joined: 27/11/2013
Location: Australia
Posts: 50
Posted: 04:03am 14 Nov 2014
Copy link to clipboard 
Print this post

Sorry,
Should have read that more carefully. I've got Micromite on the mind. I pulled out my Maximite and I tried again. I noticed it is very hard to use the watchdog timer with the serial connection and Tera Term because the serial connection is lost during the reset and you never see your program. Are you using a VGA screen? That is not affected by the reset making it easier to see what is happening.

Jimmy
 
Eloclegin
Newbie

Joined: 01/07/2012
Location: United Kingdom
Posts: 25
Posted: 04:31am 14 Nov 2014
Copy link to clipboard 
Print this post

Hi Jimbotron, yes I agree its hard to see over the connection since as you say it gets disconnected upon the error. Same happens with the MMEDIT chat screen which is what I am using.
I was likewise afraid that It might be restarting and I was just NOT able to see it.

So I added some other activity to my program, such as wiggling a digital output up and down and I watch this instead of the monitor to see if the prog is running or not running. It is definitely not restarting.

I also modified my RESTART.BAS prog and placed a line in front of the RUN line. So that I might get an indication if RESTART is running.
PRINT"THIS IS PROG RESTART!"

There is no sign of RESTART running.
 
jimbotron
Regular Member

Joined: 27/11/2013
Location: Australia
Posts: 50
Posted: 04:53am 14 Nov 2014
Copy link to clipboard 
Print this post

Hi Eloclegin,
You will probably never see the message on the MMEdit screen. I wrote a similarly simple test program, just a print and the watchdog statement. You don't actually need to generate an error as you aren't attempting to reset the watchdog timer in your test program. I could see the print message appearing on my monitor periodically as the timeout kicked in, but nothing on the serial connection.

This is all I have in my restart.bas. I does seem to work.
Print "Reset by watchdog"
WatchDog 2000


Jimmy
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9588
Posted: 05:03am 14 Nov 2014
Copy link to clipboard 
Print this post

BYPASS any serial terminal you may be using for the moment, and connect up a standard VGA monitor and keyboard to your DM.

Start the Maximite.

At the command prompt, type WATCHDOG 2000 and press [ENTER]

Two seconds later, the DM should restart.
Smoke makes things work. When the smoke gets out, it stops!
 
Eloclegin
Newbie

Joined: 01/07/2012
Location: United Kingdom
Posts: 25
Posted: 06:16am 14 Nov 2014
Copy link to clipboard 
Print this post

Thx both for the suggestions..

Grogster,
I just tried, and Indeed it does!!!

So, my lesson learned today.. Serial terminals no good for trying to observe restarts!

Thanks both, for helping out a newbie.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 11:21am 14 Nov 2014
Copy link to clipboard 
Print this post

  Eloclegin said  
I create prog RESTART.bas which has just 1 line, namely. RUN "DM500.bas"
I then Save RESTART
I then load in my main prog DM500.bas in usual way (I am using MMEDIT).


There are a number of ways to "load" your program in MMEdit.
If you are using the Load button in the Chat window, you will need to save the program.
Make sure that your restart.bas program can find the main program. Keep them both in the same root folder or change working folder before calling the main program.

If you copy your program over using the File Manager, it will be saved to where you want and then you will have to "RUN myprog.bas" to run it.

If you use "load and run" with a Maximite rather than a Micromite, the program gets copied over as "temp.bas" and load temp.bas or run temp.bas happens automatically depending on preferences.
In this case, it is advisable to rename the temp.bas to a more descriptive name and to prevent it getting overwritten the next time you use "load and run"

As you have found, rebooting the Maximite reboots the USB connection and that causes a lot of grief if a program (not just MMEdit) is connected to the USB port at the time.

If that happens, you have to close your terminal program, unplug the USB, wait for the bleeps, reinsert the USB, wait for more bleeps, restart your terminal program.

Windows makes life interesting....

Jim

VK7JH
MMedit
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9588
Posted: 01:52pm 14 Nov 2014
Copy link to clipboard 
Print this post

@ Eloclegin: Good news that you found the reason. I was starting to wonder if it was just the DM being difficult, as the watchdog command works fine normally.

[Quote=Jim]Windows makes life interesting....

Awwww, c'mon, Jim - Bill is just trying to help.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025