A Full Featured Keyer with Frequency Counter
Introduction
Currently I am working on programming a PIC16F84 microcontroller to serve as a keyer and a frequency counter with Audio Frequency Annunciator (AFA). In other words, a keyer and Morse code frequency readout.
I really enjoy operating with homebrew single band transceivers. These little radios have limited tuning range, low power consumption, and a small form factor. They generally use a 10 turn pot for tuning so I sometimes use a turn counting knob and calibration chart to determine frequency. This arrangement is awkward but a full frequency counter with LED or LCD display doesn't make sense for these rigs. Neither does any kind of dial arrangement that I can think of. The idea of a counter that outputs its frequency measurement in Morse code however, seemed ideal. These devices are commercially available but I thought it would be fun to homebrew one. Ideally this approach will also yield a device with the features I most desire.
Here is a list of the features I hope to have in the keyer/counter when it is finished:
| Feature |
Description |
| Memories |
Three pre-programmed and two that are user entered |
| Speed |
Quick adjust with pushbutton and paddle inputs |
| Sidetone |
Internally generated, can be enabled or disabled |
| Callsign |
Hard coded or user-defined, saved in eeprom |
| Iambic |
Both A and B modes supported |
| Key Modes |
Straight key,iambic,and tune modes |
| Speed rpt |
Replies with current speed setting in WPM |
| Paddle Swap |
Exchange dit and dah paddles |
| Autospacing |
Optional, inserts proper inter letter spacing |
| DE mode |
Optional, sends "DE callsign" when both paddles pressed |
| Freq. Range |
1 to 30 Mhz |
| Freq. Offset |
Selected at code assembly time |
| Freq. Digits |
1 to 7 Selected at code assembly time |
| Freq. Announce |
Initiated by pressing a push button switch |
The Approach
While I enjoy writing code, sometimes you find things in the public domain that make it difficult to justify writing the code yourself. A while back I discovered some code for a great little keyer on the K1EL web site. I promptly downloaded the code (K8) and programmed a 12C509 PIC processor with it. I built this keyer into a single band rig and later built a stand alone PIC Keyer around it. The K1EL PIC code is well written, rock solid code that yields a great keyer.
Keyer Code and Processor Choice
Impressed with the K8 keyer code, I decided this would be the base of my keyer/counter project. Trying to do this project with the 12C509 would be a problem because I don't have a pic emulator. Using the "burn and learn" approach (burn eprom, test, try to learn why it doesn't work, and erase eprom) with a windowed eprom part was an option but not a very good one. Also, because the K8 code uses all the 1K program memory I would have to do some serious hacking to make room for the AFA code. Many "burn and learn" cycles would no doubt be required. The best approach, given my modest set of development tools, seemed to be to port the 12C509 code to the 16F84. Not an easy task, but worth the effort it if yields a K8 like keyer in the 16F84.
Frequency Counter Code
There are plenty of good PIC frequency counter examples to follow. Several were found on the web and in the Microchip appnote library. The October 2000 QRP Quarterly had an article by WA1EDJ and AE4GX describing an AFA they built for the Georgia Sierra. It looked interesting so I e-mailed Sam, AE4GX and he sent me the source code. Their project was based on some 16F84 code that was written by Bernd Kernbaum DK3WX. I programmed a 16F84 with their code and experimented with it. It worked quite well and provided me with some good ideas. My approach will be to maintain as much of the keyer functionality as possible and keep the AFA features to a minimum. For example, the number of frequency digits sent and the frequency offset (IF frequency) will be configurable before assembly but probably not adjustable during operation. This should not be a problem since the intended application is single band transceivers where those parameters are pretty well fixed.
The Challenge of Putting it Together
With the keyer code in hand and several good examples of frequency counters, it seems like I am 90 percent of the way there. There are still a number of challenges though. First, I still have only 1K of memory and the K8 keyer uses almost all of that. Second, I have to make sure the two code segments are going to live together in the same program space without problems (assuming I can find room for them both).
The Development Process
My development tools consist of the following: 1.MPLAB, an assembler, debugger, integrated development package available for free from the Microchip web page. 2. PICSTART PLUS, a Development Programmer from Microchip used to burn the program into the PIC Flash memory. 3. A PIC16F84 prototype board that I built on perf board. The prototype board has a pin header that brings all the 16F84 I/O pins out where they are easily accessible. It also contains a 5 Volt regulator, pin header for external power in and out, and a reset switch. The prototype board also has enough extra space for future additions. Below are some pictures of the development tools.
Proto Board and AFA Test Circuit |
PICKSTART PLUS programming a 16F84 |
MPLAB Development Environment |
Keyer/AFA Schematic |
Progress Report
As of the end of April, I had most everything I wanted form the K8 code successfully ported to the 16F84. I wrote some code to save the code speed and most preferences in EE_PROM so that they are restored on powerup. I also wrote some code to allow adjustment of code speed by holding down the pushbutton and pressing the dit or dah paddle. I started working on the frequency counter code and then got distracted by another project for a couple of weeks. Since the first weekend in May I have been back on this project and the code is nearly finished. There are still a few things I would like to do but I only have about 13 bytes of code space left in the 16F84.
Below is an updated timetable and progress report:
| Date |
Work Done |
| 30-Mar-2001 |
AFA from QRP Quarterly article built and working |
| 01-Apr-2001 |
Begin Porting K8 code to 16F84 |
| 09-Apr-2001 |
Most K8 code now functional in 16F84 |
| 10-Apr-2001 |
Removed "Farnsworth" and "Practice" modes to gain code space |
| 10-Apr-2001 |
Developed code to change code speed with Pushbutton and Paddle inputs |
| 14-Apr-2001 |
Developed code to read and write to EE_PROM |
| 17-Apr-2001 |
Speed and mode settings now stored in EE_PROM |
| 19-Apr-2001 |
Added code to output 24 bit number in Morse |
| 20-Apr-2001 |
Removed "Speed" and associated subroutines to make room for AFA code |
| 21-Apr-2001 |
Got sidetracked on another project |
| 04-May-2001 |
Configured counter input. Added code to count pulses on RA4 |
| 05-May-2001 |
Added code to add/subtract IF offset |
| 09-May-2001 |
Fixed bug in first frequency read. Modified input circuit and RA4 levels |
| 18-May-2001 |
Created Schematic Drawing |
| 26-May-2001 |
Built Manhattan version in SST-20 and began testing |
Future Development
There are still a number of things I need to do before this project can move over to the finished projects list. Below is the TODO list:
TODO List
| Item |
Description |
| 1 |
Implement sleep mode to reduce power consumption |
| 2 |
Layout Circuit Board |
| |
|
|
|
|