Morse Magic

Many years ago, following eighteen months at sea as a Radio Officer, I began to realise that the tedium of sending telegrams by hand, could be done away with by automating the process. So it was that on my third ship, the M.V. Brassie / 3FCG, I took an Atari 800XL with its cassette recorder (bought discounted from Dixons in November 1985) and a few electronic components from Tandy / Radio Shack to build a computer - transmitter interface. I subsequently wrote a program to send morse code, first in Atari BASIC, then in BASIC and 6502 assembler, then at last entirely in 6502 assembler, and for six months successfully communicated with coast stations around the world using automated morse.

This was remarkably successful and led to one occasion when the Chief Engineer entered the radio room during a transmission. I waved him to be quiet because I was in the middle of sending a telegram and he walked over to look at the 9" Sony monochrome monitor in the corner which was displaying the outgoing message scrolling across the screen. After watching it for some time, while listening to the accompanying beeps, he stood back and said "That's fantastic!".

This was all the more remarkable because he didn't like me, we didn't get on, and yet he thought it was impressive and was prepared to say so.

This page is intended to tell the full story of how the process developed from its early stages until it was no longer needed in the mid 1990s. By the time the picture below was taken it was a year later and the project had moved on several stages. I had by then bought a disk drive for the Atari and constructed a handheld controller for the program via the joystick port, this is visible on the table just to the left of the telephone. I was also receiving morse weather reports on screen having written a simple BASIC program to decode the incoming morse and write it as text to the monitor.

In the beginning the biggest problem was how to store the morse characters as bytes in the most efficient way, in a table, from which they could be extracted as needed and sent. I started with the morse code itself because Samuel Morse had done most of the work by identifying the most frequent letters in the English language and assigning them the shortest codes. For example the letter 'e' is the most frequently occuring letter in written english and so had the shortest possible morse character, a dot.

The next most frequently occuring, the letter 't' became a single dash, and so on through the alphabet, albeit in a order derived from letter frequency rather than simple a-z. I had to find a way to use what Morse had done in digital form and started out by assigning 'e' a value of 1, and the letter 't' a value of 2. This was adequate if the message to be sent contained only the letters e or t but to cope with the rest of the alphabet I had to devise a method of coding that would allocate a unique binary code to each letter stored in memory and decided to do this by doubling the value with each displacement so for example the letter 'a' which has a morse value of dot dash became 1 for the dot plus 2 x 2 = 4 for the dash = 5. The table below shows how the character value was derived from its position.

    1st place 2nd place 3rd place 4th place 5th place 6th place
dash = 2 4 8 16 32 64
dot = 1 2 4 8 16 32


The incomplete table is here:-

Letter 1st 2nd 3rd 4th Value
E dot 1       1
T dash 2       2
A dot dash 1 4     5
M dash dash 2 4     6
I dot dot 1 2     3
N dash dot 2 2     4
S dot dot dot 1 2 4   7
D dash dot dot 2 2 4   8
R dot dash dot 1 4 4   9
G dash dash dot 2 4 4   10
U dot dot dash 1 2 8   11
K dash dot dash 2 2 8   12
W dot dash dash 1 4 8   13
O dash dash dash 2 4 8   14
H dot dot dot dot 1 2 4 8 15
B dash dot dot dot 2 2 4 8 16
L dot dash dot dot 1 4 4 8 17
Z dash dash dot dot 2 4 4 8 18
F dot dot dash dot 1 2 8 8 19
C dash dot dash dot 2 2 8 8 20
P dot dash dash dot 1 4 8 8 21
V dot dot dot dash 1 2 4 16 23
X dash dot dot dash 2 2 4 16 24
Q dash dash dot dash 2 4 4 16 26
Y dash dot dash dash 2 2 8 16 28
J dot dash dash dash 1 4 8 16 29

And so on . . . the remainder of the morse alphabet may be coded in the same way.

To be continued . . .[1256 3/10/08]

Nearly one year on [15:39 19/9/09] this remains a work in progress. . .

Complete Morse table here -> Morse Table


Diary entries from 1985 / 86 / 87



1985 December 12th Thursday

Good weather at last 1st decent sleep last night for days feel much better – now working a morse reading program which is quite short but will hopefully print out words from the radio.

At present it prints out dots and dashes from the bug key via the fire button contacts on the joystick.

Tonight hoping to add letters to the program instead of dots + dashes then after that initialization prog so it can receive at different speeds then eventually build a discrete component interface to the receiver so a tone will operate it . . . * succeded 22/12/85

1985 December 15th Sunday

Went to bed at 141100z on last night. Slept for 4 hours + got up couldn't sleep owing bad weather and thinking about computer program.

