Pico 2W providing time for my Office Clocks
Having used these clocks for the past five or so years it has shown me that they were not very good time keepers. The original Main clock which provides the time for all the others runs about one and a half minutes fast a week so I tend to correct them every couple of weeks. When they were in service they must have needed correcting daily..
The clocks work by having a main module that generates the time and then sends it serially to the other clock (TD) display modules, this keeps them all syncronised. The transmission is over a differential pair using a 75113 driver chip and the time message is sent in the same format we used for train descriptions c1980/90's - four characters compressed into three eight bit messages. Each character only requires six bits to describe the ASCII standard alpha numeric characters.
So my intention is to use a Raspberry Pi Pico 2W to do the time keeping and transmission to the clock modules. The 8748 Microcontroller currently providing this function will return to being a simple display module with a Pico module replacing the piggy back daughter board on the main clock. See my workshop clocks page from 2021.

But first I need to get samples of the serial data leaving the 8748 micro controller. I set up the original clock and connected up my oscilloscope to the two pins on the controller and took some sample waveforms of the clock pulses and the data. The yellow trace is the data and the blue trace the clock pulse.


Then I set up a prototype to see if I can get the Pico to replicate the output. I used the Pico 2W, some breadboard and a spare daughter board.
My first attempts at programming the Pico to output some numbers didn't go very well but I finally got the timing right.

My idea is to use the Pico 2W capability to connect to the internet and to use NTP time for the Pico's Real Time Clock (RTC). The challenge for me is to get it on the internet, grap the time, and re-package it for serial transmission. The coding also has to pack up the four 8 bit character codes from down to 6 bits and pack them up into three 8 bit words...this is where the fun begins..
First I programmed the Pico to connect to the internet then using ntptime I set the Pico's internal RTC. When querying the RTC it returns everything from year, month, day and not forgetting the time. I filtered out the Hours and Minutes then converted the two digit hours to separate binary numbers and the same for the minutes.
From here I parsed out each bit to be sent in the serial stream. Lastly I needed to trigger the time transmission every minute so I used the seconds from the RTC to monitor every time the 0 seconds came round to provide this trigger.
This all seems to work so I designed a new daughter board to accomodate the Pico 2W.

Now the RTC on the Pico 2W also looses or gains approximatelly 1 to 2 seconds a day which over a year amounts to 1 to 2 minutes. To mitigate this I will sync the time to the ntp server daily.



The clocks have been running for a few weeks now and I have found a couple niggles that need to be addressed. The first is that the ntp server is GMT only which means I need to do some programming to determine the last Sunday in March and October to cater for British Summer Time (BST).
The other concern is that very occasionally the time transmission gets corrupted. The Pico 2W is working right on its GPIO limits of switching speed within MicroPython so before I go and work on a solution to both these issues I'm going to try and port the program over to CircuitPython - it certainly made a big difference to the Maplin 5600 keyboard encoder..more later..