Auto reset module or the likes for the MEGA

So, this MEGA will be on my aquarium. As you can guess, they have pretty important things in it. I want to build a controller for it but I want a failsafe auto reset. What I am looking at is:

1) A module or (insert what it is I am looking for here) that will reset (power cycle the unit) automatically upon a CPU lockup. 2) Maybe something that pings the MEGA every X seconds thorough Rx/Tx lines? If it doesn't get a response, it relays the power off and back on.

I know another Mega would do this but this will be a stand alone board/module, so, it doesn't need to be that powerful, just smart enough to detect no received signal and kick a relay.

Anyone know of or built something like that?

There was a thread about this a month or so back, but I can't find it.

Your idea is sound enough, although you might need to be careful about the implementation. A smaller board (eg, a Uno) or a hand-wired board could be OK for the monitor board. Even an ATtiny85.

My personal worry would be what would happen if there was some sort of brown-out that caused both processors to lock up? For that reason I would be tempted to operate the "monitor" processor from a battery, and make sure it used sleep mode to keep power consumption down.

I made a temperature monitor here:

http://www.gammon.com.au/forum/?id=11497&reply=5#reply5

That runs from batteries and is still going strong months later. The ideal thing for you might be to monitor something important (eg. the water temperature) completely independently of the main board, and if the temperature falls out of range cycle the power on the main processor. Now that might fail if it was a hot day or something and the temperature was out of range, but the main board couldn't do anything about it.

Therin lies the conundrum. What makes the actual controllers (apex or Digital Aquatics for example) out there that much more (if any) robust than the arduino? Whatever it is, I want to implement it, of course. Second to that, there is not much we can do. I am not going to worry too much about ol Murphy and his law hanging on my shoulders. What will be will be, but, I do think a arduino would be a better alternative to just a heater stuck in the tank. Are you saying maybe im barking up the wrong tree with the Mega for aquarium control and should just go independent computers like 3-4 nanos?

Thanks for the link, I will go take a look.

It would have to be a pretty complex tank. The Uno has 20 digital input/output pins. I’m not sure you’ll need more.

I would be looking at brown-out detection (to reset the chip if the power browns out) plus a watchdog timer (to reset the chip if the main loop doesn’t get pulsed).

What makes the actual controllers (apex or Digital Aquatics for example) out there that much more (if any) robust than the arduino?

Well, we would need proof of that, I think.

Thats the thing. As long as it doesn't cost an arm and a leg (or more then the off the shelf units), we have the ability to add anything we want as we go. If brown out detection is needed, then thats no biggie.

Hmm, so a watchdog timer(?) is in order? Will have to dig into that also.

The reason I say 3-4 mini's is you mentioned everything to be on their own controller and report into a main unit. I dont know if thats over kill or not. I figure if the main unit dies/fries or locks, the others are not goinna matter. Whos to say the mini oruno will not be the one to croak? Too cold and things die. Too hot and things die. Its not like fresh water where it can handle lots of fluctuation. I would, as an added fail-safe, just have to pick either taking a chance on a stuck open or closed relay. I.E. Do I have the heater connected to the N/C and hold the relay open with power so if I lose power, worst case scenario tank goes cold, or, do I put the heater on the N/O and turn on the relay with power? Decisions decisions........ Who is to say what will trip me up?, but, the idea about a controller is to have everything in one station/location or box, or, Neptune and DA would not have it all built in together.

Oh well, this is still in its infancy, have a ways to go. First thing, since it goes from 78 to 30 here in Virginia without notice and I never have the AC or heat in the house set correctly, is to get the temp sensor working to control heaters and cooling. :)

Should I go with the Arduino Nano's or Uno's for just the sensors? Both have USB and I am sure the nanos have fewer pins, but, for temps, I dont need much.

I've been doing a bit of experimenting. As I see it the main issue would be if there was a brown-out in your power, and the processor went into some indeterminate state (ie. a loop) and didn't respond any more. This would be bad obviously, particularly if the last thing it did was turn on the tank heater, and the fish got cooked.

Tests show that with a low voltage on the +5v pin (eg. 2.5v) the processor can lock up with output pins still high (when they should be flashing in my particular code).

Now, enabling the brown-out detection seemed to fix that, with the processor going into reset and turning off the output pins.

