The uRAT Has Landed!


The uRAT now works very nicely – exactly as I had envisioned it working:

The “secret sauce” included:

  • Elecraft sharing a KPOD utility that is part of their development and QA suite (thanks Paul, N6HZ and Eric, WA6HHQ!)
  • WiringPi – Gordon Henderson of Devon, UK, who created a C library that makes it as easy to work with RaspberryPi GPIO as it is to wire up gadgets and code on Arduino. The GPIO utility was critical too – since Gordon uses Arduino pin mapping – which could confuse easily. His utility (which I wrote about a few blog posts ago) saves you from becoming really confused
  • Haydn Huntley – in Hawaii, who had the BEST TB6600 and Stepper wiring diagram and test code – so that I knew that I had the electrical wiring and dip switches correct
  • I know both C and Python, and at the right level for this project. Its 100% C – but I used Python to ensure my wiring was right and since I was learning WiringPi – it was most expedient to use Python to hack through part of the project. My C skills are a bit better than I thought – must have been those 6 months at Travana – where I did code a pretty intense C# program. But I have never gotten into the hardware stuff before, so this is just too cool

So, why is this a big deal?

  1. My Mod Bob antenna project will now be complete
  2. Its worthy of a QST Article
  3. I learned RaspberryPi and Arduino – and people at work are extremely interested – and even in ham radio now
  4. Elecraft can potentially market the KPOD to the “Maker” market. I have suggested that they maybe discuss with “Lady Ada” at Adafruit – AC2SN. This is just too perfect for the ham and maker markets and crowd
  5. Anyone can take “venerable” old analog antenna tuners and breathe new life into them. Or even build your own and get it right out at the antenna feed, and out of the shack (freeing up space and being more efficient in the process)
  6. I didn’t sit around bored whining about how conditions are crummy
  7. I put it on my LinkedIn and resume because it jives with my career, and “Internet of Things” and “Robotics” are becoming all the rage. Think about it – robots work because of Stepper motors – and this is about as simple a robot you can build
  8. I am having more fun than I think ever in ham radio and electronics. My wife said I look like I transported back to when I was 11 and build my first Heathkit – and yeah, even younger – when my parents had bought me this:

Of course, I have some code cleanup, and I am trying to decide how to share this with the world. I’d personally much rather have Elecraft distribute the code from their site since this is a KPOD-centric project, and maybe see if someone else would want to maintain a Git Repository and Open Source it. I am too busy to do that kind of administration stuff – plus I did that kind of work as an Oracle DBA for 22 years, so that was enough. At Credit Karma I created the companies first Data Dictionary in the first quarter I was there – and as a Staff Software Engineer, handed all my code over to younger people in our team and am teaching 8 people how to code in Python. This quarter I am teaching and also managing the “socialization” of the Data Dictionary and bringing in other departments as an internal sort of “Open Source” project. So – one of these kinds of projects is enough. At home – I just want to play! But the parallels behind designing and creating the uRAT and the CK Data Dictionary is a very cool and fun thing. Life is good!

Adafruit has this groovy little LCD Shield, and yes, I’m already thinking how cool would it be to enumerate the “ticks” from the KPOD and display on an LCD built into my control box. Maybe Version 1.1 – I think just getting the RaspberryPi wired up in my control box, getting the steppers out at the tuner, cleaning up the code, seeing where this project goes as far as getting it out in the world, writing a QST Article possibly, etc.

The potential for this project to become a spring board for so many fun things is what this is all about, and dreaming up product ideas is just way too much fun.

This is even more fun than last years Low Band Receiving Antenna work – and that was a blast!



u.RAT – A Very Exciting Journey!

uRat Logo Copyright (c) 2017 – Rich Holoch 

Killer logo designed by Jeff, K1NSS. The logo will be copy righted, the project will be Open Source.

A very big breakthrough today – I have the KPOD and the Stepper code working. The KPOD is the “Head” written in C:

. . . . and the Stepper code is written in Python (the Tail).

This site has really great interactive pinouts:

And I owe the Python and TB6600 driver wiring bits to Haydn from Hawaii who has the only really useful posting on the web that clearly explains how to get the Raspberry Pi working with the TB6600:

It turns out that this might be the most important part about Haydn’s Blog Post:

HY-DIV268N-5A Connects to:
EN+ RPi GPIO #4 or GND
A+ stepper green wire
A- stepper gray wire
B+ stepper red wire
B- stepper yellow wire
DC- GND (black on PC power supply)
DC+ +12v (yellow on PC power supply)


As it turns out, his HY-DIV268N-5A driver uses the same chip as my driver, the Toshiba T6600. The other “biggie” in this puzzle was accidentally getting the dip switches right on the driver. What helped me is my new bench power supply – which lets you set and limit voltage and current. The dip switches also limit current – so its easy to have the motors just sit there – not moving, even though you are sure everything is wired up right and that your code looks right.

Quite a few “variables” even for what really is a very straight forward project. If I had to brag – it wouldn’t be the code or the electronics, but the simple idea to glue two awesome products together using a Raspberry Pi – for me, the “Conceptual Design” is the coolest because I do feel its quite “elegant”. In fact, if you want to just use a rotary encoder, a couple of switches and a home brewed antenna tuner – the whole shebang could be built using parts worth maybe $100 – $150 tops. If you have a junk box – its less. Using the KPOD and the BT1500A cost me $1000 instead of just buying a remote-able Palstar AT-AUTO, which is a darn nice rig, but I don’t think is the right circuit for the open wire / balanced fed Mod Bob. The BT1500A is still my favorite antenna tuner ever, and the KPOD – my favorite tuning knob ever.

Most of the parts that you can get in the Maker world are made in China, and they either come with zero documentation or if there are more than a simple diagram, “Chinglish” that you have to reverse engineer to (hopefully) understand. Some of the products have horrible QC – the two drivers I used when I had the stepper motors turning on the Arduino worked fine – but the way they soldered the screw clamp connectors – they wouldn’t open or close and I had to solder my wires right to the board.

Luckily, these SMAKN TB6600 driver boards are top quality and I don’t have to do anything special. They run nice and cool too – and have a massive heat sink:

I purposely over engineered the drivers and motors so they would last outdoors in the heat and cold, and also so I wouldn’t have reliability issues voltage or current wise.

The “official” Arduino and Raspberry Pi boards are very high quality. Two Chinese brands that seem good (so far) are SMAKN and Elegoo. This is where Adafruit rocks – they don’t sell junk, and their prices are fine. The Pi Hut looks good too. The driver boards with the crappy connectors were from SainSmart – and while I only purchase products with high marks (reviews), perhaps I got a couple lemons?

Wow – this couldn’t come at a better time in my “hobby life”. DXCC Chasing has been stale ever since VK0EK was on the air – except for Top Band – but the wait between entities on Top Band can be long once you get above about 50 entities. I surely am very pleased that I worked what I did when I did since July 2001 – 16 years ago, but with 2 left for Top of Honor Roll and 13 left for DXCC on Top Band, I was “pining for the fjords”. Or maybe “watching the grass grow”.

Enter in this new “Maker World” and I feel like my next chapter is very clear, very exciting and opens my mind in a way that sitting around hoping some DX will activate just can’t do.

My next trick will be to add in the C GPIO control code to Paul’s Elecraft code. It might be as easy as some setup of the three pins 4, 18 and 23, I guess set enable on and then in the loop that is printing the KPOD information add a single command that pulses the direction using the sign of the integer and the step with the integer value. Something like this, which is a very small subset of this example:

#include <wiringPi.h>

const int NUM_STEPS = 6; // number of steps including half steps
int currentStep = 1; // just assume this starting point

 pinMode (4, OUTPUT) ;
 digitalWrite(4, 0);
 pinMode (18, OUTPUT) ;
 digitalWrite(18, 0);
 pinMode (23, OUTPUT) ;
 digitalWrite(23, 0);