Got up at 2.00am and spent 4 hours on computer – succeded in getting my program to print morse letters in real time using 2 different methods of character generation -

1/ DIM array storing ATASCII values + converting from my code by reading DATA statements

2/ String of letters selecting by simply A$(x,x)

2nd method is simpler and requires less memory to work since no conversions just straight print A$(x,x) = A etc

1985 December 19th Thursday

Bad weather last night couldn't sleep – woke up at 4/4.30 and got up at 5 to play with computer until 7.30, finally managed to improve Morse reader to the point where it will now read from 17 to 29's on one setting which is bloody good.

The bug is still that a long sequence of letters with spaces will cause error i.e. “qrv” no spaces.

1985 December 22nd Sunday



After several days of writing morse reading programs I today built a single stage amplifier to interface with Main Rx and successfully decoded the entire weather forecast on 4mhz from JMC both 1st + 2nd versions ie fast and slow – this achieved by running a cable down to my cabin from the relay contacts to drive the joystick fire button.

What a treat! All beautifully printed out including spaces – I am ecstatic only problem is once scrolled away then its lost so I must add string storage to program in order to memorize the rx information ie A$=”The weather fcst” . . .

The weather has improved and we are now doing 14.8 kts unheard of before this.

n.b. Re 15th of December – this morse business has taken me 1 week from drawing board to reality and remains only to be improved . . .

n.b. Actually started on 12th see diary . . .

1986 January 4th Saturday

Started work on Machine Code on Atari having typed in Simple Assembler + Disassembler so now plodding through the book to get familiar with 6502.

1986 January 5th Sunday

Having great success with Machine code + enjoying it.

Weather terrible – gale force winds and heavy seas.

1986 January 13th Monday

A busy day – aerial fell down had to work hard to find out what it was – turned out to be Ships “Pantenna” Aerial so removed it for time being -

progress made on the computer front – now able to establish position of cassette loading programme + saving ..

1986 January 29th Wednesday

Have spent the greater part of the last 10 days working on a computer program to send morse in order to make life easier with long msg's.

So far quite successful though the “proof of the pudding is in the eating”. *

Sailing tonight 1900 so they say . . . for Japan.

*(see Feb 5th for success . . .)

1986 January 30th Thursday

Making progress with our friend the Morse machine. Now writing basic operating program to improve the appearance and ease of use.

1986 February 2nd Sunday

Evening – My local [operator] (KPH 4mhz) was on tonight being super efficient as usual. However this time I had the msg on tape so no errors + no problem just a rapid tusu . . .

P.S. Please note the tone decoder will read morse from a tape and key a relay if necessary . . . .

1986 February 3rd Monday

The Morse Magic program goes on improving – now almost usable – at least the Mark 1 version is in Basic using M/L subroutines to do the work.

Ambition is to write entirely in M/L except for graphics – that's Mk 2.

Mk3 will be autoboot from tape + all M/L maybe sometime end of March for that one.

1986 February 4th Tuesday

This morning the weather is much improved, blue skies, sunshine and a calm(ish) sea.

This morning we received orders to make for Yokohama as discharge port so as already on GC course at 43n 143w not much difference in course.

I brought the computer up to the radio room this morning and tried it out but not switching relay properly – needs some amplification to give larger signal and a schmitt trigger to give sharp output keying pulses.

Built s/trigger ok and emitter follower but still no go so in the evening I built a 741 op-amplifier from cct design M/H/Jones.

Now switches reed relay well.

1986 February 5th Wednesday

This is an historic day.

This afternoon I sent an AMVER msg to NMO by computer and this evening I sent 2 long msgs to KPH with computer.

1st was Ck69 to Wallems + 2nd was Ck24 to Stochart.

However some problems remain, firstly the amp is * not soldered so vibration distorts the signal(!) and secondly it only stops between words which is a real bummer when he wants you to stop just after the start of a long word. So this needs looking at.. but yes – it works.

3rdly yes perhaps I should add collation to msg because he asked for several checks after each msg.

*(this fixed by soldering cct to pcb)

1986 February 7th Friday

Morse Magic steadily improves:- now only major bug remaining is inability to stop between letters – at present I have to pull the plug out.

We have had rain / hail / sleet and snow showers today and this at 46 north. England must indeed be fortunate to suffer so little at 53 north.

Another kick in the teeth tonight but this time only onboard. Tried computer to send Amver but vibration of vessel seems to be upsetting the reed relay so now I must try transistor switching . . .

1986 February 8th Saturday

Well I tried transistor switching but couldn't get the final transistor to saturate so it had 0.6v across it and would not properly switch the tx. So put in original mechanical relay that I found onboard – so now we try again . . .

1986 February 9th Sunday

Good morning, well today the sea is calm the sky is blue with wispy clouds + the wind is light.

Having given up on the sound reader for my morse magic owing to feedback problems from the antenna I have built a simple interface for the cassette motor control from Port A. By switching this on and off I can generate morse + switch the tx. Tested this morning on KPH for call ups + to receive a QTC. So far so good . . .

1986 February 11th Tuesday

[…] today has been very busy with msgs – 7 + Amver.

M/Magic needs a few improvements but thats inevitable . . .

1986 April 1st Tuesday

Anchored Vung/Tau Vietnam awaiting berth.

Working on antennas all day until interrupted by horde of officials – two with Sten Guns – to do papers.

Later on sent QTC to Singapore on 12mhz by computer – this is what 'she' replied:-

“excellent / perfect keying ere wish you had more msgs for me then qrx 9VG37 or / 57 any msg th u 73 and 88 for keying tu”.

Sent one to VPS but normal response qsl . .

1986 May 8th Thursday

The ionosphere finally let me down today only QSA 2/3 from JCS so no QSO. Sent 5 msgs via KPH – computer – all ok.

1986 June 29th Sunday [last Brassie entry]

Tonight sent the other charts cable

CK233 to VPS by computer.

Thank God for the computer!

[Signed off Hkg and spent 3 weeks holiday there before returning UK]

1986 November 23rd Sunday [Intermar Alliance Leith bnd Mexico]

A degree of success; today I have succeeded in running the Interrupt send routine. So now I can type in ATASCII characters to BYTE instructions and send good morse. Only bug remaining now is that two spaces together take too long.

Tonight we pass through the Azores. Tonight 40n 30west.

1986 December 6th Saturday

Long day ashore – wasted morning at Surgery then tedious afternoon at Sunrise Mall. I bought music system and disc drive for Atari plus a few books.

1986 December 10th Wednesday

Tonight, hard work on the A/D converter, fed signal from Rsve Rx into Analog Port in hope of reading it, but computer too slow. I have to eliminate VBI delays + waiting for next VBI etc. Next step is to dissassemble VBI routines to find out how to control “pokey” to get A/D fast, at will.

1986 December 12th Friday

Last night wrote “FIND” rtne for Atari. Very useful, I can now find any 16 bit number in memory in seconds + all its addresses.

Had some success today with Fast potscan routine – it takes 125uS to convert but problem is no sample + hold yet.

1986 December 25th Thursday

Evening working on computer, now able to stop and restart from beginning of last word.

Up till 1.00am – had quick beer with Old Man + Superintendent then bed.

1987 March 25th Wednesday

Last night started reworking Morse Reader + Tone decoder. Yesterday I spent the afternoon transferring tape cassette progs to disc and found I still have Morse Reader. So set up all in the evening and C/E came in to watch me receive a WX bcst from WLO with very few errors.

1987 March 26th Thursday

Up early this morning since clocks retarded without my knowledge. Used the extra time to rewrite part of Morse Reader to store incoming data in a string then print the string to disc, thus achieving permanent storage. Also added a line to read the disc back into the string, for recovery later.

1987 May 12th Tuesday

Wrote a comprehensive MOVE routine today for the ATARI, with the aid of a couple of books. This routine will move data anywhere in RAM 0 – 64k even within the block being moved i.e. 1 bit shuffle.

Intention is to use MOVE as part of Insert and Delete for text editing Morse Magic.

1987 May 14th Thursday

Continued working on RadioMate. Tidied up branch titles and Page Zero addresses to make it more organised. Merged Insert/Delete but not yet up + running although both work on their own.

1987 May 20th Wednesday

Some computer success tonight. Succeeded in getting an extra IES sent after every e, t and w. Unfortunately in a word like Between it sounds like overkill and instead of emphasising the “e's” just slows the sending speed down.

Next is to space only double “e's” like fleet, between, green, etc + ignore single “e's” altogether.

Problem remains of e before oblique stroke. This is a special case.


End of diary entries from 1985 / 86 / 87


Extract fm letter to [a fellow R/O] May 1988

Fukuyama, Japan

Wednesday 25th May 1988

So onto this morse business. Is it as fast as telex? Of course not but with any message over Ck50 it does mean that instead of getting fed up sending strings of figures and punctuation you can sit back and let the computer do the talking. I was working W/T on a tanker when I wrote my program, and having trouble with San Francisco radio in December 1986. Tanker messages are all figures, like OBS, and boring to send. I enjoy sending plain language because it has a rhythm to it but figures do not.

