Go Down

Topic: Webduino seems unstable on larger sketch (Read 840 times) previous topic - next topic

stefdageek

I searched for posts but could not find a solution...

I am using IDE 1.01, Arduino Ethernet, FTDI USB, no SD card, 12V wall wart for power, and using latest Webduino. I am reading the temperature off a TMP102 using I2C. All seemed to work fine until the size of my sketch starting reaching about 22K (the complete sketch is 26K). Since then, the main page usually comes up, the config page will too, and then a POST to the config page will just seem to hang in the browser. I also have a REST call that now also hangs. I sometimes get EPIC FAIL errors for pages that exist. The problem _may_ go away on its own but usually comes back very quickly. I have tried the trick of disabling the SD card the problem persists. It does not matter if I used DHCP or a static address, problem is still there. I may be able to make the REST call 5 times in a row and suddenly - no more responses. Unlike another post here, the lights on my ethernet jack are always on - that is I do not lose power or link state. I have also removed the TMP102 to make sure it was not something going wrong in the I2C bus. No change. When my sketch was < 22K, I never saw a single problem.

So I am here with a completed project, but so unstable that I cannot call it complete - besides code complete. Anyone has seen anything like this or has anyway to troubleshoot this?

BTW, if you use the wallwart to power the board, I cannot use the serial USB to debug the program - it will actually get the equivalent of the blue screen of death on my Mac (which I did not even ono existed). So how do you debug besides lots of recompiles and blinking a LED or something like that...

pylon

Quote
Anyone has seen anything like this or has anyway to troubleshoot this?


Lots of, in most cases it's a software failure, often caused by a RAM overflow. Show us your code. I guess it's not Webduino getting unstable but any part of the rest of the sketch.

Quote
BTW, if you use the wallwart to power the board, I cannot use the serial USB to debug the program - it will actually get the equivalent of the blue screen of death on my Mac (which I did not even ono existed). So how do you debug besides lots of recompiles and blinking a LED or something like that...


I never experienced something like that but I don't have a Mac. If your computer crashes it has nothing to do with your Arduino but only with your operating system or probably with the driver for the USB2Serial chip (FTDI). Do you have another USB2Serial which uses another driver (Arduino USB2Serial Light as an example)?

If you don't use the wallwart for powering the board, you don't experience crashes on your Mac? If powered by the wallwart, have you connected the 5V line of the FTDI cable to the Arduino? Try connecting just the other 4 pins (GND, RST, TX, RX).

stefdageek

Here's the code (a bit long). If you see some things that are not done the Arduino-way, please let me know. Still points out to some overflow somewhere. The code is pretty easy and benign. File is attached (too big to insert here). The code has been working all night unmodified except for a handful of static strings moved using the P() macro. No other changes made. Go figure...

Quote
I never experienced something like that but I don't have a Mac. If your computer crashes it has nothing to do with your Arduino but only with your operating system or probably with the driver for the USB2Serial chip (FTDI). Do you have another USB2Serial which uses another driver (Arduino USB2Serial Light as an example)?


For this one I am sure that it's the FTDI drivers for the MAC. More of a curiosity. I never that this nice polite little MAC would have a BSOD. It's prettier and in 8 languages - but still a BSOD.

Quote
If you don't use the wallwart for powering the board, you don't experience crashes on your Mac? If powered by the wallwart, have you connected the 5V line of the FTDI cable to the Arduino? Try connecting just the other 4 pins (GND, RST, TX, RX).

Good call on this one. I thought about it last night and will do this first thing this morning. Hope this fixes it - it's a pain not to have a way to debug a project...

Thanks for the help!!!

pylon

Although you have many string constants already in PROGMEM, you should put all you can there too, because they use your RAM and you don't have so much RAM (2kB).

Put all XXX.print() or XXX.println() with string constants in F() macros:

Code: [Select]
  server.print( "{\r\n \"name\" : \"" );

gets

Code: [Select]
  server.print( F("{\r\n \"name\" : \"") );

Think about every byte of RAM you can save. For example: Do you need a time server in your configuration? If yes, does it have to be a host name or is an IP address not more effective?

If you don't wanna ask these questions think about getting an Arduino Mega (has 8kB of RAM, four times the UNO's) and an Ethernet shield.

stefdageek

Thanks Pylon!

If the F() macro suitable to replace any type of static string in any call? For example strcpy() or strcmp()? Where can I find a lot more details on this and other tips on managing memory usage for the Arduino?

Again, I am changing all my code now...

pylon

Quote
If the F() macro suitable to replace any type of static string in any call?


No, only in objects inheriting from the Print class.

Quote
For example strcpy() or strcmp()?


No.

Quote
Where can I find a lot more details on this and other tips on managing memory usage for the Arduino?


http://www.arduino.cc/en/Reference/PROGMEM
http://www.arduino.cc/playground/Learning/Memory
... and of course the source code :)

stefdageek

Thanks Pylon.

Both suggestions worked.

Removing the +Vcc from the FTDI to the Arduino solved my serial debugging problem and I moved everything but the kitchen sink into Flash and no the app has been running flawlessly for the past hour...

Also reviewed the memory links you passed on. Knowledge is everything in the end... Well that coupled with some imagination...

Take care...

Go Up