Close

Hardware Design

A project log for SynchroClock

NTP Synchronized Analog Clock

liebmanliebman 09/16/2017 at 14:200 Comments

  I ran a number of experiments both attempting to directly drive the clock from micro-controller I/O pins and using an H-bridge type circuits.  Testing driving directly meant using 3.3v or 5v depending on what micro-controller I was using at the time and I was concerned with using two much power since this was designed to be used with a 1.5v battery.  I found a small low power motor controller (DRV8838) that supported motor voltages including 1.5v and decided to use that.

   To control the DRV8838 I chose an ATTiny85 to manage ticking the clock as its small, fairly low power, has an internal oscillator,  and has exactly enough I/O pins when the reset pin is converted to an I/O pin.  We need six I/O lines; three to control the DRV8838, one to receive the 1Hz signal for ticking and two for i2c communication.

   I selected a DS3231 as a Real Time Clock (RTC) as its low power, has integrated temperature compensated crystal oscillator, supports a 1Hz square wave output, and has an i2c interface.

   I chose an ESP8266 as the main controller to manage configuration and NTP synchronization as its a really cheap wifi module with a flash-able micro-controler and multiple I/O pins.

   The way this works is that the ESP8266 wakes up at a configurable interval and makes a NTP request, if the computed offset is more than a threshold, I’m using 20ms currently, the RTC is updated using a method that aligns its second boundary to where NTP says it should be. The RTC is configured to output a square wave at 1Hz with the falling edge being the second boundary.  This is connected to one of the ATTiny85’s interrupt pins and configured to interrupt on the falling edge waking the the ATTiny85 from sleep to tick the clock each second.

   I assembled this on a solder less breadboard for testing and initial software development.  In this early version I was using an Arduino Nano in place of the ATTiny85 for convenience.

Discussions