Shop OBEX P1 Docs P2 Docs Learn Events
New Morse Code encoding? — Parallax Forums

New Morse Code encoding?

After having a grand old time with Jon McPhalen's 'Beyond the LED Basics' (the article in Nuts & Volts was the whole reason I bought a Propellor 2 - Newbie here! Hi y'all! ) I thought I might have found a better way of Morse Code encoding.

I call it 'start-bit encoding'. Every character (and prosign!) is encoded in one byte. Every byte has zero or more leading zeros, and a '1' for a start bit. The leading zeros and the start bit are ignored by the decoder, and the remaining bits provide the Morse, '0' for a 'dit' and '1' for a 'dah'.

The major improvement is the ability to handle six- or even seven- symbol Morse encodings. I'm sure the theory is old hat, but here's how to make it work with JonnyMac's code. I appended _sb to each name.

(sorry about this, but very strange things happen when I try to use the code tag. It 'encodes' one line - then no more, wherever I put the closing tag. Weird.)

First, the decoder, decoder_sb.txt:

I'm sure clever folks could easily improve my decoder.

A trivial change to the calling routine, morse_str_sb.txt :

I added the inter-character delay so "STSTST" wouldn't look like "VVV", and finally the lookup table, alphas_sb.txt:

And it all remains under the MIT license.

Have fun! S.

Comments

  • JonnyMacJonnyMac Posts: 8,924
    edited 2021-03-13 18:37

    FTR, the Morse encoding that I demonstrated is by Scott Edwards, and goes all the way back to the BASIC Stamp 1 (great grandfather of the P2). I sneaked it into this (P1 powered) display:

    https://i.pinimg.com/originals/74/5c/20/745c20bd40221477bedc1732350166ee.jpg

    Each of the soldiers had a lamp between their shoulder blades, so each of those send a Morse message with the game vendor's name, the game name, and the character game. My client, Steve Wang, didn't notice this until we were set up in public. When he asked about the strange blinking, I smiled and said, "That's their IFF." Being a civilian, I had to explain "Identification, Friend or Foe" -- which he then went on to describe with some pride when giving interviews at that show (PAX West).

    I have found new forums toolbars problematic (at best); you can insert code by pressing the back-tick key three times, newline, paste you code, newline, three back-ticks. I guess the up-shot of the new system is that it's all text-based and easy to use w/o the menu.

  • Morse has its ways.

    When I had my holiday lights flash 'if you can read this send me email' (and the address) nobody did, so I figured I could make them say anything I wanted... evilgrin. Before even the Basic Stamp a chap I knew built out of TTL logic a cable tester that would put a (different) Morse character on each wire. Then he could clip up a little earpiece, and tell precisely which wire was which at the far end.

    I tried typing in 'code' and '/code' (with the correct angle brackets) but it didn't help. I didn't try three back'ticks. Oh well.

    I think you did fail to put in the 'inter-character delay' in your demo, but no worries! It was the first Propeller program I got working - thanks much! S.

  • I think you did fail to put in the 'inter-character delay' in your demo...

    Thanks for pointing that out. I'll update the code and get it to Ken for [re]posting in the Quick Byte.

  • You're welcome. Hope you understand what it's like for a first-poster with his first program to tell the God of Propellers that He Biffed That Bit... :#:)

    Next up, getting that terminal window working!
    S.

  • I prove that I'm human each and every day! Welcome to the Propeller family. It's fun.

  • Well done - can this be expanded into an Iambic paddle Keyer?

  • @PropGuy2 said:
    Well done - can this be expanded into an Iambic paddle Keyer?

    Unlikely, since all we're on about so far is processor-controlled output. If you want a paddle to do input with, that's up to you. S.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-03-14 01:17

    The morse demo I did for TAQOZ had a table of 16-bit values with every 2-bits as a space/dot/dash value although It could have been encoded a bit better.
    In TAQOZ/Tachyon I can redirect the console output to different devices and so I made MORSE an output device so if I had an LED or speaker on pin 8 for instance I could type `8 MORSE PRINT" Hello World!" CON" and it would switch to that output, tap out the message in Morse before returning to the console.

    I forgot to switch back to the console - listen! ( The default is 800Hz 24WPM )

    TAQOZ# 7 MORSE PRINT" HELLO WORLD!" ---  ok
    TAQOZ# 
    
    

    NOTE: I can attach a video file but I can't attach an audio file without compressing it!!!!!!
    EDIT: I made a video - so much more efficient and safer than an audio file, don't you think?

  • @"Peter Jakacki" said:> EDIT: I made a video - so much more efficient and safer than an audio file, don't you think?

    >

    Um, dear Sir, I would say no. The file sizes are humongous, and although I can download a few, I have to be very careful about them, which I can pick and choose and prefer, before my satellite ISP gets all over my case and turns my browsing speed back to the dial-up days.

    It would be nice to have reasonable competition for my ISP, but I don't have that here.

    So no, it is not better to have a 6MB video over a 10kB text file.

    Appreciate the efforts and all, but some of us live out in the sticks, and don't have the network connections you do. Thanks again even if I cannot use all the help you provide, S.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-03-14 06:46

    I was being rather sarcastic because all I wanted to attach directly was an audio file, not a zip, not a video, but the forum setup does "allow" it??? The video nonetheless displayed the console and how easy it was to talk morse. The original video file was 61.9MB but I compressed with WinFF out of consideration for those out in the "sticks" but there is no need to make a big case about your ISP as if it is everyone else's fault too, is there? How far out are you anyway?

    btw, I started recoding to use your single byte idea.

  • Not that far out, actually - my neighbor has an excellent view of Los Angeles, but this just happens to be one little nook in the hills that wired internet overlooked. Up here we have power and water, but no gas nor sewer lines.

    I'll get to watch your video later - The satellite offers 'free time' from midnight to 5am, if I'm up and about then. Should script a download or two...

    And I may have been a bit snarky there - I've been cranky about file sizes since using a 300 baud modem (yes, olde farte here). Sorry about that.

    Have fun! S.

  • @Scroungre Are you in the San Gabriel mountains?

  • Simi Hills. Technically, the view is of the San Fernando Valley, and Burbank on a day after rain. If you're familiar with the 118 fwy., or the railroad to San Francisco, I'm roughly on top of Santa Susana Pass.

  • Got it. I'm in Burbank. One of my clients, Steve Wang, has a shop in Chatsworth, so I do take the 5 to the 118 to Topanga Canyon. About the only time I go past Topanga is heading to Thousand Oaks to see another friend who is an amazing prop fabricator.

  • Cool. When we're all up on our vaccines I'll buy you lunch sometime.

    Until then, I'll wait for a clear day, then go down the end of the road and wave my p2 breadboard at you. :) Would you mind if I also yelled into the wind a little about your choice of 12-pin DIH headers? I have a zillion 10-pin IDC connectors, and miles of 10-pin ribbon (from old servo motor encoders, mostly), but no 12-pin! Grr!! :'(

    S.

  • @"Peter Jakacki" said:
    btw, I started recoding to use your single byte idea.

    PS - There's one flaw in my 'start-bit' encoding, and it's that the 'Transmission Error' is actually eight dits, not seven. However, this can be dealt with as a special case, because there is no valid Morse message that is seven dahs in a sequence, therefore if the "Morse Data" is $FF, then a separate test can be written to emit eight dits. There's other 'invalid codes' you could use. Dunno if that helps any. S.

  • JonnyMacJonnyMac Posts: 8,924
    edited 2021-03-15 15:59

    @Scroungre said:
    Would you mind if I also yelled into the wind a little about your choice of 12-pin DIH headers? I have a zillion 10-pin IDC connectors, and miles of 10-pin ribbon (from old servo motor encoders, mostly), but no 12-pin! Grr!! :'(

    My idea for the P2 Edge Breadboard was derived from parts already in use on the P2 Eval board -- I didn't choose the 12-pin headers, that precedent was set. Parallax took my basic idea submitted to them in the form of a 3d sketch I did with DipTrace (see image) and made it better.

    I'll look forward to that lunch.

    1920 x 1040 - 261K
  • All right, I'll shout into the wind at the Gracey Brothers. And if you're expecting lobster thermidor or something you will be sorely disappointed. 'til then! B)S.

  • Here's a morse encoder/decoder I originally wrote for the P1, managed to port it to the P2 without too much difficulty. Sends and receives with or without audio, auto-detects received keyrate and tracks gradual changes, supports all letters, numbers, punctuation, and even command digraphs.

  • Simi Valley! Lived there for many years. Two words: Red’s BBQ. And maybe Chuys... :)

  • octettaoctetta Posts: 123
    edited 2021-03-15 22:44

    @Scroungre said:
    Cool. When we're all up on our vaccines I'll buy you lunch sometime.

    Until then, I'll wait for a clear day, then go down the end of the road and wave my p2 breadboard at you. :)

    I live in Thousand Oaks, but prior to COVID times travel to Northridge for "real work"... would love a P1/P2 meetup sometime after we're vaccinated.

    -j

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-03-16 04:57

    I used your code method and decided on a table of 58 bytes for characters ! to Z with a value of 0 for invalid entries. That way I just convert lowercase, limit, and offset the ASCII code. So with the table and the ASCII stream handlers etc the code ends up at 294 bytes.

    This is what my table looks like in TAQOZ ( I had to cut out a left-hand comments column because the forum s/w mucked it up)
    --- Lookup morse code for characters ! to Z

    0 TABLE _morse
      %1101011 | %1010010  | 0         | %10001001 |
       0       | %101000   | %1011110  | %110110   |
     %1101101  | 0         | %101010   | %1110011  |
     %1100001  | %1010101  | %110010   |
       %111111 | %101111   | %100111   | %100011   |
      %100001  | %100000   | %110000   | %111000   |
       %111100 | %111110   |
      %1111000 | %1101010  | 0         | %110001   |
       0       | %1001100  | %1011010  |
       %101    | %11000    | %11010    | %1100     |
       %101    | %10010    | %1110     | %10000    |
       %100    | %10111    | %1101     | %10100    |
       %111    | %110      | %1111     | %10110    |
       %11101  | %1010     | %1000     | %11       |
       %1001   | %10001    | %1011     | %11001    |
       %11011  | %11100    |
    
    
  • I guess TAQOZ lets you specify binary without leading zeros.

    Pretty cool, tho - it had not occurred to me to use 'no start bit at all' as an 'invalid code', but that ought to work wonderfully. Have fun! S.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2021-03-18 03:58

    Yes, I have great flexibility since TAQOZ is the compiler and runtime so I can extend and modify the compiler too as needed. But the % is only necessary to force it to binary unless I am already in binary mode then I can 1011001 all I like but then I would have to prefix/suffix hex and decimal numbers. I can also mix in symbols as long as they can't be confused as a digit etc.

    Some quick tests.

    TAQOZ# %1101011 .DEC --- 107 ok                                                 
    TAQOZ# %M1.101011 .DEC --- 107 ok                                               
    TAQOZ# 1101011b .DEC --- 107 ok 
    TAQOZ# BIN ---  ok                                                              
    TAQOZ% 1101011 .DEC --- 107 ok  
    TAQOZ# #PIN56 .DEC --- 56  ok 
    
Sign In or Register to comment.