General > General Technical Chat
Cosmic rays!?
<< < (3/3)
jrmymllr:

--- Quote from: SeanB on January 12, 2023, 10:55:30 am ---Also remember the WDT should be running off the main loop, not via an interrupt that might still work code wise, it needs to be in the main routine, so that anything that sends the processor off into the twilight zone will stop resetting it, and it will implement the same restart. Also probably good to add to the main loop a power on check, to see if the reset was via mains fail, power on or WDT reset, probably by having a set of memory locations with a predefined value, that you check on power on, with reset from power on leaving them other than the magic value, and a WDT reset leaving them set to the magic. Then write a log, increment a software counter on the display, normally zero, but every WDT rest increments it, and then writes the magic values to RAM to set them anyway. Writing to display is the least damaging, as log writes use flash cycles, unless you also have a replaceable EEPROM that you use I2C to write to, and a separate device at a different address that handles volatile settings, or you have a battery backed RTC that you use the built in SRAM to add the counter to.

--- End quote ---

Yes absolutely the WDT needs to get reset in the main loop, especially since it was the main loop that got trashed. Not to say it'll always happen like that.

I think just setting up the WDT will be sufficient. I should have did that from the start and I'm not sure why I didn't. There is no EEPROM or battery backed ram, just crappy Luminary/TI flash with a 100 write endurance that I'm already wear leveling and even at that, rarely writing to. It's taken this long for something to occur where WDT would have helped :)
AlbertL:
I have a home-made home automation system built around a PLC.  When I added temperature sensors to the system, I noticed that the readings from the three indoor sensors (100 ohm platinum RTDs) instantaneously dropped by about 4 degrees F every day at exactly 6:00 AM, and began continuously fluctuating randomly in a range of several degrees F.  This continued until exactly 11:00 PM, when the readings immediately became accurate and stable, and remained that way until 6:00 AM.

There's nothing in my house that operates on that schedule, and I'm in a residential neighborhood with no industrial facilities or other potential sources of power line noise.  A power line filter didn't help.  Then I remembered that there's a 5kW AM broadcast station about 3/4 mile from my house.  I checked their schedule, and sure enough, their sign-on and sign-off times matched the start and stop times of the unstable readings.  After some experimenting, I found that the RF was getting into the PLC through its serial ports.  One of these is used for programming, and for convenience I'd been leaving it connected to my laptop all the time.  The other is used for an RS-485 Modbus RTU interface to other devices.  I unplugged the cable from the programming port and put an optical isolator on the Modbus port - problem solved!         
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod