For many years Morse code was a large part of the mandatory licensing examination in both Canada and the US. In order to get a basic license to transmit on amateur bands, a prospective amateur would have to commit him or herself to learning Morse code. This was likely a large reason why many interested in amateur radio failed to ever complete or even take their exam.
In late 2006, the Federal Communications Commission dropped the Morse code requirement from amateur radio examinations. This followed a similar decision made in 2004 by Industry Canada, the amateur radio regulatory body in Canada. This move has proved to be very popular; new hams now only need to study the actual regulations of amateur radio, as well as how antennas, radios and electronics work at a fundamental level. As a direct result of this change, the numbers of new amateurs registered each year has grown at an incredible rate.
Though most amateurs at the time were in favour of a relaxed code requirement, there was a substantial minority that opposed such a move, claiming it would speed the demise of Morse code usage. Whether this has happened is debatable. In both Canada and the US there is still a separate license for CW (continuous wave, which is what amateurs call Morse code transmissions) which an amateur needs to hold before being allowed to transmit on the CW bands. CW transmissions on non-CW bands are prohibited. Thus, to be able to practice CW by actually transmitting using a key is prohibited until after the amateur has demonstrated 12 words per minute proficiency.
Many new amateurs are taking a renewed interest in CW. Because it is not a requirement that they learn it to get on the air, hams can now learn at a slower pace and also listen to CW being transmitted. There are numerous software programs that assist in teaching the transcription of Morse code. One popular method is the Koch method. The Koch method prescribes that you start with only two letters. These two letters are ‘sent’ randomly, and the listener must write them down. After a 5-minute study period, the student compares what they wrote down with what was actually sent. If the listener got at least 90% of the letters correct, they add another letter. This method has proven to work very well. The other leading method is the Farnsworth method, in which students must learn all letters simultaneously!
My only question was ‘How can I practice sending Morse code if I can’t do it on air, and all the software I have currently is focused on the student receiving Morse transmissions?’ Well, like so many other problems I’ve had, I decided to try to solve it myself. I’ve been prototyping different methods of emulating Morse keys. The first type is the straight key, seen at left, which is what most people associate with a telegraph – a simple button on a lever that turns a switch on or off. Holding the switch down turns the switch on, creating a tone that is transmitted. Sending the dots and dashes which make up Morse code is accomplished by pushing the key down for different lengths of time. Simple, right?
Well, many hams found that they hit a wall in terms of speed with this type of key. So the Vibroplex key was invented – a precursor to the iambic paddles that are popular today. With the Vibroplex, seen at the right, the key was turned from a vertical movement to a horizontal one. Pushing the key to the right started a mechanical pendulum-type movement that created a series of dots. Pushing it to the left simply acted as a switch, in order to create dashes. This type of key was very popular; with a little bit of practice, somebody already familiar with CW could increase their speed very quickly. The speed at which the dots are created is a function of how hard the key is pushed.
An even faster method was found. As mentioned before, this type of key is called an iambic paddle, or iambic key. As opposed to the Vibroplex, which only automates the dots, an iambic key automates both dots and dashes. Pushing the key to one side produces repeated dots; pushing it to the other produces repeated dashes. The speed is usually adjusted either on the radio, or on the key itself. Most modern iambic keys are simply triggering the radio to create the beeps. Though they look very complex, at their most basic design level they are just two opposing switches that are actuated by levers. The paddles are engineered to be heavy so the key doesn’t slide around; they are also made to be comfortable to use for extended periods of time.
So my next decision was which type of key to emulate. I decided to make prototypes of both straight keys (which are still popular today) and iambic keys. You can see what an iambic key looks like to the left. I'll show you how I designed both of them in this blog. The straight key was the simpler of the two, both in software and hardware. Essentially, all that is needed is a single button that causes the software to create a beep which is sent to an external speaker. However, there are always a few different ways to do the same thing. In order to get a prototype up and running quickly, I decided to use my Arduino. I have a SparkFun RedBoard, but they are functionally identical to the Arduino Uno . The reason I ended up with a RedBoard is that I wanted to build mine as a kit. The drawback is that the USB port isn’t integrated; I’d recommend picking up a pre-assembled Uno,like this one . You can use any Arduino for this project, as long as you know which pins produce pulse-width modulation signals (PWM).
In order to make this as easy as possible, I took a piece of protoboard and cut it to fit over the footprint of the Arduino headers (see below, with the protoboard upside down beside the Arduino). I then simply soldered pin headers to each side of this piece of protoboard and then attached a button, a 1k pull-up resistor, and also a couple of female header pins for the external speaker to attach to. The button is attached to digital pin 2, and the output of the speaker comes from digital pin 6, which is one of the PWM outputs.
While you could simply put a routine inside the loop() function that constantly checks to see if the button is pressed, I found it much easier to use interrupts. If you’re not familiar with interrupts, or you’ve never used them before, there are many tutorials online describing how they work.
Instead of checking the button in an infinite loop (which would work, but then the processor would just be sitting there screaming along, checking the button over and over as fast as it possibly can – future expansion of the code would be difficult, if not impossible) I decided to use interrupts. When the button is pressed, it triggers what is called an ‘external interrupt’, which means the interrupt is generated from an external source. In our case this is our ‘key’ button. Understanding interrupts is simple – they are exactly what they are named – interrupts! When an interrupt occurs, the processor is interrupted in whatever it’s currently doing. The processor stores whatever it is working on in a temporary area, then immediately jumps to execute the interrupt
handler. The ATmega328P has many different interrupt sources, many of them inside software. For example, you could have an external interrupt from a button. When you push the button, the processor stops whatever it’s doing, and then light a LED. It then goes back to what it was doing before. Interrupts are an extremely powerful tool. Not only do they help reduce the use of unnecessary loops, they are also vital to time-sensitive tasks like sampling an analog-to-digital converter. Because I used interrupts, I had to blend C with Arduino code. Those familiar with Arduino will see that the setup() and loop() functions are still there. I’ve just added on a couple extra functions to handle the interrupts and also what to do on start-up.
Enough about interrupts – let’s move on to the beeping! The Arduino libraries include a way to activate PWM without needing to know much about the AVR registers. You’re probably already familiar with the command if you’ve used an Arduino before – analogWrite(). The name is slightly misleading, as you’re not actually writing an analog value to a pin. The analog value is being averaged by using PWM. However, in most cases – such as lighting an LED, driving the speed of a motor, etc. – the user can’t tell the difference because the PWM is happening so fast it just seems like an analog value.
PWM can also be used to create tones out of a speaker – after all, we’re just generating a frequency. If we bring that frequency down into the human hearing range, we could make the chip play Bohemian Rhapsody if we wanted! The problem is, the Arduino command analogWrite() doesn’t have any way of controlling the frequency of the PWM. So I had to use C for that part of the code. What I’m actually doing is activating the timer module attached to pin 6. I’m then telling it I want PWM mode. The PWM frequency is based off of the system clock frequency. Most Arduinos run at 16MHz, or 16,000,000 Hz. Since the timer is 8-bits wide, it can only count up to 255. So if we had the clock running at full speed, the timer would overflow once every 16,000,000/255 seconds, or 62,745 times a second. With a duty cycle of 50%, this would mean a frequency of 62.745 kHz, which is WAY too high for the human ear to listen to. This is a good frequency for motors and LEDs, but we need something around 1 kHz if possible. Luckily, the AVR designers were thinking, and included a prescaler option. This means we can divide the clock frequency by a set value. Our options are 8, 64, 256 and 1024. These would produce frequencies of 7.8 kHz, 980 Hz, 245 Hz, and 61.2 Hz, respectively. Wait a minute – 980Hz, that’s almost 1 kHz exactly! How perfect! So I chose a prescaler value of 64. This will create a tone that is very close to what most radios produce when the Morse key is pushed.
Now that we have the tone out of the way, we’re essentially done! The code activates the external interrupt associated with digital pin 2, where our button is located, and when the button is pushed the interrupt turns the PWM on. When the button is released, it turns the PWM off. Wow! That was easier than I thought it would be. I threw in a start-up routine for kicks. When the Arduino is reset or turned on, it will spell out CQ in Morse code. This is the Morse code for “calling anyone”.
I also wanted to turn things up a notch and emulate an iambic key. For this, we’re going to leave the Arduino behind and work entirely in C. This might be possible to implement in the Arduino IDE, but I find it much easier to program more complex things like this in Atmel Studio. They also have an Arduino compiler built-in, making it very easy to transition between the two programs.
Please check out the videos below -- you might even catch me sending a bit of morse code! I'm actually quite proud of how well this tool has helped me to send Morse. I've been using a piece of software by an amateur radio enthusiast whose call letters are G4FON. He developed a piece of software for the Koch method, which you can find here. After trying out many different pieces of software, I've found that this is one of the better ones.
My speed and number of letters is slowly increasing. I actually find that I can send better than I can receive! If you want to build this project, and you need help, or have questions, please contact me! You can send me a message here on element14, you can e-mail me at firstname.lastname@example.org, or you can try and catch me on the air sometime -- VA3XMR. And also, read through my comments in the code -- I tried to explain things without making them too long.