programming challenge 2014 entry - morsecode

I’m going to be posting the entries for the jpearman programming challenge slowly over the new few weeks. This first entry was from Michael Wallace of the MtSAC VEXU team. The code allows for morse code practise using a bumper switch and the cortex.

What is morse code?

(from wikipedia)
*Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment. The International Morse Code encodes the ISO basic Latin alphabet, some extra Latin letters, the Arabic numerals and a small set of punctuation and procedural signals as standardized sequences of short and long signals called “dots” and “dashes”, or “dits” and “dahs”. Because many non-English natural languages use more than the 26 Roman letters, extensions to the Morse alphabet exist for those languages.

Each character (letter or numeral) is represented by a unique sequence of dots and dashes. The duration of a dash is three times the duration of a dot. Each dot or dash is followed by a short silence, equal to the dot duration. The letters of a word are separated by a space equal to three dots (one dash), and the words are separated by a space equal to seven dots. The dot duration is the basic unit of time measurement in code transmission. For efficiency, the length of each character in Morse is approximately inversely proportional to its frequency of occurrence in English. Thus, the most common letter in English, the letter “E,” has the shortest code, a single dot.

Morse code is most popular among amateur radio operators, although it is no longer required for licensing in most countries. Pilots and air traffic controllers usually need only a cursory understanding. Aeronautical navigational aids, such as VORs and NDBs, constantly identify in Morse code. Compared to voice, Morse code is less sensitive to poor signal conditions, yet still comprehensible to humans without a decoding device. Morse is therefore a useful alternative to synthesized speech for sending automated data to skilled listeners on voice channels. Many amateur radio repeaters, for example, identify with Morse, even though they are used for voice communications.
*
Full description is here.
http://en.wikipedia.org/wiki/Morse_code

This was a good example of the type of application I was hoping the challenge would produce, it uses the cortex but is not directly related to robotics.

Michael’s code does work as submitted, however, I had trouble getting the timing of the “dits” and “dahs” to work when using a standard VEX bumper switch, I’m sure using a real morse code key would have helped with this as the travel (how far to push) of that would have been much less. I actually have a morse code key somewhere from when I was young, I did learn some morse code but have mostly forgotten it now. This is a fairly short and simple program, it uses timer 1 to measure the time of the button press and detect the short and long durations.

My major criticism of the code is that it needs the debugger to see what characters have been detected and the resultant message. I would have liked to see that displayed on the LCD screen as feedback. I created a slightly modified version that does this and also gives feedback using the VEX speaker.

Michael uses “define” statements to allow conditional compilation of some debugging statements, he uses initialized arrays to hold the definition of the pulse durations and also the characters they correspond to. The “key” array is really not needed, there is a simple arithmetic relationship that could have been used instead (character = 65 + offset, for example ‘E’ = 69). There is also no support for numerals.

The code (both original and my slightly modified version) is on github, you can find it here.

https://github.com/jpearman/vex_programming_challenge_2014

1 Like