Very accurate timebase counter

fernando_g

Senior Member
Here is an application where the PICAXE assists to implement an accurate counter.

Designers have long known that powerline frequencies in (most) developed countries maintain a long term accuracy that rivals and sometimes exceeds crystal oscillators.
Thus this is a suitable timebase for long term counters, like clocks, energy monitors and the like.
Precisely this snippet is used in a solar installation where an accurate assesment of total energy (KWhr) produced over a long period of time is a must.

The KWhr conversion has a resolution of 1 pulse per watt-hour, thus it will produce 10,000 pulses per hour at the project's maximum (10 KW) output.
The frequency comes out at 2.777 Hz maximum.

The primary counter is an old and proven 74LS93 binary counter. The PICAXE's role is to produce an accurate timebase derived from the powerline, read and reset the counter at prescribed intervals, and accumulate the results for further processing down the road.

The circuit and listing are simple and self explanatory.
Transistors Q1 and Q2 produce a clean 500 usec pulse for the PICAXE to count using an interrupt on input0. The keyword here is clean.

The role of transistor Q3 is to provide a blanking signal during the falling edge of the pulses to be counted. The 7493 increments its counts during falling edges, but since it is a ripple counter, its outputs may spike during certain transitions, yielding erroneous results. Thus during all falling edges, Q3 will produce a positive pulse that is verified by the PICAXE's PortC to determine wheter is safe or not to read QA thru QB.

The 7493 is reset after each read via output 1. The time interval between reads is defined by the constant timing_pulses which is the product of the powerline frequency and the time interval.
 

Attachments

hippy

Technical Support
Staff member
I can appreciate the need for clean mains-synch pulses, but did you try taking the feed via a suitable current limiting R straight into a PICAXE input pin of Schmitt Trigger rather than TTL type ?

I did some experimenting with a PICAXE determining a capacitor's value by ramping its charge up and down via an R and timing it going high on an ST input and results where amazingly repeatable.
 

fernando_g

Senior Member
Your idea is quite valid..... However, perhaps I'm being over-cautious here, but I wanted to have some sort of "buffer" between the powerline and the PICAXE's input.

Now; Your suggestion may be very useful for the purpose of eliminating Q3...However, as I'm here using PortC, I could not find exactly what this port looks like, whether it is also schimitt triggered or TTL level...
 
Top