Frequency Counter

The book Arduino Projects for Amateur Radio by Jack Purdum and Dennis Kidder, and the project "A Simple Frequency counter" in that book was the starting point for this project.

By the way, buy this book if you are the least bit interested in building Ham Radio Arduino projects.  It's really well written and worthwhile.

Due mainly to limitations of the 16 MHz clock speed of the ATmega328P processor, the frequency counter is limited to about 5MHz before the input waveform starts to overwhelm the processor.  The authors of the Arduino book suggest extending the range of this Frequency Counter by pre-scaling the input signal being measured with one or more divider stages using flip flops such as the 74LS74 (TTL) or 4013 (CMOS) ICs.  (A great idea!)  I implemented this project using a pair of 74LS74 based flip flop stages.  This gives me the ability to divide the input signal by 2 or 4, extending the range of the counter (theoretically) to 20MHz, which is the "native" 5MHz capability of the Frequency  Counter, multiplied by 4.

Making the overall Frequency Counter package as small as possible was a priority, so that it could fit in the existing case of--for example--a QRP radio.  Here are the main changes that I made to the project.

  1. Instead of using a full-sized Arduino such as the Uno, I used the very capable Arduino Nano 3, which is small but powerful.
  2. I created a custom "shield" to hold the additional circuitry that converts an RF input into a waveform digestible by the Arduino digital input pin.
  3. I added some jumpers on the board that can be used to select the amount of input pre-scaling.  The jumpers do two things: a. they electronically switch the desired pre-scaled input to the Arduino input; and b. they enable the code running in the Arduino to query the jumpers, and automatically adjust to different amounts of input pre-scaling without the need to recompile and re-flash the microcontroller program.  This can be adapted to a situation where different levels of prescaling are needed to cover different radio bands in a multi-band radio.
  4. In place of a standard LCD display, I used an LCD with an I2C serial interface.  This display only needs two wires plus power to function, making it more amenable to being mounted away from the Arduino and shield board.  This also freed up some Arduino pins that would have otherwise been required to drive the LCD.

Here is a photo of the custom shield.  I have two 8-pin headers mounted on the shield to mate with eight of the pins on each side of the Arduino Nano 3 board.  These two 8-pin connectors provide all the connections that the shield needs to have with the Arduino.

Three digital pins on the Arduino are used to query to position of the pre-scaler jumpers on the shield board.  Modern generations of Arduinos need to have updates pulled either up or down (as desired) to establish a valid logic state of 0 or 1.   A digital Arduino pin that is not "coerced" to a valid logic level will produce noise, and may cause unexprected results.

The three 15k resistors on the shield between the two 8-pin connectors are pull-up resistors that keep the three digital pins used to sense the jumpers at a 5v level.  When one of the three pre-scale jumpers is plugged, it grounds the Arduino input pi to which it is attached, and the microcontroller subsequently figures out which pre-scale adjustment it should be using by reading the three sensor pins.

Here is a photo of the Arduino Nano 3 mounted on the shield, and the unit measuring a signal from a signal generator.  Care must be taken to ensure that the correct pins on the Arduino are mated with the header connectors.  It's probably best to cut off any extra pins on the Arduino, to reduce the chance of incorrectly mating the two boards.

The "1" digit to the right of the MHz display indicates the level of pre-scaling that the program has detected, and is using.  I put this in mainly for testing.

Note:  The jumpering scheme that I employed could stand some improvement.  This circuit actually uses two sets of three pairs of pins /jumpers to accomplish pre-scaling.  One set of jumpers actually switches the pre-scaled input signal to the Arduino pin that measures the frequency, and the other set of pins is used solely to tell the microcontroller what prescaling factor should be used.

This means that when the pre-scale factor is changed, two jumpers must be moved.  i.e.:

Pin pairs 1 and 4 need to be jumpered for a prescale factor of 1 (no pre-scaling):

1 - xx
2 - oo
3 - oo
4 - xx
5 - oo
6 - oo

For a prescaling factor of 2, jumper positions 2 and 5.  For a factor of 4, jumper positions 3 and 3.

Below is a schematic of the project that I created using the Open Source PCB design software KiCad.  Click on the schematic to blow it up to full-size.

In addition to producing electronic schematic diagrams, it also creates all the files needed to have printed circuit boards manufactured professionally.  I'm working on creating an PCB design for this circuit that I'll send off for fabrication.  KiCad has a steep learning curve!

Ideas For Improvement:

I have a 180 MHz Teensy version 3.6 board in my spare-parts box. I'm planning to try this much faster microcontroller in this circuit.  I'm curious to how a bunch more raw processing power affects the native top-end of this frequency counter.  Such a faster microprocessor would likely eliminate the need to fuss with pre-scaling and such.

Arduino sketches (programs) like the one in this project will compile and run with little or no modifications on the Teensy.  So to try out this processor it would just be a matter of installing the Teensy libraries in the Arduino IDE on your computer, and then building and uploading the sketch (program) to the teensy in the same way as its done for the Arduino.  Then put the teensy on a breadboard and wire it up with jumpers to the transistor circuitry in the schematic.

I avoided this route originally however, and stuck with the Arduino for a few reasons:

  1. I wanted to see what could be accomplished with the dirt-cheap Arduino;
  2. By keeping project cost down, more people are likely to find it useful;
  3. The technique for using jumpers in a project, and reading them with the Arduino sketch is a very useful technique that could be used in a variety of projects.  The idea of pull-up and pull-down resistors in Arduino projects is also important.

The Teensy is 3.3v only, but because I don't need to interface it with flip flop logic chips for pre-scaling, this should not be an issue.  But be sure to not connect any 5v signals to this board, or you will likely damage it.

The Teensy 3.6 costs around $30 right now, where an Arduino Nano 3 clone can be bought for about $3.  The Teensy 3.2 is cheaper, around $20.  But even so, this pushes up the cost of the project.

Transistor Choice:

Note: I built my transistor circuit using transistor sockets, so that I could easily try out some different transistors in the circuit.  I tried about a dozen silicon NPN transistors, and every one of them worked fine.  This two-transistor circuit is sort of a "blunt force instrument" designed to present easily readable pulses to the Arduino, so I would expect that most any silicon NPN transistor would work.