Close

Basic Operation

A project log for FreqCounter

A high-precision, I2C-connected & configurable frequency/event counter good to 50+ MHz with 1Hz +/- 1 precision.

SevSev 08/21/2014 at 05:100 Comments

0: The user sets the trigger points on the signal input stage so that the input is converted from sine waves (or whatever is coming in) to square waves.  This is independant of the operation of the frequency counter loop.

1: On power-up, or upon a configuration change command from the master MCU, the Arduino sends a halt signal to the Gate, preventing signals from coming through to the counters.  The counters are cleared by a signal from the Arduino.  The Arduino selects the bit on either the timebase-counter block or on the signal-counter block which will halt the counting.  (For example, to set up a one-second gate time using a 32.768 KHz timebase, it will set the MUX to trigger on Bit 15 of the timebase-counter block.)

2: The Arduino sends the gate-ready signal. 

3: The gate waits for a falling edge on the timebase signal and then opens the gates on both signals, allowing them to flow through to their respective counters.

4: When the count on the respective counter block reaches the set bit, the output signal from the MUX battery goes high.  The gate closes and halts the signals from both the timebase and signal inputs from coming through, and the Arduino eventually picks up on the fact that the counting is done.

5: The Arduino reads both counters by cycling through the MUX chips.  It then calculates the frequency (or the count) based on its settings, and places this value in memory for asynchronous reading via I2C.  A flag, new_data, is set TRUE.  (Upon an I2C read, new_data is set to FALSE to allow the master MCU to tell if it's reading a new value or one it has previously read.)

6: Goto 2.

Discussions