Arduino Processor Reference Clock Accuracy

Of late I have been going round in circles on a project to keep our local church clock roughly on time. I say roughly as my idea of timekeeping does not accord with the aspirations of the village residents. Quote ‘ I only need to know when it is the time to go inside for a brew’ / ‘knock off for the day’ / ‘get my skates on or I will be late for work’ etc. I was thinking sub seconds and they were thinking a minute or so as being perfectly adequate. The exception is at 11am on the 11th of November when it has to be exact.

That as it may be, the project is moving along. The first problem was what to measure on the clock to reference the time adjustment. The pendulum (1.25s rate) is clearly the easiest choice and a sensor beam being broken by the pendulum swing will solve this problem. The slight problem is that the sensor will not necessarily ‘switch’ at the same time when being approached from the two directions of the pendulum swing. My Arduino skills might struggle to come up with some code to discriminate this so I reverted to simple CMOS logic. An ICM7555 acts as a monostable that has a period greater than one swing. This is triggered by the falling edge of the swing pulse derived from a simple differentiator network. The monostable extended period pulse is then gated with the incoming pulse using a CD4001 Quad NOR to always give me half the pulse rate regardless of the swing direction. That probably makes no sense at all so here is my back of an envelope waveform diagram and circuitry.

The circuit has turned out quite useful for other applications. I also refined it to have a CD4024 ripple counter fed from the output at E. This allowed extended logging periods to be achieved. I also utilised the unused gates on the CD4001 to provide an isolating buffer on the input signal. This meant the differentiating network would always see the same drive signal regardless of the incoming waveform and its source impedance.

Progress indeed. I now had a pulse train representing the clock beat period. All I had to do was measure the time taken between pulses and I could compare and adjust the pendulum rate.

Having got a reliable 2.5s pulse it was time to reverted to an Ardiuno UNO to measure the period. With some help from a friend we ran a sketch using millis to record the time between pulses. This minimalist sketch did not seem all that repeatable. I also did some tests with Frequency.h sketch code from the PJRC website (very useful source) and had similar poor results. I was using a FY6900 as my reference 1.25Hz signal and to get a 1.25Hz reading I had to offset the FY6900 quite a way from nominal. What to believe?

In a bid to get a known good reference I powered up my Arduino GTU-7 GPS module and measured the 1 second output pulse using both of the above sketches and the results were not much closer to the truth. I tried an Arduino MEGA instead of the UNO and got a different set of inaccurate results

This led me to think that the UNO and the MEGA must be the cause. Looking at these two boards, both have a 16MHz crystal which I (foolishly) believed was the processor reference and therefore could not be that much off frequency. Totally wrong. The crystal is for the USB interface, not the processor. Instead the processor has a basic 16MHz resonator – not a crystal. I got out the magnifying glass and discovered this piece of surface mounted wizardry. Low and behold if I put my finger on the resonator to warm it up, off it went into dodgy stability land. It was pretty awful. I could make my readings whatever I wanted them to be just by timing how long my finger was in contact with the surface mount resonator package. Chocolate fire guard indeed.

What to do ?

I downloaded the ATmega258P datasheet and found that I could replace the resonator with a crystal. This looked complicated with references to fusible links and reprogramming of the processor all of which made me twitch. The processor had been running on a wobbly 16MHz source so why not a less wobbly one?

