Measuring LF pulse periods: SETTIMER vs COUNT (or other methods)

I am impressed by what I've read on this forum. I have so many questions to ask, but I must resist the temptation to start new threads. But maybe I may be allowed this one, as it's foxing me at the design stage.

Here's the setup. An experimental electro-mechanical clock (a subject dear to my heart although maybe of interest to only a few hundred people on the entire planet) has a mechanical oscillator (a pendulum). It is driven by a Fedchenko drive. These work by placing a small permanent magnet at the bottom of the pendulum and detecting its swing using a sense coil and an ADC (in this case, in a PICAXE). At appropriate times, every n swings (typically 30), an impulse is delivered to the pendulum by means of a second drive coil. These work well and only take a few lines of PICAXE code: so far, so good. Assume one sense pulse per second/per swing, i.e. a pendulum with a two second period.

The problem I'm struggling with is a monitoring circuit that will reference the pendulum timing to a stable oscillator and display the pendulum's error in real time. In discrete logic one might do this by using the pendulum's one-second-ish pulses to gate a stable oscillator of a much higher frequency and look at the count of pulses received. So, for example, if the stable reference was 8192 Hz and the pendulum was bang on one second, a count of 8192 would be recorded. If a count of 8190 was recorded, the pendulum is 2/8192th of a second slow, etc. It would then be simple to generate a slow/on time/fast display updated each second, making adjustment a doddle. (Fine adjustment is by control of the drive coil's power, using a ten-turn pot connected to a variable constant-current source. This makes use of the fact that pendulums are not isochronous: their period changes slightly with the amplitude of their swing.)

Looking at the COUNT command, it seems to be dependent for its count period on the PICAXE's internal clock: it's not immediately apparent how it could be used for a 'gated' count of the sort described above. There is also the SETTIMER command, but both these seem to lend themselves to counting the one-second pulses based on the higher-frequency and accurate oscillator, i.e. the opposite of what I need. This would work, but would require a vastly longer time to generate a meaningful display, at the least many hours.

I would welcome any advice on how to use a PICAXE to measure deviations in the period of slow pulses. As long as I know it's doable, I don't need to worry about the details of the implementation at this stage. Elegance demands that I make a PICAXE do the work, but if it's not possible, a bit of external logic would do it.
 

eggdweather

Senior Member
An interesting project. My first thought was you well need a good reference clock source, a standard 32768 Hz xtal is typically 20ppm parts per million, but that's not that accurate. My Omega Seamaster watch easily achieves 1-sec per month accuracy which is about 0.75-ppm. Getting hold of such a reference oscillator is not easy, but that said you can buy the on eBay for about £15. Having got a source to measure your swing duration and the logic resolved which from your description you appear to have then its some calculations to ensure say the count command does not overflow for a pendulum period for a given reference clock input.

What accuracy are to looking to achieve?
 
As the clock will be experimental, its accuracy is unknown, but the idea I outlined is not intended to measure its absolute accuracy, just provide an aid to getting it into the right ball-park. I would use a Chronodot for this, which is good for plus or minus 3 ppm.

For long-term accuracy measurements, I will use a Microset clock timer. I just wanted to see if a PICAXE could be programmed to look at the period of low-frequency pulses based on this idea (comparing one oscillator against another).
 
Looking at SETTIMER more closely, it looks as if it can do what I want in external counter mode (manual part 2, page 232). If the reference oscillator was fed to C.0 on, say, a 28X2, while the pendulum's one-second-ish signal was monitored on another pin within a loop, the reference pulse count could be measured at the period of the pendulum.

It is a minor niggle that the SETTIMER command only available on 28 and 40 leg variants.

Incidentally, I made an error in my original posting: for 'If a count of 8190 was recorded, the pendulum is 2/8192th of a second slow', read 'If a count of 8190 was recorded, the pendulum is 2/8192th of a second *fast*'.
 
Top