Introduction: Iambic Keyer Using Microcontroller

About: Retired

Introduction

This is my first Instructable. I would like to show what is involved in building an electronic keyer for an iambic twin paddle key, such as the Bencher.

I make two assumptions here. Those of you who are following this article already have a decent knowledge about amateur radio and CW (a.k.a. Morse Code) communication, and also have experience in building electronic circuitry from a schematic. I shall therefore not go into any detail about Morse code or laying out a pcb or soldering up.

If you are a radio amateur, a.k.a. ham, or are interested in becoming one, you are probably interested in sending and receiving Morse code. Most hams prefer to use an electronic key rather than a straight key both because it is less tiring and also because it allow you to send perfect Morse at higher speeds.

I have been a ham for many years and since moving to Canada, I have mothballed my rig and have not been on air for over 10 years. Recently I struck up a conversation with a group of local hams. That got me interested again in going back on air. Having retrieved my Japanese keyer which I bought in Tokyo some 30 years ago, I found it rather bulky and not too elegant. So I thought I could make a much more compact one.

I don't need an all-singing and all-dancing keyer. All I need is one which is usable, portable, adjustable for speed, and sends perfect code. So, I decided on the following parameters:

1. The keyer can be built into a small box, say 2½" x 3½" (6.5 x 9 cm).

2. It has an internal battery but can also be supplied from an adaptor.

3. It has a built-in oscillator to monitor keyed code.

4. It gives a visual indication of key closing and opening.

5. Speed is manually adjustable from 5 wpm to 32 wpm. This is probably an overkill, normally anything from 10 wpm to 25 wpm will be good enough, but setting this up is really trivial.

Description

This keyer accepts two input lines (and common ground line) from a double paddle key. Closing the left paddle produces a string of dots and the right one a string of dashes, and closing both will produce a string of alternating dots and dashes, the initial element of which depending on which paddle is closed first. If you prefer the left paddle produces dashes and the right produces dots, simply reverse the input lines. Dots and dashes are output at a set speed between 5 wpm and 32 wpm. The default setting is 12 wpm when first installed.

The keying speed may be increased by turning a rotary encoder on the front panel clockwise, or decreased by turning counter-clockwise. Each change either increases or decreases the keying speed by 1 wpm until either the maximum 32 wpm or the minimum 5 wpm is reached and will stay at that speed until the rotation is reversed.

The current speed setting is stored in persistent memory in the pic and not lost when power is disconnected. Next time when the unit is switched back on, it remembers its last setting and will run at that speed unless changed again.

When the unit is powered up and on each change it announces its current speed in Morse code using Roman numerals, followed with a + signal. Roman numerals are used instead of Morse numerals because of my personal preference, as they seem to sound (to me at least) much nicer!

The Components

In order to make the keyer really small and with minimal parts, I decided to build it around a microcontroller. I have quite a few lying around, and I chose the Microchip 12F675 with an 8-pin footprint. Six of the 8 pins are programmable general purpose i.o. pins. I need two for input from the paddles, two for monitoring a rotary encoder, one to drive the keying relay and one for sound. So, this pic is ideal. Apart from a few resistors, a couple of decoupling capacitors, and several diodes, few other electronic parts are required. The parts list is as follows:

1 plastic project box 6.5 x 9.0 cm (or larger)

1 perf board 4 x 6 cm (or larger if you use a larger box)

1 rotary encoder

1 12F675 Microchip PIC

1 LM7805 5V regulator

1 NPN transistor (any small switching type will do)

2 1N4001 rectifier (or any other type rated at 1A or less)

2 1N4148 diode (or any signal diode)

4 10K (±20%) 1/8W resistor

1 1K (±20%) 1/8W resistor

1 560R (±20%) 1/8W resistor

1 100uF 6V electrolytic capacitor (value not critical)

1 0.001uF capacitor (value not critical)

1 12V d.c. input socket

1 3.5 mm earphone socket (for double paddle key input)

1 small power switch

1 reed relay (or a small magnetic coil relay)

1 high impedance speaker (scavenged from an old phone handset)

