Author Topic: clock beat generator  (Read 13763 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
clock beat generator
« on: February 10, 2012, 10:36:26 pm »
Right, I have been volunteered for a task. My dads frind has a clock that needs a circuit to generate a 1s beat for the coil that pushes the second hand round. So I'm thinking that being a clock something like a 555 is no good as the RC components will change with temperatures. I'm thinking a PIC 12F615 as it can run off internal clock and I can easily write some simple code to generate a 1 Hz pulse and control the duty accurately.

Is the internal clock accurate enough for this or should i use a quartz ?
 

alm

  • Guest
Re: clock beat generator
« Reply #1 on: February 10, 2012, 11:15:28 pm »
I don't know the specs of the internal oscillator by heart, but I believe it's a standard RC oscillator with a stability of 1% or so, worse over temp. This would mean that it could be about 15 minutes off per 24 hours, totally unacceptable for most applications. A 32.768 kHz crystal would be good for this application and should work with the real time clock peripheral in PICs (not sure if the PIC12 supports this).

Even a lousy computer grade (=absolute crap in crystal terms) crystal would be about two orders of magnitude better than the internal RC oscillator. A good watch has an accuracy that is measured in seconds per month. Timekeeping is one of those rare applications where absolute accuracy and tight tolerances are actually important, since it's annoying to set a clock every day, and the error adds up over long time spans.
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Re: clock beat generator
« Reply #2 on: February 11, 2012, 01:22:13 am »
i will not give the mcu internal osc (free feature) a first thought if its about accuracy of timekeeping. get the best oscillator you can afford. i have avr running with internal osc like 4MHz at one time and 4.9MHz the other time, not exact value but the point is.... crap!
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline ivan747

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: us
Re: clock beat generator
« Reply #3 on: February 11, 2012, 02:11:24 am »
Run a PIC12F629 from a 32.768kHz crystal, enable the timer 1 overflow interrupt. This way you will have an interrupt every 8 seconds by default. To change it to a second by write the value 57344 to the timer register pair minus the amount of instruction cycles taken to perform this operation. I recommend you pause the timer during the operation.

An easier way is to make a loop and wait for the second to elapse (8192 instructions must be executed). The amount of non-operational instructions to run is determined by the number of instructions per second (8192) minus the amount of functional instructions, like changing the output to high or low. This will make the code less flexible. You can use a PIC10F200 with this method, but you will have to make some loops instead of coding 8000+ NOP instructions.

When you are done check against a frequency counter just to be sure you are not executing and extra instruction.

I haven't tested any of these, but I would like to hear the results, specially if you use a PIC10F200, assembly language, and you keep the PCB under 2cm x 2cm!
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: clock beat generator
« Reply #4 on: February 11, 2012, 02:12:46 am »
a way that is commonly used in some of the modern-ish coil based clocks where a crystal is involved is a 1.024, 2.048 or 4.096Khz crystal and a matching divide by counter chip, e.g. a CD4059,

 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: clock beat generator
« Reply #5 on: February 11, 2012, 03:11:53 am »
Dallas Semiconductor do some great real time clocks with temperature compensated integrated oscillators. They have a 1Hz output on a pin. e.g. The DS3231

But (sigh) it requires a micro to talk to the chip over SPI or I2C to turn it on. Typical!

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #6 on: February 11, 2012, 08:39:57 am »
ok so I need a crystal, so a standard 20 MHz crystal is no good either ? I'm definitely using a 12F615 as I'm familiar with it. I'm afraid I'll have to write it with basic as that is al  know. My plan was for a looped program and just have "x" time high, "y" time low and fine tune it
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Re: clock beat generator
« Reply #7 on: February 11, 2012, 09:10:47 am »
ok so I need a crystal, so a standard 20 MHz crystal is no good either ?
depends... dave has video regarding 10MHz rubidium oscillator. $30$50 in ebay ;)
« Last Edit: February 11, 2012, 09:14:43 am by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #8 on: February 11, 2012, 09:12:29 am »
ok so I need a crystal, so a standard 20 MHz crystal is no good either ?
depends... dave has video regarding 10MHz rubidium oscillator. $30 in ebay ;)

link ? or is it clearly listed on the episode list, mind you I'm after doing it for a fiver
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: clock beat generator
« Reply #9 on: February 11, 2012, 09:53:17 am »
Maxim has 32.768 kHz TCXO available which might be suitable here:

http://www.maxim-ic.com/datasheet/index.mvp/id/2940

Obviously not as good as rubidium frequency standard but I guess that one might get away with ±2 PPM accuracy (about ±60 seconds/year).

Regards,
Janne
« Last Edit: February 11, 2012, 09:55:06 am by jahonen »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #10 on: February 11, 2012, 09:59:56 am »
bummer, it is nearly a tenner and needs getting in from the USA (+£15) at farnell, RS have it though  :)
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: clock beat generator
« Reply #11 on: February 11, 2012, 10:30:21 am »
A crystal is a start. But without trimming it, or compensating the frequency offset in software, you will find its accuracy being lacking, compared to what you are used from your wrist watch (while the precision is sort of ok). +/- 10 ppm are still almost +/- 1 second a day, 5 minutes/year.

Factory adjusted RTC ICs, like some of those from Maxim/Dallas are indeed a more accurate, worry free, solution, especially for a one-off.  They are more expensive, but can give you 2 minutes/year accuracy.

A rather cheap solution are radio clock receivers. You sometimes get receiver modules very cheap. I think I payed 6 Euro for my last one, but that was a DFC77. I also happen to find separate, salvageable receiver modules in cheap battery operated travel alarm radio clocks.

Decoding the signal from such a module in software is usually simple and it is easy to adjust an internal MCU timer/counter with the result of the decoding. I would recommend to still have a running, crystal clocked timer/counter in the MCU to cope with signal loss. As long as you manage to get a radio signal once a day you can keep the timer/counter very accurate. Commercial consumer radio clocks do a similar thing. To save power they just turn on the receiver a few times a day to adjust their crystal clock.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Re: clock beat generator
« Reply #12 on: February 11, 2012, 10:34:23 am »
Quote
link ? or is it clearly listed on the episode list, mind you I'm after doing it for a fiver
its clear in the list (main eevblog homepage). ep#235 & #236
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #13 on: February 11, 2012, 11:28:41 am »
A crystal is a start. But without trimming it, or compensating the frequency offset in software, you will find its accuracy being lacking, compared to what you are used from your wrist watch (while the precision is sort of ok). +/- 10 ppm are still almost +/- 1 second a day, 5 minutes/year.

Factory adjusted RTC ICs, like some of those from Maxim/Dallas are indeed a more accurate, worry free, solution, especially for a one-off.  They are more expensive, but can give you 2 minutes/year accuracy.

A rather cheap solution are radio clock receivers. You sometimes get receiver modules very cheap. I think I payed 6 Euro for my last one, but that was a DFC77. I also happen to find separate, salvageable receiver modules in cheap battery operated travel alarm radio clocks.

Decoding the signal from such a module in software is usually simple and it is easy to adjust an internal MCU timer/counter with the result of the decoding. I would recommend to still have a running, crystal clocked timer/counter in the MCU to cope with signal loss. As long as you manage to get a radio signal once a day you can keep the timer/counter very accurate. Commercial consumer radio clocks do a similar thing. To save power they just turn on the receiver a few times a day to adjust their crystal clock.

well if we are talking about worrying about the difference between 2 minutes per year and 5 minutes per year I'll take the cheaper option. The other possibility is that as it is a one off i get a cheap clock mechanism and hack that with an output transistor to interface it to the 12V this old clock runs off.

But are you saying that a micro with a generic quartz will be like 5 minutes per year accurate ? that's fine also.
 

Offline Jad.z

  • Regular Contributor
  • *
  • Posts: 83
  • Country: 00
Re: clock beat generator
« Reply #14 on: February 11, 2012, 11:56:30 am »
Hi Simon

take a look at those circuits. They are both simple, cheap and work fine, I've used both of them so i know they work fine  :)

http://www.mcamafia.de/nixie/ncp_en/ncp.htm

http://www.schematicwiringdiagram.com/t/schematicwiring/1-hz-timebase


And of course if the application is AC powered there is always the old method of dividing the 60/50Hz Down to 1Hz.
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: clock beat generator
« Reply #15 on: February 11, 2012, 12:08:08 pm »
If you can trim your oscillator to +/-10 ppm you get five minutes. A watch crystal is about +/- 20 ppm, a normal crystal +/- 30 or 40 ppm. So some trimming / compensation in software required to get to 5 minutes/year. And don't forget that the frequency is also temperature-dependent.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: clock beat generator
« Reply #16 on: February 11, 2012, 01:25:15 pm »
dividing from mains frequency is just horrible, its a 0.2% tolerance,

forgot the values, a 32.786khz signal, a CD4040 can divide by 14 bits, or 16384 leaving only 1 bit of division left able to be done by a second, or a generic flip flop, with a generic crystal with a yearly drift of a 1-3ppm can beat 1.5 minutes per year, once tuned, (variable capacitance in series or parrellel) (untuned you would be looking at about 10 minutes)

