GPS Clock Flickering Issue

Hi all,

Aim of the project
I am currently working on a GPS-based clock existing of a NEO-6M module and 4 Russian IV-6 vacuüm tubes. My goal is to multiplex the 4 tubes, giving me 4 digits: hours and minutes.

Status quo
At this moment of time the project is still in the breadboard phase to determine the feasibility of the concept. I have wired up a single tube to see if the GPS provides me with a digit derived from the GPS time data.

Problem description
As a mechanical engineer, my programming skills leave to be desired, but I'm trying. I am using the TinyGPS++ library as a basis and have written a sketch that has a single tube glowing and providing me a digit, horay! The problem is however that the tube flickers back to '0' for a split moment everytime the GPS module updates.

Possible solution
I have been tinkering with the code for quite some time now, but I can't seem to find out why the code delays for that split moment. I think there has to be a rearrangement of the code somehow.

Another solution that came to mind is to write a conditional value to the display tube that changes as soon as the GPS-read value changes. I am however quite unsure on how to rewrite my code to achieve this. That's why I would like to reach out to you guys for sume guidance.

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <SegmentDisplay_CD4511B.h>

// Choose two Arduino pins to use for software serial
int RXPin = 2;
int TXPin = 3;

int GPSBaud = 9600;

//int hourTens;
//int hourUnits;
//int minuteTens;
//int minuteUnits;

// Create a TinyGPS++ object
TinyGPSPlus gps;

// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);

SegmentDisplay_CD4511B displayDriver(8, 5, 6, 7, 2);

/*------------------------------------------------------------------------------*/


void setup()
{
  // Start the Arduino hardware serial port at 9600 baud
  Serial.begin(9600);

  // Start the software serial port at the GPS's default baud
  gpsSerial.begin(GPSBaud);
}

void loop()
{

  while (gpsSerial.available() > 0)
  {
    if (gps.encode(gpsSerial.read()))
    {
      displayInfo();
    }

    // If 5000 milliseconds pass and there are no characters coming in
    // over the software serial port, show a "No GPS detected" error
    if (millis() > 5000 && gps.charsProcessed() < 10)
    {
      Serial.println("No GPS detected");
      while (true);
    }
  }
}
/*------------------------------DEBUG------------------------------------------*/

void displayInfo()
{

  if (gps.time.isValid())
  {
    Serial.println(); //Enter tussen de regels

    Serial.print("Hour tens");
    Serial.print(" = ");
    Serial.println((gps.time.hour() + 1) / 10 % 10);
    Serial.print("Hour units");
    Serial.print(" = ");
    Serial.print((gps.time.hour() + 1) % 10);

    Serial.println(); //Enter tussen de regels

    Serial.print("Minute tens");
    Serial.print(" = ");
    Serial.println(gps.time.minute() / 10 % 10);
    Serial.print("Minute units");
    Serial.print(" = ");
    Serial.println(gps.time.minute() % 10);

    Serial.println(); //Enter tussen de regels

    /*------------------------------SPLITS GETALLEN---------------------------------*/

    int hourTens = ((gps.time.hour() + 1) / 10 % 10);
    int hourUnits = ((gps.time.hour() + 1) % 10);
    int minuteTens = (gps.time.minute() / 10 % 10);
    int minuteUnits = (gps.time.minute() % 10);

    /*---------------------------------CD4511B-------------------------------------*/

    //displayDriver.showNumber(hourTens);
    //delay(5);
    //displayDriver.showNumber(hourUnits);
    //delay(5);
    //displayDriver.showNumber(minuteTens);
    //delay(5);
    displayDriver.showNumber(minuteUnits);
    //delay(5);

    /*------------------------------------------------------------------------------*/

  }
  else
  {
    Serial.println("Not Available");
  }

  //delay(1000);
}

As soon as the GPS time becomes valid, you "serial.print" a lot of information at a very slow Baud rate (9600), then update the display. Don't do those prints at all, or increase the Baud rate to something sensible, like 115200.

To avoid flicker, the display should be updated at a constant rate, but no faster than necessary, say 30 times per second. To learn how to do that, study the Blink Without Delay example, which uses the built in milliseconds clock.

Your GPS module may get a signal near a window but they don't generally function well indoors. I'm not sure how well it will keep time if it can't see satellites.

jremington:
As soon as the GPS time becomes valid, you "serial.print" a lot of information at a very slow Baud rate (9600), then update the display.

Don't do those slow prints.

I didn't realize. Thanks!

wildbill:
Your GPS module may get a signal near a window but they don't generally function well indoors. I'm not sure how well it will keep time if it can't see satellites.

Very true indeed! The clock is placed near a window in my living room. So far, so good.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.