Show Posts
Pages: 1 [2] 3
16  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 21, 2013, 06:31:06 am
15 - 20 mS still seems like a large error to me.  There are allot of internal registers in the chronodot, so maybe with library overhead it takes that long to get the stuff written.  Maybe the library will let you set only the seconds alone which should be a lot faster to do.  You could do the slow call to set everything and then sync the second on a subsequent GPS edge.  I don't see why you can't get the error to less than 1mS.

I would agree with you. I'm going to look into the library and copy out some of the code and modify it for my own time sync.

Ok, on the GPS rising edge, that agrees with what I saw out there.  Do you find that the chronodot is making a falling edge when the GPS is doing a rising edge?
I setup my interrupts for the Chronodot and the GPS with this:
Code:
  attachInterrupt(1, pps_interrupt, RISING);
  attachInterrupt(0, rtc_interrupt, FALLING);
and the time from both looks to be in sync.

How are you measuring the sync accuracy, do you have a scope?

Am not using a scope. Do not have one.  In each of my interrupts I keep track of micros() and I just subtracted the 2 numbers to see the difference between the 2 interrupts.
Code:
void rtc_interrupt(){
  rtc_micros = micros();
  if(sqw_led_state){
    sqw_led_state = false;
  }
  else{
    sqw_led_state = true;
  }
  digitalWrite(SQW_LED, sqw_led_state);
}
17  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 20, 2013, 10:31:28 pm
I tried a different library and that worked.  I don't know what was going on with the one I was using.  I have the 2 clocks synced to within 15-20ms.  Pretty good.

I'm going to try and copy over some of the code from the library into my own sketch so I better understand exactly what it is doing.  I'll post my code later to show how I synced the 2 clocks.

For future reference, it seems like the GPS pulse rising is the start of a new second.
18  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 20, 2013, 11:30:11 am
You need to look at the GPS datasheet and verify which edge you should be looking at.  Some GPS modules put out a relatively narrow pulse so if you looked at the wrong edge, you could be as much as 999+mS in error.  The minimum error you would face by looking at the wrong edge of the GPS PPS signal is 500mS assuming a 50% duty cycle.  The time signal provided by a GPS receiver is going to be the most accurate time signal you are likely to ever encounter in every day life.  With satellite lock, it's not going to be off by even 1uS, much less a large fraction of a second.  It should take less than 1mS to set the clock in the chronodot so you should be that well aligned.

The MSB of the seconds register acts as an oscillator control bit.  If it is set, the oscillator is off.  The factory default in the chip is for the bit to be set when the device first powers up.  If you don't have a backup battery installed, your chip likely powers up with the oscillator off every time.

Don't automatically expect that because the falling edge is important to the clock chip that it is also the important edge coming out of your GPS module's PPS output.  That may not be the case.

The DS1307 is sensitive to noise pickup on the crystal if the case is not grounded.  It can also pick up environmental noise adding significant error to its timekeeping ability.  The added noise generally makes the clock gain time as the internal ripple counter is seeing extra clock ticks.  I assume that the chronodot has the same potential problems, but I have never used on.  The chronodot is supposed to be very accurate.  If you are seeing drift that results in things being visually out of sync after only a few minutes or noticing that it is not keeping time well, then you have a noise pickup problem.  For example, picking up 60HZ AC noise will add 2-3 minutes per day.

I'm using the Adafruit GPS http://www.adafruit.com/products/746
Datasheet http://www.adafruit.com/datasheets/GlobalTop-FGPMMOPA6H-Datasheet-V0A.pdf

"A pulse per second (1 PPS) is an electrical signal that very precisely indicates the start of a second. Depending on the source, properly operating PPS signals have typical accuracy ranging 10ns"

I didn't see anything in the datasheet about if it is rising or falling or what the pulse width is.  I assumed rising is a new second.
19  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 20, 2013, 10:32:12 am
Ok, I guess I'll have to look at the RTC library I'm using and see if it is turning off the oscillator.  Maybe that's why it is never in sync.