1 buttons battery connector (for 9V battery)

2 terminal connectors

1 knob for rotary encoder

2 small pieces of wire mesh

Apart from the terminal connectors, a knob and the phone socket, all the parts are shown in the attached photo. I manage to scramble together all the parts from my junk box. You may also find most of them lying around your shack, but you probably will need to buy a box, the pic and the rotary encoder. All told, it should not cost more than ten to twenty dollars even if everything is purchased new. I find that the box is the most expensive item!

None of the parts are really critical. The resistors, capacitors can be replaced with others up to 20% difference in value. The transistor and diodes can be replaced with similar ones with different markings. The ic can be substituted with other common pics such as 16F628 or 16F877. The programming code is essentially the same, only the footprints are larger which means you are wasting pins and will need a larger perf board and box. You can even implement this gadget with an Arduino but you will need to write a sketch for it.

The Circuit

The attached circuit schematic is easy to follow. Power is supplied normally from a 9 volt battery. If a 12V d.c. adaptor input is plugged in, rectifier diode D2 is reverse biased thus overriding the battery supply. A switch is provided to disconnect the battery when the unit is not in use. C1 and C2 smooth out any sudden spikes etc. on the power line, due to back emf from the coils for example. Power usage is little, in the order of 30 mA or so.

R3, R4, R5 and R6 are pull-up resistors for the pic input pins. R1 limits current to the led D3, and R2 isolates the transistor base circuit. D4, D5 are reverse biased diodes which protect any back emf from abrupt changes in current in the coils from damaging the pic or transistor. Q1 is any small npn transistor. S1 is a small relay which provides isolated keying for connecting to the transmitter. I happen to have some ancient reeds and matching coils, but you can just substitute it with a small relay, or even leave it out all together if your transmitter accepts open collector transistor input keying.

I manage to salvage a ringer speaker from an old telephone handset with 130 ohms coil resistance. You can find one similarly. An 8 ohm speaker is not appropriate and will not give you sufficient sound volume if driven directly from the pic. You will have to put in another transistor with associated components to drive such a speaker.

All told, this circuit is very tolerant of swapping in similar parts. Placement is a matter of fitting everything onto the perf board. It is fortuitous that I manage to put everything onto the board easily and neatly.

You can download a copy of the schematic from here:

https://www.dropbox.com/s/g87ssmqxg4x6axa/iambic_k...

Assembly

Soldering up takes less than an hour. The time is taken up mostly in making sure the right wires go onto the right pins. The box is drilled and cut with simple tools. The perf board takes up just about half the room inside. I cut two circular openings on the top and bottom of the box and covered them from the inside with stainless steel wire mesh (cut from a kitchen sieve bought from the dollar shop). Because of limited space on the front and back of the project box, I cut a slot on one side of the box to accommodate the adaptor power socket. This requires careful marking and cutting out with a fine tooth hobby saw. I used hot glue to glue parts onto the box unless they are already fitted with bolts or screws. The whole construction including making the box, soldering the perf board and assembling everything together took me an afternoon.

The attached photos show the final product externally and internally.

The Program Algorithm and Code

A pic is programmed with a purpose-built programmer, interfaced to your p.c. with dedicated software. I use a specialized pic programming language called JAL (Just Another Language) to write the driving program, and a K150 programmer to burn it. Talking about programming pics is really another topic and will not be dealt with here. I make no assumptions about your knowledge and experience in programming pics, so I am providing a .hex file which you can download from here:

https://www.dropbox.com/s/qsxvtgpme9aligw/iambic_v...

Simply burn this .hex file into your 12F675 pic with your favorite programmer and you are done, without worrying about the logic and so on. Of course you will have to put up with my programming idiosyncrasies.

I provide here the program written in JAL, which is a C-like language which you can easily read to understand its logic and translate it into another language and modify it if you so wish.

https://www.dropbox.com/s/b10l6tcbfo8dlcu/iambic_v...

I give no warranties but feel free to ask me if you run into any problems. You are free to use, change or share this program as long as you give me credit for writing it in the first place!