Serial.println statements just 'disappear'

Hi,

Apologies if this is a known problem but I did a quick search and couldn't find any hits.

I've got a reasonably large program (around 8k compiled) that is exhibiting strange behaviour when I issue Serial.println statements for debugging purposes. What seems to be happening is that some (not all) statements do not appear on my Serial Monitor within the Arduino IDE. Instead, all I get is the newline char, not the string that I really wanted to see. When I print numeric data, e.g. Serial.println(someIntVal, DEC) then the value seems to display, but if I issue something like Serial.println("Here is a debug statement"); then all I get (sometimes) is a blank line or a null line appearing in my Serial Monitor display. I've tried various alternatives such as reducing the baud rate from 9600 to 4800 and also trying to see if the X-CTU tool from maxstream faired any better, but nothing seems to fix the problem. I've also broken up my program into a number of libraries that are driven by a smaller base program but this had no effect on the problem. I am beginning to wonder if the problem lies with the interface between my computer (IBM T60p) and the Decimilia board which is using the USB to serial cable. Unfortunately, the laptop doesn't have a dedicated serial port, so I'm pretty restricted to how I interact with the Arduino, unless I switch computers.

As you can imagine, this is a very frustrating problem and one I would love to nail. Anyone else seen this sort of behaviour and got any ideas on what might be causing it...and more importantly, how to avoid it?

Thanks for your help.

Mike

Hi Mike, try writing a little test sketch to see if you can output some dummy strings without the main body of code, you may be running out of RAM.

I second the running out of RAM suspicion.

-j

I find that Serial.println statements often don't appear in the IDE window. It's just how you describe--you get a newline but no text. Now try expanding the serial window by dragging it upward--voila, the missing text appears, so the data is there, it just isn't being displayed. I guess it's some bug in the IDE related to scrolling. If you expand the window ahead of time, the text will come out OK until it reaches the bottom. This is with the 0011 release, a Diecimila and a Vista laptop.

Thanks for the feedback. I'm pretty sure the problem is not with my IDE window, but I had never even considered running out of RAM.

This opens up a whole new 'can of worms' that I'd not even thought about!! I had naively assumed that I had plenty of memory left, due to the program being only just over half the size of available memory. But of course, this is only the loaded image, and does not include dynamic memory use by the program for variable allocation and stack data etc.

Hmmm, well if this is the cause of the problem, and I must admit it only began to occur as my program size got larger, then I guess I'll need to reconsider a restructure of the program.

On the subject of insufficient RAM, is there some way I can query the available memory from within my application? I suspect this will not be a simple thing to do, but it would be good to see how the memory shrinks/grows as my program executes.

There is a function here http://www.arduino.cc/playground/Code/AvailableMemory that returns the amount of free ram.