codebytes.txt - description of the format of the Morse code storage format
used in the codppm... minifox controllers.

G. D. (Joe) Young  Jan 10, 2015

To conserve memory space, wherever the controllers need to store a character
which will be sent as Morse code, it is saved in a "codebyte" of 8 bits. The 
codebyte will have the format described below. Each codebyte corresponds to one
Morse character, the bits of the codebyte correspond to dots (stored as 0)
and dashes (stored as 1). Since the length of a Morse character varies, a 
mechanism to determine the length of each character is required. The mechanism
used here is to add a single bit to each codebyte which serves as a 'fence' bit
to delimit the dots and dashes of the character to be sent.

Thus, for example, the codebyte for the letter V ( di, di, di, dah) is:

   MSB                  LSB
    0  0  0  1  0  0  0  1
    |  |  |  |  |  |  |  |
    |  |  |  |  |  |  |  +-- dash
    |  |  |  |  |  |  +----- dot
    |  |  |  |  |  +-------- dot
    |  |  |  |  +----------- dot
    |  |  |  +-------------- fence bit--indicates start of code to send
    +--+--+----------------- leading bits before fence must be zero.

The format in general therefore is that there will be leading zeros, followed
by a 1 fence bit, followed by the dots and dashes of the character encoded as
zero for dots and one for dashes. The controller program reads the byte from 
right (msb) to left (lsb), locates the fence bit and discards it, then sends
dots and dashes as found for the rest of the codebyte. Additionally, a space
character is represented by a byte of all zero.

As a further more comprehensive example, condider the sequence of bytes which
corresponds to a controller sending "moe de VE7BFK/7". It is stored as the
following sequence of bytes (in binary):

  00000111 - M
  00001111 - O
  00000010 - E
  00000000 - space
  00001100 - D
  00000010 - E
  00000000 - space
  00010001 - V
  00000010 - E
  00111000 - 7
  00011000 - B
  00010010 - F
  00001101 - K
  00110010 - /
  00111000 - 7

The hexadecimal sequence would be 07 0F 02 00 0C 02 00 11 02 38 18 12 0D 32 38

For the controller software version codppmx8 (and following versions) this
sequence of bytes is stored in the microcontroller's eeprom. Consequently, to 
change the controller from one sending MOE, to one sending MOI the only byte
that needs to change is the third one--from 00000010 to 00000100 or from hex
0x02 to 0x04. Similarly, all of the fox IDs can be set by just altering the
third byte in the microcontroller eeprom, location 0x02.

This codebyte setting is most easily accomplished using the programmer software
avrdude in 'interactive' mode:

 avrdude -c usbtiny -p attiny85 -t

Then, you can examine the current eeprom contents with the command:

 dump eeprom 0x00 0x20

Then, alter the location 0x02 by entering the command:

 write eeprom 0x02 0x04

The controller will now send fox ID MOI

To alter the callsign, you will need to work out the new callsign codebytes in
the format described above, and then enter the bytes using the interactive mode
as described. Alternatively, you can use a small utility program to generate
the codebytes and save them in a .hex file which can then be loaded using the
programmer's U command. One version of the utility is an arduino program 
text2code.ino







 






