First implemented in PIC, the algorithm has since been fully rewritten and updated to run as a training program on a number of Atmel-based Arduino boards, including the Uno (ATmega328), Nano (ATmega328) and Pro Mini (ATmega168).
“Essentially, the Magic Morse algorithm assigns a weight to dits and dahs as the stream is received,” Burnette explained in a recent blog post.
“When a word space or longer is encountered, the algorithm instantly has a calculated pointer into an array stored in EEPROM and the decoded character is returned.”
According to Burnette, the algorithm is designed to generate a number between 1 and 255 for every Morse Code combination decoded.
“For every DAH identified in the stream, a binary weight is applied based upon the position of the DAH… that is, first, second, third, fourth, or fifth element,” he continued.
“DITs are not weighted but are counted with DAHs to achieve a total element count of DITs + DAHs in the character. The DAH-weights are bits 3-7 in a calculated index and the elements number make up bits 0-2.”