Frequency meter

From ShawnReevesWiki
Jump to navigationJump to search


A 5-digit frequency meter featuring an LCD display.
  • Connect 1 Hall effect switch to watch a magnet passing once per cycle.
    • Hall effect switch may be unipolar or omni-polar, but not bipolar. If unipolar, take care to place magnet correctly.
    • Switching time needs to be shorter than inverse of desired highest frequency.
  • Include a display with at least 4 characters.
  • Include a power switch to save the battery, and/or a reset switch.
  • Use a breadboard so it can be built by students, or modified.
  • Allow timing of periods up to at least 10s, accurate to 0.01s.

One difficult thing about frequency meters is that they operate by counting pulses over a given amount of time, which is only good for steady frequencies, or they count time between two pulses, which gives a period which must be a divisor in a calculation done by the micro-controller often with limited maths abilities. The fact that it is a divisor means that the precision will be inversely proportional to the frequency, in the absence of floating-point maths. The frequency will have a low limit due to the instruction-time of the micro-controller, and an upper-limit due to this divisor effect. It might be possible to add a switch to notify the micro-controller of the expected range.


Circuit diagram for a frequency meter featuring an LCD display.

For a detailed, printable diagram, see File:Frequency-meter-Arduino-on-a-board.pdf. For a previous version using a much less precise PICAXE 08M2, see File:Frequency meter-PICAXE-08M2.pdf.


See #Datasheets for specific tips.

  • Breadboard (~$5)
    • Hall effect switch, unipolar or omni-polar, with quick output rise and fall times.
  • Micro-controller. I use an Atmel ATmega328. A previous version used a PICAXE 08M2. (both $3)
    • Resonator circuit if necessary. The ATmega328 uses a 16MHz crystal and two ~20pf capacitors. (~$1)
  • Display
    • LCD Display, serial capable. I use Electronic Assembly's DOGM081 with SPI. ($10)
    • Alternatively, a TTL-to-USB or TTL-to-serial circuit for sharing data with computer ($18)
  • Hook-up wires ($2)
  • Power supply. Our LCD is expecting 4.7V to 5.3V.
A typical 5V regulated circuit, with protective diode and output capacitor. The input voltage must be greater than the dropout voltage of the regulator plus the voltage of the diode plus the output voltage (see a data-sheet).
    • 9V or a quartet of AAA with a 5V voltage regulator and capacitor(s), or
    • 120V AC to 5V DC adapter—I find phone chargers at thrift stores for $1 each, or
    • Three alkaline AAA or AA batteries, or
    • Four NiMH rechargeable batteries, or
    • Three NiMH rechargeable batteries with a 5V voltage booster.


Program without a hardware timer

For an attempt on the PICAXE 08M2, see Frequency meter with a PICAXE 08M2.

  1. Initiate the display
  2. Set an interrupt on the pin attached to the switch. Will interrupt the program wherever execution is and go to Interrupt.
  3. Loop.
    1. Increment time counter.
    2. Display frequency.
    3. Go back to Loop.
  4. Interrupt
    1. Convert count to Hz.
    2. Reset counter.

Program with a hardware timer

For an working example, see Frequency meter on Arduino.

Keep interrupt service routines as short as possible by having them set the minimum amount of variables and instead do the calculations in the main loop.

  1. Initiate the display
  2. Set a timer interrupt. Will interrupt the program wherever execution is and go to associated interrupt routine.
  3. Set a falling or low interrupt on the pin attached to the switch. Will interrupt the program wherever execution is and go to associated interrupt routine.
  4. Loop:
    1. If there's a time recorded, note it and erase it.
      1. If also there's a previous time recorded, calculate frequency.
    2. If frequency is updated, display frequency.
    3. Go back to Loop.
  5. Switch-detecting interrupt routine:
    1. Record the time now.
  6. Timer-detecting interrupt routine:
    1. Increase the time variable.


Atmel ATmega328P-PU
28-pin PDIP micro-controller.
Electronic Assembly ED DOGM081-A
8-character LCD dot matrix display, with SPI serial control.
Read various forums for discussions on using SPI between the micro-controller and this display. For example, one on how CSB must be used:
Is the display too dark? The supplied voltage is too high, try to bring it down a bit. I tame a 6V supply with a single 1N914 diode for low power circuits like this.
Diodes Incorporated Hall effect switch
This switch has a long rise and fall time, so it is not good for greater than 8Hz; but it uses very little power.
Honeywell SS451A omnipolar Hall-effect digital position sensor
Works with supplies between 3.0 and 24V, taking 4.5mA at 5V. It switches on at about 85 Gauss and off at about 50 Gauss, in either direction, in less than 1.5µs.
TT Electronics OH090 unipolar Hall-effect sensor
The OH090 is their most sensitive device, and it switches on and off in less than a microsecond. It requires the magnet to be oriented correctly, since it turns on (voltage drops to zero) when its face is exposed to a field of about 90 Gauss only from the south pole.
PICAXE micro-controller system for education

See also

See more discussion and other circuits at Circuits for teaching physics.

Bicycle speedometer is essentially the same circuit and program, only displaying a different unit, and possibly adding an interface to change the wheel-diameter.