Hydra Real time clock

Hi,

I managed running the RTC of the hydra board bei soldering the crystal and replacing the C21/C22 to 10 pF matching my crystal.

I did some experiments with a 5.5F goldcap for buffering the RTC. I connected him over a 1.2k resitor to pin 5 of socket 1 to charge him with about 1mA when hydra is powered. Without the resistor the board will not boot if the capacitor is discharged. Charging takes very long, so I precharged the capacitor to 1.2V with a external power supply. I can measure about 1.135V at pin 5 of socket 1, so the RTC is running. For my application I only need a short buffer of RTC, so the goldcap is a good solution for (2$) soldered under a extender board. Additional I will replace the 1N4148 through a shottky diode to get higher voltage for the goldcap chargingā€¦

Bored of setting the RTC during programming I found the following code to get network tiome from a time server. Works fine, so I can synchronize the RTC when bootingā€¦

   public static DateTime GetNetworkTime()
        {
            const string ntpServer = "pool.ntp.org";
            var ntpData = new byte[48];
            ntpData[0] = 0x1B; //LeapIndicator = 0 (no warning), VersionNum = 3 (IPv4 only), Mode = 3 (Client Mode)

            var addresses = Dns.GetHostEntry(ntpServer).AddressList;
            var ipEndPoint = new IPEndPoint(addresses[0], 123);
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            socket.Connect(ipEndPoint);
            socket.Send(ntpData);
            socket.Receive(ntpData);
            socket.Close();

            ulong intPart = (ulong)ntpData[40] << 24 | (ulong)ntpData[41] << 16 | (ulong)ntpData[42] << 8 | (ulong)ntpData[43];
            ulong fractPart = (ulong)ntpData[44] << 24 | (ulong)ntpData[45] << 16 | (ulong)ntpData[46] << 8 | (ulong)ntpData[47];

            var milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000L);
            var networkDateTime = (new DateTime(1900, 1, 1)).AddMilliseconds((long)milliseconds);

            return networkDateTime;

:smiley:

Miro thanks for the reply. We donā€™t have access to the web for our application though, so getting network time is not an option.

I learned something recently that I wanted to share:
A crystalā€™s defined ā€œload capacitanceā€ represents the entire load. Not just the value of each capacitors in the RTC circuit.

If the capacitors are defined as C1 and C2:
Cload = (C1 x C2) / (C1 + C2) + Cstray
where Csrtay is the capacitance of the board/traces. Typically, one can assume 5
pF - 6 pF for CStray in the equation above.

So for a 27pF crystal you would want to use 39pF capacitors
Cload = (39 * 39) / (39+39) +5pF = (1521/78) + 5pF = 19.5pF +5pF = 26.5pF

Hi Luke,

thanks for this information.

I did some runs over night and wondered that the RTC clock is drifting over 20 seconds in 8 hours. At the moment Iā€™m working with the normal clock and this is very accurate. I will synchronize it every day with internet time if neccessary.

If your RTC is running, please share your experiences about the stability of the RTC.

Another option will be the DCF77 time in Europe, there are cheap boards for under 10 bucks. I think I will use this if the receiption is possible in my heating room where the application is running.

Here is the first image of my project, a data logger for my house heating. At the moment Iā€™m logging the first values at the T43 display. Data will be stored on ad card and sent by mail over nightā€¦

Here is what I have learned:

The frequency will change with respect to temperature, it will drift over time and there is a
basic production accuracy that is characterized by the manufacturer.

Frequency Stability Over Temperature
Frequency Deviation Over Time (Aging)
Frequency Tolerance at 25 deg C

The crystal must have a total accuracy of better than +/- 50 PPM (add those 3 together).

The correct load capacitor values are very important for circuit accuracy. By slightly adjusting these capacitors, the designer can effectively ā€œtuneā€ the crystal circuit for the exact frequency required. The two load capacitors should always be the same value in order to guarantee that the crystal circuit is balanced.

I donā€™t know how to tune the crystal though with the cap values.

Reading through this thread and not finding the absolute best crystal model number for rtc q1 soldering.

Anyone with the most precise matching crystal?