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.
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.
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?
How are you measuring the sync accuracy, do you have a scope?
afremont:
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.
afremont:
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:
afremont:
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.
I have a ds3231 SQW-Pin an a GPS PPS-Pin attached to a atmega avr1284p. How do i Sync the rtc 1HZ SQW Output to the PPS from gps.? I want to have the falling Edge of the rtc SQW to Trigger exactly on the rising edge of the PPS Signal from GPS. What is the best way/Code to do this? Thank you very much!
johnhuebbe:
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).
Alternatively just record the discrepancy in a variable and regenerate a correctly timed pulse using a timer?