0

I don't understand why in my program, some lines of output to the Serial log are fine, whereas some never seem to output.

For some reason, one of the labels never gets written out. I experimented with shifting the println statements and then a different label gets ignored. I don't see any difference between the lines that work and those that don't.

In my file at https://gist.github.com/ledlogic/726ec7105ee5cc41f3cd

The first few two labels work, but not the Latitude label.

  ...

  Serial.print("UTC Time(HHMMSS): ");
  Serial.print(time);    // Time returns the UTC time (GMT) in HHMMSS, 24 huor format (H-Hour; M-Minute; S-Second)
  Serial.println("");
  Serial.println("");

  Serial.print("Latitude: ");
  Serial.print(lat, 6);    // Latitude - in DD.MMSSSS format (decimal-degrees format)  (D-Degree; M-Minute; S-Second)
  Serial.println("");
  Serial.println("");

  ...

Output from Serial Monitor (9600 baud) / privatized:

  UTC Date(DDMMYY): 10814

  UTC Time(HHMMSS): 131539

  44.9*****

  Longitude: -92.5*****

Perhaps you'll see an obvious no-no I just don't know yet for Arduino code.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
ledlogic
  • 774
  • 1
  • 9
  • 19
  • try commenting out the remainder. From the "File LogFile ... and all the prints after that to the delay(1000);. Note that Serial.print fills a buffer and then is interrupt driven to send the bytes. I ponder if the SD functions are blocking and or dumping buffers. – mpflaga Aug 01 '14 at 13:48
  • Are you using the SD card in interrupt-driven mode? – Greycon Aug 01 '14 at 14:22
  • Adding F() around the serial labels seemed to show them 100% of the time now. As far as interrupt mode, I don't think so, all SD card methods are only being called in the main loop, unless there is something it is doing on its own in the SD library. – ledlogic Aug 02 '14 at 13:48

1 Answers1

2

Lost prints often are caused from running out of RAM. Especially when they are position dependent. (See this here)

#include <MemoryFree.h>; 

and place the following in the setup.

Serial.println(F("Free RAM = ")); //F function does the same and is now a built in library, in IDE > 1.0.0
Serial.println(freeMemory(), DEC);  // print how much RAM is available, at this specific moment.

I am suspicious that dGPS.h and along with SD.h are maxing you out.

Community
  • 1
  • 1
mpflaga
  • 2,807
  • 2
  • 15
  • 19
  • Is this the library you are using - https://github.com/sudar/MemoryFree? My Arduino 1.5.7 did not come with MemoryFree so I get a compilation error. – ledlogic Aug 02 '14 at 13:31
  • I wrapped all my labels with the F() function and now I can see them all. I keep getting 384 bytes available - I might try trimming the GPS library down to just what I need - it has some extra methods I don't care about. Thanks!!! – ledlogic Aug 02 '14 at 13:43
  • Definitely running out of ram. 300 at setup. Leaves little to work with when the code starts using up the heap. Note the compile has garbage collection on to remove unused code. Where global variables will consume and not be removed if unused. – mpflaga Aug 02 '14 at 16:01