The principles involved in sending automatic morse must be fully understood before attempting to write a program, or you will tie yourself in knots. Pick up any of the Admiralty List of Radio Signals books and turn to the inside back page, top few lines. They describe exactly how morse should be sent. So we have to generate:-

1) The basic unit of time, a dot length which is identical to the space between two parts of a letter.

2) A dash length which is equal to three dot lengths and which is also the space between two letters.

3) An interword length which is equal to seven dots.

Consider also the following; every transmitted dot or dash must have a space after it to distinguish it from its neighbour. Therefore in writing a delay loop to time the sending, you can include a second loop which sends one dot space automatically prior to the next part of a letter, ok?

So first, you write a simple pair of loops which will send the letter E. The first loop switches on the tx, times the dot, then switches off the tx; the next loop times the Inter Element Space (IES), this being my terminology for spaces. In fact pls note there are three kinds of space. The IES, the ILS (inter letter space) and IWS (inter word space).

So there you are with a program to send E's. Big deal, put a GOTO 10 at the end and it will send dot, dot, dot for ever. You will also need to add a BEEP line in the first loop to generate sidetone through the TV spkr.

I'll tell you how I wrote my Mk 1 program in Basic and 6502 Assembly language. I started off by writing two delay loops. One for the dot length and one for dashes. Timing of each could be altered by a POKE (have you looked it up yet?), and checked by a PEEK. Next I reserved a section of RAM in free memory by looking at the memory map and using about 1k of space for messages. Then I looked up the letter codes in my computer reference manual to see how I could relate a given letter to its morse code character. You will find that each letter of the alphabet and each number has a numerical code between 0 and 255. This can be used to reference the stored letter to send morse and/or put a chosen chr on the screen. Now back to the morse.

Having written two timing loops, you can start to write your morse alphabet. Using BASIC you simply choose where to start your line number. Let's say 1000 for letter A. So line 1000 etc reads









This leaves you ready to send the next chosen letter having finished off by sending the IES. All clever stuff eh! Now simply write a similar routine for the other 25 letters and for the numbers and punctuation. I'll give you a hint here. You can save time by writing the E and T routines first then building up by using THEM as subroutine for the longer letters, for instance, letter F is also E R joined together isn't it. You'll soon get the idea and be able to write your own morse alphabet.

Now we come to the tricky bit. In order to send a message, you must store it in memory (and remember where it is!). Then set up a loop to step through the message one letter at a time. Say:

10 For A= 1 to 1000

20 B = PEEK(address)+A

30 GOTO 1000+B


If you can understand the next bit you are halfway to success. It is a method of using the computer ref no. to reach your little subroutine further up the program, to send the letter. The problem is that your s/r takes more than one line, but the ref nos. are succesive. You get around this by multiplying each PEEK'd ref no. by the number of lines in your s/r. Say it takes you a maximum of 10 lines to write a routine to send the letter Q. Then you set each s/r 10 lines apart; then when you read the memory for the next letters ref no. you multiply it by 10 and add the necessary offset (1000 or 2000 or whatever) to reach the correct position in your collection of s/r's.

Lastly because I am not happy about my description of the multiplying step process, here is an example. Suppose you had a random number generator that came up with a number between 1 and 5. Now suppose that each number between 1 and 5 represented a fruit to be drawn on your screen and that the routine to draw each fruit took 1000 lines of programming, and the first routine started at line 5000.

Now you can see that to reach the first routine you have to add an offset. And to reach the second routine you have to add a larger offset because the routines are 1000 lines apart. But the random numbers are sequential, 1 2 3 4 5 so it's no good just adding 4000 to each number because you will just end up nowhere as follows. 4000, 4001, 4002, 4003, 4004, and 4005.

In order to get where you want to go, you must multiply each random number by the distance between the routines; which as we have established is 1000, then add the offset.

So if your generator comes up with 3, and you want to draw at line 7000, you have to multiply 3 x 1000, then add the offset, which is 4000. Let's just go through that again in full:-

1. multiply x 1000 = 1000. Add 4000. Answer = 5000. ok 2. multiply x 1000 = 2000. Add 4000. Answer = 6000. ok 3. multiply x 1000 = 3000. Add 4000. Answer = 7000. ok

Even you can work out the other two, ha ha ha. To relate this to sending morse, remember your computer will have nearly 64 codes (128 if Capitals are included) of which you can choose about 50 to include all the major morse code chrs and punctuation. You will find yourself with a list of numbers between say 20 and 70, so the first step is to make them useful by subtracting 20, this gives you a range from 0 to 50 instead of 20 to 70. Then you start multiplying and adding the necessary offsets as you need them. In fact it is the order of the computer codes that will determine the order in which you write your routines further up the program, because that is the only way you can access them sequentially by the method I have described.