this is the simplest and quickest to implement method i know of, sorry about the odd values before,
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #17 on: February 11, 2012, 01:34:08 pm »
ok well things have changed slightly. I've just been to see the guy and he has shown me the clock. It needs 30s pulses. There is no second hand and the minute hand does steps of 30 seconds. It is an old fire station clock. so I think I need something like a 0.5s pulse every 30s, perhaps a micro controller will be the best thing ?

So will a basic crystal be fairy accurate ? like a few minutes to the year.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: clock beat generator
« Reply #18 on: February 11, 2012, 01:47:08 pm »
if tuned, a cheap 32.768Khz crystal with a yearly drift of 3ppm ends up being about a maximum of 1.5 minutes off per year, without tuning, at 20ppm initial offset is about 10 minutes to a year,
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #19 on: February 11, 2012, 01:47:44 pm »
sounds good enough
 

Offline deephaven

  • Frequent Contributor
  • **
  • Posts: 796
  • Country: gb
  • Civilization is just one big bootstrap
    • Deephaven Ltd
Re: clock beat generator
« Reply #20 on: February 11, 2012, 01:53:25 pm »
Use http://uk.farnell.com/citizen-america/cfs206-32-768-kdzf-ub/crystal-watch-32-768khz-cyl/dp/1457084 with your pic. Set the timer to interrupt every 32768 to give 1 second interrupt, then have a software counter counting 30 seconds.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #21 on: February 11, 2012, 03:44:55 pm »
well I guess I should get the hang of driving a pic with a quartz to start
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #22 on: February 11, 2012, 04:51:25 pm »
I'm getting adventurous now  ;)

I should put in a fast forward button so that the time can be set, and I could put in two trim buttons to increase and decrease the speed slightly and a reset button, that way if I'm that far out it can be trimmed and the time set
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: clock beat generator
« Reply #23 on: February 11, 2012, 06:58:24 pm »
You could use an oscillator/counter/timer IC such as the CD4060, CD4541 or CD4536 and a divide by n counter CD4059 to get 1/30Hz from a 32768Hz watch crystal.
 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: clock beat generator
« Reply #24 on: February 11, 2012, 07:41:00 pm »
UK mains might not be very accurate short-term, but over any given 24 hour period it is very accurate indeed. If you aren't limited to battery power and you want the ultimate accuracy, you can get cheap GPS modules off Ebay that give a 1pps output. Obviously having a 2ppm output requirement now messes that up. Sigh.

Online IanB

  • Super Contributor
  • ***
  • Posts: 11859
  • Country: us
Re: clock beat generator
« Reply #25 on: February 11, 2012, 11:43:45 pm »
dividing from mains frequency is just horrible, its a 0.2% tolerance

The mains frequency in the UK used to be required by law to keep perfect time. It has been very common for mains powered clocks to get their timing from the mains. I believe the power companies are trying to get that standard relaxed now, but as far as I know it remains a pretty good time reference for clocks.

For Simon my first thought would have been to get the mains frequency and divide it down. It only needs discrete circuitry, not even an MCU.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3713
  • Country: us
Re: clock beat generator
« Reply #26 on: February 11, 2012, 11:57:51 pm »
dividing from mains frequency is just horrible, its a 0.2% tolerance,

In the US and Europe mains frequency is controlled by atomc clocks.  There can be short term fluctuations where short term could be weeks. Over the long term it is more stable than any crystal.  If you plug your clock in and set it while the grid is a couple of minutes behind, it will gradually slew forward and then stay permanently a few minutes fast.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: clock beat generator
« Reply #27 on: February 12, 2012, 12:30:48 am »
well atleast its offset here, all the grid connected solar inverters really mess with the grid in aus, not just voltage but frequency,
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #28 on: February 12, 2012, 11:30:42 am »
dividing from mains frequency is just horrible, its a 0.2% tolerance

The mains frequency in the UK used to be required by law to keep perfect time. It has been very common for mains powered clocks to get their timing from the mains. I believe the power companies are trying to get that standard relaxed now, but as far as I know it remains a pretty good time reference for clocks.

For Simon my first thought would have been to get the mains frequency and divide it down. It only needs discrete circuitry, not even an MCU.

I was starting to consider that but now i also need a very small duty cycle although I guess a monostable can sort that (555).

The clock coil does use 0.17 to 0.22 amps so I also need to look carefully at power consumption and the type of batteries I use.

the original setup of this clock in a firestation was that there were a number of clocks in series connected to a battery and a switch that was worked by a pendulum to give the timing. Obviously the timing bit was the more expensive so it was easier to wire all clocks in series and used one central reference. The battery voltage is unknown and i guess was possibly changed according to how many clocks were in series so that is probably why there is a min/max spec for the coil on the back of it
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16276
  • Country: za
