## Friday, October 21, 2011

### Horologium Romanum

Despite the Roman Empire’s  sanitation, medicine, education, wine, public order, irrigation, roads, fresh-water system, and public health: they never had a decent digital clock. Well here it is!

The following video shows the clock in action. The clock is speeded up by over x100 so you can see a full 12 hours in just a minute or two.

The project uses only components that were available in the 1970s, 74 series chips, LEDs and resistors and a 50Hz or 60Hz clock signal.

There is plenty of support in the 74 series logic chips for driving 7 segment displays and Nixie tubes. But it seems nobody ever thought about developing a roman numeral driver chip! (I wonder why :)

I’ve broken this project into several segments and will describe each in turn:

• Derive a pulse per second from clock source (divide by 50 or 60)
• Count 60 seconds to obtain minutes
• Count minutes and display in roman numberals (0 to 59)
• Count hours and display in roman numerals (1 to 12)

For the display I opted to make the roman numeral letters using LEDs out on a breadboard: crude but adequate to illustrate the logic in action. If there was no limit to my time or budget I would have liked to have crafted something more elaborate.  Neon tubes would have been fantastic but way beyond my budget.

## Decoding roman numerals

Before describing each segment, a little background on roman numerals. Here are numbers 1 - 60 laid out in a table.

On close inspection it can be seen it’s rather systematic. The important observations are this: we are only dealing with digits 0 - 59 and and the 0 - 9 of the 10s digit can be substituted for (blank),”X”,”XX”,”XXX”,”XL” and “L” respectfully, and the 0 - 9 of the units digit can be substituted for (blank),”I”,”II”,”III”,”IV”,”V”,”VI”,”VII”,”VIII”,”IX” respectfully.

For the units display I'm going to use 7 display elements which I'll call I3, X0, V0, I2, I1, I0. For the 10s display I will use 4 display elements: X3, X2, X1 and L0.

An important aid in decoding roman numberals is to be able to count in ‘decades’. For this reason I chose the 74390 decade/bi-quintary counter. So lets look at the truth table for the numbers 0 - 9 with the 74390 in bi-quintinary mode. Shown here is the Qn pins on the counter and the desired state of the display.

 Q0 Q3 Q2 Q1 I3 X0 V0 I2 I1 I0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 2 0 0 1 0 0 0 0 0 1 1 3 0 0 1 1 0 0 0 1 1 1 4 0 1 0 0 1 0 1 0 0 0 5 1 0 0 0 0 0 1 0 0 0 6 1 0 0 1 0 0 1 0 0 1 7 1 0 1 0 0 0 1 0 1 1 8 1 0 1 1 0 0 1 1 1 1 9 1 1 0 0 1 1 0 0 0 0

By visual inspection the following rules for driving the display can be deduced:

I0 = Q1 OR Q2
I1 =  Q2
I2 = Q1 AND Q2
V0 = Q0 XOR Q3
X0 = Q0 AND Q3
I3 = Q3

And now the 10s display. The task is simplified because we're only interested in counting up to 59.

 Q0 Q3 Q2 Q1 X3 X2 X1 L0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 2 0 0 1 0 0 1 1 0 3 0 0 1 1 1 1 1 0 4 0 1 0 0 0 0 1 1 5 1 0 0 0 0 0 0 1

L0 = Q3 OR Q0
X1 = Q1 OR Q2 OR Q3
X2 = Q2
X3 = Q1 AND Q2

## Dividing 50Hz to get one pulse per second

For this project I'm using a timing signal derived from the mains frequency (although for prototyping I've been using an Arduino which allows me to experiment with various frequencies). In Europe and many other parts of the world this is 50Hz.  To get one pulse per second this signal will need to be divided by 50. This is easy with the 74390: either divide by 5 and then by 10, or vice versa. All else being equal I think it's a good idea to reduce the working frequency as soon as possible, therefore I opted to divide by 10 first, and then by 5.

