Morse Code Encoder

VK2IDL Morse Encoder

The VK2IDL Morse Encoder came about more from a desire to build some interesting electronics projects rather than a need to actually send Morse code. I had studied Morse Code back in the 1980’s as a requirement for my advanced AOCP and used it regularly enough to maintain a reasonable proficiency for a number of years. Having recently returned to amateur radio after a long absence, I started looking for on-line Morse training websites in the hope of recovering some of my proficiency. In the process I was curious to note that there were a number of commercially manufactured Morse decoder units available, although reports on their performance varied but there wasn’t much I could find in the way of Morse Generators. And so, the idea of building my own Morse encoder was born.

My Morse Encoder is base on a Arduino, specifically the Arduino Nano. While you could use any number of Arduino modules, I chose the Nano for its small size, which enabled a compact unit.

My original design brief was to create a device that allowed Morse Code to be sent by typing text on a keyboard rather than using a Morse key. It was initially targeting those who were new to Morse Code or who were no longer as proficient as they once were (for whatever reason). The interface included a keyboard adjustable Morse speed setting and a series of preset buffers, to speed up common conversational texts such as CQ calls and contact details etc. I later added hardware inputs to allow a manual key and a Morse Paddle to be connected, but they were initially intended as secondary options to using the keyboard.

To use the keyboard function, the user needed to have the Arduino IDE running with the Mose Encoder connected via its USB port. Text typed on the PC’s keyboard would then be converted to Morse Code which the encoder would sent to your HF transmitter. The text was displayed in the ‘Monitor’ of the Arduino IDE.

Typing Morse using the Arduino IDE

While the keyboard option work quite well, it locked the device to the Arduino IDE which reduced its versatility (and portability). To make the device more portable I needed to add an in-built LCD to display the Morse being sent. This also required a software Morse decoder to decode and display live Morse from the paddle or straight key directly onto the LCD. To complete the portability requirements for those using a Morse Key, I also added a rotary control for adjusting the Morse Speed from 6 to 30 wpm (and removed this function from the keyboard). The unit is now completely portable for users who wish to send Morse by hand, but it can still be connected to the Arduino IDE (if the user prefers) to type their Morse code via a keyboard. The Morse Encoder will generate Morse code from a straight key, a paddle or by typing text on a keyboard. The Morse is displayed on its own 4 line, 20 character LCD as it is being sent, making it particularly good for Morse practice as it gives live feedback on your accuracy. The knob-adjustable Morse speed control displays the selected speed setting on the LCD in wpm. When using a paddle, the timing of the dits, dahs and inter-element spacing is automatic based on the speed you have set. The unit is designed to directly drive the Morse key input of an HF radio.

For a future project, I’m considering adding a direct keyboard connection to completely eliminate the need for the Arduino IDE when typing Morse, but that will require a significant hardware change. In the mean time Ive preferred to keep it simple.

Below is short video showing the Morse Encoder unit in operation. In this video I am sending Morse using a home-made paddle. The Encoder unit is the lower device and is connected to the keyer input of my Yaesu HF transceiver. The device at the top is my prototype Morse Decoder unit which I will be releasing as separate project shortly. It decodes Morse from my Yaesu receiver and displays it on the LCD. In this case it is picking up the Morse feedback from the side tone of my Yaesu transmitter as I am sending Morse. As you can see the decoded Morse matches that of my Morse Sender. Also note that the software version in the video shows ver 1.4. The final release listed here is v2.0.

You may note in the video above that I first sent a dah before starting the CQ Morse message which resulted in a ‘#‘ character on the LCD. This was to highlight the fact that the decoder-section of the unit requires one initial character to determine its timing and in doing so it usually decodes that character incorrectly. You can either ignore this and accept that the first character will be displayed incorrectly or you can trigger the first incorrect decode with a bogus character as I have done in the video.

Morse Encoder Schematic Diagram

As you can see from the schematic above the component count is quite small. The Arduino I used is the Nano with the Atmega 328P chip. DO NOT mistakenly get the Atmega 168P version as the memory size is too small. I chose the Nano for its extremely compact size, plus you can buy them for less than AUD$4.00 each through Banggood. The one I used is the Geekcreit ATmega328P Nano V3 which I’ve found to be reliable and good quality. I tend to buy 3 at a time so I have some an hand for new projects. To program this board you’ll need to download and install the correct board drivers for the ‘Arduino Duemilanove or Diecimila’ board into your Ardiuino IDE.

