Wednesday, August 29, 2012

MSP430 Morse Code

 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, 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.
 #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;}

    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

Thursday, August 23, 2012

Modding old radios

I'm kind of curious if there's any activity around modifying older radios. I have a couple of HTX-202's that I'm eyeing for some work one day. My favorite one is actually the first Ham Radio I ever owned, it was new in box from Radio Shack circa 1993/1994. Probably 1994, but I'm not sure how long I had it before I officially had my ticket. The other one is a Hamvention special some guy in the flea market was apparently desperate to get rid of.

My original is exhibiting the ER-1 code, for a dead/dying memory backup battery. The Hamvention one has some weird squelch problem where it won't always open squelch when it receives a signal. It also had ER-2 when I first turned it on, but that was easily cleared. It also is in seriously bad need of being disassembled so I can spit and polish the case some. This Hamvention 202 was really beat up in it's former life.

According to the service manual, these radios are split up into two main PCBs, an RF board and a CPU board. I wonder if I can figure out how to control the RF board with a homebrew CPU board. Then flash, or some other non-volatile memory could be used to store the programming. Other features could be added as well. DCS maybe?

I remember finding a page about EF Johnson radios for 900mhz where someone made an external control system for one that made it frequency agile. Of course, now that I want to link to it, it's nowhere to be found.

Here are a couple of relevant links but talking about FRS radios:

Thursday, August 2, 2012

TP-Link TL-WR703N

I know this isn't strictly Ham Radio but it could be useful for HSMM.

These units are around $24 on ebay, shipped from China.

Found this on Hackaday not too long ago. Basically this device is meant to be a little 3g travel router. You can plug in a 3g USB adapter and share that Internet connection to multiple devices over wifi. It also supports ethernet. Of course, the unit I bought had a Chinese GUI so that might have been a bit hard.

Fortunately, OpenWRT has been ported to this. Here are the instructions to install it:

You are looking for squashfs-factory.bin. I wish I could remember where I read how to flash this with the Chinese GUI. Here's where you need to go. Login to the GUI at with admin/admin as username and password. Then on the left-hand side, scroll to the bottom and pick the last link. Then when the sub-menu appears, pick the 3rd link down. There's a long textbox area with a button next to it, if you click that button then you can pick the image you want to flash it with. Then click the other button on the screen to start the flash. It will take several minutes. Once it is done you won't get a webpage back. Plug into the unit with an ethernet cable and then telnet to the default IP address of and set a password for root. Once you do that it automatically disables telnet and enables ssh. You can still use telnet until you log out though.

Here are some links that I'm reading about this so far:

You can install a web interface again, I haven't made mine work since I got it installed yet. I will be making another blog post on this. It defaults to Access Point mode when it first comes back up. I set mine up to run in client mode connected to my existing Wifi in order to give it access to the Internet so I could download packages on it.

There are people tapping into the GPIO (general purpose input/output) lines built into this device. So for $24 you can get a 400mhz linux computer, with Ethernet, Wifi and USB ports and several GPIO that is about the size of a new package of Post-It notes. It also uses only about 100ma as well. Beyond HSMM, this could also be handy for use in remotely controlling radios, maybe with a usb sound card you could even do something like echolink on it.

I hope to read about what others are doing with it. My focus is more on using it to setup home automation sort of things. I'm waiting on some solid-state relays and I plan on using one to control the lights in my garage, as well as giving me a real-time readout of the garage door's status.