Decade counter 1 (on the left) divides the incoming 50Hz signal by 10 bring the frequency down to 5Hz, and then decade counter 2 (on right) then divides it by 5 bring it to 1Hz.

You say tomato, I say tomato...

In the US the mains frequency is 60Hz which complicates things a little. Thankfully it's not difficult to fix. Connecting 2Q0 AND 2Q1 will cause decade counter 2 (on right) to reset at 6, thereby dividing the incoming frequency by 60.

## Dividing seconds by 60 to get one pulse per minute

This is identical to the US mains 60Hz problem described in the previous section. I use a 74390 and tie the MR (reset) of decade counter 2 to 2Q0 AND 2Q1. The Q0 pin forms the input to the minutes counter.

## The Minutes Counter and Display Decoder

This purpose of this segment is to count minutes from 0 to 59 and then roll over to 0. It also decodes the counter output pins (1Q0 to 3 and 2Q0 to 3) to drive a roman numeral display. Decade counter 1 (on left) counts minutes and decade counter 2 (on right) counts the 10s of minutes. The roll over at 60 is accomplished by feeding 2Q1 AND 2Q0 (ie 6 on the 10s counter) to the counter reset.

## The Hours Counter and Display Decoder

The hours count from 1 - 12 which is a problem: the 74390 has no preset capability: it's always all 0s on reset. So how to get the clock to roll over to value 1?  This took a bit of thinking and I (eventually) came up with a solution that involved two D flip-flops (7474) in series.

The first D flip flop delays the falling edge of 2Q1 by one clock cycle and the second flip flop delays it by a further cycle. By ANDing  Q bar of the first flip flop with Q of the second flip flop I get a pulse which is delayed by one clock cycle. I then OR that to the input of the hours counter and it creates an second short pulse whenever the clock rolls over.. causing the clock to start at a count of 1.

## Conclusion

This is really just a proof-of-concept which was prototyped using a breadboard. However the electronics checks out and could form the basis a more permanent project.  I had some ideas on ways of (safely) tapping into the mains 50/60Hz signal to get a high precision clocks signal. Modern power utility networks control the frequency to a very high degree of accuracy (if averaged over 24 hours) and is as good as typical quartz crystal solution. Unfortunately I've run out of time. I might follow this up in a separate post later if there is interest.

Also I ran out of time on the clock setting function, which is a pity, because it's important :) This was going to be implemented by feeding the pulse-per-minute output from the seconds counter together with the output of a microswitch to a XOR gate and then forwarding the output of the XOR gate to the minutes counter.  This would allow the user to manually advance the minutes with each key button press (there may be need to debounce the switch). Ditto for the hours counter.   An alternative approach is use a microswitch to feed the 50Hz clock signal to the seconds stage, advancing the clock at high speed while the switch is depressed.

The bill of material:
• 4 x 74390
• 4 x 7408 (AND gates)
• 2 x 7486 (XOR gates)
• 3 x 7432 (OR gates)
• 1 x 7484 (D flipflops )
• LEDs (lots, about 70 + limiting resistors)
• 50Hz (or 60Hz) signal generator (using Arduino for prototype)
• 5V power supply (using Arduino 5V power supply)

The Arduino sketch to generate the 50Hz signal is:

void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);   // set the LED on
delay(10);
digitalWrite(13, LOW);    // set the LED off
delay(10);
}



jdesbonnet said...

Correction: BOM incorrectly lists a 7484 for the flipflops: it should be 7474.

Harley Pebley said...

"For the display ... Neon tubes would have been fantastic but way beyond my budget."

I wonder if EL Wire would work; kind of a modern pixie display.

Tom said...

But... but...! The Roman's divided daylight into 12 hours and nighttime into another 12 hours, regardless of season, so that daytime hours were longer in summer and shorter in winter, and the converse for nighttime hours. Perhaps incorporating astrological information, latitude, etc. exceeded Roman programming capability which might explain why they left digital clocks to future civilizations.