GPS shield skipping seconds

I have just built a UNO together with a GP3906 shield from Sparkfun together with an OLED 1309 display and whilst all the functions work the timing is off.
By which I mean it sometimes misses the seonds every now and then. As you can see I'm using outputs for the last 5 seconds to light leds part of another project but even if I remove that part from the program it has no effect.
Could one of the many fine experts here shed any light on why this maybe happening please?

#include <U8glib.h>
U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
#include <TinyGPS++.h> // Include the TinyGPS++ library
TinyGPSPlus tinyGPS; // Create a TinyGPSPlus object
#define GPS_BAUD 9600 // GPS module baud rate. GP3906 defaults to 9600.
#include <SoftwareSerial.h>
#define ARDUINO_GPS_RX 7 // GPS TX, Arduino RX pin
#define ARDUINO_GPS_TX 6 // GPS RX, Arduino TX pin
SoftwareSerial ssGPS(ARDUINO_GPS_TX, ARDUINO_GPS_RX); // Create a SoftwareSerial
#define gpsPort ssGPS  
//#define SerialMonitor Serial
 int ledPin1 =  2;
 int ledPin2 =  3;
 int ledPin3 =  4;
 int ledPin4 =  5;
 int ledPin5 =  A0;
 int ledPin6 =  A1;
void setup()
{
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
//  SerialMonitor.begin(9600);
  gpsPort.begin(GPS_BAUD);
}
void titlepage() {  
 u8g.setFont(u8g_font_fub11);  
  u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. 
  u8g.drawStr( 0, 13, "Satellites:");
  u8g.drawStr( 0, 33, "Date:");
 u8g.drawStr( 0, 58, "Time:");
enum {BufSize=6}; // If a is short use a smaller number, eg 5 or 6 
char buf[BufSize];
snprintf (buf, BufSize, "%d", tinyGPS.satellites.value());
u8g.drawStr(84, 13, buf);
snprintf (buf, BufSize, "%02d", tinyGPS.date.day());
u8g.drawStr(42, 33, buf);
snprintf (buf, BufSize, "%02d", tinyGPS.date.month());
u8g.drawStr(64, 33, buf);
snprintf (buf, BufSize, "%02d", tinyGPS.date.year());
u8g.drawStr(90, 33, buf);
snprintf (buf, BufSize, "%02d", tinyGPS.time.hour());
u8g.drawStr(46, 58, buf);
snprintf (buf, BufSize, "%02d", tinyGPS.time.minute());
u8g.drawStr(68, 58, buf);
snprintf (buf, BufSize, "%02d", tinyGPS.time.second());
u8g.drawStr(90, 58, buf);
}
void leds(){
if ((tinyGPS.time.second())== 55)  {digitalWrite(2,HIGH);
} else {digitalWrite(2,LOW);}
if ((tinyGPS.time.second())== 56)  {digitalWrite(3,HIGH);
} else {digitalWrite(3,LOW);}
if ((tinyGPS.time.second())== 57)  {digitalWrite(4,HIGH);
} else {digitalWrite(4,LOW);}
if ((tinyGPS.time.second())== 58)  {digitalWrite(5,HIGH);
} else {digitalWrite(5,LOW);}
if ((tinyGPS.time.second())== 59)  {digitalWrite(A0,HIGH);
} else {digitalWrite(A0,LOW);}
if ((tinyGPS.time.second())== 00)  {digitalWrite(A1,HIGH);
} else {digitalWrite(A1,LOW);}  
}
void draw(){
  titlepage(); 
}
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
       while (gpsPort.available())
      tinyGPS.encode(gpsPort.read()); // Send it to the encode function
  } while (millis() - start < ms);}

void loop()
{
{  u8g.firstPage();   
   do { draw();
   }while(u8g.nextPage());
leds();   
   }
smartDelay(1000);
}

I will make a guess. You don't read the GPS in the main loop, and when you go off in the main loop to do other things, perhaps your GPS input buffer overflows. When you've got periodic data coming in , you must be set up to read it, thereby clearing the buffer. If you miss some reads, results can be unpredictable.

Good luck.

This is a common problem with those example programs... smartDelay isn't. As jrdoner said, timing issues are the problem.

Another problem is that library doesn't really know when one GPS interval stops and another begins. Your main loop should be synchronized with those intervals.

My NeoGPS library addresses those problems and more. It's much faster and smaller, and it is synchronized with the GPS interval. See the Troubleshooting page for more information.

I would also suggest using something that's more efficient than SoftwareSerial. AltSoftSerial is much better, but it only works on 2 specific pins. NeoSWSerial is next best.

Cheers,
/dev

jrdoner you hit the nail on the head yes the function smartDelay was not in the correct location in the program loop!

/dev fantastic library your NeoGPS has two super examples that have been integrated into my next project namely NMEABlink and NMEAcoherent thank you so much.

SoftwareSerial has been my go to program as it has allowed me to run this OLED display which already occupies the 8,9 pins and I simply moved to 6,7. But I do like the speed and size of your NeoSWSerial many thanks.

What a great forum this is!