Re: clock beat generator
« Reply #29 on: February 12, 2012, 01:43:46 pm »
Simple method is to take a clock ( Cheap single cell wall clock is perfect, and looks of the clock don't matter here) and rip apart the clock mechanism, to get the small PCB with the crystal, divider and clock driver out of it. Make a note of which pads go where. Power it from a 1.5V supply ( a resistor driving a red LED and a 100uF bypass capacitor) and use a single NPN transistor with a 10k base resistor and 10k collector resistor as a level shifter. Gives a simple source of pulses at 2 second intervals, now you just use 2 4017's to divide by 5 and 3 respectively, using the output from 2 ( or 1) from the second divider to trigger a 0.5 second monostable to drive the clock coil.  Being a slave clock in a master slave system you probably will need a simple 24V DC supply to drive the coil, which does not need to be regulated, an 18VAC transformer and a bridge with 1000uF/50V capacitor will work fine . Use a 7812 to make 12V for the dividers, and drive the clock from the 12V rail, the LED will double as a power indicator.
 

Offline siliconmix

  • Frequent Contributor
  • **
  • Posts: 466
  • Country: wales
Re: clock beat generator
« Reply #30 on: February 12, 2012, 05:07:13 pm »
dividing from mains frequency is just horrible, its a 0.2% tolerance

The mains frequency in the UK used to be required by law to keep perfect time. It has been very common for mains powered clocks to get their timing from the mains. I believe the power companies are trying to get that standard relaxed now, but as far as I know it remains a pretty good time reference for clocks.

For Simon my first thought would have been to get the mains frequency and divide it down. It only needs discrete circuitry, not even an MCU.

I was starting to consider that but now i also need a very small duty cycle although I guess a monostable can sort that (555).

The clock coil does use 0.17 to 0.22 amps so I also need to look carefully at power consumption and the type of batteries I use.

the original setup of this clock in a firestation was that there were a number of clocks in series connected to a battery and a switch that was worked by a pendulum to give the timing. Obviously the timing bit was the more expensive so it was easier to wire all clocks in series and used one central reference. The battery voltage is unknown and i guess was possibly changed according to how many clocks were in series so that is probably why there is a min/max spec for the coil on the back of it

make a extra special job of it simon and drop one of these in there.use the pic to decode the signals
http://www.ebay.co.uk/itm/MSF-Atomic-Clock-Receiver-Module-Rugby-Atomic-Clock-/230740011322?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item35b92d293a#ht_2314wt_932
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #31 on: February 12, 2012, 05:33:20 pm »
no sure I need to go that far lol
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11859
  • Country: us
Re: clock beat generator
« Reply #32 on: February 12, 2012, 05:58:45 pm »
the original setup of this clock in a firestation was that there were a number of clocks in series connected to a battery and a switch that was worked by a pendulum to give the timing. Obviously the timing bit was the more expensive so it was easier to wire all clocks in series and used one central reference. The battery voltage is unknown and i guess was possibly changed according to how many clocks were in series so that is probably why there is a min/max spec for the coil on the back of it

That was a very common thing once upon a time--I think it was called a master clock system. My school had such a system and probably every other school did too. It permitted every clock in every building to show exactly the same time, so all the lessons could keep to the same timetable and start and end exactly on cue. You would find clock systems like that in offices, factories, stations, everywhere. I'm not sure its even obsolete today because even quartz clocks can't keep time that accurately. And imagine if you had to go around and manually adjust dozens of clocks to adjust them, rather than just adjusting the central master clock?
 

Offline siliconmix

  • Frequent Contributor
  • **
  • Posts: 466
  • Country: wales
Re: clock beat generator
« Reply #33 on: February 12, 2012, 06:00:51 pm »
the rugby signal is still used it's on digital watches and weather clocks
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: clock beat generator
« Reply #34 on: February 12, 2012, 06:11:14 pm »
the original setup of this clock in a firestation was that there were a number of clocks in series connected to a battery and a switch that was worked by a pendulum to give the timing. Obviously the timing bit was the more expensive so it was easier to wire all clocks in series and used one central reference. The battery voltage is unknown and i guess was possibly changed according to how many clocks were in series so that is probably why there is a min/max spec for the coil on the back of it

That was a very common thing once upon a time--I think it was called a master clock system. My school had such a system and probably every other school did too. It permitted every clock in every building to show exactly the same time, so all the lessons could keep to the same timetable and start and end exactly on cue. You would find clock systems like that in offices, factories, stations, everywhere. I'm not sure its even obsolete today because even quartz clocks can't keep time that accurately. And imagine if you had to go around and manually adjust dozens of clocks to adjust them, rather than just adjusting the central master clock?

Sadly this is a single clock hence he needs the timing generator.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf