GPS clock skipping seconds on 7 segment display

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
heroant
 
Posts: 1
Joined: Sun Jan 13, 2013 12:40 am

GPS clock skipping seconds on 7 segment display

Post by heroant »

Hello
I'm using the Adafruit ultimate GPS Breakout and a 7 segment display Adafruit Backpack
and when I write the seconds to the display it skips every other second also the colon on the display pauses

here is the code, it's almost like the one on the gps-clock example, i just changed it to display minutes and seconds.
I'm not sure if it can be fixed or it's how the gps searches for signal and it causes to pause the display.
thanks in advance for the help.

Code: Select all

------------------------------------------------------------------------------------------------
// Written by Tony DiCola for Adafruit Industries.
// Released under a MIT license: https://opensource.org/licenses/MIT
#include <SoftwareSerial.h>
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "Adafruit_GPS.h"


// Set to false to display time in 12 hour format, or true to use 24 hour:
#define TIME_24_HOUR      false
#define HOUR_OFFSET       -5
// I2C address of the display.  Stick with the default address of 0x70
// unless you've changed the address jumpers on the back of the display.
#define DISPLAY_ADDRESS   0x70


// Create display and GPS objects.  These are global variables that can be accessed from both the setup and loop function below.
Adafruit_7segment clockDisplay = Adafruit_7segment();

SoftwareSerial gpsSerial(8, 7);  // GPS breakout/shield will use a 
                                 // software serial connection with 
                                 // TX = pin 8 and RX = pin 7.
Adafruit_GPS gps(&gpsSerial);


void setup()
{
  // Setup function runs once at startup to initialize the display and GPS.
  // Setup Serial port to print debug output.
  //Serial.begin(115200);
  //Serial.println("Clock starting!");

  // Setup the display.
  clockDisplay.begin(DISPLAY_ADDRESS);

  
  // Setup the GPS using a 9600 baud connection (the default for most
  // GPS modules).
  gps.begin(9600);
  gps.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);// Configure GPS to onlu output minimum data (location, time, fix).
  gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);// Use a 1 hz, once a second, update rate.
  enableGPSInterrupt();// Enable the interrupt to parse GPS data.
}

void loop()  // Loop function runs over and over again to implement the clock logic.
{
  // Check if GPS has new data and parse it.
  if (gps.newNMEAreceived()) 
    {
     gps.parse(gps.lastNMEA());
    } 
  int displayValue = gps.minute*100 + gps.seconds;


  // Now print the time value to the display.
  clockDisplay.print(displayValue, DEC);

  
  // Add zero padding when in 24 hour mode and it's midnight.
  // In this case the print function above won't have leading 0's
  // which can look confusing.  Go in and explicitly add these zeros.
 
    if (gps.minute < 10) 
      {
       clockDisplay.writeDigitNum(0, 0);
      }
      if (gps.seconds < 10) 
      {
       clockDisplay.writeDigitNum(3, 0);
      }
  
  clockDisplay.drawColon(gps.seconds % 2 == 0);
  clockDisplay.writeDisplay();// Now push out to the display the new values that were set above.
  // Loop code is finished, it will jump back to the start of the loop
  // function again! Don't add any delays because the parsing needs to 
  // happen all the time!
}

SIGNAL(TIMER0_COMPA_vect) {
  // Use a timer interrupt once a millisecond to check for new GPS data.
  // This piggybacks on Arduino's internal clock timer for the millis()
  // function.
  gps.read();
}

void enableGPSInterrupt() {
  // Function to enable the timer interrupt that will parse GPS data.
  // Timer0 is already used for millis() - we'll just interrupt somewhere
  // in the middle and call the "Compare A" function above
  OCR0A = 0xAF;
  TIMSK0 |= _BV(OCIE0A);
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: GPS clock skipping seconds on 7 segment display

Post by adafruit_support_rick »

I don't see anything wrong with your code. I think you have a wiring problem that is corrupting the data from the GPS. Post some pictures of your wiring and soldering

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”