Shop OBEX P1 Docs P2 Docs Learn Events
Making Sense Of Character Codes — Parallax Forums

Making Sense Of Character Codes

ArchiverArchiver Posts: 46,084
edited 2003-09-06 18:16 in General Discussion
I'm new to stamps and ran across the following program that I would
like to modify for my own needs. I'm having some difficulty figuring
out the scheme being used to identify (index1) the characters.
Neither an ASCII, Hex, Oct, nor html code table seem to correspond
with what the author is using. Is he adding a binary number (morse
routine) to some other number? I basically want to customize the
characters.

Any and all help is appreciated!

Thanks

Frank Matthews



'{$STAMP BS2}
'KC8QNO Beacon Software for the Basic Stamp 2
'Pin 1 controls the morse key on the rig
'Pin 2 controls the LED on the Stamp


INDEX1 VAR Byte
INDEX2 VAR Byte
ELEMENTS VAR Byte
CHARACTER VAR Byte
DELAY CON 1500
I VAR Byte
C VAR Byte

IDENTIFY:
LOW 2
FOR I = 1 TO 8 'Loop for one "dit" every 2 sec
CHARACTER = 1 'until ID string (8 times)
GOSUB MORSE
PAUSE 2000
NEXT
PAUSE 1000 'Time Between Words
FOR INDEX1 = 0 TO 2
LOOKUP INDEX1,[noparse][[/noparse]20,20,20],CHARACTER 'VVV
GOSUB MORSE
PAUSE 1000
NEXT
FOR INDEX1 = 0 TO 5
LOOKUP INDEX1,[noparse][[/noparse]132,1,66,164,227,130],CHARACTER 'BEACON
GOSUB MORSE
NEXT
PAUSE 1000
FOR INDEX1 = 0 TO 1
LOOKUP INDEX1,[noparse][[/noparse]131,1],CHARACTER 'DE
GOSUB MORSE
NEXT
PAUSE 1000
FOR INDEX1 = 0 TO 5
LOOKUP INDEX1,[noparse][[/noparse]163,164,229,212,130,227],CHARACTER 'KC8QNO
GOSUB MORSE
NEXT
PAUSE 1000
FOR INDEX1 = 0 TO 6
LOOKUP INDEX1,[noparse][[/noparse]129,35,3,164,227,68,66],CHARACTER 'TUSCOLA
GOSUB MORSE
NEXT
PAUSE 1000
FOR INDEX1 = 0 TO 1
LOOKUP INDEX1,[noparse][[/noparse]164,227],CHARACTER 'CO
GOSUB MORSE
NEXT
PAUSE 1000
FOR INDEX1 = 0 TO 1
LOOKUP INDEX1,[noparse][[/noparse]194,2],CHARACTER 'MI
GOSUB MORSE
NEXT
PAUSE 1000
FOR INDEX1 = 0 TO 1
LOOKUP INDEX1,[noparse][[/noparse]3,163],CHARACTER 'SK
GOSUB MORSE
NEXT
RETURN
MORSE: ELEMENTS = CHARACTER & %00000111
IF ELEMENTS = 7 THEN ADJUST1
IF ELEMENTS = 6 THEN ADJUST2
BANG_KEY:
FOR INDEX2 = 1 TO ELEMENTS
IF CHARACTER >= 128 THEN DAH
GOTO DIT
REENTER:
CHARACTER = CHARACTER * 2
NEXT
GOSUB CHAR_SP
RETURN
ADJUST1:
ELEMENTS = 6
GOTO BANG_KEY
ADJUST2:
CHARACTER = CHARACTER & %11111011
GOTO BANG_KEY
DIT: HIGH 2
LOW 1
PAUSE 175
LOW 2
HIGH 1
PAUSE 125 'Letter Speed (DIT and DAH must match here or
the code
GOTO REENTER 'sounds funny
DAH: HIGH 2
LOW 1
PAUSE 375
LOW 2
HIGH 1
PAUSE 125 'Letter Speed (DIT and DAH must match here or
the code
GOTO REENTER 'sounds funny
CHAR_SP:
LOW 2
HIGH 1
PAUSE 500 'Time Between Letters (Characters)
RETURN
WORD_SP:
LOW 2
HIGH 1
PAUSE 1200
RETURN

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-09-06 16:49
    Hi, Frank,

    It looks like the code might have come from
    http://www.qsl.net/kc8qno/beacon.html. That page recommends
    going to Parallax's web site for more information.

    A quick search on http://www.parallax.com/ for "morse" yielded a
    link to the Stamps-In-Class book "Earth Measurements" at
    http://www.parallax.com/detail.asp?product_id=28153. You can
    download the PDF form on that book, and learn about the encoding
    of the characters starting on page 10.

    It is a clever piece of encoding.

    HTH,
    Daniel

    >
    Original Message
    > From: Frank Matthews [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Dfm5p5vtdgtRvs7uYmy22JfIbdfXXNHactDIl7sAs3DS2zaZ17iq4JaZK5HItpdVhy3v1A]fmnnc@c...[/url
    > Sent: Friday, September 05, 2003 10:52 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Making Sense Of Character Codes
    >
    >
    > I'm new to stamps and ran across the following program
    > that I would
    > like to modify for my own needs. I'm having some
    > difficulty figuring
    > out the scheme being used to identify (index1) the characters.
    > Neither an ASCII, Hex, Oct, nor html code table seem
    > to correspond
    > with what the author is using. Is he adding a binary
    > number (morse
    > routine) to some other number? I basically want to
    > customize the
    > characters.
    >
    > Any and all help is appreciated!
    >
    > Thanks
    >
    > Frank Matthews
    >
    >
    >
    > '{$STAMP BS2}
    > 'KC8QNO Beacon Software for the Basic Stamp 2
    > 'Pin 1 controls the morse key on the rig
    > 'Pin 2 controls the LED on the Stamp
    >
    >
    > INDEX1 VAR Byte
    > INDEX2 VAR Byte
    > ELEMENTS VAR Byte
    > CHARACTER VAR Byte
    > DELAY CON 1500
    > I VAR Byte
    > C VAR Byte
    >
    > IDENTIFY:
    > LOW 2
    > FOR I = 1 TO 8 'Loop for one
    > "dit" every 2 sec
    > CHARACTER = 1 'until ID string (8 times)
    > GOSUB MORSE
    > PAUSE 2000
    > NEXT
    > PAUSE 1000 'Time Between Words
    > FOR INDEX1 = 0 TO 2
    > LOOKUP INDEX1,[noparse][[/noparse]20,20,20],CHARACTER 'VVV
    > GOSUB MORSE
    > PAUSE 1000
    > NEXT
    > FOR INDEX1 = 0 TO 5
    > LOOKUP INDEX1,[noparse][[/noparse]132,1,66,164,227,130],CHARACTER 'BEACON
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]131,1],CHARACTER 'DE
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 5
    > LOOKUP INDEX1,[noparse][[/noparse]163,164,229,212,130,227],CHARACTER 'KC8QNO
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 6
    > LOOKUP INDEX1,[noparse][[/noparse]129,35,3,164,227,68,66],CHARACTER 'TUSCOLA
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]164,227],CHARACTER 'CO
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]194,2],CHARACTER 'MI
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]3,163],CHARACTER 'SK
    > GOSUB MORSE
    > NEXT
    > RETURN
    > MORSE: ELEMENTS = CHARACTER & %00000111
    > IF ELEMENTS = 7 THEN ADJUST1
    > IF ELEMENTS = 6 THEN ADJUST2
    > BANG_KEY:
    > FOR INDEX2 = 1 TO ELEMENTS
    > IF CHARACTER >= 128 THEN DAH
    > GOTO DIT
    > REENTER:
    > CHARACTER = CHARACTER * 2
    > NEXT
    > GOSUB CHAR_SP
    > RETURN
    > ADJUST1:
    > ELEMENTS = 6
    > GOTO BANG_KEY
    > ADJUST2:
    > CHARACTER = CHARACTER & %11111011
    > GOTO BANG_KEY
    > DIT: HIGH 2
    > LOW 1
    > PAUSE 175
    > LOW 2
    > HIGH 1
    > PAUSE 125 'Letter Speed (DIT and DAH must
    > match here or
    > the code
    > GOTO REENTER 'sounds funny
    > DAH: HIGH 2
    > LOW 1
    > PAUSE 375
    > LOW 2
    > HIGH 1
    > PAUSE 125 'Letter Speed (DIT and DAH must
    > match here or
    > the code
    > GOTO REENTER 'sounds funny
    > CHAR_SP:
    > LOW 2
    > HIGH 1
    > PAUSE 500 'Time Between Letters (Characters)
    > RETURN
    > WORD_SP:
    > LOW 2
    > HIGH 1
    > PAUSE 1200
    > RETURN
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text
    > in the Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-09-06 18:13
    Hi Frank,

    The characters in the LOOKUP statements are the Morse code, in two
    parts. The rightmost three bits contain the number of dits and dahs
    to send, and the leftmost 5 bits contain the pattern, 0 being a dit
    and 1 being a dah. For example:
    E 1 %00000 001 one element, a dit
    M 194 %11000 010 two elements dah dah
    V 20 %00010 100 four elements dit dit dit dah
    The routine "plays" the sequence from left to right by looking at the
    most significant bit. Each time through the loop, at label REENTER,
    the code is multiplied times two to shift the next bit left to be
    played.

    A special case is made if the number of elements is 6 or 7, although
    there does not seem to be punctuation in the LOOKUPs. The timing is
    established by hard coded pauses.

    -- Tracy




    >I'm new to stamps and ran across the following program that I would
    >like to modify for my own needs. I'm having some difficulty figuring
    >out the scheme being used to identify (index1) the characters.
    >Neither an ASCII, Hex, Oct, nor html code table seem to correspond
    >with what the author is using. Is he adding a binary number (morse
    >routine) to some other number? I basically want to customize the
    >characters.
    >
    >Any and all help is appreciated!
    >
    >Thanks
    >
    >Frank Matthews
    >
    >
    >
    >'{$STAMP BS2}
    >'KC8QNO Beacon Software for the Basic Stamp 2
    >'Pin 1 controls the morse key on the rig
    >'Pin 2 controls the LED on the Stamp
    >
    >
    >INDEX1 VAR Byte
    >INDEX2 VAR Byte
    >ELEMENTS VAR Byte
    >CHARACTER VAR Byte
    >DELAY CON 1500
    >I VAR Byte
    >C VAR Byte
    >
    >IDENTIFY:
    > LOW 2
    > FOR I = 1 TO 8 'Loop for one "dit" every 2 sec
    > CHARACTER = 1 'until ID string (8 times)
    > GOSUB MORSE
    > PAUSE 2000
    > NEXT
    > PAUSE 1000 'Time Between Words
    > FOR INDEX1 = 0 TO 2
    > LOOKUP INDEX1,[noparse][[/noparse]20,20,20],CHARACTER 'VVV
    > GOSUB MORSE
    > PAUSE 1000
    > NEXT
    > FOR INDEX1 = 0 TO 5
    > LOOKUP INDEX1,[noparse][[/noparse]132,1,66,164,227,130],CHARACTER 'BEACON
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]131,1],CHARACTER 'DE
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 5
    > LOOKUP INDEX1,[noparse][[/noparse]163,164,229,212,130,227],CHARACTER 'KC8QNO
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 6
    > LOOKUP INDEX1,[noparse][[/noparse]129,35,3,164,227,68,66],CHARACTER 'TUSCOLA
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]164,227],CHARACTER 'CO
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]194,2],CHARACTER 'MI
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]3,163],CHARACTER 'SK
    > GOSUB MORSE
    > NEXT
    > RETURN
    >MORSE: ELEMENTS = CHARACTER & %00000111
    > IF ELEMENTS = 7 THEN ADJUST1
    > IF ELEMENTS = 6 THEN ADJUST2
    >BANG_KEY:
    > FOR INDEX2 = 1 TO ELEMENTS
    > IF CHARACTER >= 128 THEN DAH
    > GOTO DIT
    >REENTER:
    > CHARACTER = CHARACTER * 2
    > NEXT
    > GOSUB CHAR_SP
    > RETURN
    >ADJUST1:
    > ELEMENTS = 6
    > GOTO BANG_KEY
    >ADJUST2:
    > CHARACTER = CHARACTER & %11111011
    > GOTO BANG_KEY
    >DIT: HIGH 2
    > LOW 1
    > PAUSE 175
    > LOW 2
    > HIGH 1
    > PAUSE 125 'Letter Speed (DIT and DAH must match here or
    >the code
    > GOTO REENTER 'sounds funny
    >DAH: HIGH 2
    > LOW 1
    > PAUSE 375
    > LOW 2
    > HIGH 1
    > PAUSE 125 'Letter Speed (DIT and DAH must match here or
    >the code
    > GOTO REENTER 'sounds funny
    >CHAR_SP:
    > LOW 2
    > HIGH 1
    > PAUSE 500 'Time Between Letters (Characters)
    > RETURN
    >WORD_SP:
    > LOW 2
    > HIGH 1
    > PAUSE 1200
    > RETURN
  • ArchiverArchiver Posts: 46,084
    edited 2003-09-06 18:16
    Frank,

    The CHARACTER variable in the program encodes the international morse
    code alphabet and the number of elements (dots or dashes) in each
    character.

    The three least significant bits represent the number of elements -
    the total number of dots and dashes in the morse code charcter.

    The most significant bit is not used. The remaining five bits
    represent the sequence of dots and dashes with a '1' being a dash and
    a '0' a dot.

    For example, the four bits for character 'C' are 1010 or dash-dot-
    dash-dot.

    Hope this helps,
    Marylou
    _______________________________


    --- In basicstamps@yahoogroups.com, "Frank Matthews" <fmnnc@c...>
    wrote:
    > I'm new to stamps and ran across the following program that I would
    > like to modify for my own needs. I'm having some difficulty
    figuring
    > out the scheme being used to identify (index1) the characters.
    > Neither an ASCII, Hex, Oct, nor html code table seem to correspond
    > with what the author is using. Is he adding a binary number (morse
    > routine) to some other number? I basically want to customize the
    > characters.
    >
    > Any and all help is appreciated!
    >
    > Thanks
    >
    > Frank Matthews
    >
    >
    >
    > '{$STAMP BS2}
    > 'KC8QNO Beacon Software for the Basic Stamp 2
    > 'Pin 1 controls the morse key on the rig
    > 'Pin 2 controls the LED on the Stamp
    >
    >
    > INDEX1 VAR Byte
    > INDEX2 VAR Byte
    > ELEMENTS VAR Byte
    > CHARACTER VAR Byte
    > DELAY CON 1500
    > I VAR Byte
    > C VAR Byte
    >
    > IDENTIFY:
    > LOW 2
    > FOR I = 1 TO 8 'Loop for one "dit" every 2
    sec
    > CHARACTER = 1 'until ID string (8 times)
    > GOSUB MORSE
    > PAUSE 2000
    > NEXT
    > PAUSE 1000 'Time Between Words
    > FOR INDEX1 = 0 TO 2
    > LOOKUP INDEX1,[noparse][[/noparse]20,20,20],CHARACTER 'VVV
    > GOSUB MORSE
    > PAUSE 1000
    > NEXT
    > FOR INDEX1 = 0 TO 5
    > LOOKUP INDEX1,[noparse][[/noparse]132,1,66,164,227,130],CHARACTER 'BEACON
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]131,1],CHARACTER 'DE
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 5
    > LOOKUP INDEX1,[noparse][[/noparse]163,164,229,212,130,227],CHARACTER 'KC8QNO
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 6
    > LOOKUP INDEX1,[noparse][[/noparse]129,35,3,164,227,68,66],CHARACTER 'TUSCOLA
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]164,227],CHARACTER 'CO
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]194,2],CHARACTER 'MI
    > GOSUB MORSE
    > NEXT
    > PAUSE 1000
    > FOR INDEX1 = 0 TO 1
    > LOOKUP INDEX1,[noparse][[/noparse]3,163],CHARACTER 'SK
    > GOSUB MORSE
    > NEXT
    > RETURN
    > MORSE: ELEMENTS = CHARACTER & %00000111
    > IF ELEMENTS = 7 THEN ADJUST1
    > IF ELEMENTS = 6 THEN ADJUST2
    > BANG_KEY:
    > FOR INDEX2 = 1 TO ELEMENTS
    > IF CHARACTER >= 128 THEN DAH
    > GOTO DIT
    > REENTER:
    > CHARACTER = CHARACTER * 2
    > NEXT
    > GOSUB CHAR_SP
    > RETURN
    > ADJUST1:
    > ELEMENTS = 6
    > GOTO BANG_KEY
    > ADJUST2:
    > CHARACTER = CHARACTER & %11111011
    > GOTO BANG_KEY
    > DIT: HIGH 2
    > LOW 1
    > PAUSE 175
    > LOW 2
    > HIGH 1
    > PAUSE 125 'Letter Speed (DIT and DAH must match here or
    > the code
    > GOTO REENTER 'sounds funny
    > DAH: HIGH 2
    > LOW 1
    > PAUSE 375
    > LOW 2
    > HIGH 1
    > PAUSE 125 'Letter Speed (DIT and DAH must match here or
    > the code
    > GOTO REENTER 'sounds funny
    > CHAR_SP:
    > LOW 2
    > HIGH 1
    > PAUSE 500 'Time Between Letters (Characters)
    > RETURN
    > WORD_SP:
    > LOW 2
    > HIGH 1
    > PAUSE 1200
    > RETURN
Sign In or Register to comment.