Arduino-based Master Clock for Schools
Intro: Arduino-based Master Clock for Schools
If your school, or kids school, or other location relies on a central master clock that is broken, you may have a use for this device. New master clocks are available of course, but school budgets are under extreme pressures, and it really is a satisfying project if you have the necessary skills.
This master clock controls the signals sent to the slave clocks, and keeps them synchronized. The firmware in the clock currently supports the National Time synchronization protocol. The master clock also controls the bells that can be set at scheduled times during the day. The firmware in the clock currently supports two bell zones (indoor and outdoor bells).
The firmware in the clock also automatically adjusts to daylight savings time (this can be turned off). This library might also be useful for other clock-projects (make sure to also get the modified DateTime library).
The clock is set up by connecting it to a computer via the Arduino USB port, and running a Java control program with a GUI interface. Once the time has been set, and a bell schedule loaded, the computer can be disconnected.
The design of the clock emphasizes simplicity, with a minimum of controls. Any complex setup is better handled by running the control program on a computer and temporarily connecting to the clock. The picture shows the front panel of the clock. The switch allows bells to be turned off completely if bells are not wanted (holidays, teacher training days etc.) The LEDs are normally all green, anything else indicates an unusual state.
This master clock controls the signals sent to the slave clocks, and keeps them synchronized. The firmware in the clock currently supports the National Time synchronization protocol. The master clock also controls the bells that can be set at scheduled times during the day. The firmware in the clock currently supports two bell zones (indoor and outdoor bells).
The firmware in the clock also automatically adjusts to daylight savings time (this can be turned off). This library might also be useful for other clock-projects (make sure to also get the modified DateTime library).
The clock is set up by connecting it to a computer via the Arduino USB port, and running a Java control program with a GUI interface. Once the time has been set, and a bell schedule loaded, the computer can be disconnected.
The design of the clock emphasizes simplicity, with a minimum of controls. Any complex setup is better handled by running the control program on a computer and temporarily connecting to the clock. The picture shows the front panel of the clock. The switch allows bells to be turned off completely if bells are not wanted (holidays, teacher training days etc.) The LEDs are normally all green, anything else indicates an unusual state.
STEP 1: Find Out About the Master Clock You Are Replacing
The master clock that was replaced by this project was a "Rauland 2490 Master Clock". It had stopped working during a storm with heavy lightning. The slave clocks were moving very quickly (continuous synchronization signal), and the master clock was subsequently shut off.
Thus the clocks in the school all showed about the same time, but all wrong, and always wrong. This proves that the expression "even a broken clock is right two times a day" is false.
You will need to know:
* what protocol is used by the slave clocks (can probably guess based on the make of the clocks)
* how many zones are used for bells (indoor, outdoor, different buildings etc)
Your school (or other location) may even have documentation in the form of wiring diagrams. These can be very helpful when installing the new clock.
Thus the clocks in the school all showed about the same time, but all wrong, and always wrong. This proves that the expression "even a broken clock is right two times a day" is false.
You will need to know:
* what protocol is used by the slave clocks (can probably guess based on the make of the clocks)
* how many zones are used for bells (indoor, outdoor, different buildings etc)
Your school (or other location) may even have documentation in the form of wiring diagrams. These can be very helpful when installing the new clock.
STEP 2: You Need These Items
The picture shows some of the component you will need. You will need more. Please leave a note if I forgot something. Unfortunately, this instructable is constructed after the fact so I do not have all the pictures I would like.
* Arduino (or similar) with a Atmel '328 and a USB connection (the Duemilanove is perfect)
* 12v wall wart (say 250 mA, depends on the number of relays you will be driving)
* 9V battery, holder, and connector
* LED's (one green, two red/green)
* diodes
* resistors
* relays (one for each bell zone, and one or more for the synchronization signal)
* LCD (standard 2x20 character HD44780-compatible display)
* suitable enclosures (large, medium, and small project boxes)
* plug and jack for power (5.5/2.1 mm for example)
* various screws and miscellaneous hardware
Computer with
* Arduino IDE installed (with the libraries needed, see step 5)
* the Java-based Master Clock Control program (and a Java runtime environment, and the rxtx library)
* USB port available
* USB cable for connecting to the Arduino
* time set to something reasonable
* Arduino (or similar) with a Atmel '328 and a USB connection (the Duemilanove is perfect)
* 12v wall wart (say 250 mA, depends on the number of relays you will be driving)
* 9V battery, holder, and connector
* LED's (one green, two red/green)
* diodes
* resistors
* relays (one for each bell zone, and one or more for the synchronization signal)
* LCD (standard 2x20 character HD44780-compatible display)
* suitable enclosures (large, medium, and small project boxes)
* plug and jack for power (5.5/2.1 mm for example)
* various screws and miscellaneous hardware
Computer with
* Arduino IDE installed (with the libraries needed, see step 5)
* the Java-based Master Clock Control program (and a Java runtime environment, and the rxtx library)
* USB port available
* USB cable for connecting to the Arduino
* time set to something reasonable
STEP 3: Put It Together the Hardware
I used three project boxes
* one large box for the electronics
* one medium box for the relay circuits (a mix of low voltage and high voltage)
* one small box for the high voltage connections
Make holes in the boxes where screws can hold them together.
Also make holes where wires can go between the boxes.
The small box also needs holes where wires can be hooked up for installation.
The medium box needs a hole for attaching the 9V battery holder.
The large box needs holes for the USB connector of the Arduino and a hole for the power jack.
The lid/top of the large box also needs holes for the LEDs, the switch, and the LCD.
* one large box for the electronics
* one medium box for the relay circuits (a mix of low voltage and high voltage)
* one small box for the high voltage connections
Make holes in the boxes where screws can hold them together.
Also make holes where wires can go between the boxes.
The small box also needs holes where wires can be hooked up for installation.
The medium box needs a hole for attaching the 9V battery holder.
The large box needs holes for the USB connector of the Arduino and a hole for the power jack.
The lid/top of the large box also needs holes for the LEDs, the switch, and the LCD.
STEP 4: Build the Electronics
Schematics will be added soon!
STEP 5: The Arduino Firmware
Load the "Master Clock Firmware" Arduino sketch into the Arduino IDE.
You will also need to install a number of other libraries (if you do not have them installed yet)
* DateTime (use the modified version attached here)
* DaylightSavings (see the next step)
* DateTimeStrings
* Flash
* Streaming
* LiquidCrystal (comes with IDE)
The libraries together with the code makes the sketch too large to fit in a Arduino ATmega128, which is why an '328 is needed. Perhaps if you remove some code that you do not need for your project it can fit.
You will also need to install a number of other libraries (if you do not have them installed yet)
* DateTime (use the modified version attached here)
* DaylightSavings (see the next step)
* DateTimeStrings
* Flash
* Streaming
* LiquidCrystal (comes with IDE)
The libraries together with the code makes the sketch too large to fit in a Arduino ATmega128, which is why an '328 is needed. Perhaps if you remove some code that you do not need for your project it can fit.
STEP 6: The DaylightSavings Library
This is an optional library that works together with the modified DateTime library.
If your daylight savings changes are not identical to the US post 2007 regime, then it is only necessary to modify a single function that is located in its own file. In fact, as more file for different locales are provided, they can all be distributed and chosen by simply using the one correct file. This limits the amount of code generated for this library.
If your daylight savings changes are not identical to the US post 2007 regime, then it is only necessary to modify a single function that is located in its own file. In fact, as more file for different locales are provided, they can all be distributed and chosen by simply using the one correct file. This limits the amount of code generated for this library.
STEP 7: The Java Control Program
This image show a screenshot of the Java Master Clock Control program running. First and foremost, it is used to set the time on the Arduino board.
It is possible to communicate with the Master Clock using the serial tool of the Arduino IDE.
It is possible to communicate with the Master Clock using the serial tool of the Arduino IDE.
STEP 8: Installation
If you are at all unsure about the safety precautions necessary when installing the new mater clock, you should probably consult an electrician.
The cleanest way to install the new master clock is to simply bypass the connections of the old master clock. For example, if there is a terminal on the old master clock that pulls to ground when the sync signal is "on", then connect this wire to the sync terminal of the new master clock. The other side of the sync terminal should then be connected to ground so that when the relay connects the wire to the ground the same effect is achieved.
Alternatively, the relay terminals can be connected to a hot wire (120 or 24V AC depending on slave clock specifications) and then to the sync wire. It really depends on the configuration of the existing system and how much you are willing to get your hands dirty.
The cleanest way to install the new master clock is to simply bypass the connections of the old master clock. For example, if there is a terminal on the old master clock that pulls to ground when the sync signal is "on", then connect this wire to the sync terminal of the new master clock. The other side of the sync terminal should then be connected to ground so that when the relay connects the wire to the ground the same effect is achieved.
Alternatively, the relay terminals can be connected to a hot wire (120 or 24V AC depending on slave clock specifications) and then to the sync wire. It really depends on the configuration of the existing system and how much you are willing to get your hands dirty.
STEP 9: It Works!
The new master clock has been installed and is working properly at an actual elementary school.
This is a great way for all the teachers to know who you are. Random children will come up to you and thank you for "fixing the clocks". Yes, people will even approach you in the local grocery store and thank you! They key here of course, is not to replace the broken master clock right away, but to wait a while before doing so.
The master clock handled the 1 November 2009 transition from daylight savings to standard time. The master clock showed the correct time, but the slave clocks did not. This was due to an electrical wiring problem (bug) where the synchronization signal relay was getting power only from the battery, and the battery was too weak. This was fixed and now the battery drain problem has also been fixed.
This is a great way for all the teachers to know who you are. Random children will come up to you and thank you for "fixing the clocks". Yes, people will even approach you in the local grocery store and thank you! They key here of course, is not to replace the broken master clock right away, but to wait a while before doing so.
The master clock handled the 1 November 2009 transition from daylight savings to standard time. The master clock showed the correct time, but the slave clocks did not. This was due to an electrical wiring problem (bug) where the synchronization signal relay was getting power only from the battery, and the battery was too weak. This was fixed and now the battery drain problem has also been fixed.
28 Comments
breitung1 6 years ago
Great idea. Would love to see schematics like nearly every other post/comment. Please teach the community how you do this...
Thank you in advance!
snewpaney 7 years ago
can you provide master clock control .jar for windows
AzizulH5 7 years ago
can i get the schematics ?
thanks please reply a.s.a.p
krish_embed 10 years ago
Please instruct me how to set alarm without using java programming i.e only use of hyper terminal etc, Bcz Java code doesn't work in my system.And please send schematic i would be a great help to me.
regard
Krish
JonIrving 11 years ago
AJC894 11 years ago
zzebrowski 12 years ago
Just a quick note to say that this is an awesome project.
Cheers!
Zak
pyperdown 13 years ago
tobyasz 14 years ago
How do I download the schematics?
thanks.
chunkyhomestyle 13 years ago
niamheus 13 years ago
MasterClockMaker 13 years ago
(1) You only stop the clock 2 minutes before the hour, and then apply the correction signal on the hour. You could only stop/start once per hour though.
(2) If you used a higher frequency (120Hz) the clock would run twice as fast, maybe that could be useful?
It would be so much simpler with a digital clock!
Perhaps taking an analog clock apart could help, I don't know exactly how they work.
Also, there are other slave clock protocols. Some advance only when sent a signal by the master clock. I think these are referred to as "impulse" control. I don't think they have second hands though. Maybe driving the second and minute hands separately somehow can achieve what you need.
Sorry I don't have a clear answer. I'll think some more and try to come up with something!
niamheus 13 years ago
I could go with option 1 then.
How does the master clock know the position of the hands on the slave clock?
Thanks for replying so quickly.
MasterClockMaker 13 years ago
So if the slave clock is slow, it will be corrected. If it is a little fast, nothing happens (I think), if it is very fast (or ahead), it will be an hour ahead after the sync. Hence the 12 hour sync, when everything will be 6 (pm or am looks the same).
There are some different protocols. "My" clocks use the National, or Standard Time protocol. There are some other similar, but slightly different ones.
For you, it would be a simple matter to cut the power for two minutes, and the clock hands would not move (not the second hand either). Turn on the power and it moves normally, except that it is 2 minutes behind. Apply the sync signal (for 25 seconds in my case) and the clock hands move fast to the next hour.
I hope this helps
niamheus 13 years ago
On a radio controlled clock mechanism, when the battery is inserted, the clock turns to 12. It then stops and waits for the correct signal. If the signal is recieved, the clock turns to the correct time. If the signal is not recieved, the clock starts operating as a quarts mechanism from 12.
Do you know is there any way we could make the clock work as a quarts movement without waiting for the signal?
Thanks Niamh
MasterClockMaker 13 years ago
Maybe if you take one apart it would be clearer.
Regular quartz clocks can be manipulated. They have a simple
motor that takes (~1.5V) pulses of alternating polarity, one short
pulse per second. If you generate these pulses (say with an Arduino)
they can be slower or faster in any way you wish. If you stop the pulses,
the clock will stop. If you send 10 pulses every second, the clock will
move 10x as fast, the second hand moving around the dial in 6 seconds!
It is tricky and unreliable to make it go backwards, as the direction is
designed into the metal parts of the motor (people make clocks that go backwards by flipping this piece of metal).
Anyway, If you use this idea, the clock (especially the second hand)
will move quickly as you "catch up" to real time. Using electronics
to generate the pulses allows for a lot of flexibility.
Let me know if I need to explain more.
Good luck!
spudstud 14 years ago
MasterClockMaker 14 years ago
Just change the name of the file you download to what it is supposed
to be, and it should work. Let me know if there is a problem. It should
definitely work on Mac OS X (it may not find the right port on Windows).
I'll see if I can get you the source code somehow, that would probably
be more useful for you.
The easiest communication is just by using the serial console in the
Arduino IDE. That's a good place to start.
MasterClockMaker 14 years ago
And yes, you can use the code for an alarm clock or any kind of timer.
The shift from daylight savings and back again has worked beautifully.
KC0GRN 14 years ago
Here is my situation. My church has a manual electric buzzer system (push one of the 3 buttons in the church and the buzzers go off, it only buzzes for as long as you hold the button) for signaling Sunday School, Church and Wednesday night programs.
What I thought would be nice is to have an arduino controlled clock to automatically sound the buzzers at the proper time intervals, and for the proper length of time, like a short or a long buzz to signal a 5 minute warning.
Obviously this doesn't need slave clocks, it just needs to operate a relay switch to take over for the manual buzzer buttons.