Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:30 10 Oct 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 : PM Standard - HW Watchdog issue...

     Page 2 of 4    
Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 07:14am 07 Oct 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  External watchdogs are the way to go. A dual 555 would be fine. True and tested, with no micro content.


Starting to think along those lines myself at this point.  
Do you have an example dual 555 circuit?

EDIT: At this point, I think I am over-analyzing things.  I need the MMBASIC WatchDog to work if the code falls over - that's it.  According to the manual, CTRL+C will STOP the Watchdog, and that is perfect.  I just need it to trigger if the code falls over to the command-prompt OR gets stuck in a code-loop.

That should be do-able inside the FW, without needing an external Watchdog chip or circuit, but I am still interested in exploring that idea.
Edited 2025-10-07 17:21 by Grogster
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6319
Posted: 07:20am 07 Oct 2025
Copy link to clipboard 
Print this post

Just in case you are really desperate
 '
 ON ERROR IGNORE
 OPTION AUTORUN ON
 WATCHDOG HW 8000
 PRINT "Started"
 DO
   PAUSE 100
   PRINT 8/0
   IF MM.ERRNO THEN
     PRINT "Error number ";MM.ERRNO
     PAUSE 10000
   ENDIF
   
 LOOP



As long as you keep checking for errors before the world self-destructs.

Jim
VK7JH
MMedit
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 07:22am 07 Oct 2025
Copy link to clipboard 
Print this post

THANKS!  

I will try this tomorrow.
Smoke makes things work. When the smoke gets out, it stops!
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2766
Posted: 07:25am 07 Oct 2025
Copy link to clipboard 
Print this post

I guess a work-around could be to insert this at all likely points in the program, provided the program doesn't control anything that could do damage.
ON ERROR SKIP [nn]
'your code section
If MM.ERRNO then
  'print location to file and/or console or perhaps VAR SAVE error$
  CPU RESTART
EndIf


Edit.
Me too slow!
Edited 2025-10-07 17:32 by phil99
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10464
Posted: 07:32am 07 Oct 2025
Copy link to clipboard 
Print this post

I'll add a new feature in the next beta

ON ERROR RESTART

That way any error will cause the system to reboot and autorun can work its magic

Note that if anywhere in the program you use any other ON ERROR command you would need to reset the ON ERROR RESTART afterwards
Edited 2025-10-07 17:36 by matherp
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 07:57am 07 Oct 2025
Copy link to clipboard 
Print this post

That sounds brilliant, Peter.
Does that essentially bypass the Watchdog command? (HW or Software versions)
Smoke makes things work. When the smoke gets out, it stops!
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2766
Posted: 08:05am 07 Oct 2025
Copy link to clipboard 
Print this post

It doesn't sound like it. If there is an actual lock-up it will be frozen too.
A hardware (internal or external) watchdog would be needed for that.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10464
Posted: 08:17am 07 Oct 2025
Copy link to clipboard 
Print this post

  Quote  Does that essentially bypass the Watchdog command? (HW or Software versions)


As phil99 says - no. Take the example "do:loop" no error but without a watchdog not much else is going to happen
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 08:22am 07 Oct 2025
Copy link to clipboard 
Print this post

OK, so then is that any use?
No offense, Peter.....

I am so brain-phucked at this point.
I need sleep.  
Smoke makes things work. When the smoke gets out, it stops!
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5328
Posted: 08:24am 07 Oct 2025
Copy link to clipboard 
Print this post

Hi Phil,

I don't think so. If I read the thread correctly, Grogster wanted to use the watchdog to also protect against unforseen programming flaws. Like reading an ADC, and by circumstance the ADC outputs a real 0, not 0.001. There is some math and that accidentally causes a divide by zero error. It is hard to predict everything that can go wrong. Especially when there is a lot of math. I witnessed the same with my thermal camera. And ON ERROR RESTART would make the unit alive (in stead of hanging infinite) with these errors.

Grogster wanted to use the watchdog to do this, but apparently that did not work. Which is strange, since it should. You are not updating the watchdog timer anymore when an error hits since the program stalls. It should restart.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 08:32am 07 Oct 2025
Copy link to clipboard 
Print this post

  Volhout said  Grogster wanted to use the watchdog to do this, but apparently that did not work. Which is strange, since it should. You are not updating the watchdog timer anymore when an error hits since the program stalls. It should restart.

Volhout


YES!!!
Smoke makes things work. When the smoke gets out, it stops!
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1576
Posted: 09:12am 07 Oct 2025
Copy link to clipboard 
Print this post

FWIW:

To incorporate an independent WD, they are stocked by LCSC. Current consumption 13 µA typ.






stwd100.pdf
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8175
Posted: 09:46am 07 Oct 2025
Copy link to clipboard 
Print this post

555 watchdog on an arduino
The signal to the RST pin could be used to do something different, but you get the general idea.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5328
Posted: 10:02am 07 Oct 2025
Copy link to clipboard 
Print this post

Phil, Mick,

I think the combination with watchdog (for loops) and on error restart (for errors) could solve Grogsters problem.