Geekcreit ATmega328P Nano V3

The Morse key input on my Yaesu FT757GX HF transceiver is switched using a 2N2222 transistor from pin D6 of the Nano. The output of D6 pulses high with the Morse code, switching on the transistor which pulls the key input to ground.

Nano pin D5 drives an LED which flashes with the Morse Code to provide a visual indication that Morse is being send (as seen on the video above).

The Morse speed is controlled by a 10k potentiometer connected to one of the Nano’s analog ports (A0). The minimum and maximum limits can be set within the software.

The LCD is an LCD2004A, 20×4 Blue HD44780 Character LCD with an IIC/I2C Serial Interface. I purchased my locally on eBay for under AUD$10 or you can pick them up from Banggood or Amazon for a little less if you don’t mind the slower shipping. The I2C bus is important as it reduces the LCD connection down to 4 wires. Note that the LCD is available with backlight colours in Blue, Green, Orange and White. If you plan on building the matching Morse Decoder unit, I recommend you purchase both LCDs at the same time to ensure the backlight colour will match, as the colour shade varies between manufacturers

Note there is a blue variable resistor on the I2C interface board. This allows adjustment of the LCD’s contrast and is often turned to minimum when the board is shipped. If you connect your LCD and the back light is working but you cant seen any characters or even the blocks where the characters are placed, try adjusting this control.

LCD2004A, 20×4 Blue HD44780 Character LCD with an IIC/I2C Serial Interface

The 3x 100nf capacitors on the Morse Key inputs are to reduce transients and prevent erratic character generation caused by switching noise from your Morse key contacts.

Prototype Assembly

The circuit was first laid out for testing on a breadboard (above), then, once development was completed, the parts were transferred to a multi-hole PCB and manually wired together using wire-wrap wire. The external connections were made using standard multi-strand connecting wire. I have not provided PCB construction details. The circuit is relatively simply as I suspect anyone who has achieved their full amateur call has enough ability to assemble this project. At the end of this page I have listed the components required along with some sources for purchasing them.

Encoder PCB Assembly

In my installation, I aligned the Nano’s USB socket and the paddle socket so that when the paddle socket is secured to the case by its nut, the USB socket is able to protrude through the case. If the USB socket is inset too far into the case, you will not be able to plug a connector into the USB port. Assembly layout is not critical and you can choose any assembly method that suits your installation.

The assembled components ready for mounting in the case