// step the motor. 1 for clockwise, -1 for counter-clockwise
void step(int dir) 
    currentStep += dir; 
    if (currentStep>NUM_STEPS) 
        currentStep = 1; 
    else if (currentStep<=1) 
        currentStep = NUM_STEPS; 

int main()
    int i, x, c; 
    // initialize WiringPi library 
    x = wiringPiSetup (); 
    if (x == -1) 
        printf("Error on wiringPiSetup.  Program quitting.\n"); 
        return 0; }

Introducing The u.Rat

u.RAT = Universal Remote Antenna Tuner

The devil is in the details – but if I had to have a very simple product brochure that explained what the u.RAT is, this would be it. I would say you can use any analog antenna tuner that you like – in the shack or remote out at the antenna. I’d say that the Palstar BT1500A is my tuner of choice for non coax (open wire fed) antennas. And while my tuner only has two knobs, three knob tuners and even tuners with switched inductors can be used. Its a perfect way to breath life into that old antenna tuner that’s just laying around – or, the antenna tuner you wanted to home brew yourself.


The Final Design of the “Universal Remote Antenna Tuner” (U.RAT)

I have the hacked N6HZ (Paul from Elecraft) C program ready to have the GPIO call added (as soon as I get that breakout board), and I also have to get the steppers working with the drivers, and will need a program that watches for an input pin to go high to trigger the steppers. I did find an Arduino sketch and complete wiring and dip switch settings:

There are code and wiring references for the Raspberry Pi, but looking at this Arduino sketch, all I have to do (to complete the prototype) is add a function that gets called with two parameters – which stepper to turn and which direction. Since the rotary encoder sends plus and minus numbers the direction is in the sign of the number – minus for CCW and plus for CW. I hope I don’t run into any rude surprises, and I don’t think I will – but I still have to get the KPOD to turn one and then the other stepper. The devil is always in the details, and I am very excited that I might have this working by tomorrow night (since the last parts that I need won’t be here until tomorrow). As I said before, the design and prototyping aspect of this project is one of the most fun learning “journeys” I have had – and my mind has been expanded so far beyond just chasing after DXCC entities (for 16 years) that it is the most welcome change in my hobby. To be fair – we are now at a place where the first “waves” of hackers have done so much work that I get to just jump in and skate. They did the hard work. Secondly – I didn’t just sit on my butt in the shack all those years – I had been a “Maker” – but an antenna maker, and now that I really have hit “Peak Antenna”, I very much needed this change. OK – back to the topic at hand . . .

I posted this before, but its so good, here is what I need to do once I get the breakout board and jumpers that have male to female connectors:

This fellow gives several very important tips that other tutorial videos don’t. Here is another one that has a really nice description of how Stepper Motors work:

The final “product” is a Universal Remote Antenna Tuner (U.RAT). It is meant to be used by anyone who wants to take a two knob antenna tuner and remote it at the antenna. Hackers can add a third control if they like – and the KPOD rocker switch easily supports three – but the BT1500A only has two, so that’s as far as I will take the project. Here are the benefits:

  • Take any old commodity analog tuner and remote it. Used antenna tuners can be had on the cheap
    • The tuner at the antenna might be more efficient than in the shack. I think for open wire balanced tuners this is a must
    • The KPOD used to tune the antenna tuner takes up far less space in the shack and is just too cool
  • The KPOD can be used to also control other things like a wireless remote antenna switch. Future versions might use the F buttons for memories. Some antenna tuners have switches, so the F buttons could be mapped to switch positions
  • The project will be Open Sourced
  • Elecraft gets to market the KPOD to the Maker Community as well as the Ham Community (if they wish). My all time favorite ham radio company is Elecraft – I’m a huge loyal fan for sure – and they have sponsored more DX-peditions than anyone. I hope I can help them sell KPOD’s!