Rather than hack the UNO board, I eased the processor out of its socket and bent pins 8 (ground),9 (xtal) and 10 (xtal) out horizontally and plugged the processor back into its socket. Using a three pin socket pushed onto the pins as a mounting, I assembled the crystal across pins 9 and 10 and two shunt capacitors (approx 33pF) to the ground pin. The crystal came from RS Components (#8149440) and was a 30ppm spec. This socket mounted lash up was then pushed into place on the floating process legs – very healthy, no damage done to the processor or the board. Here is the ugly mess.

Switched on. It worked.

Suddenly all my test source readings took on a very stable repeatability and the readings were very close to what I expected. The GPS referenced 1s pulse was reading 0.999936 and my SY9600 was reading 0.999958. It looked like my new crystal reference must be slightly off frequency but a tweak of the shunt capacitor values will fix this. I think the SY9600 has a 10MHz TCXO so it should be good but I think I tend to believe the GPS pulse as being more accurately delivering a 1Hz rate.

The experts will tell me I should be adjusting the fusible links but I am inclined to stick with what I have got, it is working.

The result is I now have an ability to measure the pendulum rate and from this I can derive an advance and retard flag.

I am currently designing the front end circuitry as shown above into a PCB ‘shield’ to plug into the UNO. This will take the sensor input and give a slow or fast command pin output. More on this and general progress to follow.

Update (30/9/2024)

I changed the two crystal oscillator shunt capacitors to be a 22pFSMD in parallel with 1p8 caps when using the RS crystal as mentioned. Below is a suitable layout for the crystal and shunt caps. There are positions for two caps on each leg of the crystal. 15pF in parallel with 6.8pF would also work. I checked the frequency was close using a GPS derived 1pps signal feeding pin 8 on the UNO while running the frequency.h demo sketch.

The board can be connected using the mounting holes or it can be cropped and the residual pcb tracks used as direct connections using pins 10 and 9 both of which are bent out from the IC body. Pin 8 was left plugged into the IC socket and bridged and soldered across with a wire clipping to the crystal board. The crystal mounts on the rear. The board is so simple you could mill it on single sided copper clad with a burr in a Dremel.

The picture below shows the first milled version in place on the UNO. The layout above is a later tweaked version to better match the pcb pads to pins 9 and 10.

Links to similar or related post are listed below : –

3D Printed Length Gauge for In Barrel Mainsprings

I had received a clock to repair and wasn’t sure if the mainspring was correctly dimensioned. I remembered that William Smith had described a gauge for checking this in his book ‘Clockmaking & Modelmaking Tools and Techniques’ (pages 21 – 26). This gauging tool consists of two profiled plates that slide together to overlay the end view into the clock barrel. Bill’s design used 1/16″ brass plate but it struck me that a 3D printed version would be equally suitable and much quicker and easier to make.

In use the gauge is overlaid on the end view of the barrel as shown below. The point A is aligned with the outer diameter of the barrel arbor. The top plate is then slide until the inside edge of the barrel wall is aligned with point B. For a correctly chosen mainspring it should align with the corners C and D.

I sketched Bill’s design in Fusion 360 and extruded the two component parts to have a 2mm thickness before printing on my Qidi X Smart 3 in PLA. The two parts are fastened together to be a sliding fit with two M4 screws. The threads for these are modelled in the 3D print. A handling knob can be added in a similar fashion.

Here is my PLA printed equivalent.

The STL print files can be downloaded on the link below. It is not something that you will use every day but just a ‘useful to have when needed’ item. “Better to have it and not need it, than need it and not have it” (Jimmy Diresta).

Links to similar or related post are listed below : –

Superb Qidi Technical Support

One of my X Smart 3 printers suddenly started to show an error message that the temperature sensor on the hot end was not rising correctly.

I emailed Qidi support and talked with Annie. She said it was a hot end failure and would get a replacement hot end assembly shipped to me. This was on Monday. The replacement hot end arrived last night (Wednesday) and I fitted it this morning. Printer fixed and back up and running. I was staggered by the service.

Qidi might not be as well recognised as Bambu Labs but Qidi’s Technical Support certainly know how to look after their customers. Lovely machines and superb back up.

Links to similar or related post are listed below : –

Creating Customised Threads in Fusion 360

As ever this started off with a need and from the need came some learning.  In my experience such needs are always welcome for the resulting learning benefit but inevitably lead to a few hours of frustration.

We have a small Jacuzzi spa at our home in France.   It has two cartridge filters that are screw mounted into the sump of the spa.   The threads on the cartridges are plastic and are loosely defined as 2” SAE spec. (I think SAE is a fine pitch thread (?) and as the filter threads are around 5mm thread to thread pitch, they don’t seem to me to be fine pitch).

When filling the spa from empty, Jacuzzi recommended that the filters are removed and the filler hosepipe nozzle is wedged into the outer vacated of the two filter holes. The nozzle has to be jammed in place by packing a cloth or sponge around it.   Filling via the filter mounting ensures the spa fills from the bottom up with minimal potential for an airlock in the pipework.

The problem with this is that the filler hose tends to have a mind of its own and when your back is turned it will liberate itself from the filter hole and whiplash round like a demented cobra and give you an unexpected bath.

After one such soaking I resolved to stop this happening.   What was needed was an adapter plug to fit into the “2” SAE” socket that would accept a standard hose push fit connector.  This would hopefully keep the rampant serpent retained during the filling process.

I opted to use a standard commercial male hose connector for the interface to the filler hosepipe. These have a DIN Pipe thread specification (G26.441 x 1.814 mm).   This left me with the need to model the 2” SAE from scratch which on inspection appeared to take the form of a pseudo Acme profile but with an asymmetric thread to valley ratio.

Having failed to find anything helpful on the Internet I set about creating a custom thread in Fusion 360. New experience ….

Here is the resulting adapter. 

The attached ZIP file below has the full write up, the STL file and the source Fusion file.

Links to similar or related post are listed below : –

TA12 USAF WW2 transmitter and 1938 Truphonic MA5T receiver

Like all engineers and particularly radio engineers I have a squirrel mentality heavily influenced by emotional attachment. I tend to keep stuff. This is part ‘might be useful one day’, a symptom of my ‘make do and mend’ upbringing and part not being able to bear parting with things.

This weekend is the Newbury Amateur Radio Club annual meet and sale. Together with two likeminded techies we have booked a couple of tables to offload some of our accumulated junk.

I have decided to take two items that meet the emotional attachment category. They both have a story attached that relate to how my interest in radio evolved.

The first is my maternal grandparents Truphonic MA5T domestic radio. As a family we regularly visited them at their ‘2 up – 2 down’ terraced house in York. The radio sat on their sideboard in the kitchen and it totally absorbed me as I would tune up and down the bands and fiddle with the preset station levers. Truphonic were a London based manufacturer and the MA5T was an upright version of the MA5, both of which dated around 1938. The valve line up was TH4B\TDD4\VP43\PENA4\1W3. When I wasn’t playing with their radio I was taking their torches to pieces and making circuits with light bulbs. The technical seed was sown.

The second piece for disposal is a TA12 USAF airborne transmitter as used in WW2 on board B17s etc. It runs a pair of 807s. The story around this is similar.

My radio interest had blossomed and through a contact of my father I had acquired a WW2 R1155A receiver from a radio amateur in York. I became an avid shortwave listener. Wire antennas festooned the back garden and I spent hours with headphones clamped to my head searching for signals from round the globe.

Those familiar with the R1155A will know that its short wave coverage begins at around 3MHz and completely misses the 1.8MHz to 2MHz amateur band known as Top Band. If you were lucky enough to own a R1155N this band was covered but the N model was much less common being used mainly for marine comms rather than bomber command.

However as a family we had a Pilot Blue Peter domestic radio which covered LW/MW and SW frequencies. Unusually it had continuous coverage across these bands. This meant it covered Top Band. This was somewhat unusual for a domestic radio. Occasionally I would switch it on and tune around and one night happened upon a very strong amateur signal on Top Band. Given that the Pilot had little or no antenna connected the transmission had to be local. This was my first contact with Alf Whitelock whose callsign was G3BNM. He was indeed local and lived in Alne which was around 9 miles away.

This was the start of a long and close relationship with Alf. He took me under his wing and taught me so much about radio both operating and building. He was regularly on Top Band with his nephew John G3WQM and Ted G3TNM. Alf ran a pseudo crossband duplex transmission retransmitting the incoming audio from John (4m) and Ted (2m) and so all three of them and anyone listening to Alf could hear everyone talking.

Alf helped me improve my R1155 with external pre-amps and converters so I had full coverage of all the amateur short wave bands. I would regularly bike to and from Alne and would always struggle on the return journey with so many donated radio parts strapped to my bike.

Alf was not young and inevitably he died when I was in my late teens. I was devastated. I felt like I had lost a very special adopted grandfather. He left me his HF station. It was a 6 foot high rack with huge power supplies, modulators and antenna tuner. The heart of the station was the TA12 airborne transmitter. While all the other components have long since gone, I could not bear to part with the TA12 and it has remained with me now for over 50 years. He voice came to me via this radio and it has a very emotional connection.

So what to do ? Two items of huge sentimental value that is personal only to me. My kids don’t care for granddad’s weird hobbies and my accumulated ‘junk’. On my passing both these radios will go to landfill or similar. Taking them to the Newbury event might stir some interest with a historic preservation body. I can then rest knowing that these two radios have moved on and will have an extended life.

But maybe I’m just hoping that nobody shows any interest and I can bring them back home and put them back in the attic for a few more years …..

UPDATE : Both the TA12 and the MA5T sold. Both went to heritage radio collectors. The buyer of the MA5T said he had never seen this particular model and thought it very rare. He was looking forward to restoring it. Result.

Links to similar or related post are listed below : –

Verified by ExactMetrics