Introduction: Playing With Hand Wall Clock

Electronic hand wall clock (commercial marking quartz) are nowadays nothing special. It can be bought in many shops. In some of them they are extremely cheap; with price about €2 (50CZK). That low price can be motivation to take a closer look to them. Then I recognized, they can be interesting toy for newbies in electronic, who have not so many resources and who are mainly interested into programming. But would like to present own development to others.
Because cheap wall clock are very tolerant to experiments and beginners trials, I decided to write this article, where I would like to present basic ideas.

Step 1: Working Principle

It is easy to recognize, that clock using for movement some kind of stepper motor. The one, who already break apart some clocks recognized, that it is only one coil instead of two in usual stepper motor. In this case we are talking about "single phase" or "single pole" stepper motor. (This name is not used so often, it is mostly analogical derivation for marking used for other full stack stepper motors).
The one who already start thinking about working principle has to ask question, how it is possible, that motor always rotate in right direction. For working principle description is useful following image, that show older kinds of motors.

On first image is visible one coil with terminals A and B, gray stator and red-blue rotor. Rotor is made from permanent magnet, that is reason, why it is color marked, to be visible, in what direction is magnetized (it is not so crucial, what pole is north and what is south).
On stator you can see two "grooves" close to rotor. They are very crucial for working principle. Motor works in four steps. We will describe each step using four images.

During first step (second image) is motor energized, that terminal A is connected to positive pole and terminal B is connected to negative pole. It make magnetic flux, for example in direction of arrow. Rotor will stop in position, that it's position will correspond with magnetic flux.

Second step follows after disconnect of power. Then magnetic flux in stator is stopped, and magnet have tendency to rotate to position, it's polarization is in direction of maximum volume magnetic soft material of stator. And here are crucial those two grooves. They pointing to small deviation of maximum volume. Then rotor is rotate a little in clockwise direction. As shown on image 3.

Next step (fourth image) is with voltage connected reverse polarity (terminal A to negative pole, terminal B to positive pole). It mean, magnet in rotor will rotate in direction of magnetic field by coil. Rotor use shortest direction, that is again clockwise.

Last (fourth) step (fifth image) is same as second. Motor is without voltage again. Only one difference is, that magnet starting position is opposite, but rotor will again move to direction of maximum material volume. That is again position clockwise a little.

That is all cycle, first step follows again. For motor movement is steps two and four understand as stable. Then it is mechanically transferred to with gearbox 1:30 transfer rate to position of the second hand of watch.

Step 2: Working Principle Cont.

Figures show voltage waveform on motor terminals. Numbers means all seconds. In reality pulses are much smaller compare to spaces. They are about ones of milliseconds.

Step 3: Practical Disassemble 1

I used one of cheapest wall clock on market for practical disassemble. They have few pros. One is, that price is that low, that we can buy few of them for experiments. Because manufacturing is strongly oriented to price, they does not contain any complicated clever solutions as well as no complicated screws. In reality they does not contain any screws, only plastic click locks. The we need minimum tools only. For example we need screwdriver only for gouge out those locks.

For disassemble of wall clock we need flat tip screwdriver (or any other poke stick), clothes peg and working mat with raised edges (that is not mandatory, but make search for wheels and other small parts more easy).

Step 4: Practical Disassemble 2

On back side of wall clock can be found three latches. Two upper at position of numbers 2 and 10 can be unlocked and cover glass can be opened
When glass is open, it is possible to pull off clock hands. It is no necessary to mark position of them. We will always return them to position 12:00:00 When clock hands are off, we can unmount clock movement. It have two latches (at position 6 and 12). It is recommended pull out movement as straight as possible, otherwise movement can get stuck.

Step 5: Practical Disassemble 3

Then it is possible to open movement. It have three latches. two on positions 3 and 9 hours and then third on 6 hours. When opened, it is enough to remove transparent cogwheel between motor and gearbox and then pinion, that is connected with rotor of motor.

Step 6: Practical Disassemble 4

Motor coil and stator holds on one latch only (at 12 hours). It not holds to any power rails, it apply to power rails only by press, then removing is not complicated.
Coil is threaded on stator without any holder. It can be easily take off.

Step 7: Practical Disassemble 5

On bottom side of coil is glued small printed circuit board, that contains one CoB (Chip on Board) with six outputs. Two are for power and they are terminated on bigger square pads on board for apply power rails. two outputs are connected to crystal. By the way, the crystal is 32768Hz and can be de-soldered for future use. Last two outputs are connected to coil.
I found as more safe to cut off traces on board and solder wires to existing pads on board. When I tried to unsolder coil and connect wire directly to coil, I always tear off coil wire or damaged the coil. Soldering new wires to board is one of possibility. Let us say, that more primitive. More creative method is to connect coil to powering pads and keep powering rails for connection to battery box. Then electronics can be putted inside battery box.

Step 8: Practical Disassemble 6

Quality of soldering can be checked by using ohmmeter. Coil have resistivity about 200Ω. Once everything is OK, we cam assemble wall clock back. I usually throw power rails out, then I have more place for my new wires. Photos are taken before power rails are thrown. I forget to take next photo when they are removed.

When I'm finished with completing movement, I'm testing it by using second clock hand. I put the hand to it's axle and connect some power (I used CR2032 coin battery, but AA 1,5V can be used as well). Simply connect the power in one polarity to wires and then again with opposite polarity. Clock have to tick and hand shall move by one second.
Once you have problems to complete movement back, because wires take more place, simply rotate coil ant put it opposite side. Once not using power rails, it have no effect to clock movement. As it was stated already, when putting hands back, you have to put them to pointing to 12:00:00. It is to have correct distance between hour and minute hand.

Step 9: Wall Clock Usage Examples

Majority of simple examples focusing to display time, but with various modifications. Very popular is modification is called "Vetinari Clock". Pointing to Terry Pratchett book, where lord Vetinari have wall clock in his waiting room, that ticking irregular. That irregularity unsettle waiting people.
Second popular application is "sinus clock". It mean clock, that accelerate and decelerate based on sinus curve, then people have feeling, they are sailing on waves. one of my favorite is "lunch time". That modification mean, that clock go little faster in time between 11 to 12 hour (0.8 sec), to have lunch earlier; and little slower during lunch time between 12 to 13 hour (1,2 sec), to have little more time for lunch and to make up for lost time.

For majority of those modifications is enough to use simplest processor, using working frequency 32768Hz. This frequency is very popular with clock makers, because it is easy to make crystal with this frequency, and it ban be easy binary divided to complete seconds. It have two benefits to use this frequency for processor: we can easy re-cycle crystal from clock; and processors usually have minimal consumption on this frequency. Consumption is something we are solving so often when playing with wall clock. Especially to be able power clock from smallest battery, as long as possible. As it was already stated, coil have resistivity 200Ω and is designed for cca 1,5V (one AA battery). Cheapest processors usually working with little bigger voltage, but with two batteries (3V) working all of them. One of cheapest processor on our market is Microchip PIC12F629, or very popular Arduino modules. Then we will show how to use both platforms.

Step 10: Wall Clock Usage Examples PIC

Processor PIC12F629 have operating voltage 2.0V - 5.5V. Usage of two "mignon batteries" = AA cells (cca 3V) or two AA rechargeable AA accumulators (cca 2,4V) is sufficient. But for clock coil it is twice more than designed. It causes at minimum unwanted increase of consumption. Then it is good to add at minimum series resistor, that will create suitable voltage divider. Resistor value has to be about 120Ω for accumulator power or 200Ω for battery power calculated for pure resistive load. In practice the value can be little smaller about 100Ω. In the theory one resistor in series with coil is enough. I still have tendency, from somehow reason, to see motor as symmetric device and then putting resistor with half resistance (47Ω or 51Ω) next to each coil terminal. Some constructions adding protection diodes to avoid negative voltage to processor when coil is disconnected. From the other hand output power of processor outputs are enough to connect coil directly to processor without any amplifier.
Complete schematic for processor PIC12F629 will look like as described on figure 15. This schematic is valid for watches without additional control elements. We still have available one input/output pin GP0 and one input only GP3.

Step 11: Wall Clock Usage Examples Arduino

Once we would like to use Arduino, we can take a look to datasheet for processor ATmega328. That processor have working voltage defined as 1.8V - 5.5V for frequency up to 4MHz and 2.7V - 5,5V for frequency up to 10MHz. We have to be careful with one shortcoming of Arduino boards. That shortcoming is presence of voltage regulator on board. Big amount of voltage regulators have problems with reverse voltage. This problem is widely and best described for regulator 7805. For our needs we have to use board marked as 3V3 (designed for powering 3.3V) especially because this board contain crystal 8MHz and can be powered starting of 2,7V (it mean two AA batteries). Then used stabilizer will not be 7805 but its 3.3V equivalent. Once we would like to power board without using stabilizer, we have two options. First option is, connect voltage to pins "RAW" (or "Vin") and +3V3 (or Vcc) together and believe, that stabilizer used on your board have no under-voltage protection. Second option is simply eliminate stabilizer. For this is good to use Arduino Pro Mini, following reference schematic. That schematic contain jumper SJ1 (on figure 16 in red circle) designed for disconnecting internal stabilizer. Unfortunately majority of clones does not contain this jumper.

Another advantage of Arduino Pro Mini is, that it does not contain any additional converters, that can consume electricity during normal run (that is small complication during programming).
Arduino boards are equipped by more and more comfortable processors, that have not enough power for single output. Then it is good to add at minimum small output amplifier using pair of transistors. Basic schematic for battery power will look like as shown on figure.

Because Arduino environment (the "Wiring" language) have attributes of modern operation systems (then have problems with accurate timing), it is good to think about usage of external clock source for Timer0 or Timer1. It mean inputs T0 and T1, they are marked as 4 (T0) and 4 (T1). Simple oscillator using crystal from wall clock can be connected to any of those inputs. It depend, how accurate clock you would like to produce. Figure 18 show three basic possibility. First schematic is very economical in meaning of used components. It provide more less triangular output, but in full voltage range, then it is good for powering CMOS inputs. Second schematic using inverters, they can be CMOS 4096 or TTL 74HC04. Schematics are more less similar each other, they are in basic form. Third schematic using chip CMOS 4060, that allow direct connection of crystal (equivalent 74HC4060 using same schematic, but different values of resistors). Advantage of this circuit is, that it contain 14 bit divider, then it is possible decide, what frequency is used as timer input.

Output of this circuit can be used for input T0 (pin 4 with Arduino marking) and then use Timer0 with external input. That is not so practical, because Timer0 is used for functions like delay(), milis() or micros(). Second option is connect it to input T1 (pin 5 with Arduino marking) and use Timer1 with extra input. Next option is to connect it to interrupt input INT0 (pin 2 in Arduino marking) or INT1 (pin 3) and use function attachInterrupt() and register function, that is periodically called. Here is useful divider offered by chips 4060, then call must not be that often.

Step 12: Fast Clock for Model Railroaders Hardware

For interest I will present one useful schematics. I need to connect more wall clocks to common control. Wall clocks are far away each other and on the top of it environment characteristic is more industrial with bigger electromagnetic noise. Then I returned back to old systems of buses using bigger voltage for communication. Of course I did not solved working on battery, but I used stabilized power supply 12V. I amplified signal from processor using driver TC4427 (it have good availability and good price). Then I'm carrying signal 12V with possible load up to 0.5A. I added simple resistor dividers to slave clocks (on figure 18 marked as R101 and R102; Again I understand motor as symmetric, that is no necessary). I would like to increase noise reduction by carrying more current, then I used two resistors 100Ω. To limit voltage on motor coil is connected bridge rectifier B101 in parallel with coil. The bridge have shorted DC side, then it represent two pairs of anti-parallel diodes. Two diodes mean voltage drop out about 1.4V, that is very close to normal working voltage for motor. We need anti-parallel because powering is alternating in one and opposite polarity. Total current used by one slave wall clock is then (12V - 1.5V) / (100Ω + 100Ω) = 53mA. That is value acceptable to avoid noise.

Here is two switches on schematics, they are for controlling additional functions of wall clock (speed multiplier in case of model railroaders).
Daughter clock have one more interesting feature. They are connected using two 4mm banana connectors. They are holding wall clock on the wall. It is useful especially once you would like to set some specific time before start using, you can simply unplug them and then plug back again (wooden block is fixed to wall). If you would like to create "Big Ben", you need wooden box with four pairs of sockets. That box can be used as storage for clocks when they are not used.

Step 13: Software

From software point of view is situation relative simple. Let us describe realization on chip PIC12F629 using crystal 32768Hz (recycled from original clock). Processor have one instruction cycle four oscillator cycles long. Once we will use internal clock source for any Timer, it mean instruction cycles (called fosc/4). We have available for example Timer0. Timer input frequency will be 32768 / 4 = 8192Hz. Timer is eight bit (256 steps) and we keep it overflow without any barriers. We will focus only for timer overflow event. The event will occur with frequency 8192 / 256 = 32Hz. Then when we would like to have pulses one second, we have to create pulse every 32 overflow of of Timer0. One we would like to have clock running for example four time faster, then we need 32 / 4 = 8 overflow for pulse. For cases we are interested to design clock with irregular but accurate, we have to have sum of overflows for few pulses same as 32× number of pulses. Then we are can fount in irregular clocks matrix like this: [20, 40, 30, 38]. Then sum is 128, that is same as 32×4. For sinus clock for example [37, 42, 47, 51, 55, 58, 60, 61, 62, 61, 60, 58, 55, 51, 47, 42, 37, 32, 27, 22, 17, 13, 9, 6, 4, 3, 2, 3, 4, 6, 9, 13, 17, 22, 27, 32] = 1152 = 36*32).
For our clock we will use two free inputs as definition of divider for fast run. Table dith dividers for speeds is stored in EEPROM memory. Main part of programm can look like this:

MainLoop:
	btfss	INTCON,T0IF
	goto	MainLoop			; wait for Timer0

	bcf 	INTCON,T0IF
	incf	CLKCNT,f

	btfss	SW_STOP				; if STOP switch is active,
	clrf	CLKCNT				; clear counter every time
	
	btfsc	SW_FAST				; if fast button is not pressed
	goto	NormalTime			; calculate only normal time
	
	movf	FCLK,w
	xorwf	CLKCNT,w

	btfsc	STATUS,Z			; if FCLK and CLKCNT are the same
	goto	SendPulse
       		         	    		                                  
NormalTime:
	movf	CLKCNT,w
	andlw	0xE0 				; bits 7,6,5
	btfsc	STATUS,Z			; if CLKCNT>=32
	goto	MainLoop
	goto	SendPulse

Program using function SendPulse, that function create motor pulse itself. Function count odd/even pulse and based on that create pulse on one or second output.
Function using constant ENERGISE_TIME. That constant define time during that is motor coil energized. Thus it have big impact to consumption. Once it is so small, motor is not able to finish step and sometimes it happens, that second get lost (usually when second hand goes around number 9, when it going "upwards").

SendPulse:
	incf	POLARITY,f
	clrf	CLKCNT

	btfss	POLARITY,0
	goto	SendPulseB
       		         	    		                                  
SendPulseA:
	bsf 	OUT_A
	goto	SendPulseE

SendPulseB:
	bsf 	OUT_B
	;goto	SendPulseE

SendPulseE:
	movlw	0x50
	movwf	ECNT
SendPulseLoop:
	decfsz	ECNT,f
	goto	SendPulseLoop
	bcf 	OUT_A
	bcf 	OUT_B
	goto	MainLoop

Full source codes can be downloaded at the end of page www.fucik.name.
Situation with Arduino is little complicated, because Arduino using higher programming language and using own crystal 8MHz, we have to be careful what functions we are using. Use of classical delay() is little risky (it calculate time from function start). Better results will have usage of libraries like Timer1. A lot of Arduino projects counts on external RTC devices like PCF8563, DS1302, etc.

Step 14: Curiosities

This system of wall clock motor usage is understand as very basic. It exist a lot of improvements. For example based on measuring Back EMF (electrical energy produced by movement of rotor magnet). Then electronic is able to recognize, once hand are mover and if not, then quickly repeat the pulse or update the value of "ENERGISE_TIME".
more useful curiosity is "reverse step". Based on description it look like, that motor is designed for one direction of rotation only and it can not be changed. But as presented on attached videos, change of direction is possible. The principle is simple. Let us go back to motor principle. Imagine, that motor is in stable state of second step (Figure 3). Once we will connect voltage as presented in first step (Figure 2), motor will logically start rotation in reverse direction. Once the pulse will be short enough and will end up slightly before motor raise stable state, it will logically flicker over a little. Once in time of that flicker will arrive next voltage pulse as described on third state (Figure 4), then motor will continue with direction as it started, it mean in reverse direction. A little problem is, how to determine duration of the first pulse and once to create some distance between first and second pulse. And most worst is, that those constants vary for each clock movement and sometime vary for cases, that hands goes "down" (around number 3) or up (around number 9) and as well in neutral positions (around numbers 12 and 6). For case presented on video I used values and algorithm as presented in following code:

#define		OUT_A_SET	0x02		; config for out a set out b clear
#define		OUT_B_SET	0x04		; config for out b set out a clear
       		         	    		                                  
#define		ENERGISE_TIME	0x30
#define		REVERT_TIME	0x06

SendPulse:
	incf	POLARITY,f
	clrf	CLKCNT

	btfss	POLARITY,0
	goto	SendPulseB

SendPulseA:
	movlw	REVERT_TIME
	movwf	ECNT
	movlw	OUT_B_SET			; start with pulse B
	movwf	GPIO
RevPulseLoopA:					; short time wait
	decfsz	ECNT,f
	goto	RevPulseLoopA
	movlw	OUT_A_SET			; then pulse A
	movwf	GPIO
	goto	SendPulseE

SendPulseB:
	movlw	REVERT_TIME
	movwf	ECNT
	movlw	OUT_A_SET			; start with pulse A
	movwf	GPIO
RevPulseLoopB:					; short time wait
	decfsz	ECNT,f
	goto	RevPulseLoopB
	movlw	OUT_B_SET			; then pulse B
	movwf	GPIO
	;goto	SendPulseE

SendPulseE:
	movlw	ENERGISE_TIME
	movwf	ECNT
SendPulseLoop:
	decfsz	ECNT,f
	goto	SendPulseLoop
	bcf		OUT_A
	bcf		OUT_B
	goto	MainLoop

Use of reverse steps increase possibility of playing with wall clock.
We can found sometimes wall clock, that have smooth movement of second hand. We have no scare about those clock, they are using simple trick. The motor itself is same as motor described here, only gear ratio is bigger (usually 8:1 more) and motor spinning faster (usually 8x faster) that makes effect of smooth movement. Once you decide to modify those wall clock, do not forget to calculate requested multiplier.

Clocks Contest

Participated in the
Clocks Contest