This little project just took on a life of its own this afternoon. What started out as an experiment in writing a single program to read output data from my radio via the RS232 serial interface has turned into a full blown radio remote control program.
The current state of the program will let me control my rig from a remote PC across the local network at my QTH.
There are 4 separate programs involved in this. Much of the code from my previous blog post comprises the heart of the system.
Here is how it all works. On the PC that is connected to the radio (we will call this the PC-Radio system) resides two programs – K2client.py and K2server.py. On the remote PC across the network (we will call this the PC-operator system) resides two other programs – client.py and server.py. On the PC-Radio system, the programs each have to communicate with both the network and the radio. The K2client.py program takes any output data from the radio and sends it out to the network to be received as feedback from the radio by the server.py program on the PC-operator system. The K2server.py program receives any data sent to it from across the network by the client.py program on the PC-operator system and passes these as commands to the radio. The radio takes the command, gives feedback, and cycle begins again. As a diagram, it looks like this.
server.py[PC-operator system]client.py —————->K2server.py [PC-Radio system]K2client.py —>
^ (operator) (network) (radio) |
It was not as that this was all entirely necessary. I could have downloaded software already designed to do this, and have used such in the past with my computers and radio. However, for me, it is the difference between buying a radio and building a radio. You can accomplish the very same thing in the end, e.g. communication. Both ways are OK. However, there are added benefits from building equipment such as the opportunity to learn, pride in the work one has done, the sense of accomplishment, etc. The same is true for this type of homebrewing, the only difference is that it is homebrewed software rather than hardware. The Python source code for the project is available. This code is very minimalist and intended only to demonstrate the principles involved. Please feel free to use, adapt, or modify it in any way you may wish.
NOTE: The code from my previous blog post contains comments that explain how to take this Linux implementation of RS232 communications and adapt it for use on a Windows system. Also note that there are hard coded IP addresses in the code that would need to be changed for implementation elsewhere. Aside from those differences, this code should be fully cross-platform and usable anywhere as it pertains to the parts dealing with the serial and network communications. The control codes and settings I am sending to my radio may not be applicable to your own, so please see the users or programming manual for your rig for appropriate codes, settings and methods for communicating and controlling it. Additionally, the code found in this project that implements the network socket clients and servers are adaptations of code found at evolt.org.
#k2test1.py 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:
#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 = ser.read(150)
#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
K2_data = ser.read(150)
if K2_data != “”:
print(“Reseting K2 AutoInfo mode OFF”)
print(“Closing Serial Port”)
Fldigi (Fast Light Digital Modem Application) is a cross-platform modem program that supports most of the digital modes used on the amateur radio bands.
Fldigi is a digital modem program for Linux, Free-BSD, OS X, Windows XP, W2K, and Vista (probably Win7).
Bill – WA5PB
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
Today was the annual Science Day at TSU (Tarleton State University – Stephenville, TX). The amateur radio club, Tarleton Area ARC, takes the opportunity to set up our emergency power solar array and operate a ham radio station outside as a demonstration of both solar energy and radio technology. This same day is the day that new students and parents tour the campus, so we have lots of foot traffic passing by us. It is a good opportunity to educate the public about the solar energy and stir up some interest in amateur radio. We had quite a few people stop by to visit and it was a very successful event I felt. We operated from my Elecraft K2 QRP radio to a half-wave dipole for the 20 meter band. Very good contacts were made to Indiana and Iowa via SSB and PSK31. The only difficulty for the day was with a laptop running Ubuntu 10.10, which I have blogged about here. Many thanks to Larry Barr, K5WLF, for providing the solar energy setup and being my operating partner on the air.
A new echolink repeater for Erath County, TX is on its way! The K5TSU/R.
After many years of faithful service of the KD5HNM repeater, the trustee Justin McClure has had to shut it down due to network infrastructure changes at his location. Many thanks to Justin, KD5HNM, for having made this available to us in Erath County, TX. Yesterday, some of us began discussing the possibility setting up a new Echolink repeater for our Ecom/WX use. It was amazing that within an hour we had what appears to be a very solid plan for bringing it online. A radio, computer an location have all been identified. Also, a call sign, K5TSU. This is the call sign of our local university ham club at Tarleton State University.
K5WLF has written up a great tech-note on how to calculate battery run-time. Very handy in any situation where running on battery power is critical. A great overall blog post, the tech-note is found about half way down. Check it out!
K5WLF post with tech-note: http://www.rebelwolf.com/blog/?p=195
An update to K5WLF’s previous blog entry with information concerning the C/20 discharge rate of batteries, please see it for important additional information: http://www.rebelwolf.com/blog/?p=203
Bill – WA5PB
My buddy K5WLF has had big success on 160 with a Short Coil-Loaded Dipole. This is great news for those without much room for a big 160m antenna.
K5WLF discusses some useful WX watching resources.
After reading this blog post, I tried installing the GR Level 3 weather radar program K5WLF mentions on an Ubuntu system via Wine (the Windows emulator). It works!
Bill – WA5PB
Here on SDF.org there are nearly 2000 clearly identified and active Amateur Radio operators. That is a great base of users from which to draw an active membership of the newly forming SDFARC – the SDF.org Amateur Radio Club. There has been a fair amount of interest shown so far, even with the relatively limited word that has been put out about it. It is hoped that this organisation will be able to be an international Amateur Radio Club that will serve the interests of Amateur Radio Operators who are members of SDF.org. We are planning on having nets, starting out by using echolink (see the growing list of echolink repeaters we are using: http://sdf.org/?tutorials/sdfarc_repeaters), but hope to expand our communications to also include HF, CW, and other modes. If you are a Ham and already an SDF.org member, please consider joining us. Find our discussions about SDFARC on the SDF.org shell bboard Amateur sig, or on the SDFARC webforum. If you are just a visitor to my blog but are interested. Please visit the WA5PB Ham Website to find out more about becoming a licensed Amateur Radio Operator. Also, please visit SDR.org to learn how to join the best online community on the Internet.
Bill – WA5PB
The WA5PB Amateur Radio & Unix Webpages
Amateur Radio Log Entry for WA5PB
Contact: Stephen Jones (aka smj) Call Sign: W0TTY
Mode: UHF/VFH via Echolink Sigs: 55
Date/Time: Dec. 29, 2009 0730 UTC
Notes: Great first contact with Stephen! We were working on the logistics for setting up a regular net for the SDFARC. Both of us were using actual radio equipment at our own QTH through local Echolink enabled repeater systems. We discussed issues with the connection, logistics, etc.
F2FO, amateur since 1959, shows the different stages of the construction of a triode lamp carried by him. This lamp has established links with other amateurs located on 4 continents.
If you want more information, visit his personal website: http://paillard.claude.free.fr
K5WLF highlights a very useful, free software package that aids the in the production of professional quality front panels for various Ham Radio construction projects.
from the K5WLF Blog
The following is by fellow ham, Jeff Davis – N9AVG. I have enjoyed it for years since I first read it sometime in 2000. I read it occasionally to remind me about the preciousness of the limited time we have. I hope you enjoy it too. By the way, Jeff Davis has also written a book by the same name.
1,000 Marbles book
Jeff also has an awesome blog!
A Thousand Marbles
by Jeff Davis – N9AVG (KE9V)
The older I get, the more I enjoy Saturday mornings. Perhaps it’s the quiet solitude that comes with being the first to rise, or maybe it’s the unbounded joy of not having to be at work. Either way, the first few hours of a Saturday morning are most enjoyable.
A few weeks ago, I was shuffling toward the basement shack with a steaming cup of coffee in one hand and the morning paper in the other. What began as a typical Saturday morning, turned into one of those lessons that life seems to hand you from time to time. Let me tell you about it.
Walking into the shack, I flipped the switch on the Astron power supply. That fired up the dual-band mobile that is usually set on the local repeater frequency and it also brought my HF rig to life. In a few seconds, I was tuned to 7.040mhz, the QRP calling frequency. Early morning on 40 meters can be interesting and like fishing, you just never know what you might snag.
I turned the gain control up until the volume was comfortable, then I leaned back and scanned the local paper. Another shooting, another bombing, some terrorist group threatening retaliation, and the government debating a tax increase. Well, at least it’s reassuring to see that the world hasn’t changed since the evening news report the night before.
In the background, I heard a station calling “CQ FISTS”. Before I have time to call him a VE3 with a booming signal calls him and so begins another QSO on 40 meters. Before long, that QSO has ended and another was underway.
After a quick coffee refill, I went back to the shack, put the headphones on, and begin tuning around. There was a strong signal on 7.035mhz calling CQ. I returned his call and made contact with a fellow in Kennebunk, Maine. We exchanged signal reports and proceeded to tell each other about our rigs, antennas, and the weather. A few minutes more and my new friend told me he must QRT because he is meeting several of the local hams for breakfast. We signed off, with “73” to each other.
Then I turned the dial up into the phone portion of the band in order to listen to a Saturday morning swap net. Along the way, I came across an older sounding chap, with a tremendous signal and a golden voice. You know the kind, he sounded like he should be in the broadcasting business. He was telling whoever he was talking with something about “a thousand marbles”. I was intrigued and stopped to listen to what he had to say.
“Well Tom, it sure sounds like you’re busy with your job. I’m sure they pay you well but it’s a shame you have to be away from home and your family so much. Hard to believe a young fellow should have to work sixty or seventy hours a week to make ends meet. Too bad you missed your daughter’s dance recital.”
He continued, “let me tell you something Tom, something that has helped me keep a good perspective on my own priorities.”
And that’s when he began to explain his theory of a “thousand marbles.”
“You see, I sat down one day and did a little arithmetic. The average person lives about seventy-five years. I know, some live more and some live less, but on average, folks live about seventy-five years.”
“Now then, I multiplied 75 times 52 and I came up with 3900 which is the number of Saturdays that the average person has in their entire lifetime. Now stick with me Tom, I’m getting to the important part.”
By this point, I was completely hooked on this QSO. Forget the swap net, I wasn’t moving from this frequency until I heard what the old man had to say.
“It took me until I was fifty-five years old to think about all this in any detail”, he went on, “and by that time I had lived through over twenty-eight hundred Saturdays. I got to thinking that if I lived to be seventy-five, I only had about a thousand of them left to enjoy.”
“So I went to a toy store and bought every single marble they had. I ended up having to visit three toy stores to round-up 1000 marbles. I took them home and put them inside of a large, clear plastic container right here in the shack next to my gear. Every Saturday since then, I have taken one marble out and thrown it away.”
“I found that by watching the marbles diminish, I focused more on the really important things in life. There is nothing like watching your time here on this earth run out to help get your priorities straight.”
“Now let me tell you one last thing before I sign-off with you and take my lovely wife out for breakfast. This morning, I took the very last marble out of the container. I figure if I make it until next Saturday then I have been given a little extra time. And the one thing we can all use is a little more time.”
“It was nice to meet you Tom, I hope you spend more time with your family, and I hope to meet you again here on the band. 73 Old Man, this is K9NZQ, clear and going QRT, good morning!”
You could have heard a pin drop on the band when this fellow signed off. I guess he gave us all a lot to think about. I had planned to work on the antenna that morning, and then I was going to meet up with a few hams to work on the next club newsletter.
Instead, I went upstairs and woke my wife up with a kiss. “C’mon honey, I’m taking you and the kids to breakfast.”
“What brought this on?” she asked with a smile. “Oh, nothing special, it’s just been a long time since we spent a Saturday together with the kids. Hey, can we stop at a toy store while we’re out? I need to buy some marbles.”
K5WLF relates an account of how the lost art of Morse Code saved the day, and many lives, when modern signalling equipment failed.
The Future of the Past
It is with great pride that I announce that the Tarleton Amateur Radio Club (TAARC) is slated to receive a funding grant of $2000 from Texas Lions via the Stephenville Lions Club. Our past president at Lions Club, Cindy Watson, worked long and hard on getting this for us in response to the initiative Lions International has started for Lions Clubs to become more involved in emergency and disaster situations in the communities they serve. When news of this initiative reached the Stephenville Lions Club, of which I am also an officer, I made them aware of the needs of TAARC for a set of solar panels, batteries and charge controller for our EmComm trailer so we can better server Erath County with our EmComm Amateur Radio abilities when grid electric power is unavailable. At long last, the grant has been approved thanks to Cindy Watson’s efforts on our behalf. Many thanks to Cindy and the Stephenville Lions Club for their support of Emergency Communications and Amateur Radio in our community. I feel that a wonderful partnership has been established between two great organisations that seek to better server their local community.
Bill Allen – WA5PB
An insightful article by Larry Barr, K5WLF, on maintaining good public relations as we practice our craft as Amateur Radio Operators.
The Public Face of Amateur Radio
K5WLF just started up his own blog. Check it out.
The following was recently written by a friend of mine, Larry Barr – K5WLF, during an email discussion on the recent trend of Emergency Communications blurring the line between Amateur Radio and Commercial Radio. His comments were so insightful that I thought to share them here.
While I guess we ought to be glad that the “instant hams” at least want to join in the drills and training nets, I’m seeing what I perceive to be an underlying, and very real, danger in the current trend. It’s beginning to look like some of the hospitals et. al., are turning to amateur radio equipment to serve as their primary solution in the event of a failure in their normal communications system. Which, in my understanding, is generally internet based.
I believe that they should, instead, be creating properly engineered and well-installed commercial radio systems to serve in that capacity. For that is the proper service in which they should operate. If, in the event of emergency or disaster, their commercial system fails, then they can call on us to provide their emergency comms for them. And we will gladly help them.
I’m always happy to see new hams come into our hobby, but I don’t hold with the “teach for the test” approach to licensing courses. I personally will not teach a course that does not include operating rules and procedures, because I refuse to create a licensee that has no knowledge of proper operating skills.
The daily interchange of QSOs on the ham bands do more to form a skilled and practiced operator than one or two SETs a year could ever do. If we fail to instill in those whom we train a love for all aspects of our avocation, we deprive not only them, but ourselves as well of the joys of our hobby.
There is much discussion going on about the need to preserve our spectrum allotments and to maintain the vitality of our beloved hobby. Let us not drop the ball by allowing amateur radio to become a de facto backup service for institutions which are properly required to operate on other bands and under the jurisdiction of another radio service.
If the excrement truly impacts the turbine, let there never be a question that ARES, RACES and the entire amateur radio community will be there to give our full assistance, as we always have. But, in the meantime, we must work to ensure that the purity of our operations is preserved and that our service is not usurped by commercial entities looking for a cheap and easy solution to their communication problems.
The fine men and women of the amateur radio service have a proud tradition of giving their all when their help is needed. And we will forever be there for those who require our help, our equipment and our operating skills. But we must not tolerate the misuse of our service under the guise of emergency communications for commercial organizations. I don’t agree with the FCC all that often, but in this case, I believe that they were correct in their ruling.
There is one other question that I’ve never heard addressed. If I correctly understand the patient privacy requirements, there are certain precautions that must be adhered to ensuring that patient information is not divulged to persons not directly involved in that case. Transmission of patient info over internet or commercial radio service can be encrypted, preserving its privacy. Since encryption is prohibited on the amateur bands, how can a hospital transmit patient info on the amateur service without committing an infraction of the privacy requirement? It may be that the amateur service won’t legally provide all the capability that they’re looking for anyway.
I encourage all amateurs to continually strive to ensure that our bands and our service are used properly and in compliance with FCC regulations. For we are always in danger of losing our allocations, since we are the only service that doesn’t return a revenue to the government. We continue to exist primarily because of our ongoing response to emergencies; local, regional and national. If we permit our allocations to be misused, we will be in danger of losing them forever.
Larry D. Barr, K5WLF
PIO, ARRL NTX District 3
SKYWARN Spotter/Net Control
Erath County (TX) ARES AEC
Erath County (TX) RACES CLO (Alt)
Erath County (TX) Emergency Management