Monday, May 25, 2020

Furlogh 40 gets CAT Control





One of the pleasures of a homebrew rig is that if it doesn't have a feature that you want, you can always add it. So this past weekend I added functionality to the F40 to make it work with Ham Radio Deluxe and other PC programs.  With a properly configured rig, Ham Radio Deluxe makes working DX much easier. It has an integrated DX spot function that lets you see the DX spots on your bands of interest.  If you see a station you would like to work you simply click on the entry and radio tunes to that frequency.  To log a new QSO, its just a couple of clicks and HRD picks up the frequency and mode directly from the rig.  But to do this you need to have a rig that supports some version of the Computer Aided Transceiver (CAT) protocol.   Happily, virtually every modern (and most not-so-modern) commercial rig has CAT capability that let you control most or all of the rigs settings from a PC program like HRD or WSJTX.  But how do you implement CAT control in your homebrew rig?

Enter Pavel Milanes (CO7WT).  Building on earlier work by James Buck (VE3BUX), FT857D arduino Lib, Pavel created the FT857d- CAT Control for Arduino Library (FT857d)

Pavel's library is elegant and straight-forward to add to an existing Ardhino sketch.  It implements the rig control functions that emulates a Yaesu FT857D transceiver.  The library handles all of the communications and protocol handling allow you to connect the Arduino to a PC via USB.

For the technically curious, here is what I had to do to integrate the CAT library in the F40 Sketch:

After installing the library using the Arduino IDE's Sketch -> Add library command. I loaded up the exampl program that Pavel provides and was pleasantly suprised that he had done most of the work,  I had to make a couple of small changes to my main sketch and them modify functions that Pavel provided  function to handle connecting the library to the rig code for things like changing and displaying frequencies and modes,

From my main sketch's setup() rountine I made a call to setupCat() which registers a series of call back functions described below.  Then from the main loop I made a call to checkCat() where all the magic happens.

Following Pavel's example I created a seperate .ino file that connects our particular righ to the FT857d library. It has one function for each CAT command,  We have to supply the working bits to connect it to our rig’s software, for example:

  1. catGoToggleVFOs() is  called when the PC program directs changing VFOS,  This is where we put the code to switch between VFO A and B
  2. catSetFreq(long f) is called to change the active VFO frequency to whatever the PC program wants
  3. catGetFreq() – returns the current active VFO frequency to the PC program so it can display the frequency that the rig is tuned to.
  4. And so on. 

Taking two examples…  here is my code for catGetFreq()

long catGetFreq() {
    // this must return the freq as an unsigned long in Hz, you must prepare it before
    long freq;
    if (active_vfo == VFOA) {
      freq = vfoAfreq-bfo;
    } else {
      freq = vfoBfreq-bfo;
    }
    // pass it away
    return freq;
}

This function is invoked when the PC software wants to know what the current active frequency is – usually to display it in the UI or to use it for logging.

It references the control variable from my main sketch.

  1. active_vfo – is either VFOA or VFOB  (#defines in my main sketch)
  2. vfoAFreq and vfoBfereq are variables that contain the current value of the two VFO settings – with the bfo offset already applied
  3. bfo – is the bfo offset frequency

So all the code does is recover the operating frequency from whichever is the active VFO and return that the cat library.  Pavel’s library will send it back to the PC program for display or logging or whatever.

And here is my code for catSetFreq()

void catSetFreq(long f) {
   //
   // Change the frequency of the current active VFO
   // Clock frequency is the operatingfrequecy plus the BFO 
   // 
   if (active_vfo == VFOA) {
       vfoAfreq=f+bfo;
       setVFO(VFOA, vfoAfreq);
   } else {
       vfoBfreq=f+bfo;
       setVFO(VFOB, vfoBfreq);
   }
}

The CAT library calls this routine when the PC software has issued a command to tune to a new frequency.  All I do here is add the BFO offset to the requested operating frequency and call the setVFO() function in the main sketch which updates the SI5351 clocks and the F40 display.   

So far I have it tested it with Ham Radio Deluxe, WSJTX and FLDIGI, and FLRIG and the get and set frequency routines work fine.  Next step will be to implement software PTT.  

Thanks to James and Pavel for their contribution to the F40. This mod opens up a whole new world of possibilities.  Check this space for progress reports.

I am happy to provide the sketch to anyone interested, but I would like to keep track of who is using it.  Just send an email to KK4DAS@gmail.com.

73 from Great Falls,

Dean

KK4DAS