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:

try:
    loop:
        if rocker left position:
            read encoder
            move left stepper by encoder amount
        else
             read encoder
             move right stepper by encoder amount
except:
   politely shut down

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

http://elinux.org/RPi_GPIO_Code_Samples#C.23

/*
   pulse.c
 
   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 */
 
      time_sleep(0.5);
 
      gpioWrite(18, 0); /* off */
 
      time_sleep(0.5);
 
      /* Mirror GPIO24 from GPIO23 */
      gpioWrite(24, gpioRead(23));
   }
 
   /* Stop DMA, release resources */
   gpioTerminate();
 
   return 0;
}

 

There are also some video examples out there:

https://www.youtube.com/watch?v=jY7KVruyGjs

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 . . .

ZP5/NX4N: DXCC #87 on 160M!

Picture Perfect Greyline QSO with Paraguay – Map from VOACAP Online

Its been 3 months since I’ve worked any DX, and Top Band is my last stop on the DXCC Train. I worked Chris with the wrong antenna and a very high SWR. I used 100 watts into the “both direction” (180 degree broadside) setting of my 40M phased vertical array. This is the antenna that I often use as a very quiet Top Band RX antenna – in fact – by accident – last summer I found that this antenna meet or beat any other RX antenna and even some expensive equipment (NCC-2) that I tried. After our QSO, I found the Mod Bob to be the best RX antenna – even with its extra noise. I also did hear Chris on the Wellbrook ALA1530LNP – so boy, do I have my 160M RX antennas all dialed in and snug as a bug in a rug.

I MUST get out back and switch the Mod Bob manually to 160M – ASAP! And leave it there – heh heh . . . 

I really think we have turned the corner on 160M – that we are past the worst of the decline of Cycle 24, and that we are about to start having great Top Band and Low Band propagation. I also have had this theory that the “run up” to the Summer Solstice is the worst time of the year for Top Band, but that things start getting better every day past it. It makes sense – we start having shorter days.

Luckily, several teams known to activate on 160M are now on the calendar, and these are one’s I need – and which also should be very workable, if not easy:

  • V47JA – Jon does a good job from St. Kitts and Nevis – July 12 – August 5
  • T88GA – I swear I worked it last year, but was NIL, so I will try again – July 22 – 30
  • 5T5OK – Mauritania – not easy, but possible – September 16 – 28
  • VK9XI – Christmas Island – October 2 – 10
  • VK9CI and VK9CZ – active October and November
  • TO2SP – St. Barts – November

I very seriously doubt that I will work 3Y0Z on 160 – and think It will take all of the steam I can throw to get them on one band – my guess will be 40M, maybe 20M and 30M.

There will be others, but I could actually make DXCC on 160M – which will give me 9BDXCC within this next year. I actually feel like it will happen in 2018, after Bouvet.

Its funny how I thought I had all the time in the world to get this remote antenna tuner project done – but its already July 7, which just seems like this summer is moving very fast. I’m having fun – but always look forward to the Fall months, and our October all the way through Thanksgiving gives us superb weather.

A celebration is in order after work – Viva Top Band!

 

My First Oscilloscope

The Arduino and Raspberry Pi offer a wonderful set of inputs and outputs which will let me really dig in and start to understand electronics and computers in a way I have never been able before. I know that there are continuous signals and voltages and pulsing signals and voltages, and vaguely remember PWM (Pulse Width Modulation) from my ham test – but I am a visual learner – so a scope will no doubt be a great addition to my little “lab”.

I’m also getting a variable power supply.

Well, I really feel like I’m moving fast into my next “chapter” in my hobby. DXCC and DX-ing was great for all those years – as was antenna designing and building, but the combination of hardware / software / firmware has caught my entire attention.

The best news – since I am coding C and Python in conjunction with this Maker world – it firmly aligns with what I do at work.

To Pi or Not to Pi?

The Raspberry Pi with DRV8825 drivers

Nanotec Support Tutorial web page, which I learned about from this excellent tutorial on how to set up steppers on a Raspberry Pi:

https://www.youtube.com/watch?v=LUbhPKBL_IU

Rototron has a great web site with many Python and Raspberry Pi tutorials:

https://www.youtube.com/channel/UCp2rS5TxRt6W8fieAk74bIw

The “existential technical question” I’m having is whether or not to use an Arduino or Raspberry Pi for this project. It will all hinge on what happens with the Elecraft KPOD. Paul, N6HZ is the lead developer and will be helping me troubleshoot why his C code isn’t finding the KPOD on my Raspberry Pi. It seems as though a HIDRAW service or Daemon is not started on Raspian. Regular HID devices are detected, but not HIDRAW.

If we do get it to work, then there is a very compelling reason to go with the Pi – and that is – I can do everything with one board. I really don’t want to even think about having to use the Raspberry Pi just for the KPOD and then have it talk to the Arduino for the stepper control – that is overly complex and a waste of money.

The Raspberry Pi offers the ability to use Python or C – and I can also use it more as a command and control platform than Arduino – which is more like a single “slave” application.

I’ve learned that there is a Python to C interface called boost.Python, so I can call Paul’s C code from Python. This means that the KPOD code just looks like a device driver of sorts.

So, there is a clear decision:

  • Arduino if I end up building my own control box
  • Raspberry Pi if I use the KPOD

I really, really want to use the KPOD since that ends up  taking this project beyond just getting the job done. Imagine if I help Elecraft open their KPOD device to the Maker market? That would be pretty durned awesome! I also love the KPOD and would love to have it as my controller.

I’m doing research on Pi stepper drivers – but I know its all do-able. I’m also starting to think about an oscilloscope. This is all way too much fun!