Ethernet diagnosis help

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Ethernet diagnosis help

Post by angusgr » Tue Apr 30, 2013 11:30 pm

drewgarth wrote: c) I discovered that for some reason either the linux version of the IDE was somehow not allowing me to use an 8s watchdog timeout, so i was forced to change this to 2s
Perhaps the WDTO_8S constant is missing from the avrlibc (underlying C library) version on the Linux install you have?

I just had a thought, it is possible some network operation in your sketch could take more than 2s but less than 8s? Meaning it wouldn't have tripped a watchdog reset before, but does trip one now.

In theory, the software reset when the Arduino starts up should take care of this, but if the W5100 was in the middle of some other SPI transaction then it may not recognise the reset command.

As you've already said, changing the watchdog usage pattern to only enable the watchdog timer when you actually want to reset right now (ie wdt_enable(WDT_120MS); while(1) { }) may be the best solution (although then you won't get a reset if the sketch does get locked up blocked on something.)

Although it may be wise to put in a hardware reset regardless, just to be sure.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Ethernet diagnosis help

Post by angusgr » Wed May 01, 2013 1:37 am

angusgr wrote:You could even program the ATmegaU2 on the EtherTen to act like an external Watchdog for the main ATmega328p, using one of the digital pins on its programming header to wire back to Reset. But that might be unnecessarily complex. :)
Doh, I just realised this can't possibly work due to the ATmegaU2 & the Atmega328p sharing the same reset line. Oh well, external components (or a hacky single wire) it would have to be!

ngp99
Posts: 49
Joined: Sat Jul 14, 2012 1:53 am
Location: Dee Why NSW

Re: Ethernet diagnosis help

Post by ngp99 » Wed May 01, 2013 1:57 am

drewgarth wrote:Hi ngp99,
When summing numbers they will eventually exceed the limit of the variable....and when millis() roles over and re-zeros I didnt want to find out the hard way 40 days in that my logic was flawed in dealing with the rollover....Hence resetting once a day means that any logic errors will be revealed in a day. If it works for 24 hours and resets, it should work indefinitely.....
Thanks for your comment. This is becoming important!

I was thinking that the watchdog is a precaution rather than a must-have, and even a band-aid for slack-arsed software. But I have already been getting apprehensive about variables, and now even more so.

My situation is similar to yours. I have two remote monitor stations that must be able to stay unattended for about ninety days, and survive power failure and internet service service drop-out, particularly as the internet connection is somebody else's. The Etherten proved the point but I had to move to a Mega. The incomplete prototype worked fine, sending data to cosm every ten seconds for over a month.

But I recognise the vital difference. Thus far I am merely passing data through to cosm and the SD. No accumulation, and no counting.

This is a situation that is about to change. I am incorporating the Freetronics/Jaycar water flow meter and, for the first time, I have to count millis and accumulate data. This involves new and spooky variables - unsigned long, and millis - that I have never had to use before.

I have been calibrating the turbines over the last week with no problems, but I have just now read that millis is only good for 50 days.

So it looks like I could be in line for a watchdog........

Plus, indeed, temporary storage and retrieval of up to four numbers......... Gawd, and I have just a month to get this sorted.

drewgarth
Posts: 14
Joined: Thu Apr 25, 2013 10:07 pm

Re: Ethernet diagnosis help

Post by drewgarth » Wed May 01, 2013 3:25 am

@NGP99, unfortunately yes, there are many challenges in this situation where you have remote unattended Arduino's. To be perfectly honest I have been trying to get this working for over a year though a combination of testing at home, and visit the site, only to find another bug.

Like you i have a remote area power supply, a 3g modem, plugged into a draytek router.
Initially, i had problems because in the depths of last winter i didnt have enough solar power coming in to drive the inverter, weatherstation, router and arduino. But luckily one of my first incarnations of my monitoring software showed that to be the problem.
I have had 3g routers go offline, so now my draytek autorboots every 24 hours.

And i also had an arduino ethernet sheild combo, locking up, which is what lead to the quest for a reset solution in the first place. I then had about 3 months of uptime before christmas, before i swapped out and struck my current problem.

The rollover of millis() caught me offguard at one point too....watchdogs and autoresets of equipment have become my lifeline to keeping things up and running.

As you can tell from my code, one of the struggles i had in implementing the watchdog is the default times for ethernet connections causing the watchdog to trigger.
So now I can call the watchdog in a function, though as Angus and I have noted that will not catch any other code lockups.....It also wont reset the Wiznet.
The hardware reset which i will probably try (in addition to the single wire solution) is http://www.playwitharduino.com/?p=291&lang=en, but that also wont catch hung code....

Plenty of challenges. Feel free to PM me if you want to bounce around other ideas

cheers
Andrew

drewgarth
Posts: 14
Joined: Thu Apr 25, 2013 10:07 pm

Re: Ethernet diagnosis help

Post by drewgarth » Wed May 01, 2013 3:33 am

@Angus,
i just checked and as it turns out I was using both version 1.01 on Linux and on windows at home. Though I am now using 1.04 at home.
angusgr wrote:
drewgarth wrote: c) I discovered that for some reason either the linux version of the IDE was somehow not allowing me to use an 8s watchdog timeout, so i was forced to change this to 2s
Perhaps the WDTO_8S constant is missing from the avrlibc (underlying C library) version on the Linux install you have?

I just had a thought, it is possible some network operation in your sketch could take more than 2s but less than 8s? Meaning it wouldn't have tripped a watchdog reset before, but does trip one now.

In theory, the software reset when the Arduino starts up should take care of this, but if the W5100 was in the middle of some other SPI transaction then it may not recognise the reset command.