Practise your PEEKS and POKES because they will return the numbers you need for processing.

I cannot make it any clearer than that. The rest is up to you, until we meet again in person. Good luck [xxx]. I love this detailed programming and only wish I was closer at hand to help you out. The programming is far more fun than the using of it I assure you, and the number of bells and whistles to be added is never ending. (Automatic Q codes, QSL, updated QTH from the bridge etc,). Variable speed isn't really that important. Although I have it now, I was never asked to change speed during the six months in 1986 that I used it. (sending at about 23's). But you must have a method of going back one or two words for repeats, also a method of editing the message. This is where it gets hard work to program. You will find that the morse generation is the easy part believe me!

Just to whet your appetite for the real thing, the way I am now sending morse with the Mk 2 is by using one byte of memory to store each letter of text, where a binary 1 represents a dash, and a binary 0 represents a dot. The morse is sent by using an assembly language instruction called ROTATE. There is no BASIC equivalent, but what this does is to move the byte bit by bit sideways through what is called the CARRY BIT. By reading the carry bit and sending it to the dot/dash timing loops, you can send morse and also have your program in much less space.

More programming notes from the 1980s diaries

When I first set out to write a morse program, I learned Atari Basic so that I could gain access to the registers via Peek and Poke, and create arrays to store data on an Atari 800XL with 1010 cassette recorder.

As it became clear I would have to learn assembler to progress further, I bought Compute!'s Machine Language for Beginners by Richard Mansfield from a computer shop in Long Beach California when the Brassie was in there for bunkers.

I typed in the Simple Assembler for Atari from the appendices, and saved it to cassette tape (I didn't buy the disk drive version until much later).

I then began to learn ML from the book, using both Basic, and ML via the simple assembler.

My first morse program was written in Basic with little bits of ML when I had to gain access to the ports to switch the transmitter with Peek and Poke. The first attempts were made by producing a tone from the monitor speaker and using a PLL chip to detect the presence of the tone and switch a relay; not a great success because the tone would drift, or rather the circuit tolerance would drift, and it had a narrow band for the PLL.

I soon switched to using the cassette motor port on the back of the computer having found the hardware register reference in a book. I had to address these registers to get them to switch the motor on and off and thus the transmitter. I didn't know if the relay or transistor switch inside the computer could tolerate the transmitter voltage of 24v so instead of taking a chance, I used a 5v relay powered by a PP3 to switch the tx.

Once this was working I had a program to send morse code.

As the weeks went by I wrote more and more of the program in ML and reduced the Basic until the whole program was written in ML apart from loading it into the computer from the cassette in the morning. The computer then stayed on all day with the program in it, until I went to bed.

Each day I would load the program from Basic 'load "morse magic"' and then this would run in ML. I typed in the telegrams using the interface I had designed, and sent the messages as needed. I had to connect the two transmitter key wires at the back of the computer, this was a bit fiddly. I had to do this every day because it was the same socket as was used for the cassette recorder to load the program. How I could have done with this on a cartridge! I used the innards of two banana plugs as connectors for the cassette motor switch, since they had a two way + split in the ends which meant they would friction fit over a metal pin.

Good things that happened at sea

One day I was transmitting using the Atari Morse Magic program and the French C/E (we didn't get on), came in for something. I was transmitting so waved him quiet but he stayed and came over to the screen. I told him briefly what was happening as the message scrolled across the screen and he said "That's fantastic!". An unheard of complement from a man who didn't like me. One of my better days at sea :-)

The other one was of course the day a girl at 9VG sent me 88s after one telegram and said "I wish you had more telegrams for me". What a day that was. Unfortunately I spoiled it a bit by telling her I was using a computer to send the morse.



The only remaing listings for the receiving program (complete) and the transmitting program (excerpts) are available to view at this link:-

  Morse Magic  

My personal development notes for the project are not yet online, I'll have to think about that, the listings are of more importance at this stage.



As the years went by more and more ships had telex over radio (TOR) or satellite communications and the need for morse diminished.

I sent my last QTC (morse telegram) in 1994 to Haifa Radio 4XO to book a telephone call and that was that.

GMDSS or the Global Maritime Distress and Safety System had made our profession redundant and thousands of radio officers across the world either left the sea or retrained for other jobs onboard ship.

Many became Electro Technical Officers but it was a very different role devoid of one's own office and it didn't suit everybody. It didn't suit me. You were no longer a head of deparment of one, answerable only to the Captain.

Send any questions about the above to Paul