N9XLC

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 29 August 2012

MSP430 Morse Code

Posted on 19:17 by Unknown


 Just a small project I worked on this past weekend 8/24-8/25. I have several of these cheap MSP430 Launchpad dev kits from TI. What a deal they are too, $4.30 each. I intended on configuring it to further my Kenwood TM241a project, but got sidetracked and made a program to send my callsign in Morse Code. I ended up using Energia, which is a port of the Arduino IDE but this one makes MSP430 programs. It seems most of the same commands are supported, but not all.

I really need to get setup to program in C or even try my hand at ASM. I tried ASM on the PIC microcontrollers a couple of years ago but gave up on it fairly quick. Maybe I'd do better now? I'm not sure the Wiring language would produce code fast enough to bit bang 1200 baud serial with a clock.

Code for my project is below. It would be fairly easy to modify this to make a beacon, or foxhunting cpu, or even an ID for a repeater or standalone rig. If you do something with it, I'd appreciate a link back to my radio blog, n9xlc.blogspot.com and maybe drop me a line to let me know. I'd probably write an entry about it and link to your site.

It's not technically hard to add other characters and I think it's fairly self-explanatory. I'm not 100% happy with using the IF statements to cycle through the letters. I'd be happier with an array and a For loop with an index number but this works. I tried to set up a constant type like an UIntTable to store the characters, but I only received error messages when I tried to use that. It may not be fully supported in Energia yet, or probably I didn't fully understand it.

I know I'm not the first person to do this by a long shot, but it was a fun challenge and it did help me familiarize myself somewhat in Energia, maybe next time I'll rewrite this in C? I see there are videos of others who have written Morse Code projects for the MSP430 on Youtube with a little more pizzazz than mine, such as audio out and a serial terminal for input.
/*
James Hall - N9XLC
Small program to push out my callsign via the red LED on a MSP430 board.
Developed 8/24/2012-8/25/2012

Started off modifying, then totally replacing the code in the 'Blink' example project.
This could probably be wrapped up in a function to send out arbitrary sentences.
Only enough morse code is implemented to get my callsign out, but it would be trivial to add the rest.
Could be used to blink out current temp or maybe short status info in morse code in other projects.

 http://www.arduino.cc/en/Tutorial/BitMask
 http://wiring.org.co/reference/bitwiseAND.html
 http://wiring.org.co/reference/bitwisebitshiftleft.html
 */
 #define output 2 // pin 2 has the red led on a msp430 board, pin 14 is the green led.
 
unsigned int mask = 1;
int dot = 1;
int dash = 3; //dash is equal to 3 dots
int lspace = 1; //spacing in same letter is 1 dot
int llspace = 3; //spacing between two letters in same word is 3 dots
int wspace = 7; //spacing between two words is 7 dots.

int didot = 2;
int didash = 3;
int spacems = 100; //100ms is a little slower than 20wpm (60ms) so maybe 13-15wpm?
// 10 dot, 11 dash, 00 end
// unsigned int is 16 bits
unsigned int cwN = 11; //0000 0000 0000 1011 <-read right-to-left
unsigned int cw9 = 767; //0000 0010 1111 1111
unsigned int cwX = 235; //0000 0000 1110 1011
unsigned int cwL = 174; //0000 0000 1010 1110
unsigned int cwC = 187; //0000 0000 1011 1011
byte testbyte;
  
void setup() {
  // initialize the digital pin as an output.
  // Pin 14 has an LED connected on most Arduino boards:
  pinMode(output, OUTPUT);
  pinMode(14, OUTPUT);
 // pinMode(5, INPUT);
}

void loop() {
  digitalWrite(14, LOW);
  digitalWrite(output, LOW);
  unsigned int cwout;
  unsigned int mask = 3;
  int callsign = 1;
  
while(callsign) {
 if (callsign == 1) {cwout = cwN;}
 if (callsign == 2) {cwout = cw9;}
 if (callsign == 3) {cwout = cwX;}
 if (callsign == 4) {cwout = cwL;}
 if (callsign == 5) {cwout = cwC; callsign = 0;}
 callsign++;

    while (cwout) {
     testbyte = cwout & mask;
       if (testbyte == 2 ) {
          digitalWrite(output, HIGH);
          delay(dot * spacems);
          digitalWrite(output, LOW);
         } 
           if (testbyte == 3 ) {
            digitalWrite(output, HIGH);
            delay(dash * spacems);
            digitalWrite(output, LOW);
           }
       delay(spacems * dot); //inner letter spacing
    
     cwout >>= 2; 
    }
 delay (spacems * dash); //outer letter spacing

}

delay (spacems * wspace); //word spacing
}

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Freescale MC13260 SoC Two-Way Radio IC
    Found this in a mailing-list post the other day. Very neat, it's a System-on-Chip that is almost everything you need to make a radio fro...
  • Packet Hailing Channel
    Hailing frequencies open captain! http://nwdigitalradio.com/products/ Kidding, good talk. Skip a few minutes in to avoid an intro. I was sk...
  • (no title)
    My pixie II kit I built the other day. It's not "Done", I have some work to do on it. I really need a small bit of coax to con...
  • (no title)
    There have been a couple of interesting developments recently that I'd like to highlight. The first one, I'm most excited about it, ...
  • PL-2303 Troubles cannot start device code 10
    Having to deal with this issue, again, lately gave me the idea for this post. Ever buy a radio programming cable, or a cheap USB-Serial adap...
  • IC-9100
    This is a new, very expensive, HF/VHF/SHF tranceiver that Icom is advertising and potentially going to release later this year. It can do HF...
  • Kenwood TR-9000 Service manual
    Found this up on scribd, hopefully it'll help me with my TR-9000 problems. TR9000Ser
  • TR-9000 frequency problem
    Ran into a weird issue the other day on my TR-9000 when turning it on after a long time of being powered down. My band limits were set to 14...
  • "High-Speed" data and digital voice
    It's a sham that faster digital modes haven't really caught on. I've read about 56k packet in the past. Most radios today suppor...
  • Kenwood TM-241a
    I'm working on reverse engineering the remote control interface on my TM-241a. When it was a new radio you could buy options to use it: ...

Categories

  • AMPS
  • AMSAT
  • arg
  • arm
  • cellphone
  • Chinese Radios
  • Codec2
  • D-Star
  • DTV
  • FT-1DR
  • game
  • hsmm
  • neat
  • oddball
  • openbts
  • repair
  • sbc
  • sdr
  • SoC
  • sstv
  • the future
  • TM-241a
  • usrp

Blog Archive

  • ►  2013 (15)
    • ►  May (7)
    • ►  April (2)
    • ►  March (2)
    • ►  February (2)
    • ►  January (2)
  • ▼  2012 (17)
    • ►  September (1)
    • ▼  August (3)
      • MSP430 Morse Code
      • Modding old radios
      • TP-Link TL-WR703N
    • ►  May (3)
    • ►  April (6)
    • ►  March (2)
    • ►  February (1)
    • ►  January (1)
  • ►  2011 (33)
    • ►  December (1)
    • ►  November (3)
    • ►  October (3)
    • ►  September (4)
    • ►  August (5)
    • ►  May (1)
    • ►  April (1)
    • ►  March (5)
    • ►  February (4)
    • ►  January (6)
  • ►  2010 (23)
    • ►  December (3)
    • ►  October (2)
    • ►  September (1)
    • ►  August (2)
    • ►  July (2)
    • ►  May (8)
    • ►  April (4)
    • ►  March (1)
Powered by Blogger.

About Me

Unknown
View my complete profile