As you've already said, changing the watchdog usage pattern to only enable the watchdog timer when you actually want to reset right now (ie wdt_enable(WDT_120MS); while(1) { }) may be the best solution (although then you won't get a reset if the sketch does get locked up blocked on something.)

Although it may be wise to put in a hardware reset regardless, just to be sure.
I must admit the need to go to a 2s timeout caught be off guard, so i may need to spend more time trying to understand how to get the 8s timeout available again in the compiler (since it worked previously), and with your thoughts above I can now see how that may have caused a potential lockup

It looks like I will end up with a combination of both a watchdog and an external timer driven reset. The fact that you had a CRO to monitor the reset pulse has convinced me of that.

haha and after all of this I will probably get down to the site next time and find a dead spider on the circuit causing all of this grief anyway :)

ngp99
Posts: 49
Joined: Sat Jul 14, 2012 1:53 am
Location: Dee Why NSW

Re: Ethernet diagnosis help

Post by ngp99 » Wed May 01, 2013 3:53 am

drewgarth wrote: The hardware reset which i will probably try (in addition to the single wire solution) is http://www.playwitharduino.com/?p=291&lang=en, but that also wont catch hung code....

Plenty of challenges. Feel free to PM me if you want to bounce around other ideas
Thank you.

I understand there are two scenarios: anticipated, millis rollover etc.
unanticipated, hung code

As for dead spiders, I am using standard GPO weatherproof boxes. This was originally for Uno and they are probably pretty good for that but they involve too much work for Mega and I will make my own in future.

If you have stuff outside the Arduino format, a weatherproof 8-pole sub-distribution box might be a good option.

drewgarth
Posts: 14
Joined: Thu Apr 25, 2013 10:07 pm

Re: Ethernet diagnosis help

Post by drewgarth » Wed May 01, 2013 11:13 pm

Hi Guys,
this looks like a really cute way of doing the hardware reset without the need for timer chips etc.... So I thought I would share.

http://electronicsfordogs.com/articles/ ... atmega-328

My electronics brain isnt working too well this morning. In this example, circuit diagram, where does the end (top in pic) of the resistor connect to?

cheers
Andrew

ngp99
Posts: 49
Joined: Sat Jul 14, 2012 1:53 am
Location: Dee Why NSW

Re: Ethernet diagnosis help

Post by ngp99 » Thu May 02, 2013 12:19 am

It's a straightforward res/cap timer. The top connection is to the 5v rail. I think the circuit is for a bare bones Atmel, rather than an Arduino board and it looks too good to be true. It does say it is a hardware reset but is it good to do everything? The 555 device mentioned before is also a res/cap timer, so maybe that is essentially a belt and braces vertion of the same method,

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Ethernet diagnosis help

Post by angusgr » Thu May 02, 2013 2:14 am

drewgarth wrote:@Angus,
i just checked and as it turns out I was using both version 1.01 on Linux and on windows at home. Though I am now using 1.04 at home.
OK, good to hear. That's probably not the issue then.
drewgarth wrote:It looks like I will end up with a combination of both a watchdog and an external timer driven reset.
Good plan. I think I'd do this too for something so hard to physically access.
drewgarth wrote:Hi Guys,
this looks like a really cute way of doing the hardware reset without the need for timer chips etc.... So I thought I would share.

http://electronicsfordogs.com/articles/ ... atmega-328
This is a neat idea but I share ngp99's concerns that it might not work.

Specifically, when the output drives reset low it will discharge the capacitor very rapidly down from 5V. However, the article assumes it will discharge instantly all the way to 0V. It might not - the ATMega328p datasheet (linked before) says (on the same page I indicated) that a reset pulse can be anything below a range 0.2 x Vcc - 0.9 x Vcc (ie 1V - 4.5V.) So it may only discharge as low as 4.5V before the reset trips, the pin goes high impedance, and the slowly charges back up through the resistor.

Similarly, they assume they need to charge to at a least 2V logic level before the reset de-asserts but the specs say 1V.

To be half sure this would work I'd want to look at the RESET voltage on an oscilloscope, and check for a combination where RESET stayed below 1V for >2.5us. However this is still relying on unspecified factors that may vary with time, with temperature, or between chips.

An external driver circuit using a 555 (or even another microcontroller or Arduino) would be more reliable, you can actually guarantee the reset pulse always meets specifications.
drewgarth wrote:The hardware reset which i will probably try (in addition to the single wire solution) is http://www.playwitharduino.com/?p=291&lang=en, but that also wont catch hung code....
FWIW I'm pretty sure this also won't reset the W5100 chip, it's no better than the Watchdog timer in that regard. The DTR signal tells the Arduino to "jump to bootloader", but it doesn't issue a full external reset. For that to work, the 555 output needs to be connected to the RESET line not D0. For that to work, the output needs to change from active-high to active-low (one way to achieve this is to use a logic inverter IC, or there may be a way to reconfigure the 555 to do it.)

Cheers,

Angus

drewgarth
Posts: 14
Joined: Thu Apr 25, 2013 10:07 pm

Re: Ethernet diagnosis help

Post by drewgarth » Thu May 02, 2013 2:27 am

Thanks guys...
OK, so with regards the 555 hardware reset, i grabbed the wrong link from my bookmarks.
The following one is designed for holding RST low and should therefore reset the W5100 as well
http://www.openhardwarehub.com/projects ... show_all=1

With regards the simple RC circuit, I found that idea because i searched for RC Circuit, Amtel, arduino and reset.

I just quickly hooked it up and tested it and it is working away resetting every 5 seconds.
Having said that Angus, i share your concerns re how long the RST is held low. Without an oscilloscope, I cant tell. But it is resetting, so it must be mostly working, or else having 5v applied through the resistor would be keeping RST high....Though whether it is a clean, complete and reliable reset is another story!

cheers
Andrew

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests