The £1.00 atomic clock - Page 1
Forum section: electronics / projects

author: picitup
author_rank: Regular Contributor
timestamp: January 20, 2017, 04:23:21 pm
content: Ok you guessed it, this is a fun project :-)Brimming with enthusiasm with my new BG7TBL gpsdo, I though I could connect the 1Hz output to my £1.00 quartz clock from the pound shop. After all, how hard could it be?There are some photos below of the teardown which was fun as the clock module case acts as supports for the gears. I'm really pleased I took some photos as I found a couple of gears on my bench and had no idea where they came from without looking back at the photos.On the photo ClockModuleLayout you can see the electronics and the solenoid. In fact there are only 3 electronic components, the chip under the black blob, the xtal which is probably 32.768KHz and a piezo speaker which is excited by the chip. If you look at the cog at the open poles of the solenoid, what is not so clear is the cylindrical magnet fitted to the underneath of the cog.Now for some testing. I assumed the solenoid is pulsed, and operates some kind of escape or ratchet mechanism but it's a little trickier than that.The solenoid was actually powered by AC, with a pulse going positive every 2 seconds and another going negative every 2 seconds. The ratchet is actually the solenoid turning the magnet/cog by attracting and repelling the magnet. 0.5HzAC_SolenoidPulses shows the scope connected across the solenoid coil.SingleNegativeSolenoidPulse shows a single negative pulse stretched out and you can see that it's approx 31mS long and about 0.9v. So that's a 0v signal pulsing +0.9v and -0.9v, each at 2 seconds, making the 1 second pulse to move the second hand.At this point, the hope of simply connected, or buffering the 1Hz pulse from the gpsdo goes out of the window. But I'm in this for the long hall so will try to interface it and get it working.The coil is approx 133 ohms, so if I=V/R the current passing through the coil is 0.9/133 = 7mA.

author: bpiphany
author_rank: Regular Contributor
timestamp: January 20, 2017, 07:26:26 pm
content: I recently took a similar clock movement apart. Mine simply pulsed alternating ends of the coil every second (that is one end the first second and the other the next second and so on), all "positive". If I remember correctly the pulses where ~50ms. What does the signal at the other end of you coil look like? I'll try to get an oscilloscope shot of mine..When I had it opened I suddenly wondered what made it run in the correct direction. Turns out if you pull that fork core out of the coil and flip it upside down the clock runs backwards

author: PA0PBZ
author_rank: Super Contributor
timestamp: January 20, 2017, 07:27:03 pm
content: Just a silly idea: Feed your 1Hz clock into a flipflop so you get 1s high-1s low, see the LTSpice below. The green is the ff output, the blue is the voltage over the coil.Not sure if you need the diodes and of course play with the value of the cap.

author: picitup
author_rank: Regular Contributor
timestamp: January 21, 2017, 08:40:32 am
content: @bpiphany it sounds like your solenoid maybe had 2 coils? Mine only has one with the cylindrical magnet between the poles. Funny you could make your clock go backwards. There could be a market here.....@PA0PBZ that's not a silly idea. I'll give it a try later on today. I had thought of using a jk flipflop as a divide by 2 then use the normal and inverted outputs to provide the AC voltage but the way you used the capacitor is brilliantly simple.I also considered using a couple of class B direct coupled amplifier circuits, but that's getting to complicated for a simple project.The only other idea was to use a pic chip to do:The frequency / 2The monostable pulse for the coilThe high impedance output (no connection) for the coilBy using 2 outputs, they could be 1 0 for 30ms, high Z for a second then 0 1 for 30ms, high Z etc.....After looking on the Microchip MAPS selector, the PIC10F320 looked useful and could be a single chip solution with no external components:Supply voltage - 2.3 - 5.5v - CR2016 battery?Internal 31KHz oscillator - no xtal needed50mA I/O current, so no external buffersAvailable in 8 pin DIP packageCost £2.00The firmware could be as simple as polling an input pin for change then setting the outputs appropriately, or even better, set an input pin to trigger an interrupt, waking the device from sleep, and that would extend battery life. Guess I'll see how much time I want to spend on it. I wouldn't expect the PIC10F320 to draw a massive amount of current at 31KHz.Well I've ordered a couple of pic chips, but will definitely try your idea @PA0PBZ as I think it has a lot of merit.I'll report back when I have some more progress.CheersSteve

author: bpiphany
author_rank: Regular Contributor
timestamp: January 21, 2017, 10:23:39 am
content: I'm pretty sure I connected ground to the battery(-) and probed both ends of the coil. Two connections from the black-dot-processor, one to each end of the coil. One positive 50ms pulse at the one end of the coil should make a magnetic filed in one direction, after that an equal positive pulse at the other end turns the magnetic field the other way. The first cog of the movement is a two pole permanent magnet that simply aligns to the field from the coil. That's why I'm interested in how the signal at the other end of your coil looks like. Is it permanently grounded or is it inverted relative to the signal you measured? I still believe you should be able to get away using the same kind of pulses that drive the movement I've got. All you should need to do is alternate the magnetic field in the coil. You may need to play around with voltage and pulse width to get it right i suppose.

author: SeanB
author_rank: Super Contributor
timestamp: January 21, 2017, 03:57:05 pm
content: Standard H bridge, the chip has 2 totem pole CMOS output stages, and simply gives an alternating high pulse on each output. You can get the same with a simple single divider and a simple monostable, triggered on the leading edge of the input clock, to enable a pair of AND ( or 2 cascaded NAND gates to get the AND function) gates to drive the clock coil, using a series resistor to limit the current, enabling you to drive them off 5V.There is a CMOS clock driver chip herehttps://www.digchip.com/datasheets/parts/datasheet/147/H1344-pdf.php

author: picitup
author_rank: Regular Contributor
timestamp: January 21, 2017, 04:35:27 pm
content: @bpiphany I see what you're asking. I didn't check any of the voltages with respect to the battery voltage, I just measured across the coil and said that is what I need to replicate. Unfortunately, I cut a bunch of tracks now to isolate the solenoid and battery, but if I open it up again, I'll take the measurements you suggest.@PA0PBZ I tried your idea and used a microswitch to supply +0.9v and then short to ground. 100 and 220uF did not store enough charge to operate the solenoid but 320uF did just. To allow a bit of leeway, I also tried 470uF which also worked fine. Press the microswitch, the capacitor charges and it ticks, release and the capacitor discharges and it ticks again. At least I know the hardware is in place and working. Hopefully I won't find any more cogs on the bench :-)I liked your diagram and trace - which software is that?@SeanB thanks for the data sheet. Very interesting. It's the H formation I'm intending to use with the pic chip when it comes. I did do some scribblings using discreet logic, but was seduced by using a single 8 pin chip for everything. I was looking for a jk flipflop with high current source/sink outputs and output enable then realised what I needed was a good 'ole pic chip.I've not played with pics for a long time and I see Microchip now give away fully functioning compilers for free and the more you pay the better the code optimisation. This is a good move for me, as I don't tend to write huge programs and if I do, simply use a chip with more memory.The ladies are off shopping tomorrow so I have a free day. I wonder if I have an old pic wired up somewhere? I could write the code tomorrow and then transfer it when the PIC10F320 arrives. Hm.....

author: PA0PBZ
author_rank: Super Contributor
timestamp: January 21, 2017, 07:24:44 pm
content: Quote from: picitup on January 21, 2017, 04:35:27 pmI think you can safely use a higher voltage and as a result a smaller cap, the circuit I showed was powered by a 5V square wave.QuoteI already mentioned it in my first post, it's LTSpice from Linear Technology, it's free.http://www.linear.com/designtools/software/

author: picitup
author_rank: Regular Contributor
timestamp: January 22, 2017, 11:40:20 am
content: Thanks I tested it on 0.9v as that was what I measured, but I'm sure you're right, a 30mS pulse with higher voltage and current isn't going to smoke it.Thanks for the tip on LTSpice, I must have skimmed over it. I'll download it and have a play.Having a dig around the shed, I managed to find a knocked up pic development board with and ICD header and a PIC16f1825 soldered to it. My MPLAB stuff was way out of date, so I downloaded MPLAB X IDE and XC8 from the microchip web site. My pickkit 3 programmer wouldn't work with a connection failed error message and a bit of googling revealed how to wipe the OS and then MPLAB reloaded a newer os and it works great. The intention is to get it working and then transfer it to the PIC10F320 when it arrives.So far I've managed to select the internal oscillator (31KHz) and flash an LED. I'm hopeful I'll get it working today, but we'll see as I'm pretty rusty on pics.CheersSteve

author: picitup
author_rank: Regular Contributor
timestamp: January 22, 2017, 08:40:12 pm
content: Well after spending the whole day refreshing myself on PIC programming, I've generated version 1 of the code. It waits for RA2 (the gpsdo 1pps) to go high, then outputs either a positive or negative pulse on RA0 and RA1, the opposite of the last one to flick the solenoid. In between pulses, RA0 and RA1 both go high so there's no current flow in the solenoid.Shame you can't upload videos here. You can see the gpsdo output led flas in sync with the clock ticking. And just to prove it, the clock stops if you disconnect the 1pps output.I was surprised at the current consumption, which was 1.3mA and is a little high for battery operation. I thought about sleeping for say, 850mS and then waking up with a timer, but the sleep instruction halts the program, but the current consumption is still 1.3mA. I think this is due to the internal oscillator being unaffected by sleep. A possibility is to use an external 32.768 Khz oscillator, but I need to read a bit more on sleep and how it works.The other option, is just power it from a USB charger but we'll see how things go. Once the PIC chip arrives in the post, I'll make a better job of it on stripboard so hopefully it can be mounted inside the clock.Attached is a pic of the lash up and the source code for anyone that's interested.Thanks for reading...Steve

author: bpiphany
author_rank: Regular Contributor
timestamp: January 22, 2017, 09:15:17 pm
content: After re-reading a couple of times I now realize you already said what I was trying to say on how to toggle the output pins. I also learned about the concept H-bridge.. Nice work =)This is one of the more creative clock modifications I've seenhttps://www.tindie.com/products/nsayer/crazy-clock/Clocks running backwards has been around since forever from prank gizmo stores. I just never knew they were the exact same, just slightly tweaked.I have a pet feeder also with a simple clock movement rotating the opening mechanism one turn in 24 hours. That's another factor 2 gear, but it's still impressive how much torque all that gear reduction gives. In a "smooth running" movement I took apart the first wheel turns 8 times faster, and the pulses are actually 50% duty cycle.For fun I copied the gearing of my movement to this neat gear script someone made goo.gl/JB0OIv

author: picitup
author_rank: Regular Contributor
timestamp: January 23, 2017, 08:02:47 am
content: Hi yes I thought we were saying the same thing, just coming at it from different angles :-) The crazy clock made me laugh and made me think. If my clock is essentially PIC controlled, I could do this by maybe queueing the 1pps from the gpdso and providing the clock tick pulses in a non-linear way.The pet feeder sounds cool. Do you have a piccy?@PA0PBZ thanks for the reminder on LTSpice. I've downloaded it and will play with it and produce a proper circuit diagram rather than my usual photo of some scribbling on paper :-OI'm really enjoying this project. What I assumed to be a simple buffering of the 1pps gpsdo signal, has turned into a small PIC project, and I've updated the compiler and dev environment from Microchip and will learn some new PIC stuff, like how to use sleep in detail.CheersSteve

author: bpiphany
author_rank: Regular Contributor
timestamp: January 23, 2017, 08:18:49 pm
content: Forgot my tick-tock movement at home this morning, but I took this shot of the oscilloscope measuring the smoother one (easily getting anything out of the WFM files from the scope seemed like an arduous job). Drilled a couple of holes to get at the coil pads. Each channel reads 8Hz with a 50% duty cycle. It doesn't show in a still shot, but if the Rigol isn't wandering around by itself, there's quite a bit of jitter in the signals.The feeders open when the notch in the dial lines up with the arrow. I haven't actually disassembled the movement, but they are of the tick-tock-1-second type.

author: picitup
author_rank: Regular Contributor
timestamp: January 24, 2017, 02:57:48 pm
content: I'm guessing if the frequency is 8Hz that it's a bit more of a stepper motor than the conical magnet in mine. Yes I think you should be cautious about taking the movement apart as you might have cog & spring sickness :-)I had a play with the current consumption, experimenting with different options. I set the tick delay to 5 seconds, so I had time to measure the current with and without the solenoid being excited. The first port of call was the xtal. The PIC circuit already had a 32.768 watch crystal so I switched from the internal 31KHz oscillator to the external xtal, but sleep mode still drew 1.3mA. After a bit of diddling around, I changed the idle state from 11 to 00 and the operating current dropped markedly. With this change, the exciting current for the coil was 8.8mA (for 30mS) and then just 320uA at all other times. I thought the coil may be drawing power when both pins are high, so I disconnected the coil but the current was high with 11 on the pins and low with 00. So it seems that the pic draws more quiescent current with the pins at 11 than 00. Weird.Still, 320uA for 97% of the time is much better than 1.3mA.I was going to have a sleep instruction, and the 1pps gpsdo signal connected to an interrupt pin, then it would be sleeping most of the time, but sleep doesn't draw any less current than 320uA so no point in over engineering it. I've seen it suggested that you should use the internal RC oscillator for lower power, but the PIC16LF1825 I have currently doesn't have one, but the PIC10F320 does, but that's in the post so I'll check it when it arrives and report back.

author: bpiphany
author_rank: Regular Contributor
timestamp: January 24, 2017, 05:10:21 pm
content: They are quite the same, just a couple of extra cogs in there. And slightly better build quality. Getting them back together isn't that bad... But you should be aware of that alreadySeems like I forgot to bring the second movement today again

author: bpiphany
author_rank: Regular Contributor
timestamp: January 25, 2017, 11:31:37 am
content: Finally did it.Also a side by side comparison of the two. They even bothered to screw the core in on the better quality movement. It's also not trivially flippable. You'd have to drill holes in it to make it fit (or snip some plastic I suppose).Also talking about great gear reductions without mentioning the machines with concretehttp://www.qedcat.com/archive_cleaned/120.htmlThey have been made in different varieties

author: KMoffett
author_rank: Regular Contributor
timestamp: January 25, 2017, 06:54:14 pm
content: To generate a 1Hz signal from the bipolar drive on the battery clicks. Some clocks have + to - pulses, others have -to + pulses. Thus the two versions.Ken

author: philpem
author_rank: Frequent Contributor
timestamp: January 25, 2017, 10:55:52 pm
content: Quote from: bpiphany on January 20, 2017, 07:26:26 pmEven more fun -- if you send signals way faster than 1Hz to the clock coil, you can get the movement to intermittently move backwards, but it's not reliable.I did this for a "wonderland clock" (think Alice in Wonderland) prop a few years back, but eventually settled on a design which ran the second hand faster and slower but kept the seconds and hours hands accurate (whatever time it gained, it lost by slowing down). Sadly due to external factors it didn't make it into the show, which was a shame after all the effort taken to get the timing absolutely bang on!I had a V2.0 of the mechanism which locks to a 1PPS signal. Think I did it with a few flipflops and a 555 (to generate the coil drive strobes), but only breadboarded it.Seems like this is a popular project - and rightly so - seeing a clock doing laps has an amazing ability to make people laugh out loud!

author: picitup
author_rank: Regular Contributor
timestamp: January 27, 2017, 10:28:22 am
content: Yes it is popular, maybe we should all get out more?The PIC10F320 arrived and I banged it on some stripboard with an ICD header which also acts as the battery connector. In hindsight, I wish I'd made the stripboard long and thin rather than square, then it would fit well inside the old battery compartment.After a couple of hours test, I noticed that although the second hand was moving, the hours and minutes weren't. Bummer. After taking the clock mechanism apart and putting it back together again, it worked fine, so I guess something hadn't quite connected to the right place.With a bit of hacking, I managed to fit a BNC connector on the back to connect to the 1pps gpsdo signal and have drawn a diagram using LTSpice (thanks PA0PBZ)The PIC source code is exactly the same, apart from some #pragma configs that did not exist for the new simpler chip. The 1pps signal is fed into input RA2 which can also be configured as an interrupt, so that will allow for further development, maybe the crazy clock?The only slight issue is that if you unplug the 1pps gpsdo signal, the second hand can move occasionally as that input is floating and probably needs a pull up/down resistor to make it more stable.As a quick test, I set the clock to the second last night and checked it this morning against:https://www.timeanddate.com/worldclock/uk/londonAnd it was bang on. Not a severe test, but a start.Well, that's me all done now. Thanks to everyone that posted up :-)CheersSteve

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 28, 2017, 10:24:25 am
content: I have recently built a slave clock driver for my Pragotron clock...You could make the PIC aware of the hands of the clock (i.e. tell it when it is in sync), the PIC can then record this (use EEPROM levelling to avoid wear) and then in the presence of a power fail it could subsequently catch the clock hands up with real-time. (You obviously need to either wait for the hands to be correct or drive it faster than time is advancing to catch up).That way you never have to set the hands again.https://aardvarklabs.wordpress.com/2016/05/21/pragotron-slave-clock/

