Arduino controlled cockpit clock from a Boeing 747

Hi everyone,

I could really use some advice on how control a cockpit clock from a 747 that I bought off ebay. (I'd like to make a hugely cool desk clock) Here is what I know so far:

All clocks in the cockpit reference the same master time base. In other words, they don't have crystals in them that would allow them to run independent. You can think of it the same way the clocks in a school building or airport are all slaved to the same clock source. Anyway, in the real world these clocks would be running of the "28VDC Hot Battery" bus and would never loose power. All the clocks in the cockpit are connected together to a time base that creates a 60Hz signal. You an either build that signal as a square wave yourself with the Arduino. Depending on the model the two phase signals for the clock (they drive a stepper inside) are either in the range 0 to 5VDC or 0 to 24VDC.

I am having trouble with the two phase aspect of driving the stepper motors. I know that one must be 90 degrees out of phase with the other. However I don't know how to do this.

So far I can make a 16.5ms period square wave (Blinking an led) but can't figure out how to add another 90 degrees phase shifted.

All comments, suggestions etc are most welcome, and I'll post the results.

16.5ms is 16500 microseconds (usecs). Don't you just need to start the other blink 4125 usecs after the first one starts?

...R

Thanks for the reply!

Yes it seems that I do... But I'm not sure how. I'm running the script for blink without delay, but I can't seem to find how to start one after the other (I'm not savvy enough!).

Best,
Jordan

Try this ...

void loop(){
currentMicros = micros();
if ( (currentMicros - nextMicro1) >= 16500UL){
PIND = 0x00010000;  // toggle D4 - writing 1 to PINx toggles a bit
nextMicro2 = nextMicro1 + 4125UL; // time to phase shift
nextMicro1 = nextMicro1 + 16500UL; // time to next flip
}
if ( (currentMicros - nextMicro2) >=4125UL){
PIND = 0x00100000; // toggle D5
}
//
// do other stuff while waiting 
//
} // end loop

Fascinating as this exercise may be, the Arduino does not have a sufficiently accurate crystal timebase for a clock.

If you use it, you need an actual RTC module, and your task is to lock the Arduino's generation of the quadrature signals to the RTC.

There certainly used to be ICs which generated 50 or 60 Hz from a crystal, often a "colorburst" (cheap) crystal. It would be relatively simple to find one where a readily available crystal could generate 120 or 240 Hz, which you could feed to a dual flip-flop chip. If you have 120 Hz and 50 Hz, an Ex-Or gate will give you quadrature signals. If you have 240 Hz, just a dual D flip-flop connected as a "ring" counter will give you the quadrature signals.

Hey Paul,

Yes, it would be great to get the clock as accurate as possible but I'd like to try and get it close to get the unit running. After that I'll go the RTC route.

Thanks for your input!

J

How’s this look?

59.9997 to 60.0002Hz on GW Instwk GDS2204A that was calibrated this summer.

59.97 on an older uncalibrated Extech handheld multimeter

DS0001.BMP (1.37 MB)

? 2 minutes per year.

I figured out that the GW Instwk ... is an oscilloscope, but I can't figure out where you are getting the super-accurate square wave from? And is it the 'scope that was calibrated or the thing producing the square wave?

...R

CrossRoads:
How's this look?

59.9997 to 60.0002Hz on GW Instwk GDS2204A that was calibrated this summer.

59.97 on an older uncalibrated Extech handheld multimeter

The square wave is being generated by an Uno.

The scope was calibrated when I bought it.

I presume, then, that you mean the accurately timed square wave is produced by a standard un-modified Uno. I had wrongly assumed from the earlier posts that your pictures were from a specially calibrated "clock".

Interesting ...

...R

Yes, square wave is from a standard Uno Rev 3.
Similar result with an older Duemilanove.
micros() can be pretty accurate.