Show Posts
Pages: [1] 2 3
1  Using Arduino / Networking, Protocols, and Devices / MAC addresses on Newer Ethernet shields on: March 11, 2014, 10:19:05 am
Now that the new Ethernet shields are coming with a sticker giving them a MAC address do you have to use it??? Is it burned into ROM on the 5100 chip?

As I understand it you still have to include a Mac address in your code for Ethernet.begin()
2  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet stability on: March 24, 2013, 02:01:06 pm
Hi Stewie I was going to go down the 'watchdog timer' route thinking that the one second drumbeat on the interupt would stop when the programme hangs. Using the drumbeat to continuosly re trigger a 555 monostable is simple enough though it would involve a new master PCB for the system, but Ive discovered the Web I/O can hang by itsself and the drum beat caries on dutifuly measuring temperatures and recording data. Other times the data recording stops but the Web server functions don't It all seems to vary with howmany Serial.print statments I've put in a particular version tyring to track the problem.  That smacks of memory overload but FreeRam() is returning between 630 and 750 bytes depending on where in the programme I ask the question.

Thanks to SurferTim for the 'time out' code I'll try that when the current test falls over.
3  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet stability on: March 24, 2013, 09:15:21 am
Your problem seems to be a bit like mine, but I'm not too sure about the racetrack cause. I'd like to know how you get on with coding for the 5100 chip.

My set up is a Uno and ethernet shield with sd card and relay outputs. The sketch converts the resistance of Analoug PT1000 sensors into temperatures which then set the relays. Every 10 mins all the data is dumped to the SD card for record purposes. and a Web server section allows this data to be viewed over TCP/IP on another computer, It is alos possibe to alter the thermostat settings from the pc. Also the clock is set by NTP via UDP at startup and then suposedly once a day ther after. all the bits of the programme work (Thermostat settings, A/D conversion, Data to SD card, SD card to Web page, NTP update) but when they are all together somthing causes a crash after a few hours.

I've looked at Power supplies, SD card formatting, SD card maloc bug, EthernetUDP memory creep, and FreeRam()) nothing seems to make any diference, and its been driving me crazy for 6 months.
4  Using Arduino / Programming Questions / Using pointers to strip values out of an UDP array returned by time server on: March 07, 2013, 10:45:43 am
I'm trying to reduce the amount of SRAM and stack space used by the conventional method of getting the 4 bit NTP time returned by a UDP request by using pointers but it is failing to compile. Given that the 4 bytes required are at ofsets 40-43 of the array that is returned and that they are in the right order high to low we should be able to just point to them as an 'unsigned long' rather than go through the rigmarol of making a high word and a low word then combining these.

I've also added a bit of code designed to pole through three possible NTP servers in case there is a null return

void sendNTPpacket()

  const byte NTP_PACKET_SIZE= 48;      // NTP time stamp is in the first 48 bytes of the message
  byte packetBuffer[NTP_PACKET_SIZE];  //buffer to hold incoming and outgoing packets
  byte * NTP_POINTER = packetBuffer;   // pointer to start of packet buffer )
  unsigned long ntpEpoch = 0;                // to hold number of seconds returned by time server
  unsigned long * ntpEpoch_POINTER;     // pointer to NTP Epoch need this to ensure we pick up all 4 bytes and not just the first one
  ntpEpoch_POINTER = NTP_POINTER + 40; pointer to osition of the 4 required bytes in the array
  byte i =0;                            // we have 3 NTP addresses so cycle through them if needs be
  while (!ntpEpoch && (i<3)){           // if ntpEpoch comes back with zero try one of the others
    // set all bytes in the inputBuffer to 0
    memset(packetBuffer, 0, NTP_PACKET_SIZE);
    // Initialize values needed to form NTP request
    // (see URL above for details on the packets)
    packetBuffer[0] = 0b11100011;   // LI, Version, Mode
    packetBuffer[1] = 0;     // Stratum, or type of clock
    packetBuffer[2] = 6;     // Polling Interval
    packetBuffer[3] = 0xEC;  // Peer Clock Precision
    // 8 bytes of zero for Root Delay & Root Dispersion
    packetBuffer[12]  = 49;
    packetBuffer[13]  = 0x4E;
    packetBuffer[14]  = 49;
    packetBuffer[15]  = 52;

    // all NTP fields have been given values, now
    // you can send a packet requesting a timestamp
    Udp.beginPacket(ntp_servers[i], 123); //NTP requests are to port 123
    if (Udp.parsePacket() !=0 ) { 
      // We've received a packet, read the data from it
      //,NTP_PACKET_SIZE);  // read the packet into the buffer,NTP_PACKET_SIZE);  // read the packet into the buffer
      //the timestamp starts at byte 40 of the received packet and is four bytes,
      ntpEpoch = *(ntpEpoch_POINTER) - 2208988800UL;
    }  //end 'If ( Udp.parsePacket() )' if we didnt have a time ntpEpoch is still zero
  i++;  // try another address it could still come back with zero but its unlikely
  }//end while
  if (ntpEpoch) { // figure is not zero so we've to reset
    timeError = systime-ntpEpoch;
    systime   = ntpEpoch; 
  else {
    ReStart =3;//No return from NTP therfor systime is not updated
} //end 'sendNTPpacket'

the IDE is returning 'error: cannot convert 'byte*' to 'long unsigned int*' in assignment'.
Using pointers seems a neat idea but I'm not getting very far with it at the moment I'm sure somebody else has done this already but I havent found it in the playground or forum yet
5  Using Arduino / Project Guidance / Re: Serial monitor stops working on: February 19, 2013, 12:07:22 pm
Hi Lefty,
I learnt my computing on a LEO II using 5 hole punched tape for programming and input 50 years ago!! So its in my nature to automatically use all the memory optimisation that I can.

I'm not using the String class to avoid the known bug, just Char[] arrays. The text for the Client.print, File.print & Serial.print all use the F macro for fixed text and I'm using integer arithmatic in all but 2 sums. memfree() is reporting 650 bytes of sram free at the worst part of the programme on every cycle, as such I don't appear to have a memory leak so something else must be happening.

I don't want to tear the libraries apart and reverse engineer them unless I have to. I just want the project to run as an embeded system, trouble free for the next 25 years!!!
6  Using Arduino / Project Guidance / Re: Serial monitor stops working on: February 19, 2013, 10:59:03 am
Yes the arduino is usuall still running when the monitor stops. Its reading a set of analog temperature sensors every second, averaging them over 15 seconds worth of readings then setting some switches and taking a snapshot recording of everything every 10 min onto an sd card. Also the data can be read back over the ethernet. Those pards still work most of the time.

I'm actually trying to debug somthing that realy stops the Arduino but that happens  at 2 or 3 day intervals. I would like to put more Serial.print statements into the code to find the bug, at the moment I'm just printing things like FO/FC/FDNO for 'file open/file close/file did not open' etc to cut down the amount of ram on the PC that the text on the monitor takes up and to stop the sketch gatting too big, its 28K before I start filling it  up outputs for debugging.

So any suggestions as to which serial monitor I can leave running for days would be welcome. I supose I don't even need yesterdays activity when everything is working ok Just the bit where the Ardunio comes to a halt.
7  Using Arduino / Project Guidance / Serial monitor stops working on: February 19, 2013, 03:45:02 am
Does nay body else have the problem of the serial monitor on the host PC simply stopping displaying any more data returned from the Arduino. This happens to me after 4 to 16 hours while I'm looking for a bug that causes a hang. The arduino is putting out a circa 100 byte block of data every 10 mins.

At first I thought that the PC was running out of ram but the 4:1 variation in the time it takes to come to a halt make me doubt that.
8  Using Arduino / Programming Questions / Re: Data Logger stops recording on: January 18, 2013, 10:40:04 am
The whole code is too long to post the .ino is 29Kbyte. Is there another way to open it up for peer review?
9  Using Arduino / Programming Questions / Data Logger stops recording on: January 18, 2013, 06:35:32 am
My current project (uno R3 + Ethernet shield + SD, IDE v1.0.1) Which is supposed to record analog data every 10 mins as a CSV file. The set up also functions as a web server so that I can pull the data off. The SD card just stops recording from time to time. I have consiously not used strings because of the known memory bug in the library and use char arrays instead.

Dispite avoiding strings I'm wondering if the problem is a string memory issue. Delving into the hierarchy of the libaries I find that by including SD.h this then then calls for SDfat.h, no supprise but this in turn calls for Print.h.

Now comes the rub, Print.h calls for Wstring.h which calls for string.h TWICE!

So although I've deliberatly avoided strings the buggy libary is called eventually.

I don't see how I can avoid this as I have to use 'dataFile.print("...);' and 'client.print("...);' to send info to the SD card and ethernet.

Would it be valid to use 'dataFile.write' and 'client.write' instead? and does anybody know if this avoids the use of string.h
10  Using Arduino / Microcontrollers / Re: Is there Brown-out detection for Arduino Uno? on: January 11, 2013, 10:27:10 am
Ive been pushing the problems of the unpredictable malfuncuntion of my Uno/ethernet shield combination around for some time now (see above) and I thought I had cured the problem by replacing the 220uF smoothing capacitor on the PSU with a 4700uF one!, (Jack Christensen suggested the PSU might be the problem).

However I'm still intermitently getting some sort of hang on the ethernet, not as frequent but it still happens. IE comes back with a cant connect but I can go into CMD and ping the IP address and get a responce with no losses.

Also sometimes the set up stops recording data to the SD card.

Given that we have fluky mains here I keep comming back to the BOD function and the interaction of the Uno and the W5100 chips. I've discovered that the uno chip does not pull the reset line low when it activates so there is no reset of the W5100 on brown out.

Now if the 5V arduino resets the brown out may not be long enough for the W5100 to actually switch off which could leave it in an indeterminate state when the arduino wakes up again. This could also be the reason for lossing the SD card data if the SPI lines are screwed up

Nick Gammon suggests forcing the ethernet shield to reset when the arduino BOD activates, but Ive not found any circuits or software for this and there is no reset output on the processor. Does anybody hsave any advise on this.

I've also looked at Issue 888 which has veen solved in version 1.0.3 which I could incorporate with an update but I dont see that this would stop the problem
11  Using Arduino / Project Guidance / Re: Garage Door/ Gate controller with Ethernet - Web server hangs after ~ hour on: December 26, 2012, 06:29:23 am
Another thought: are you using static IP address for the Ardunio? If you are then even setting your router for this static address may not be enough as on some routers DCHP routine will still run. It should just give the required address and extend the the lease but this is not always the case.

Fixed or static what you could try is to put an  Ethernet.maintain(); in the loop part of the script. If your router gives 1 hour leases then the maintain call should be on a 50 min cycle to get ther first. I'll admit I've not tried this on the current project as it put about 5K! in hte sketch and would blow the 32K available.

For 'wildbill' from memory the previous problem with the ethernet library was something to do with not closing the connection properly.
12  Using Arduino / Project Guidance / Re: Garage Door/ Gate controller with Ethernet - Web server hangs after ~ hour on: December 26, 2012, 04:36:43 am
Sounds a bit like my problem on a thermal control/data logging/data access via the web project but my web server stops after days rather than hours. At the moment I'm chasing the possibility of Brownouts being the cause. See;topicseen#new.

There used to be a problem with the ethernet library that could cause this sort of thing but that was supposedly fixed in the 1.0.1 release if the IDE

How big is your sketch? mine's massive at 29600 bytes and 360bytes of ram free (iand its still missing a bit of functionality). I consiously used only null terminated Cstring arrays and the (F("bla bla bla")) form for fixed strings.

I'd be interested in how you get on.

13  Using Arduino / Microcontrollers / Re: Is there Brown-out detection for Arduino Uno? on: December 26, 2012, 04:11:55 am
Does anybody know what happens with things like the ethernet shield when the BOD activates?
On my current project the web servercode or the shield seems to stop working (IE comes up with a connection problemand wont display the pagefrom the SD card) even though there is a backup battery.
Ironically the SD card keeps on recording data every 10 min, though it ocasionally misses a beat.
The only way to get communications going again seems to be a 'power off' reset!
14  Using Arduino / Microcontrollers / Re: Is there Brown-out detection for Arduino Uno? on: December 19, 2012, 04:05:13 am
Thanks for the info on the USB program loader. I've now got a copy of the Arduino cookbook which also mentions such things.

As to programme bugs, then if thats the case it must be in the libraries somewhere, but the problem of programme corruption is random in its symptoms but it happens after the mains has a funny five minutes - but not always.

As to the standard Uno having BOD at a lower voltage than the point that the chip becomes unstable, what were the people who design and build the things thinking of - not very good engineering in my book.

15  Using Arduino / Microcontrollers / Re: Is there Brown-out detection for Arduino Uno? on: December 18, 2012, 09:53:47 am
I'm comming to this late and brown outs may be one of my problems, the mains here seems to be particularly dirty. Certainly I'm getting programme corruption.

I've just put a 9V alkaline battery (through a diode to prevent back feeding) onto the barrel plug as well as the custom mains PSU for the system (9v transformer 4 diodes and a 220microfarad capacitor) that is pluged into the 9V pin on the uno board. Its not elegant or a long term solution but should keep the thing alive and let me work out if its spikes or sags/brownouts that are causing the problem.

Is there a way of setting the fuse bits other than using another arduino??

Conversely does anybody know about the effects of voltage spikes on the 328 chip
Pages: [1] 2 3