The interrupt I'm using is when the PPS pulse from the GPS goes high.  The GPS PPS seems to be accurate (at least to my eyes).  I've compared it to other atomic clocks I have and it looks to be pulsing right at the second and doesn't skip a beat.

Here is a bit of my code, where I use the interrupt from the GPS PPS and RTC SQW to light up 2 LEDs (to visually see if the clocks are in sync).  When I set the time in my loop, they are never in sync.  I'll try and look through the RTC library code tonight and post what it's doing.

Code:
const int PPS_LED = 13;  //pin 13
const int SQW_LED = 11;  //pin 11
const int SQW_PIN = 2;
const int PPS_PIN = 3;
volatile boolean pps_led_state = true;
volatile boolean sqw_led_state = true;

void setup () {
  pinMode(SQW_LED, OUTPUT);
  pinMode(PPS_LED, OUTPUT);
  pinMode(PPS_PIN, INPUT);
  pinMode(SQW_PIN, INPUT);
  digitalWrite(PPS_LED, LOW);
  digitalWrite(SQW_LED, LOW);
  attachInterrupt(1, pps_interrupt, RISING);
  attachInterrupt(0, rtc_interrupt, FALLING);
}

void pps_interrupt(){
  if(pps_led_state){
    pps_led_state = false;
  }
  else{
    pps_led_state = true;
  }
  digitalWrite(PPS_LED, pps_led_state);
}

void rtc_interrupt(){
  if(sqw_led_state){
    sqw_led_state = false;
  }
  else{
    sqw_led_state = true;
  }
  digitalWrite(SQW_LED, sqw_led_state);
}
20  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 19, 2013, 10:46:59 pm
Maybe I'm not doing something right with my code.  Currently I have my Interrupt from the GPS PPS pulse trigger setting the Chronodot, but when I compare the time between the two after it is set, they are never synced.  If I reset the sketch multiple times, they time they are out of sync is never the same.  It seems like the 500ms delay that is listed in the datasheet is not consistent.
21  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 19, 2013, 04:58:57 pm
Is the falling edge of the Chronodot's 1hz square wave when the clock ticks over a new second?  or is that on the rising edge?
22  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 19, 2013, 08:02:38 am
It's simpler than that. When the pulse from the GPS occurs, get the time from the GPS, set the RTC with RTC.set() and the system time with setTime(). The falling edge of the 1Hz signal from the RTC should then be synchronized with the pulse from the GPS.

Be sure to call setSyncProvider() in setup() to keep the system time in sync with the RTC time.

Being naive here, Is the pulse width from the RTC 500ms?
23  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 18, 2013, 10:19:48 pm
Ok,  so it seems like I need to keep track of the number of mills from when the PPS goes off and then count up 500 mills and then set the time.

I'll try and write up a simple sketch to test it out.  Thanks!
24  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 18, 2013, 09:51:43 pm
Hmm... ok.  I guess I'll have to rethink how I setup my project.  My goal was to sync the Chronodot's clock to an interrupt set off by the pulse from the PPS pin of the Ultimate GPS.

Right now I get the time from the GPS and set the time on the Arduino (using time.h library) and on the Chronodot (using DS1307RTC.h library) once the interrupt goes off.   The time on the Arduino seems to be in sync with the GPS, for a while anyway until it drifts.  But, it looks like the Chronodot and the GPS are not synced (to within less than a second)  My hope was to sync the Chronodot to less than 50 milliseconds of the GPS.
25  Using Arduino / General Electronics / Chronodot - Sync 1hz square wave? on: March 18, 2013, 01:29:06 pm
Is it possible to sync the 1hz square wave of the Chronodot to an interrupt or button press?  So that the square wave is in exact sync.

I'm working on a clock project and would like to sync the Chronodot's RTC to the exact time an interrupt goes off or the exact time someone presses a button (after setting the time into some variables).
26  Using Arduino / Networking, Protocols, and Devices / Re: Adafruit Ultimate GPS - How do I use PPS to trigger interrupt? on: March 18, 2013, 07:40:41 am
attachInterrupt(1, pps_interrupt, RISING);

