Searching \ for '[PIC] Morse speed' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Morse speed'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Morse speed'
2007\03\17@112754 by Dennis Crawley

picon face
part 1 3928 bytes content-type:text/plain; (decoded 7bit)

On Friday, March 16, 2007 8:23 PM [GMT-3=CET],
William Chops Westfield  wrote:

{Quote hidden}

Bill,

This is my C approach.

//*************************************************
unsigned char MorseChar;
unsigned char i,a,dot,dash;

MorseChar= 0xED;                   // code + stop bit
dot=dash=a=0;                      //testing purpose
                                  //
for(i=0x80;i > 0x00;i >>= 1)       //rotate a 1 used as mask
  {                               //
    a |= i;                       //preparing a mask
    if(MorseChar ^ (MorseChar&a)) //xoring only lsb bits.
      {                           //
       if((MorseChar & i)> 0)     // is a one?
         {                        //
          dot++;                  //send a dot
         }                        //
       else                       //
         {                        //
          dash++;                 //send a dash
         }                        //
      }                           //
    else                          //
      {                           //
        break;                    //end of char!
      }                           //
                                  //
   }                              //
//*************************************************

lookup table (see attached file)
The dots are represented by 1's and the dashes by 0's.
A stop bit was used as Wouter pointed earlier.
The table is ordered by ASCII value minus 34, since 34 is the very first
character value.
So the Table is only 62 bytes long!. I arbitrary used
[ 11111111 91  0xFF
\ 10110100 92  0xB4
to represent Error symbol (it supoused to have no errors)and the "new"
symbol @. The older @ is a combination of AC.
Only 7 bytes of the table are unused.
The C can`t handle the error sign. So that is a particular case.:)

Regards,
Dennis Crawley.






part 2 1299 bytes content-type:text/plain;
(decoded 7bit)

" 10110110 34  0xB6
# 00000000 35  0x00
$ 11101101 36  0xED
% 00000000 37  0x00
& 00000000 38  0x00
' 10000110 39  0x86
( 01001100 40  0x4C
) 01001010 41  0x4A
* 00000000 42  0x00
+ 10101100 43  0xAC
, 00110010 44  0x32
- 01111010 45  0x7A
. 10101010 46  0xAA
/ 01101100 47  0x6C
0 00000100 48  0x40
1 10000100 49  0x84
2 11000100 50  0xC4
3 11100100 51  0xE4
4 11110100 52  0xF4
5 11111100 53  0xFC
6 01111100 54  0x7C
7 00111100 55  0x3C
8 00011100 56  0x1C
9 00001100 57  0xC0
: 00011110 58  0x1E
; 01010110 59  0x56
< 00000000 60  0x00
= 01110100 61  0x74
> 00000000 62  0x00
? 11001110 63  0xCE
@ 10010110 64  0x96
A 10100000 65  0xA0
B 01111000 66  0x78
C 01011000 67  0x58
D 01110000 68  0x70
E 11000000 69  0xC0
F 11011000 70  0xD8
G 00110000 71  0x30
H 11111000 72  0xF8
I 11100000 73  0xE0
J 10001000 74  0x88
K 01010000 75  0x50
L 10111000 76  0xB8
M 00100000 77  0x20
N 01100000 78  0x60
O 00010000 79  0x10
P 10011000 80  0x98
Q 00101000 81  0x28
R 10110000 82  0xB0
S 11110000 83  0xF0
T 01000000 84  0x40
U 11010000 85  0xD0
V 11101000 86  0xE8
W 10010000 87  0x90
X 01101000 88  0x68
Y 01001000 89  0x48
Z 00111000 90  0x38
[ 11111111 91  0xFF
\ 10110100 92  0xB4
] 00000000 93  0x00
^ 00000000 94  0x00
_ 11001010 95  0xCA

part 3 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2007\03\17@131701 by Orin Eman

picon face
My C version using the previously discussed stop bit scheme:

void
SendMorseChar(char c)
{
#ifdef DEBUG
ASSERT(c);  // For the truly paranoid
#endif

do
{
   char len = 1;
   if ( c & 0x80 )
   {
       len = 3;
   }

  // (Start a bit)

   while ( len-- )
   {
       Delay(DITLEN);
   }

   // (Stop a bit)

   c = c << 1; // Careful about integer promotion here,
                    // c <<= 1 may work better depending on the compiler.
} while ( c != 0x80 );
}

Orin.

2007\03\17@192547 by Timothy J. Weber

face picon face
One minor nit:

Orin Eman wrote:
> My C version using the previously discussed stop bit scheme:
>
> void
> SendMorseChar(char c)
> {
> #ifdef DEBUG
> ASSERT(c);  // For the truly paranoid
> #endif

Usually this is redundant, because ASSERT is defined something like this:

#ifdef DEBUG
#define ASSERT(b)  if (!b) { complain(); }
#else
#define ASSERT(b)
#endif

So you don't need the extra #ifdef around the ASSERT call.

On the other hand, some systems use the presence of NDEBUG to turn off
ASSERT, instead of the absence of DEBUG.  One or the other convention
helps avoid clutter.
--
Timothy J. Weber
http://timothyweber.org

2007\03\17@231211 by Orin Eman

picon face
On 3/17/07, Timothy J. Weber <spam_OUTtwTakeThisOuTspamtimothyweber.org> wrote:
{Quote hidden}

You're right,

What I really should have done was make it fail safe and put
if ( !c )
  return;
there instead and avoided the infinite loop if 0 was passed in.

Orin.

2007\03\18@022714 by Orin Eman

picon face
Fixes:

Added the inter-bit delay.
Prevented infinite loop if called with 0.
Optimized inner loop.

On 3/17/07, Orin Eman <.....orin.emanKILLspamspam@spam@gmail.com> wrote:
> My C version using the previously discussed stop bit scheme:
>
void
SendMorseChar(char c)
{
if ( !c )  // For the truly paranoid
   return;

do {
  char len = 1;
  if ( c & 0x80 )
  {
      len = 3;
  }

  // (Start a bit)

   do {
       Delay(DITLEN);
    } while ( --len );

   // (Stop a bit)

    Delay(DITLEN); // Interbit delay

  c = c << 1; // Careful about integer promotion here,
                   // c <<= 1 may work better depending on the compiler.
} while ( c != 0x80 );
}

2007\03\19@214246 by Dennis Crawley

picon face
part 1 233 bytes content-type:text/plain; (decoded 7bit)

Hi all.
I've finished with this working over my desk.
The pic code better than me!
Well thank you for the inputs, here is a whole applet on a 12F675.
I hope someone enjoy this.

regards,
Dennis.



part 2 9584 bytes content-type:application/octet-stream; (decode)

part 3 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...