bicyclesonthemoon.info / Some projects / ZEGARIO

A circuit for controlling a railway clock




Introduction

(click on pictures to get a higher resolution version if available)

In this document I describe the device I built for controlling a railway clock.

There is also a video available, much less serious than this document:
zegario.mp4
The video is in Polish language but subtitles are available in English and Polish:
zegario-english.vtt
zegario-polish.vtt
The video is also available on youtube (with subtitles available as well):
https://youtu.be/URVqvCyzog8"

I have a railway clock produced by KZŁ. This kind of clock can't work on its own but it requires a master clock which will provide a 24V signal every minute: +24V every even minute and -24V every odd minute. This will make the clock advance its position by 1 minute.




This kind of mechanism works very similarly to a more familiar quartz mechanism, with the difference that here it moves the minute hand every minute instead of moving the second hand every second.


So I needed to create a device which would fulfil the role of a master clock. Actually, I already received such device together with the clock but it did not meet my requirements. There is nothing wrong with it, it works well, but I made up some other requirements and wanted to create my own device according to them.

The device I received (not the one I built):



Goals and requirements

I wanted to create a device which:

Power supply


A very simple power supply is used. A transformer with its output side split in half. Both sides go through a diode and capacitor to produce a rectified DC supply.

I chose to use a transformer with output split in half because the 24V needed by the clock is too high for the ICs I used. This allows them to be powered by 12V instead.

The transformer which I had available produces slightly higher voltages. So wherever the schematic says 12V it's actually 15V and where it says 24V it's 30V. Luckily the clock still works at 15V.

100Hz square wave


The same transformer which supplies power also supplies a 50Hz reference. Or rather a 100Hz reference as I'm counting each half separately. The half waves go into the 555 IC which compares the levels internally and switches its output when thresholds are crossed. This produces a 100Hz square wave. The ON and OFF times are not equal but that's not a problem.


The power supply frequency is actually a good time reference (in many countries, but not all).

Power-ON reset


There is a circuit for creating a reset pulse based on a 555 IC. While the capacitor is charged after connecting power the output is high and after reaching a threshold it goes low and stays there.

This is resetting the counters and flip-flop used in other parts of the device.


Dividing the frequency

The 100Hz signal has to be divided to produce signals with a lower frequency. An output pulse must be produced every minute and its duration should be slightly less than 1s.

I decided to use the pulse duration of 0.75s ands 80 such pulses each minute. This means dividing the 100Hz by 75 and then by 80. Other values can be used as long they give 6000 when multiplied. The pulse should be long enough that the clock manages to move to the next minute in that time and short enough that it's possible to set the time without waiting forever. If the power supply frequency is 60Hz then the 2 factors multiplied should give 7200.

First divider


Two 4029 counters are used together in binary countdown mode to make an 8 bit counter. The 100Hz signal is used as the clock signal. Wherever the PRESET ENABLE is high the counter is preset to a value selected by jumpers. I use the value 75 (and NOT 75-1=74) to divide by 75.


With each rising edge of the 100Hz signal the counter counts down by 1. When 0 is reached, the CARRY OUT output goes low. This output, inverted, goes into a 555 IC. This is to filter out any very short pulses which might appear there before really reaching 0.

This filtered output is used as the tick signal in the next stage. Also it is indicated by an LED.

This signal is then OR-ed with the 100Hz signal and inverted. This OR-ed with the reset signal goes into the PRESET ENABLE input which resets the counter.

The OR with the 100Hz signal is needed. This makes the CARRY OUT signal to remain low as long as the 100Hz clock is high. Otherwise the counter would be reset immediately producing a very short pulse.


Second divider


The second dividing stage is very similar to the first one. Here the input clock signal is the tick produced in the previous stage. The preset value is such (I use 80) that the resulting output is exactly 1 BPM.




There is one additional thing not present in the previous stage. The CARRY OUT signal can be replaced by the lowest bit of the counter (inverted or not - selected by jumper) if a button is pressed. It should be inverted if the preset value is odd and not inverted if the preset value is even. This causes the output signal be generated at each tick, to allow setting the time.


Output polarity selector


The 1 BPM signal goes into a 4027 J-K flip-flop. At each rising edge its output is flipped. The 1 BPM signal is OR-ed with both the straight and inverted output. This way each minute only one of the signals is activated.


And if the button is pressed the signals appear without the 1 minute delay.


Each of these signals is turning on a relay which connects the clock to the positive or negative voltage taken from the transformer and rectified with a diode and capacitor. A jumper allows to select 12V or 24V. (or currently 15V and 30V)


Finished circuit




Case

I build a case from leftover wood pieces. The front wall I made from transparent plastic. I attached a button and the power input connector and the output connectors. Also 2 metal pieces for hanging it on the wall.






Usage

If more than 1 clock is used some additional steps are required when connecting for the first time:

Update 17.08.2024

Design flaw discovered

This circuit had a design flaw in this part:

At first, everything could seem OK with it. When button is not pressed it will generate a pulse every minute. And when button is pressed it will generate a pulse every tick o fthe previous divider.

But this analysis does not consider what happens when the button state is changed. The button can be pressed or released at any time, not synchronised with the ticks of this device. This can lead to 2 problematic situations.

Goals and requirements for design update

Modification of the divider

Updated design. Changes are in colour


Now the button state does not interfere with the divider directly. Instead, it changes the state of a JK flip-flop, which then for 1 full cycle lets through the tick signal from the previous divider. It's wired so that it will only allow this every second pulse, so now when setting the time, there will pauses between the pulses.

I had some unused logic gates left in the integrated circuits used in this device:

I used them all and additionally I repurposed one more NOT gate. I also removed some jumpers.




Timing changes

I changed the divider settings on jumpers to 24 and 250. Now the duration of one pulse is 0.24s and there are 250 such pulses in 1 minute. When setting the time, the pulses appear every 0.48s because of the pause.

This was the shortest pulse I could achieve and my clocks (I have 2 now) still work correctly with shorter pulses.

The requirement for the divider settings is that both values multiplied together give 6000 (7200 in case of a 60Hz power supply) and the values are less than 256 (must be represented by 8 bits).

Here is a list of all valid settings.
first dividersecond dividerpulse durationpulses per second when setting time
242500.24s2.08333333...
252400.25s2
302000.3s 1.66666666...
401500.4s 1.25
481250.48s1.04166666...
501200.5s 1
601000.6s 0.83333333...
75 800.75s0.66666666...
80 750.8s 0.625
100 601s 0.5
120 501.2s 0.41666666...
125 481.25s0.4
150 401.5s 0.33333333...
200 302s 0.25
240 252.4s 0.20833333...
250 242.5s 0.2

External connector added

I added a 5-pin DIN connector. To allow connecting a device which can remotely monitor and adjust the time. For example after power loss.




It has all the required signals:

I'm considering updating this to include also the TICK signal. But I have not decided yet.

Next steps