Picaxe clock regulation

Rampz

Well-known member
Hello All
I thought it best to start a new thread for this, just testing a tilt switch has run to 6 pages.

The goal is to regulate the time of a clock by increasing or decreasing the pendulem swing by elctromagnet against the actual time, seems the best to use a DS3231 as PhilHornby says a very accurate time chip, first goal to buy one and get the time and date up on a screen, with the ability to provide a level of correction as required

Later to get a reliable pick up from the clock as to where it thinks the time is and look at how to regulate it, i do know a bit about how its done with current versions and can apply similar lines in this project, have some ideas to then take the project further than anyone currently does
 

AllyCat

Senior Member
Hi,

So perhaps I should copy my recent post from that other thread to here:

Indeed, (IMHO) the DS3231 is a great little chip. Note that there are (at least) two styles of "breakout" module available: One has a holder (on the rear) for a standard (usually non-rechargeable) lithium coin cell (e.g. CR2032) which might or might not be supplied, and (optionally) it may also carry an I2C EEPROM chip. Unlike some RTCs, the DS3231 does NOT contain any "spare" (User) NV (battery-backed) RAM. Another style, often called "DS3231 for Pi", is tiny (the soldered 5-pin vertical header socket is the largest part) and carries a soldered-in rechargeable button cell, but beware that some sellers do not supply this (which will be difficult to source later). :(

Cheers, Alan.
 

Rampz

Well-known member
Hi,

So perhaps I should copy my recent post from that other thread to here:

Indeed, (IMHO) the DS3231 is a great little chip. Note that there are (at least) two styles of "breakout" module available: One has a holder (on the rear) for a standard (usually non-rechargeable) lithium coin cell (e.g. CR2032) which might or might not be supplied, and (optionally) it may also carry an I2C EEPROM chip. Unlike some RTCs, the DS3231 does NOT contain any "spare" (User) NV (battery-backed) RAM. Another style, often called "DS3231 for Pi", is tiny (the soldered 5-pin vertical header socket is the largest part) and carries a soldered-in rechargeable button cell, but beware that some sellers do not supply this (which will be difficult to source later). :(

Cheers, Alan.
Hello Alan,

Thank you for adding the above to the new thread

Yes i see there are a few about, mainly with the I2C interface, what is the best way to go in your opinion?
 
Last edited:

AllyCat

Senior Member
Hi,

It rather depends if size is a criterion.

The basic I2C chip is SMD, but 5v tolerant and you can usually activate PICaxe's internal Weak Pullup resistors for SDA and SCL, so probably only a backup battery needs to be added. But personally, I can't be bothered to design my own PCBs (now).

I keep a few of the "3231 for PI" modules in my parts box (having checked that the button cell was included), but the regular 6-pin modules with a coin cell (CR2032) and EEPROM (AT24C32) are probably the easiest and best value, directly available from several UK-based ebay sellers.

Cheers, Alan.
 

hippy

Technical Support
Staff member
Given it would seem you would be running the pendulum monitoring continuously, to count each 'tick', it seems there would be little use for using any battery backed-up capability, no need for any Eeprom or NVRAM storage.

I would just buy the cheapest breakout module I could find.
 

AllyCat

Senior Member
Hi,
I would just buy the cheapest breakout module I could find.
The cheapest will probably come from China (eventually, and don't forget the Chinese New Year shutdown is imminent) and the EEPROM appears to be included almost as standard (in these modules). A battery will allow the time to be set-up "on the bench" (e.g. when programming the PICaxe), so the end-user/installer interface might not need to be much more than a push-button to add or subtract a few seconds (or synchronise to a time signal).

So yes, a RTC is very probably the best solution: MSF reception is often recommended/better overnight (not very convenient for a professional installer), the valves (tubes) for Droitwich (R4 198 kHz) might die any day now (but probably won't), and GPS reception (or even mobile phone coverage) could be problematic inside a church with thick stone walls and leaded-light windows. :)

Cheers, Alan.
 

Rampz

Well-known member
Given it would seem you would be running the pendulum monitoring continuously, to count each 'tick', it seems there would be little use for using any battery backed-up capability, no need for any Eeprom or NVRAM storage.
Hippy, what tends to happen is the regulator regulates for 55 mins in the hour then for 5 mins waits for the clock to strike the hour to get its bearing on time, most Turret clocks don't have a second tick tock like a domestic type clock, the hour pickup is either from the bar that lifts to start the chimes or the bar that starts rotating a after this bar is lifted, the user has to count how many times the bar spins before the clock chimes the hours and that info is put into the regulator so it can count the hour etc. then works out how meny second fast or slow it is and makes the electro magnet attract or repel for a number of minutes to speed or slow the clock pendulem

Space isn't an issue, and i would design any pcb needed for the picaxe, screen and timebase module how ever it fitted
 

Rampz

Well-known member
Ok i have ordered someting for around £3.50 inc delivery, seems to be with the I2C and the eeprom, i also see there is an aging offset that could be used to make slight corrections positive or negative to the time, its seems this offset alters slightly based on temp so could be good, looks like i will need 2x picaxe pins to operate it.

I guess if i am operating a screen then i will need another 8x output pins

Be good to know when the system goes onto battery so an input for this, 1x input

Ability to alter settings, maybe 1 button sequences though setting screens, 1 button for incrementing the value, 2x inputs for this

Upto 2x pickups for pendulem and hour position, 2x inputs

positive or negative for electromagnet, 2x outputs i think

Ability to grab pendulem for summer winter changeover, up to 2x outputs for this

Be good to have a few spare for everything i have either forgotten or haven't worked out i will actually need

Looks like i need something like the 40X2 ?

Or am i better have 1x picaxe doing time and any system settings then talking to another picaxe doing the main program?

Thoughts please for direction?
 
Last edited:

AllyCat

Senior Member
Hi,
...... looks like i will need 2x picaxe pins to operate it [the RTC]. ...
I guess if i am operating a screen then i will need another 8x output pins........
That could be done on just the two I2C pins (and perhaps more things as well). So certainly all would be possible on a 20M2 or even less, but it may depend how "expensive" you want the product to look (and/or how much time developing the program code). :)

HERE is my example of using this RTC module (at the top right corner of the photo in #1) with an I2C "graphics" OLED and an 08M2 (with pins to spare), but it uses quite "advanced" programming techniques. Similarly, the "parallel" LCD or OLED character displays can be fitted (or are available) with an "I2C backpack". Some of my RTC interface program is shown in this OTHER CODE SNIPPET, but much more detail has been posted by others, for example by "marks". ;)

Cheers, Alan.
 

Rampz

Well-known member
Hi,

That could be done on just the two I2C pins (and perhaps more things as well). So certainly all would be possible on a 20M2 or even less, but it may depend how "expensive" you want the product to look (and/or how much time developing the program code). :)

HERE is my example of using this RTC module (at the top right corner of the photo in #1) with an I2C "graphics" OLED and an 08M2 (with pins to spare), but it uses quite "advanced" programming techniques. Similarly, the "parallel" LCD or OLED character displays can be fitted (or are available) with an "I2C backpack". Some of my RTC interface program is shown in this OTHER CODE SNIPPET, but much more detail has been posted by others, for example by "marks". ;)

Cheers, Alan.
Thank you Alan I will have a read up
 

erco

Senior Member
The mechanical engineer in me is more interested in the mechanical side of:

regulate(ing) the time of a clock by increasing or decreasing the pendulem (sic) swing by elctromagnet against the actual time

IMO the size, power, and location of the electromagnet and pendulum length, weight and angle of swing are important variables that wildly affect the outcome. Are you blipping the pendulum constantly to keep it in motion, and you will vary it to adjust?

Pendulums only approximate SHM for small angles of displacement. The actual frequency & period vary with displacement. You might be able to vary the swing to play catchup. Get a government grant and let's deep dive this. :)
 

Rampz

Well-known member
Are you blipping the pendulum constantly to keep it in motion
Erco no its not blipped as such, the electromagnet is switched on for a constant period based on the calculated difference in time, this will invole some on site work to find out how long is needed on average per second time difference against how long switched on is required to correct, i know the time required changes with length of pendulem so there is a user adjustable value to add ms to said value to correct for it

Get a government grant and let's deep dive this.
The original manufacturer of the unit as seen in the "tilt switch test rig thread" has stopped production due to ill health and production recently passed to the bloke i am advising for tilt switch issues, so i am in a position where any expense for prototyping is covered and i give my time, so i am kind of funded, so there is room to do something, what do you have in mind? All the coding is way past my current ability, but am learning.

Simon
 

micrometal

New Member
I am a church bell-ringer and, as often happens, became the de facto keeper of the local church clock. (Incidentally, this has autowinders for both the going train and the striking train, but the clock is barely 150 years old and so the auto-winders are integrated into the clock and are able to use micro-switches as sensors). I am just at the mental planning stage of a personal project to help me set the clock for good timekeeping.

I have seen clock regulation projects before. Usually they have some type of adjustable weight mounted on the pendulum (like the well-known pennies on Big Ben). Using a magnet to affect the swing duration seems much better, but @erco's comment is important.

IMO the size, power, and location of the electromagnet and pendulum length, weight and angle of swing are important
I agree. The pendulum on our clock weighs over one hundredweight, so isn't easily moved. However it is possible to regulate the clock manually, with care, to within 5 seconds per week and this is an accuracy of better than 0.001%, so only very small corrections are needed. I guess that a mechanical engineer could calculate the force necessary to affect the pendulum sufficiently.
 
Last edited:

hippy

Technical Support
Staff member
Hippy, what tends to happen is the regulator regulates for 55 mins in the hour then for 5 mins waits for the clock to strike the hour to get its bearing on time, most Turret clocks don't have a second tick tock like a domestic type clock, the hour pickup is either from the bar that lifts to start the chimes or the bar that starts rotating a after this bar is lifted, the user has to count how many times the bar spins before the clock chimes the hours and that info is put into the regulator so it can count the hour etc. then works out how meny second fast or slow it is and makes the electro magnet attract or repel for a number of minutes to speed or slow the clock pendulem
So what you are effectively doing is timing the period between hour chimes to figure out if it is running fast or slow ?

That makes sense and shouldn't be at all complicated to implement. I certainly wouldn't have expected to need a 40X2, merely an 08M2 though a 20X2 might prove helpful in calculating the maths to determine what adjustment is needed.
 

Rampz

Well-known member
I guess that a mechanical engineer could calculate the force necessary to affect the pendulum sufficiently.
Hello Micrometal, its not so much the force needed more the duration that force needs to be applied to correct the difference thats needed, i am aware that is different for each clock and the length of the pendulem has an effect so the electromagnet is fitted in different places based on that. I am advising someone that already manufacturers a unit that does it and has done for sevarl years, but we feel going to a picmicrocontroller could give added benefits over the current system so looking to re-design the system in this direction

Currently the electromagnet that is used doesn't draw more than 300ma at 12vdc
 
Last edited:

Rampz

Well-known member
So what you are effectively doing is timing the period between hour chimes to figure out if it is running fast or slow
Yep that's what i need to do at the first point, if you look at my post #9 i will have other inputs and outputs needed maybe 11 plus driving an oled screen, maybe i am best leaving that to a backpack? There will be some user adjustment needed via some push buttons along with the screen
 

hippy

Technical Support
Staff member
Yep that's what i need to do at the first point, if you look at my post #9 i will have other inputs and outputs needed maybe 11 plus driving an oled screen, maybe i am best leaving that to a backpack? There will be some user adjustment needed via some push buttons along with the screen
I have to to admit it isn't clear to me why any of that is needed for a simple "The goal is to regulate the time of a clock by increasing or decreasing the pendulem swing by elctromagnet against the actual time". Obviously there needs to be a connection to the I2C chip, a means to input the 'chime event', some means to output an influence on swing, but not sure what else would be needed.
 

Rampz

Well-known member
I have to to admit it isn't clear to me why any of that is needed for a simple "The goal is to regulate the time of a clock by increasing or decreasing the pendulem swing by elctromagnet against the actual time". Obviously there needs to be a connection to the I2C chip, a means to input the 'chime event', some means to output an influence on swing, but not sure what else would be needed.
Hippy increasing and decreasing with an electromagnet needs the ability to reverse the supply to push rather than pull, may need to be able to adjust time onsite, adjust the ageing setup in the I2C chip to help keep everything as accueate as possible a screen would be best way for the bloke looking after the clock to see the details and the amount of correction etc, its easy enough for us all with the terminal in the editor etc

The second function these systems have is to be able to adjust the clock for daylight saving time, for this it would need additional inputs and outputs

To do this they need to be able to sense the pendulem swing, reach out and stop it using a linear actuator, wait the required amount of hours and release at the right time, i want to start with the best chip or chips based on your recomendations?
 

erco

Senior Member
Sounds like power/efficiency isn't an issue, you just need to make trim adjustments, micrometal says 0.001%, so a small electromagnet that could push/pull a permanent magnet on the pendulum could work (a million variables involved).

Barely related and barely a robot, but my "Ticktock" rocking robot always draws smiles at shows. I need to add LED eyes.

 

micrometal

New Member
Hi Rampz,
Currently the electromagnet that is used doesn't draw more than 300ma at 12vdc
That is quite a decent current, but no problem for a mains supply, of course. And the solution is a lot better than moving weights up and down. Is there anything on the web that shows more?

At the moment I am just thinking of ways to measure the going more easily than having to be at the clock when it strikes. I am planning to count the pinion teeth between the escapement and the minutes shaft (not as easy as it sounds) and simply count the pendulum swings over a few precisely measured hours. This only requires a pendulum sensor, which could be Hall effect or photo-diode.
 

Rampz

Well-known member
Is there anything on the web that shows more?
Micrometal if you look at one of my other threads "tilt switch test rig" post #109 there is a clip posted by PhilHornby that shows a clock with the setup already fitted

At the moment I am just thinking of ways to measure the going more easily than having to be at the clock when it strikes.
If you watch during the clip, the way its done on this clock is just as i am planning on doing it, pendulems swing at different rates on different clocks, ofcourse you have one clock to deal with so its easier for what you want to do, you will see the sensor is on the shaft that is engaged to chime the hours, on some clocks this will turn several times before the clock chimes, that needs to be counted and adjusted in the code, its better to do the regulation at the end of end or start of an hour, you will always know where you are and can adjust accordingly, make an adjustment and then repeat each hour, best done with a hall effect sensor i think
 

Rampz

Well-known member
This is how “Smith of Derby” do it:
Interesting thanks Jack, the advantage Richard's version has is it can deal with a running fast or running slow clock, Smith's have to alter the pendulem setup to make it run fast and then they catch and stop the pendulem like they say, bet thats fun with a 4m pendulem.

They think as standard they can get to an accuracy of 2 seconds a year, thats unlikely without the GPS upgrade

All good information either way
 

Jack Burns

New Member
the advantage Richard's version has is it can deal with a running fast or running slow clock, Smith's have to alter the pendulem setup to make it run fast and then they catch and stop the pendulum
I agree it’s better to continually tweak the timing like Richard does. The link to Smith was mainly to show the setup of their pendulum grabber for anyone who hasn’t seen it before.

For completeness, here’s a video of Richard’s setup.
richardwhiteclocks.co.uk/regulators/bstgmt-time-change
 

Rampz

Well-known member
I agree it’s better to continually tweak the timing like Richard does. The link to Smith was mainly to show the setup of their pendulum grabber for anyone who hasn’t seen it before.
Don't get me wrong Smith's do a great product, i bet they have spent plenty on development, and they charge plenty for it, i want to build an equally good unit but without the cost.

The Smith's unit grabs the pendulem with an electromagnet, Richard uses a permanent magnet when he catchs the pendulem which his version does during daylight saving time changes, and uses the electromagnet for time adjustment,

So an advance to this would be to include a failsafe, if either drive motor fails, or a total power fail of some time, then lets go grab the pendulem during a fault, when the fault has cleared lets restart the clock at the correct time, Richard's catch mechanism when retracted pulls the magnet from the electromagnet releasing the pendulem, meaning during a power fail it would still be held, the picaxe would happily run at very low voltage until needed, this feature isn't available on any clock regulator, its my input from helping develop the auto winders and the problems they can have

For completeness, here’s a video of Richard’s setup.
richardwhiteclocks.co.uk/regulators/bstgmt-time-change
The video of Richard's is his daylight saving time change rather than his time regulation, in the video the unit creeps out to catch the pendulem as you see, the black collar then pushes the 2 parts away when needed to restart the clock hours later

Cumbria clocks do their own setup too if anyone can find it, i haven't looked
 

Rampz

Well-known member
Hobby Components
Jack Burns, great service from Hobby Components, arrived this morning with battery.

My development board is still full of MP3 player for another few days then we can all get started

How reliable is the I2C transmission system, i did read somewhere that the supply to it could come from a picaxe pin so it can be reset if required? I this the way you all keep them reliable?
 
Last edited:

AllyCat

Senior Member
Hi,
How reliable is the I2C transmission system, i did read somewhere that the supply to it could come from a picaxe pin so it can be reset if required? I this the way you all keep them reliable?
The I2C Bus was invented exactly 40 years ago (Happy Birthday) and has been used in a vast number of TV sets and many other Consumer Electronics Products ever since, so I think you can assume that it's fundamentally very reliable. :)

However, it was originally intended for 5 volt (TTL) systems, but many components now use 3.3. volts (or lower) so some care is needed. It should work fine at 3.3. volts but there can be complications with "mixed" (3.3 / 5 volt) systems. Therfore, some (but not all) "breakout" modules include not only a 3.3 volt regulator (and pull-up resistors) but a pair of Transistors/FETs to act as level shifters. Personally, I rarely bother to fit pullup resistors, but activate the PICaxe's internal Weak Pullup Resistors in case the pullups have been omitted from (all) of the I2C breakout modules. Of course a "large" bus using naked chips (i.e. not assembled with breakout modules) does need pullup resistors of a suitable value and location.

But ultimately, the I2C Bus does have a Handshake/Acknowledge protocol so it can become "hung", particularly if there are multiple Slaves and/or multiple Masters (the latter is better avoided). Of course a total power-down and restart can cure a Bus Lockup, but this might not be convenient or possible in practice. Therefore, there are standard procedures to "Clear" the Bus, which basically involves attempting to read 8 serial data bits back from the bus, to ensure that any device which has become "confused", whilst sending its data, will complete the task and release the Bus.

Cheers, Alan.
 

rq3

Senior Member
Hippy, what tends to happen is the regulator regulates for 55 mins in the hour then for 5 mins waits for the clock to strike the hour to get its bearing on time, most Turret clocks don't have a second tick tock like a domestic type clock, the hour pickup is either from the bar that lifts to start the chimes or the bar that starts rotating a after this bar is lifted, the user has to count how many times the bar spins before the clock chimes the hours and that info is put into the regulator so it can count the hour etc. then works out how meny second fast or slow it is and makes the electro magnet attract or repel for a number of minutes to speed or slow the clock pendulem

Space isn't an issue, and i would design any pcb needed for the picaxe, screen and timebase module how ever it fitted
If I were doing this, I would adjust the clock to run slightly fast, and then use the electromagnet to delay the pendulum as required. No need to both "pull" and "push" the pendulum.
 

hippy

Technical Support
Staff member
How reliable is the I2C transmission system, i did read somewhere that the supply to it could come from a picaxe pin so it can be reset if required? I this the way you all keep them reliable?
I2C is extremely reliable and there should be no need to take any special precautions to keep it reliable.
 

Rampz

Well-known member
If I were doing this, I would adjust the clock to run slightly fast, and then use the electromagnet to delay the pendulum as required. No need to both "pull" and "push" the pendulum.
Thats how Smith's do their's, but the go and fit the system, where as Richards system was designed to be self fit to keep costs down, so works best if the system can be just fitted without trying to instruct someone how to speed their clock up, so while what you say would makes perfect sense, a push pull setup is easier for self install
 

PhilHornby

Senior Member
I would love to electronically regulate my Grandfather clock, but a thought struck me...
...why not simply remove the pendulum and interact directly with the clock. Otherwise, we're trying to regulate the regulator!

I don't know if it's applicable to large scale 'tower clocks' (it might even be more applicable, since they seem to have huge pendulums).

25212

The clock is driving the pendulum (not the other way round, as it first appears). If you remove the pendulum, the clock goes into warp drive!
So, to my mind, it just needs something to interfere with the 'crutch', on an accurately timed basis.

I know next to nothing about actuators, servos, solenoids, stepper motors or anything related.

What kind of mechanism could I use? (I'd love to use 'something magnetic' - i.e. with no moving parts. I need it to function for another 170 years, with no maintenance :) )
 

erco

Senior Member
...why not simply remove the pendulum and interact directly with the clock.
Heresy! Confound you! Pendulums are LIFE! We need MORE pendulums, not less!

I LOVE old clocks, I've repaired them since an early age... there must be some German clockmaker in my genes. Cleaning, oiling, adjusting the beat (leveling they clock and centering the escapement lever travel), I love it all. Never rebushed one, but have frankensteined enough together and have a healthy respect for the mechanics. As you say, shoot for 170 year lifetime. I doubt if a servo would last a month in continuous duty. Maybe not even a week.

Consider how many billions of ticktock impulses an old pendulum clock has endured, it's mind blowing. One tick per second is 31.5 million per year. And how all that energy (springs or weights) is dissipated so slowly, just enough to keep the pendulum moving. Even cheap electric clocks & wristwatches are so efficient they can ticktock for a year off a single battery. Just amazing.

How long until Big Ben ticks again?

Fun fact: An interesting grandfather clock I repaired was from the mid-1800s here in the US. It was in beautiful shape except for the mismatched front door, which was fairly course solid wood, hastily stained, on ugly hinges. Originally it would have been a glass door to show off the swinging pendulum & weights. I subsequently learned that during the Civil War, the lead weights from many clocks were confiscated to melt into musket balls! Owners would hang ROCKS in place of the weights to power the clock, so owners retrofitted wooden doors to hide the ugly rocks.
 
Last edited:

Rampz

Well-known member
I don't know if it's applicable to large scale 'tower clocks' (it might even be more applicable, since they seem to have huge pendulums).
I don't think the power that be would be very impressed ie the Diocese who control all work on church clocks, give permission for works etc, going a stage further for your clock Phil, since you can't see the mech why not just keep the hands and pop a quartz movement behind, will keep perfect time?

Seriously though for small house clocks its a thought, maybe a row of electromagnets under the pendulem position pushing the rod side to side? You are going to struggle with space for most options and reliability
 

PhilHornby

Senior Member
I don't think the power that be would be very impressed ie the Diocese who control all work on church clocks, give permission for works etc, going a stage further for your clock Phil, since you can't see the mech why not just keep the hands and pop a quartz movement behind, will keep perfect time?
I can't see it's any different to removing the weights and replacing them with a coil spring and a motor...
... maybe a row of electromagnets under the pendulum position pushing the rod side to side?
Don't forget - it's the clock doing the "pushing" - the crutch needs stopping, or braking periodically. Perhaps a single electromagnet at the centre position could do it? I need some sort of measure of the forces involved.

I could stop it for a whole minute, then let it do 30 ticks and 30 tocks in rapid succession, to reduce wear (on my mechanism). I'm betting that would sound extremely annoying though :).
 
Top