Friday, 26 May 2017

BASIC Tech Group - MyNews - 45 Testing PA, WSPR, more on SWR

Finally the 20dB attenuator I ordered from China has arrived. I need this as even the lowest output setting of my VFO is too much drive power for the small 3W PA amplifier I have. So now I can turn it down to get the PA operating in its linear range. So I have been trying agin to send WSPR weak signals and am looking for a result on WSPRnet.org.

IMG 1095

Here's the set up, from right to left

- Windows PC (I am a Mac man, but this seems not so bad) running HDSDR and WSTJ software, using VB to pipe audio from one to the other.

- The SDR receiver, which is an Elektor SDR Arduino shield and an Arudino Uno.

- The VFO, which has an AD9851, RTC (using a DS3231) and a buffer amp. Software is loaded to run WSPR on 40m at 7040.1kHz, the 20dB attenuator is plugged in the back of the VFO.

The small PA amplifier module, from eBay, running 2W output from a supply of 13.8V

IMG 1097

More on SWR

In the last post I talked about an SWR meter using a normal bridge circuit. The output from the bridge FWD & REF RF was handled by two AD9307 log amplifiers and fed to the analog inputs of an Arduino Nano. This drove an OLED display showing FWD power and SWR. Fiddle as I might I could not get stable results, probably as a lot of the circuitry was on a plug-and-play breadboard. So I am having a rethink.

I have browsed the web for ages and this is what I have come up with. I will wire this up on a proper PCB to test it:

IMG 1096

I have abandoned the AD8307s and gone back to what most people use - a couple of germanium low drop diodes. The PA amplifier this will be used with is 2-3W output, so their should be enough volts to run the thing. Calibration can be done in software.

As you can see I want to retain the measurement of RF output - just the voltage on the line, which can be shown as power when the system is matched to a 50R load. For this I am using a tried and trusted AD8307 circuit which will display 10mW to 10W. This AD8307 output will also be used to trigger the auto RX/TX switching of the PA.

Wish me luck.

Monday, 15 May 2017

BASIC Tech Group - MyNews - 44 The SWR meter

As part of my planned QRP PA, giving 3.2W output on 40, 30 & 20m, I am including an SWR meter. These look simple but are far from it.

The circuit I am trying to build is based on an Arduino Nano to do the calculations and drive a OLED display, and a couple of AD8307 log detectors to measure the Forward and Reflected power outputted from a conventional circuit using tow 1:10 transformers to measure the load line current and voltage.

Screen Shot 2017 05 15 at 12 46 10

When a wave travels from TRX to ANT a forward voltage FWD is output, when a reflected wave travels from ANT to TRX a reflected voltage REF is output. That's the theory anyway. (see this plagiarism article) The actual circuit looks like this

Screen Shot 2017 05 14 at 14 42 57

So far so good.

PROGRESS SO FAR

What I have done so far is to buikd the AD8307s and Nano circuit,

IMG 1086

and write some software to display a couple of bars for FWD power, SWR, display the values and say which band I am operating on. This involves detecting (over an average of ten measurements) the AD8307 outputs in millivoltss, converting this to dBm according to the ICs slope of 25mV/dB, converting this to dBm and then milliwatts across the 50R

IMG 1085resistors.

I have found that individual calibration is needed to get the same sensitivity from each AD8307, see code below. The slopes seem to be equal, but the intercepts different. Anyway I am now getting roughly the correct SWR for a 20dB Return Loss.

And at the moment I am stuck as my SWR transformers do not seem to giving the right outputs. I am driving the TXR end from my AD9851 VFO buffer outputs with 10mW and using a load of 50R at the output, built-into my RF Meter box. And the results are WRONG - Negative SWR! Reflected power bigger than Forward power... Why?

Code

// PA_LPF_TRX_OLED
// V0.95 16-5-17 need h/w for testing/calibTFMRLOSSn
// to add TRX

#include "Oled_128X64_I2C.h"

// analog reference (mV), A/D count, read avg
// slope and TX/display trigger (mW)
#define AREF 3300
#define ADCOUNT 1023
#define READAVG 10
#define TXTRIG 2

// analog inputs, band button, band relays, TXRX relay (PTT)
#define FWDPIN A0
#define REFPIN A1
#define SW 4
#define BAND1 7
#define BAND2 6
#define PTT 5

// display variables
double mwFwd, mwRef, swr;

// display text for bands
char bandTxt[][4] = {
  "40m", "30m", "20m"
};

byte band;

bool txFlag;

void setup() {

  Serial.begin(9600);

  pinMode(SW, INPUT_PULLUP);
  pinMode(BAND1, OUTPUT);
  pinMode(BAND2, OUTPUT);
  pinMode(PTT, OUTPUT);

  // analog ref AREF
  analogReference(EXTERNAL);

  oled.begin();

  // start on 40m
  band = 0;

  // TX off
  txFlag = false;
}

void loop() {
  int aFwd, aRef, n;
  double mV, dBm;

  // read SWR bridge inputs and average
  aFwd = 0;
  aRef = 0;
  for (n = 0; n < READAVG; n++) {
    aFwd += analogRead(FWDPIN); // typ +20dB level, gives 0dB at AD8307, or 2.5V (775 d/a)
    delay(50);
    aRef += analogRead(REFPIN); // typ -10dB level, gives -30dB at AD8307, or 1.5V (465 d/a)
  }
  aFwd /= READAVG;
  aRef /= READAVG;

  // 1. Adj slope for 20dB drop (470/50R), plot
  // 2. Adj intercept for correct mW
  // aFwd to mW, slope & intercept
  mwFwd = convert(aFwd, 25.0, -86);
  mwRef = convert(aRef, 25.0, -88);

  Serial.print("F: ");
  Serial.print(aFwd);
  Serial.print("\t");
  Serial.print(mwFwd, 3);

  Serial.print("\t R: ");
  Serial.print(aRef);
  Serial.print("\t");
  Serial.println(mwRef, 3);


  // calc SWR
  swr = ( 1 + sqrt(mwRef / mwFwd) ) / (1 - sqrt(mwRef / mwFwd) ); // calc SWR

  // band change
  if (digitalRead(SW) == LOW) {
    while (!digitalRead(SW));
    if (band < 2) band++;
    else band = 0;
    bandSw();
  }

  // switch to TX at 100mW
  if (mwFwd > TXTRIG) {
    digitalWrite(PTT, HIGH); // TX = HIGH
    txFlag = true;
  }
  else {
    digitalWrite(PTT, LOW);
    txFlag = false;
  }

  dispUpdate();

  delay(50); // loop stability
}

// convert A/D count, to mW
double convert(int aIn, double sl, double cal) {
  double mV, dBm;

  mV = (double)(map(aIn, 0, ADCOUNT, 0, AREF));
  dBm = (mV / sl) + cal;
  return pow(10.0, (dBm / 10.0));

}

// band relays, wiring HIGH = relay ON
void bandSw() {
  switch (band) {
    case 0:
      digitalWrite(BAND1, HIGH);  // 40m
      digitalWrite(BAND2, HIGH);
      break;
    case 1:
      digitalWrite(BAND1, HIGH); // 30m
      digitalWrite(BAND2, LOW);
      break;
    case 2:
      digitalWrite(BAND1, LOW); // 20m
      digitalWrite(BAND2, LOW);
      break;
  }
}

//=====PICTURE LOOP
void dispUpdate() {
  oled.firstPage();
  do {
    dispMsg(20, 0, "QRP POWER AMP"); // title

    dispMsgS(0, 15, "FWD");
    dispMsgS(0, 25, "SWR");
    dispMsg(50, 35, "FWD");
    dispMsg(50, 50, "SWR");
    dispMsgL(10, 40, bandTxt[band]); // band "40m" "30m" "20m" large font

    // values display active only on TX
    if (txFlag == false) {
      dispBar(20, 15, 5, 0); // blank bars
      dispBar(20, 25, 5, 0);
    }
    else {
      dispBar(20, 15, 5, mwFwd / 50 ); // 0-5000mW = 0-100bar
      dispBar(20, 25, 5, (swr - 1) * 25); // 1-5 = 0-100bar
      if (mwFwd > 1000) {
        dispNum(80, 35, mwFwd / 1000, 1);
        dispMsg(110, 35, "W");
      }
      else {
        dispNum(80, 35, mwFwd, 0);
        dispMsg(110, 35, "mW");
      }
      dispNum(80, 50, swr, 2);
    }
  } while (oled.nextPage());
}



Thursday, 11 May 2017

BASIC Tech Group - MyNews - 43 Next project, a QRP PA

The final box in my chain of QRP station items for digital transmissions is to be a 3.2W QRP PA. The block diagram for this is:

IMG 1082

I have found a 3.2W RF amplifier module on eBay which I will use. It has a gain of 35dB and works from a +12V supply (I tried another one to play with and it worked well, but was only 2W). To drive this from my VFO I will use an external 20dB attenuator and adjust the output with the variable gain buffer of the VFO.

Next in the chain are a set of 3 switched LPFs for 40, 30 & 20m followed by a SWR bridge. All is controlled by an Arduino Nano microcomputer. This switches the LPF relays, reads the SWR bridge and displays FWD forward power and SWR on an OLED display. RX/TX switching is automatic when ever the PA forward output is above 100mW. So far I have developed some provisional software, you can see the OLED display, and a wired up an SWR detection board. Now to breadboard the AD8307s for detection of FWD & REF outputs from the bridge, and drive the Nano analog inputs for the display...

IMG 1081

By the way in the background you can see my SDR-ELEKTOR, RF_POWER_METER and VFO running Hellschreiber S-MT software transmitting a HELL_S-MT beacon signal, displayed on the screen in Argo software:

Screen Shot 2017 05 11 at 14 31 28