Wednesday, January 29, 2020

HackRF One case

When I first started working on a Spectrum Analyzer design I needed some way to check the sweep ranges of the local oscillator, and output of stages.  Since some of these were in the 100s of MHz., my oscilloscope would not be enough, and my frequency counter could not follow the frequency when doing a sweep.   I had used one of the inexpensive RTl_SDR dongles before, and they had worked fairly well.  I recently saw an ad for a 'HackRF One' on AliExpress with a TCXO for under $70.  This unit covers from 1MHz. to 6GHz., can do 20 Million Samples per Second, and can be used as a transmitter as well as receiver.  I have seen it available bundled with a selection of antennas, accessories  and in a case for over $300.  

 Delivery time was only about two weeks. Looking at the board I was impressed with the quality. and I liked the fact that it used SMA connectors for the antenna, and oscillator in and out connectors.

The one from AliExpress was the board only, so I would need to make a case for it.  After some quick measurements, I modified one of my standard case designs to fit.  
 I decided to use a one piece design with guide slots for the circuit board.  I have found this to be very solid, and makes mounting circuit boards very easy.  I printed it using some Carbon Fiber filled filament I had on hand.  Don't think the Carbon Fiber pieces in the filament are long enough to do any shielding, but it sure looks nice.  

 Next I designed and printed a front and back for the case.  After putting it all together it makes a very nice looking unit.  A little taller than the ones I have seen with  some of the complete units, but still a very nice case that will give good protection to the board. Still in the process of trying several of the different SDR software packages that support the HackRF.  Will write up something on them a little later.

For anyone interested, I have the .stl files available at

Meanwhile still waiting on some of the parts needed for the 'TinySA' to arrive.  I think the Chinese holiday delayed everything. 

Monday, January 20, 2020

Small update to the Step Attenuator

When I first built the step attenuator,  I wanted it to check  linearity of amplifier stages.  I only needed a relative change in the insertion loss of the attenuator.  Recntly I was able to use my NanoVNA to measure the actual insertion loss across the total frequency range I am interested in.  I also received some questions about showing the actual insertion loss instead of the relative value,

Because of this I made a change to the code to switch the display value from relative to actual by a long press of the encoder knob.

 First I added some definitions and variables

float InsertionLoss = 2.6;  //insertion loss of attenuator at 0 dB 
int InLossMode  = 0;       // actual insertion loss or relative
#define ActualLoss  0   // display  value selected actual +                                  //insertion loss 
#define RelLoss     1   // display just value                                                //selected without insertion loss

The code to read the button push was modified to also check for a long press if you want to change display mode to show the actual insertion loss.
  // check button for display mode and step size
  if (button) {
    if (button == SHORT_PRESS ) { //  toggle step size
      if (AttenStep == 1) AttenStep = 10;
      else AttenStep = 1;
      button = 0;
    else {         // toggle insertion loss display type
      if (InLossMode == ActualLoss) InLossMode = RelLoss ;
      else InLossMode = ActualLoss;
      button = 0;

The display routine was modified to show th display value depnding on the InLossMode variable,

  if (InLossMode == ActualLoss) {    // show actual insertion loss
    display.setCursor(20, 15);
    display.print("Actual  ");       // indicate type 
    display.setCursor(10, 30);       // clear last value
    display.print("       ");
    // update display
    display.setCursor(10, 30);
    display.print( (AttenValue + InsertionLoss), 1) ; 
  else {
    display.setTextSize(1);        // show relative value
    display.setCursor(20, 15);
    display.print("Relative ");    // indicate type 
    display.setCursor(10, 30);
    display.print("       ");      // clear last value
    // update display
    display.setCursor(10, 30);
    display.print( AttenValue, 1);
  // display "dB." 
  display.print( " ");
  display.setCursor(80, 38);
  display.print( " dB.");

Updated code is available at


Wednesday, January 15, 2020

Starting on a Tiny Spectrum Analyzer

I have been playing with building a simple spectrum analyzer for a couple years now.  I have tried several different versions, and have ran into similar problems with all of them.  For what I want I need several different resolution bandwidth settings. For more than two band-widths  the overall complexity becomes greatly increased. I have tried several different approaches, but have not been happy with anything I tried.  I had joined the Homebrew Test Equipment group on ( , when it started.  Recently there has been a series of posts on a Tiny SA that has most of the features I would like to have.  It has a interface to a PC application for control and display.  I plan on adding a TFT dispalay to make it a stand alone instrument.  I have several STM-32 'Blue Pill' modules that I purchased a year ago. I think one of them should work well for this project.

This SA uses a pair of inexpensive SI4432 wireless ISM transceiver modules.  For use in a SA the important features of the SI4432 transceier is a frequency range of 240 to 940 MHz. at up to 20dBm output, variable receive bandwidth using DSP technology, and a Receive Signal Strenth Indicator signal with  .5 dBm. resolution down to about - 120 dBm. Complete modules with all the support components needed are available for less than $5 through the normal sources.

There are two different filters in the SA that I needed to design for a circuit board.  The first is the input low pass filter.  I decided a range of up to about 200 MHz. should be more than adequate for what I need.  My favorite design tool for filters is Elsie, with it  I can quickly design various types of filters, and tune the circuit to use standard value components.

For the low pass I decided on a 7th. order capacitor input filter. Playing with the program and values I have on hand, I came up with this circuit.

 This should give a frequency response similar to this, depending on the actual components used.

I had some circuit boards made by one of the Chinese board houses and, built and tested the LPF.  I used some SMD capacitors I had on hand from an assortment I purchsed a while ago.  Using a online calculor I designed and wound some air core inductors that are close to the values needed. ( )
   I used some 24 guage silver plated wire wound around a 3mm. screw as a form.  Four turns for the first inductor and five turns for the other two. 
 Connecting the circuit to the NanoVNA using one temporary SMA connector, and with a little reforming of the coils I was able to come up with  a filter with the following response.

I had to settle for a little bit lower cutoff frequency than the original design to reduce the passband ripple but will be fine for the frequency range I want.  It also gives me the option of using a 315 MHz. first IF frequency if I want to try instead of the 432 MHz. in the original Tiny SA.
The next filter I need to build and test is the first  IF bandpass filter,
This will use a pair of  432 MHz. SAW filters.