One Hertz Challenge

This project began around 1790 with someone in England  sawing and filing on sheet brass  After considerable effort and skill, gears and a frame emerged from the sheet.  More effort and skill created the works for a long case clock.   A 39" pendulum was attached and the clock became eligible for the one hertz challenge.  Sort of.  Heinrich Hertz wouldn’t be born for another 67 years, so it was the one cps challenge.  

A long pendulum is more accurate than a short one.  Thus long case clocks were the accuracy champions of their era.  We call them grandfather clocks these days, but that didn’t happen until the song was written in 1876.

This clock has had a hard life.  At some point its case was lost or irreparably damaged.  A common practice was to create a wag-on-the-wall.  The works were attached to a bracket and hung on the wall where it continued marking time.  So it was with this one on the wall of my dad’s house.   I inherited it from him 20 years ago and it sat in a closet until a couple of weeks ago when I realized the One Hertz Challenge was an excuse to do something I’ve thought about for years.  

While long cases were the accuracy champs of 1790, they are not so good by modern standards — plus or minus a few minutes a week.  A few bucks worth of parts, some software and it can recover past glory — atomic clock accuracy over long periods while synced to NTP.  Why not?

The first rule of old clocks is that changes must be reversible. Don't drill any holes or permanently attach modern hardware.  So a 3D printed bracket rests on top of the works.  An arm extends down behind the pendulum holding a clip that slides up and down the spring that holds the pendulum, changing the pendulum’s length and the timing of the clock.

A NEMA 9 stepper motor attached to a 10-32 machine screw moves the clip.  The stepper has 400 steps per revolution.  1/32" linear movement per revolution gives ridiculous clip precision of   0.000156" per step.  A DRV8833 dual H-bridge drives the stepper, an ESP32C3 runs the H-bridge, the PID controller, an NTP client, and serves a web page for monitoring and control.  

A piezo sensor taped to the clock's back plate provides the pendulum timing.  The sensor is connected to a dual op-amp.  One section of the op-amp amplifies the piezo signal 47 times.  The other section is a Schmitt trigger providing a clean pulse to the ESP32C3.  The circuit is shown below.  This is well outside my expertise, but Gemini made it possible.

Software

The software is written in MicroPython and runs on the ESP32C3.  It was developed in collaboration with Gemini AI.  I started programming in the 1960’s.  Mostly in assembly language but sometimes in hex or octal.  Since then, I’ve climbed through Fortran, C, C++, Smalltalk, and more to progressively higher levels of abstraction.  

AI is the highest level yet.  I can write “I’d like a MicroPython program for the ESP32C3 that uses NTP to adjust the time of a long case clock.  There is a sensor on GPIO 10 that ticks with each pendulum swing and a stepper motor on GPIO 2-5 that changes the pendulum length”.

I get a fully formed program back.  It took a couple of hours of back and forth to get details right, add some features,  and shake out some bugs,   I still needed to dive into the code to chase bugs or confirm function. But coding directly might have taken a week or so. One caution: if the chat gets too long, Gemini starts making silly errors.  Little syntax errors, leaving code out, just general confusion.  I get the last good files and use them to start a new chat.

There are three MicroPython modules and one html module.  main.py implements the core functions.  It counts the pendulum swings. ...

Read more »