The other thing to do is enable the watchdog timer, which basically guards against some strange bit of program logic from which you don't recover (a software error). This isn't totally foolproof, if you "pat the dog" when you shouldn't, or if you have a major bug, but it should help.

You would need to make sure that it "fails safe" so that if the output pins are off (or indeed, high impedance) then heaters etc. fail into the safest mode they can. That might require external pull-up or pull-down resistors to make sure that external relays fail into the "off" position.

Then, of course, I would extensively test it, trying to simulate power failures, brownouts, etc.

A simple fail safe (fail off) approach is to have the outputs driving through a capacitor to a charge pump (another capacitor) which then drives the control transistor for the relay. These components (avoiding electrolytic capacitors) are most unlikely to fail, they certainly cannot "crash" as they have no software.

The whole thing is one of risk management, and you cannot have “no risk”.

Possibly the heater might fail (even though the computer thinks it is on), ditto for the pump. Or if you use a relay it might “stick” in the “on” position, overheating them. The power might go off for 48 hours.

Depending on the value of the fish (emotionally and otherwise) you might have a backup system that at least monitors the tank and warns you if things are out of range. If you are home in time to save them, a simple audible alarm could do. If you are away for long enough for them to die, some sort of auto-dialler or email-er might be required. That might not work if the power failed.

A more proactive system might be something like a monitor which measures the temperature, and sets up a (simple) web page with a Ethernet shield. Then you could connect to that from work and check the tank from time to time. The absence of a connection would then warn you of a power outage.

If the backup system ran from batteries, then it would survive a power outage.

Well, the problem with a saltwater tank is that unless you are there every 12 hours to catch a mishap, you can only do the best you can and not worry about it. There are a bazillion failsafes I could apply, but, then it becomes too much of a job. The main goals are, no matter what happens (in the computers simplest form), aside from over heating, the tank can hold out a day. Vacations would be a little sketchy but is a given that the tank is up for grabs when that time comes.

Now, while I usually opt for NOT staring danger in the eyes when I have the power, I will be implementing a few fail safe modes. Until then, this is where I am at. I have ordered

1 ) cheesy 1 x 12 serial screen for $2 to let me know the arduino works (until I get the time to do the 3.2 touch)
2 ) 3.2 touch screen to use later down the road
3 ) off brand Uno to get tinkering for $11
4 ) 12 pack of relays
5 ) MB102 Breadboard Power Supply $3
6 ) DS3231 AT24C32 IIC High Precision RTC Module Clock $7.50
7 ) DS18B20 temp sensor
8 ) Breadboard and 40 male/female jumpers
9 ) Email notifications of failure, but, thats gonna be some interesting coding. I need to learn how to just turn on and off an electrical outlet first. :slight_smile:

That should get me going for now, though I am sure I missed something. I plan to use the Uno for inserting code into the cheap chips, pulling them off the Uno board and then using them as standalone chips on other PCB’s. I can have every single device have its own controller and not take up any pins on the Uno and just have the Uno give me status and do routine checks etc. Maybe I could even write a ping code at the end of each unit to ping the Uno and if it does not get a signal, it alerts me to a problem?

Once the Uno is functioning properly in corporation with the other modules, I will probably try the Due board, or, if I run across a crazy deal on a Mega, I may grab that.

Well, more for the future, but, does that plan look okay so far?

The things I will tackle in the head as I start to practice coding/compiling will be

  1. brown outs
  2. Watchdog …something something, lol
  3. What relays do what when/with loss of power
  4. Extreme power supply filtering for a clean signal

Please let me know if I am missing anything or you want to expand on anything. Anything at all. :slight_smile:

Thanks

Editors note: For heaters, I think I will run 3 relays (they are cheap) in series on a N/O setup. One can stick all it wants. The chance of 3 sticking on at the same time??

That sounds OK, although a solid-state relay would probably be OK, as it wouldn't stick.

Also you can get immersible thermistors (I think I got one from Adafruit) which would let you dangle the sensor in the water. Failing that I supposed wedging one against the dry side of the glass would be pretty close.

I would also do a quick Google to see if there are any gotchas that people who have actually done this have come across.

I was thinking of solidstate but I would want a hefty one. First glance at looking at them, I have found they need a heatsink. Me no likely this. With running 400w to 800w of heaters, I think I would just rather have a HD standard relay and run stright through the metal contacts and reduce the heat, not to mention use that heat for the tank. Then again, if it gets that cold in the room, the room does need to be heated. Hmmmm...............

The DS18B20 temp sensor actually is "supposed" to be submersible. Checked that out also, though, I didn't see any "gotchas" in the 5 pages I did hit. I will def dig into it before I put it in 100% usage. :)

So, whats up with you Aussies and Europeans over there? Usually us Americans are all over this do it yourself stuff. Seems like you all are leading this round? I guess us fat azz Americans are really getting lazy, lol??

One thing to keep in mind for critical applications (which might include pet fish :wink: ) is the need for redundancy for certain functions. A critical process controller might determine that they need three input sensors for every critical measurement such as tank temperature and use a 2 out of 3 software voting logic to detect the possibility of a faulty or damaged sensor. Sometimes having a simple independent control loop not using a micro, such as a temp sensor wired to a relay to kill heater power irregardless of what the micro is doing is a good solution.

Lefty

Hello all,

I found this topic, and it seems similar to what I need. I also wants to prevent my system based on DUE against failure ( freeze or looping ). Main influence has program it self of course. Arduino also has its internal WDT.

But I still would like to implement and external watchdog. Because I am also using DS3231 RTC modul, I did a little reserch... It should have two programmable interrupts. Is there any way to use it as external WDT (reset) for arduino board?

Thanks in advance for any advice. Miro

There are plenty of WD chips around, most will also detect brown out and can be used for manual reset as well. The MCP1316 is one I've used, but there is MAX16055 and MCP131 and many others I'm sure.

If you want to be real secure look for a "windowed" WD chip, they will reset if you kick them too often as well as not often enough.

If you also need an RTC there are RTCs with built in WD as well, eg the MAX6916.


Rob

thanks a lot for useful feedback. I found MAX6324, but seems quite expensive. The one you have used is much cheaper, and seems very well. Is it really so simple? Just connect in accordance datasheet example circuit and pulse from aduino into WDI pin of Watchdog. And if pulse frequency will be greater or less, WD IC will trigger reset?

The MCP1316 is not a windowed WD so it will only detect pulses > the time period. For your app I would think that’s good enough but that’s up to you.

I haven’t written software for it, I designed it into a product and the client wrote the software but they are happy so I guess it works fine.

Attached is the circuit I used on a Mega-compatible board.

Note that with this chip the WD doesn’t start until the first falling edge on WDI, so you have time to get your act together before enabling it.


Rob

thank you for posting circuit, seems easy :) i see a pullup resistor on WDI pin, so arduino was pulling down in this case. It is not windowed, but it should not be a problem for me if.... My expectation is that if arduino IO pin will hangs, so WD IC WDI pin will stay wihout change for WT period than reset pin will be pulled down by WD open collector output. does not matter if arduino IO pin will hang high or low. Is my understanding good?

I really do not need to detect if my atmega pulsing faster...i can not see any reason why it could happen.

The pullup is to keep WDI at reset when the Arduino’s pins are inputs.

The Arduino starts it off by pulling low, after that there had better be a pulse train at < the timeout period.

does not matter if arduino IO pin will hang high or low. Is my understanding good?

Yes, WDI is edge triggered.

I really do not need to detect if my atmega pulsing faster…i can not see any reason why it could happen.

Stuck in a loop that pulses the WDI pin maybe. But yes for this app I think you will be OK.

There are ways to increase the security, for example you don’t just pulse WDI every loop,

loop () {
    func1();   
    func2();  
    func3(); 
    kick_dog();
}

as this will be happy no matter what is going on with your code. You have some conditions, for example

int ok;

loop () {
    ok = 0;
    func1();    // does an ok++ if everything ok
    func2();   // does an ok++ if everything ok
    func3();   // does an ok++ if everything ok

    if (ok == 3)
      kick_dog();
  else
     while(1);
}

this way you only keep the WD at bay if all functions are happy.


Rob

I am real electro noob, so thank you for your patience and effort with explanation. It is clear now, and I will use it in my application. Previously I was thinking to build WD based on 555 timer, but MCP1316 will be more reliable and circuit needs less components. One more thank you for your support Rob. Miro

but MCP1316 will be more reliable and circuit needs less components.

Yep, IIRC (it's been a while since I looked at them) the 555 will stay triggered if pin 2 is held low.


Rob