The feature set of the first version will be very simple. The idea is that other contributors can extend and fork the code into other projects and ideas. I have no vision for fully automatic or WiFi – at least for now. This project firmly plants me as a Maker-Ham or a Ham-Maker?

I will add this finished project to my resume. My motivation was to learn and get a cool remoted antenna tuner and a great low band antenna out of this project, but the process I just went through aligns perfectly with my Data Architect role – and extends my capabilities into a Product Designer.

Raspberry Pi GPIO Breakout Board

The Raspberry Pi’s IO ports (GPIO) are not that easy to access, so they make a nifty way to prototype circuits like what I am trying to do.

I also learned about a utility that is part of a C library called wiringPi which is one of a few that lets you easily access the GPIO input and output pins in a similar manner as how you access pins on the Arduino.

wiringPi comes with a really cool utility called gpio, and it lists all of the pins on the GPIO and their state.

I am learning so much more and so much faster than I ever learned anything in my DXCC chasing days. Holy smokes.


Raspberry Pi and GPIO in C

I will just hack Paul, N6HZ’s C program which already reads the KPOD since it already has a loop looking for KPOD “events”. In fact, it sort of does what this pseudocode does, except the code in italics:

        if rocker left position:
            read encoder
            move left stepper by encoder amount
             read encoder
             move right stepper by encoder amount
   politely shut down

The code that I need to add is GPIO code, and I found a wiki with examples here:

   gcc -o pulse pulse.c -lpigpio -lrt -lpthread
   sudo ./pulse
#include <stdio.h>
#include <pigpio.h>
int main(int argc, char *argv[])
   double start;
   if (gpioInitialise() < 0)
      fprintf(stderr, "pigpio initialisation failed\n");
      return 1;
   /* Set GPIO modes */
   gpioSetMode(4, PI_OUTPUT);
   gpioSetMode(17, PI_OUTPUT);
   gpioSetMode(18, PI_OUTPUT);
   gpioSetMode(23, PI_INPUT);
   gpioSetMode(24, PI_OUTPUT);
   /* Start 1500 us servo pulses on GPIO4 */
   gpioServo(4, 1500);
   /* Start 75% dutycycle PWM on GPIO17 */
   gpioPWM(17, 192); /* 192/255 = 75% */
   start = time_time();
   while ((time_time() - start) < 60.0)
      gpioWrite(18, 1); /* on */
      gpioWrite(18, 0); /* off */
      /* Mirror GPIO24 from GPIO23 */
      gpioWrite(24, gpioRead(23));
   /* Stop DMA, release resources */
   return 0;


There are also some video examples out there:

One thing I learned is that I can get rid of using vi as my editor and use vim or nano:

It looks like this level of C code is actually much simpler than the C# code I wrote at Travana – which was a complex parser using the “Builder” pattern.

The only trick will be figuring out how to map whatever values are sent by the KPOD and translate these values into something the GPIO library can accept as a parameter. I already have the code hacked so it does this:

I think this will be big fun and that I am certainly up for the challenge!

The “Other” Half of the Eagle Has Just Landed . .

This may not look sexy, but it is. After some serious debuggery, I got the Elecraft KPOD to work with the Raspberry Pi 3 b. Thanks to Paul, N6HZ, the lead developer of the KPOD code, and also the KPOD firmware updater, a real thorny problem was solved. My advice to anyone who has a KPOD – download the KPOD utility and update the firmware NOW. Prior to going through this process, neither of my KPOD commands could be seen on Linux or Windows. Now they both are, and the second half (really the “front end”) of my project is working.

So, now I have two parts of the puzzle working – my Raspberry Pi receives commands from the KPOD, and my Arduino runs the stepper motors. This weekend I will get the Raspberry Pi to run the stepper motors, and then I have a big design decision – do everything with a Pi or go “client – server” with Raspberry Pi telling its Arduino “minion” to do as requested . . .