Does the above not do that already?
I used this http://arduino.cc/en/Reference/AttachInterrupt as my reference. I didn't see any code in their example that calls out pinMode(3,INPUT); for using Interrupt 1.

Edit:
I do have
pinMode(PPS_PIN, INPUT);
in my project code.  I just failed to include that when I posted it in my original message.
27  Using Arduino / Networking, Protocols, and Devices / Re: Adafruit Ultimate GPS - How do I use PPS to trigger interrupt? on: March 17, 2013, 10:24:45 pm
I'll try that out and see if it works.  Thanks for the suggestion.
28  Using Arduino / Project Guidance / Re: 6 digit 7 Segment display - TPIC6B595 schematic component? on: March 17, 2013, 11:10:49 am
I'm having trouble using the PPS on the GPS unit to trigger an interrupt.  I posted a new question here: http://arduino.cc/forum/index.php/topic,154776.0.html  if anyone wants to follow along/help.
29  Using Arduino / Networking, Protocols, and Devices / Adafruit Ultimate GPS - How do I use PPS to trigger interrupt? on: March 17, 2013, 11:05:38 am
I need some help with using the PPS on the Ultimate GPS.

I have the PPS pin from the GPS hooked to digital pin 3 on my Arduino Uno (which is interrupt 1, correct?).  I want to turn on a LED that I have hooked to digital pin 13.  I have the following code running on my sketch, but the LED does not turn on and off at 1 second intervals.  The LED flickers on and off (and somewhat erratic). It seems somewhat timed to 1 second intervals, but not always.

Is there something I need to do to use the PPS?  Like pull up/down resistors?

Code:
boolean pps_led_state = true;
int  PPS_LED = 13;

void setup () {
  pinMode(PPS_LED, OUTPUT);
  digitalWrite(PPS_LED, LOW);

  attachInterrupt(1, pps_interrupt, RISING);
}

void loop () {

}

void pps_interrupt(){
  if(pps_led_state){
    pps_led_state = false;
  }
  else{
    pps_led_state = true;
  }

  digitalWrite(PPS_LED, pps_led_state);
}

This is the datasheet for the GPS http://www.adafruit.com/datasheets/GlobalTop-FGPMMOPA6H-Datasheet-V0A.pdf
GPS in question http://learn.adafruit.com/adafruit-ultimate-gps
30  Using Arduino / Project Guidance / Re: 6 digit 7 Segment display - TPIC6B595 schematic component? on: March 13, 2013, 08:05:44 pm
I added a 16V 1000uF electrolytic polarized capacitor to the power going into the LCD screen.  Didn't change the flickering.  It seems to flicker whenever it is refreshed.  I played around with the code some and only have it refresh every 10 seconds.  When it is just static there is no flickering.  (also, the flickering seems to be coming from the LEDs that act as the backlight)

The only things I can think of that would be the cause of the flickering are: power or cheap LCD.  smiley-confuse Could the Arduino not be able to deliver enough current to the screen when it refreshes?  The datasheet says it typically draws 250mA. (doesn't give a min or max, just typical)

The other thing I noticed is that the time displayed on my 7 segment display is slow by about 1/2 to 3/4 of a second. (I compared it to a SkyScan atomic clock and an online clock) I don't need my clock to be crazy accurate, but 1/2 to 3/4 of a second is off too much.  Could it be taking this long for the GPS to send the NEMA data to the Arduino, have the Arduino parse it out, then use it to set the time?  Would the update go any faster if the GPS was hooked into the hardware serial pins 0 & 1 TX/RX?

I did a simple test and hooked up the PPS signal wire to a teeny tiny speaker and could hear the pulses every second.  They matched exactly (as best my ears could tell) to the seconds from both of my clocks.  So, I think a plan would be to have the Arduino listen to and count the pulses and use that to sync for the clock.  Unless anyone has suggestions.  I'm all ears.  smiley
Pages: 1 [2] 3