The case I used is a standard grey plastic 130 x 68 x 44mm Jiffy box from Jaycar (cat # HB6023). I mounted the LCD, rotary control and LED in the lid and drilled holes for the sockets and USB connectors in each side of the case.

Installation in the case. The LCD, rotary control and LED are mounted in the lid.
The two sockets on the right are the input for the manual key and the TX Output to the radio.

Software

The Arduino sketch can be downloaded from GitHub using this link: https://github.com/ideal54/morse-code-encoder-v2

If you do not have any experience in writing code for an Arduino or programming one you should take a look at some of the excellent YouTube videos that are available on the subject. To program the Nano, you will need to install the Arduino IDE which is a free editor for creating and uploading the code. You can download it from https://www.arduino.cc/en/Main/Software. Alternatively, if you prefer not to install the IDE you can use the Web Editor at the same location to program your Arduino board.

LCD Library

You will need to install the LCD library into your Arduino IDE to support the LCD. The library I used is from Francisco Malpartida and can be downloaded from bitbucket.org/fmalpartida/new-liquidcrystal/downloads . At the time of writing this, the latest version was 1.5.1 .

Customising the Sketch

After opening the sketch in the editor you will need to make a couple of edits to customize it for yourself. Arduino code uses a variation of C++ code so if you are familiar with C++ you will largely be able to understand how this works.

If you are using a different Arduino board such as the Arduino Uno, then your pin-outs may not match those of my Arduino Nano. The pin labels I’ve used in the sketch refer to the Arduino pin’s function rather than its physical pin number, so if you using a different Arduino board, keep this terminology when connecting your components and will not need to change the software to suit your board.

The rotary potentiometer used to control the Morse speed connects to pin A0. You can also adjust the Morse speed limits here (although other factors also affect the final results)

int speedPin = A0;    // Center pin of the speed potentiometer
int wpm_Min = 7;      // The highest morse speed value
int wpm_Max = 36;     // The lowest morse speed value

Other pin connections are shown below. If using another Arduino board refer to its pin layout for digital Pins D6, D7, D9, D10 and D11.

// Morse Output pins
int morsePin_LED = 7;     // Morse Code LED Output pin D7
int morsePin_CODE = 6;    // Morse code keyer Output pin D6

// Morse-Key Input Pins
int keyPin = 9;           // Input D9 for traditional morse key
int paddlePin_LEFT = 10;  // Input D10 for morse paddle (Left side)
int paddlePin_RIGHT = 11; // Input D11 for morse paddle (Right side)

Preset Morse Messages are used to set the preset buffer text for when using the keyboard. You should edit the name, location and call sign in these buffers to match yours. If you wish you can also completely change the messages but KEEP THEM BELOW 50 CHARACTERS as this is the limit of the buffer.

In the code below:

Change VK2IDL to your own call sign.
Change IAN to your own name.
Change PORT MACQUARIE to your own town or city .
Change 5 BAND TRAP DIPOLE to your own antenna setup.

// ============== Preset Morse Messages Here ===============
char CQ_Mess[] = " CQ CQ CQ DE VK2IDL VK2IDL K ";
char NAME_Mess[] = " NAME IS IAN IAN. ";
char QTH_Mess[] = " QTH IS PORT MACQUARIE. ";
char SIGNAL_Mess[]=" YR RST ";
char ANT_Mess[] = " ANT IS 5 BAND TRAP DIPOLE. ";
char CQTest_Mess[] = " CQTEST CQTEST CQTEST DE VK2IDL. ";

In the code below, edit the sign-on messages by replacing VK2IDL with your own call sign. This is in two separate locations, one for printing on the Arduino’s serial monitor and the other for printing on the LCD

  // Print the Header on the monitor
  Serial.print("=== VK2IDL Morse Code Generator Version "); // Print initialisation header  

  // Print the header on the top line of LCD
  lcd.setCursor(0,0);                 // Position the cursor
  lcd.print("VK2IDL Morse Encoder");  // Print initialisation header

And that’s about it for the code. Ive included lots of descriptive information in the code so that hopefully you will at least understand what each section does.

Parts List

The following parts can be obtained from a range of sources. I have listed some that I have used. I have included links for the Nano and LCD which should take you to the associated items on eBay or Banggood. The rest can be purchased from any components supplier, I have listed Jaycar simply because I purchased most of these parts from them as they were my local store.

  • Geekcreit ATmega328P Nano V3 x 1. . . . . . Banggood
  • Transistor NPN 2N2222 x 1: . . . . . . . . . . . . . Jaycar [ZT2298]
  • 6.5MM Socket x 3 . . . . . . . . . . . . . . . . . . . . . . Jaycar [PS0182]
  • 220 Ohm 0.25watt resistor . . . . . . . . . . . . . . Jaycar
  • 100 Ohm 0.25watt resistor . . . . . . . . . . . . . . Jaycar
  • 100nf ceramic capacitor . . . . . . . . . . . . . . . . Jaycar
  • 10k linear pot x 1 . . . . . . . . . . . . . . . . . . . . . . Jaycar [RP8510]
  • LCD 2004A x 1 . . . . . . . . . . . . . . . . . . . . . . . . . 2004 20×4 Blue HD44780 Character LCD with IIC/I2C Serial Interface Module from eBay
  • Jiffy Box Grey 130 x 68 x 44mm . . . . . . . . . Jaycar [HB6023]
  • Knob (for 10k pot) . . . . . . . . . . . . . . . . . . . . . Jaycar[HK7733]
  • 6.5mm stereo Plugs . . . . . . . . . . . . . . . . . . . . Jaycar [PP0116]
  • Green LED 3mm . . . . . . . . . . . . . . . . . . . . . . . Jaycar

End.