This last example demonstrates how to calibrate the RV-8803's oscillator using the Clock Output pin. Again, we first initialize the RV-8803 on the I C bus.
Next, we zero out any calibration settings that may be present and set the clock output to a 1 Hz square wave:
rtc.disableAllInterrupts();
rtc.setCalibrationOffset(0); //Zero out any calibration settings we may have
rtc.setPeriodicTimeUpdateFrequency(CLOCK_OUT_FREQUENCY_1_HZ); //Set our clockout to a 1 Hz square wave,
rtc.enableHardwareInterrupt(UPDATE_INTERRUPT); //Enable the interrupt
Next, we'll use our oscilloscope or logic analyzer to look at exactly how precise the 1 HZ square wave is (It could be off by a few microseconds, which
can add up over time). In order to do this, you'll need to time the output of the INT pin. Once you have the RTC's output frequency measured carefully,
go ahead and replace the "dummy" frequency that we've put in the example by default (1.0000012 Hz) with the one that you've just measured. We then
take the difference between this measured frequency and the desired 1 Hz clock signal, and multiply it by 1,000,000 to get the Parts Per Million (PPM)
offset that we must give to our oscillator.
float measuredFrequency = 1.0000012; //Measured frequency in Hz (CHANGE THIS TO YOUR MEASURED VALUE)
float newPPM = (measuredFrequency - 1) * 1000000; //Calculate PPM difference between measuredFrequency and our desired 1 Hz wave
Once we've replaced our measuredFrequency , we can uncomment the below line that actually places this new setting into the RTC to change the offset
for the crystal. Make sure you don't do this until you've changed your measuredFrequency . From here, you should be able to upload code and see the
square wave oscillator closer to a perfect 1 Hz. If not, recomment the below line, upload, and try again.
//rtc.setCalibrationOffset(newPPM); //Uncomment this line after you have changed the value of measuredFrequency to load the new c
alibration into the RTC
Using the USB Logic Analyzer with sigrok PulseView
JUNE 25, 2018
A quick primer on using the sigrok signal analysis software with our 8-channel,
24MHz USB logic analyzer.