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:

https://pinout.xyz/pinout/ground

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:

http://www.nlogn.com/blog/

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

HY-DIV268N-5A Connects to:
DIR- RPi GPIO GND
DIR+ RPi GPIO #18
PUL- RPi GPIO GND
PUL+ RPi GPIO #23
EN- RPi GPIO GND
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: http://raspberrypihobbyist.blogspot.com/2014/02/stepper-motors.html

#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; 
    MoveStepper(currentStep);}

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:

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!