author: picitup
author_rank: Regular Contributor
timestamp: January 28, 2017, 12:49:34 pm
content: That takes me back.... In 1975 I worked for British Telecom, the UK phone company and they had clocks all round the exchange, all controlled by a single pendulum and electrical contacts to provide 1 pulse per minute. The thinking was that although the time may not be exact, at least all the clocks in the exchange told exactly the same time.I see what you're saying; set the clock and the time in the pic and then it can supply approximate pulses if the gps is missing or power fails, then catchup when it's back. Of course, this also opens up the area of @bpiphany crazy clocks.Neat idea :-)

author: NivagSwerdna
author_rank: Super Contributor
timestamp: January 28, 2017, 04:24:30 pm
content: Quote from: picitup on January 28, 2017, 12:49:34 pmI really meant it would just STOP in the absence of power but when power was reapplied and the time was recalculated again it would adjust the hands automagically. The power drops in our house quite frequently due to general electrical tinkering and building work etc.

author: picitup
author_rank: Regular Contributor
timestamp: February 04, 2017, 02:10:59 pm
content: OK thanks I get it now.Well I happened to be in the pound shop again and they had wall clocks on sale so I thought it would be nice to have a bigger clock controlled by the GPSDO.BTW the first yellow clock has kept time to within the second for a week. No great news, but at least it shows it's working.While bending the outer case to remove the bezel, I managed to crack it as it's thin glass (see pic) . Bummer. I may have some thin acrylic sheet somewhere.It came apart pretty easily and attached are some photos of the teardown. The second issue was the glue holding the copper on the PCB is rubbish and I managed to tear off the pads which connect the solenoid (see WallClockPCB). So a short pause while placing a blob of Araldite over the area to fix it down again.The solenoid works in pretty much the same way as the previous clock, with a cylindrical magnet being driven by a positive then negative pulse (see scope traces). The waveform is 0.5Hz, with a 30mS pulse of a touch over 1v.Fortunately, I bought 2 PIC10F320 chips, so there's one spare for just such an occasion.When the araldite has set, I'll do some more and report back which will probably be tomorrow.CheersSteve

author: picitup
author_rank: Regular Contributor
timestamp: February 04, 2017, 02:14:17 pm
content: OOps, piccies

author: NivagSwerdna
author_rank: Super Contributor
timestamp: February 06, 2017, 11:14:00 am
content: Those traces are exactly what I see on cheap IKEA clocks (I have quite a large pile of the them left over from a fundraising project where I used to convert them to run backwards and replace the faces)I have a large clock with a broken glass which I have been meaning to fix. It seems that getting glass cut isn't much of a problem if you shop around although I haven't done this yet myself. (You need to decide on the type of glass, thickness etc... must do that one day)My main wall clock doesn't have a second hand so the number of pulses to get back in step following a power interruption isn't too bad. Watching it for the DST change is also fun.

author: picitup
author_rank: Regular Contributor
timestamp: February 27, 2017, 04:03:35 pm
content: Sorry for the slow reply, things have been hectic. @NivagSwerdna you've confirmed my beliefs that everything is made by one person in Taiwan and just re-badged.I managed to get another £1.00 clock to replace the glass I bust and set to work. The hardware and software is exactly the same as the first attempt, apart from a 22K resitor from input to ground to stop spurious triggers when the BNC is disconnected and a microswitch (NC) to disconnect the input signal to set it exactly to the second. You get the second hand to the top, press the switch and the clock stops then let go when you want it to start again.I've attached a couple of piccies and I've just spotted the face doesn't line up with the BNC. Bummer a bit of twisting required and no breaking of glass.Also attached is the new diagram which includes the 22K resistor and microswitch.CheersSteve