I do not want a hardware watchdog reset while developing. Depending on how your program exits or your ctrl-C moment, it kicks in when you don't want it (during SD card saving). But honestly ON ERROR RESTART may be just as ravaging.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3307
Posted: 10:41am 07 Oct 2025
Copy link to clipboard 
Print this post

  Grogster said  Yeah, but doesn't MMBASIC force a WatchDog even if the code falls over to the command-prompt?

Correct.

Presumably you are using OPTION AUTORUN so that the program runs after the watchdog has forced a reboot.  The PicoMite differs from the Micromite in that it will NOT restart if there has been a "system error" (ie CPU exception).  Even worse, the AUTORUN option is also turned off, so cycling the power will not cause the program to run, you must connect to the console and re-enter OPTION AUTORUN.  This caught me out with the Watering Controller using MMBasic 5.xx.xx which was always falling over with a system error.  

To handle this Peter added the ,NORESET option to OPTION AUTORUN.  My opinion is that the program should always restart, regardless of the error, but there you are, you now have to use this option.  This is important because, if your program is failing due to a system error it could be just sitting there at the command prompt waiting for you to connect to the console and enter RUN.

Geoff
Edited 2025-10-07 20:44 by Geoffg
Geoff Graham - http://geoffg.net
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5328
Posted: 10:56am 07 Oct 2025
Copy link to clipboard 
Print this post

I can imagine the boot-2-basic computers to prefer console/keyboard entry after a reset. Console or keyboard are available. But or microcontrollers and Game*Mites the OPTION AUTORUN,NORESET should be the preferred solution. There typically is no console and this means the unit is dead when autorun fails.

And in case of the boot-2-basic computers, the feared endless reboot cycles can be stopped with ctrl-C anyway, since you assume the console/keyboard to be present.

My vote: always autorun (default use NORESET).

Volhout

Phenix: nice suggestion. But the longest time available (hardwired in the chip) is 1.6 seconds. Maybe a bit to short. Nice for real time applications, but Grogster uses 8 seconds now, maybe for a reason.
Edited 2025-10-07 21:03 by Volhout
PicomiteVGA PETSCII ROBOTS
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1576
Posted: 08:57pm 07 Oct 2025
Copy link to clipboard 
Print this post



Yeah in my world that's a useless mutt, not a watchdog. I understand though  
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 12:11am 08 Oct 2025
Copy link to clipboard 
Print this post

  Geoffg said  
  Grogster said  Yeah, but doesn't MMBASIC force a WatchDog even if the code falls over to the command-prompt?

Correct.

Presumably you are using OPTION AUTORUN so that the program runs after the watchdog has forced a reboot.  The PicoMite differs from the Micromite in that it will NOT restart if there has been a "system error" (ie CPU exception).  Even worse, the AUTORUN option is also turned off, so cycling the power will not cause the program to run, you must connect to the console and re-enter OPTION AUTORUN.  This caught me out with the Watering Controller using MMBasic 5.xx.xx which was always falling over with a system error.  

To handle this Peter added the ,NORESET option to OPTION AUTORUN.  My opinion is that the program should always restart, regardless of the error, but there you are, you now have to use this option.  This is important because, if your program is failing due to a system error it could be just sitting there at the command prompt waiting for you to connect to the console and enter RUN.

Geoff


YES - I think this is EXACTLY what is happening.  I can't confirm it 100%, as the VCP has also vanished, but I THINK this is what must be happening.  And as the 2040 is NOT restarting and NOT therefore continuing with the autorun, it just sits there in limbo doing nothing.

I will have a play around with that NORESET option.

I was totally unaware of the PM difference in this respect, to the MM2 for example.
Good to know, but that is a real gotcha type of problem!
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9677
Posted: 01:29am 08 Oct 2025
Copy link to clipboard 
Print this post

I'll also make a change to future PCB's, so that the console is available on COM1 on pins 0 and 1 of the WS-Zero module.  I'm currently using pin-1, but only as a standard digital input, so I can move that to any other pin, and use pins 0 and 1 as a local serial connection to the console, so that even if the VCP part of the 2040 decides it does not want to talk, I should have a direct path to the interpreter via the COM port.

I will enable both the USB VCP and the COM1 console with the "B" option.
This does mean I have to get more PCB's made, but that is no real problem.
I'll look into the possibility of adding a dual-555 type watchdog to the PCB at the same time, but I have to go read that link that was posted.

EDIT: Read the 555 timer watchdog page - very simple and elegant, and seems like good insurance to include this I think.  Of the units I have found that have "Crashed", and where the VCP won't even connect, pressing the RESET tact on the WS-Zero module DOES make the unit recover, so I think I need to make sure this circuit is included on the next set of boards.

Then I'll have to update all the old units to be sure they won't just stop working!  

I've just discovered that the WS-Zero module does not route out the "RUN" pin, which is the 2040 reset pin.  I'll have to use a linking wire to the tact switch, which is not idea, but....C'est La Vie....
Edited 2025-10-08 11:43 by Grogster
Smoke makes things work. When the smoke gets out, it stops!
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1034
Posted: 03:04am 08 Oct 2025
Copy link to clipboard 
Print this post

Some ideas from @captainboing for connecting to the serial port when servicing/trouble shooting a field unit.Adding a socket could be useful.

Simple Serial Console Connection
F4 H7FotSF4xGT
 
     Page 2 of 4    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025