RSS Feed


Comments RSS

Serial Communications using Python  by Bill Allen – WA5PB
#This is an experiment in communicating with an Amateur Radio transceiver
#via Python through RS232 serial communications.  Similar code could be used
#to communicate with any device supporting serial communications.

#This was written using Python 2.6.5, but I like using the new
#Python 3.x print function so we pull it in for use here.
from __future__ import print_function

#We will be using the PySerial library to provide RS232 serial communications.
#PySerial is a third party library module that can be found here:
import serial

#Configure the serial port to communicate with the Elecraft K2 xcvr.
#I am coding this on a Linux system, so the device string /dev/ttyS0
#works for the first serial port.  Your system my use a different serial
#port device.  For a Windows system, try COM1 for the first serial port.
ser = serial.Serial(‘/dev/ttyS0’, 4800, timeout=1)

#Sanity check for the K2 AutoInfo mode, turn it off.

#Now set the K2 AutoInfo mode to mode 1 and get some initial data.

#Read up to 150 bytes of returned data from the K2 and print it out.
K2_data =

#Now set the K2 AutoInfo mode to return the most data while it is being polled.
#Ctrl-C will be used to end the program.  End the program gracefully by trapping
#the Ctrl-C, turning off the K2 AutoInfo mode and closing the serial port prior
#to exiting.
while True:
        K2_data =
        if K2_data != “”:
    except KeyboardInterrupt:
        print(“\nOK, exiting…”)
        print(“Reseting K2 AutoInfo mode OFF”)
        print(“Closing Serial Port”)
        raise SystemExit(0)

electronics experimentation

There are lots of ways to experiment with electronics.  One way is to use a programmable testbed system.  There are several available at various costs.  One that I am looking at that seems interesting is the Arduino UNO, which sells for about $30.   I was shown this one at work by our electronics engineer.   I may get one for myself to play with.  It looks like a very inexpensive way to experiment with programmable electronics.  Such system can be used for data output and display, data collection, motor control, ham radio applications, and much more.

The main website.

A hands on turtorial.

Another programmable testbed system that is quite popular is the Parallax Basic Stamp.

The Arduino UNO

computer sound cards, so many uses!

The PC sound card may just be one of the most useful electronic devices that nearly everyone owns.   Not only can you listen to music with it, but you can do nearly any Ham Radio digital mode.   However, did you know you can also use your PC+sound card combination as a spectrum analyzer or even as an Oscilloscope?   Here are links to software that will allow you do this.  Both are easy to install and free.

Spectrogram 5.17 – for Windows.   I did all the xtal alignment work on my Elecraft K2 radio with this program.

Baudline – for Linux, Mac OS X, and Solaris SPARC systems.   This one has LOTS of features.  Simple to install!  Download, unzip, and run the “baudline” program from the unziped folder.

Bill – WA5PB