Sunday 24 April 2022

29 - Testing and Measuring Small signal RF amplifiers

An Amplifier amplifies! a small signal going into the input produces a bigger signal at the output. What are the relevant details? The parameters that matter.

Gain: a gain can be expressed in several ways and you must be clear if it is Voltage gain or Power gain. If the input impedance and output impedances are the same then these are simply related. If not you have to convert from one to the other at the input and also the output and manually work out each gain separately, simple enough using Ohm's law

Gain can be expressed as a number such as 10, again, you need to know if this is a voltage gain or power gain. If one amplifier is followed by another then you multiply the gains - if expressed as numbers. If the second amplifier has a gain of 8 then the combined gain is 80. It is also common to express gain in decibels, these are calculated by taking the logarithm of a gain number (and multiplying by 10 if it is a power gain or by 20 if it is a voltage gain. When you have two amplifiers connected together and you know their gains in dB you add these to combine them - if one has a gain of 10dB and the other has 9dB then the combined gain is 19dB. Addition is easier than multiplication which is why dBs are popular.

Bandwidth: The upper and lower frequencies where the gain drops by 3dB, in power terms this is a drop of 50%, in voltage terms it is a drop of 29.9%.

The parameters above are easily tested; a signal generator and oscilloscope will show the voltage response, particularly if you use the oscilloscope to look at the input voltage at the same time as the output voltage. Voltage Gain is Vout/Vin. You can use peak voltage, peak to peak voltage or RMS, as long as the waveforms are the same shape, preferably sinewaves and you are consistent between measuring input and output and there is no distortion. If you express Vout/Vin as a number, e.g 7 you can convert this to dB by taking the base ten logarithm of 7 and multiplying by twenty which gives about 17dB as Av. It is important that the amplifier sees a load at the output, usually 50 Ohms. It should also be driven by a source with the same internal impedance that the amplifier will see when it is used in a final system, again often 50 Ohms. Your signal generator might have two outputs, with a Internal Impedance of 600 Ohm or 50 Ohm. Pick the right one or add an external attenuator. 

You don't even need an oscilloscope although you can't just use your DVM or a voltmeter directly since they don't work at frequencies above audio (and maybe not even at audio) but you can use a simple diode detector with your DVM. These can even read power directly - see the RSGB handbook.  You could even make a simple signal generator if you are testing on a budget.

if you know Zin and Zout of the amplifier you can work out the power in and power out (Square the voltage and divide by the impedance) and this gives you the power gain. You can express Power Out divided by Power In as a simple number or in dB, e.g if the ratio is 49:1 this is a power gain of 17dB. To convert to dB you take the base ten log and multiply by ten. We usually use power in RF work. 

With experience you probably will memorise a few conversions to make your life easier. 3dB is 2:1, 6dB is 4:1, 9dB is 8:1 - do you see the pattern here? adding 3 to the dBs doubles the ratio. Likewise 10dB is 10:1, 20dB is 100:1, 30dB is 1000:1. The pattern here is that the digit in front of the zero of the dB figure tells you how many zeros to put in the ratio after the leading '1'. This is only true for power ratio and the equation 10Log(ratio) As an example, note that 36dB is 30dB + 6dB and this is a ratio of 1000 to 1, multiplied by a ratio of 4 to one so it represents 4000 to 1.

If everything is 50 Ohms you can usually read of the mW or dBm scale of your signal generator. You will need to add a dummy load to the output if you are using a normal oscilloscope. Alternatively you can use a Spectrum Analyser(SA) at the output. These usually have an internal impedance of 50 Ohms by design. The SA has the advantage that its display is in dBm directly. Provided your output is meant to be driving 50 Ohms. You must attenuate the output if it might overload the Analyser. I  use a £100 SDRPLay RSP1a and a homebuilt attenuator. 

dBm's are the ratio with respect to 1mW so 36dBm would be 4000mW (i.e 4 Watts). dB's are just a numeric ratio, dBm are an actual, absolute power. You will also sometimes see dBV or dBuV. There are actual voltages, not just ratios. I discovered lately that FFTs in LTSpice are displayed in (rms) dBV and you need to add 13dB to get dBms. That is not in the manual! 

There are lots of calculators online to convert dB to ratios, dBv, dBuv or dBm or dBWs. You often must know the relevant impedances for these calculators to work, they usually assume 50 Ohms. E.g https://www.rfmentor.com/content/dbm-dbw-dbuv-calculators

It is most convenient if the SA has a tracking generator and then you can get a direct plot of the frequency response. If not you have to pick different frequencies and plot graphs in graph paper or in a spreadsheet (Excel can "join up the dots" for you)If Zin and Zout are 50 Ohms you can use a NanoVNA, and the NanoVNA can even measure/check Zin and Zout. But you frequently need attenuators at both the output of channel 0 (port 1) and channel 1(port 2) of your NanoVNA, the first protects the amplifier (DUT - Device Under Test) and the second the input of the VNA - it needs to be below a milliwatt.

I repeat do not apply the NanoVNA to a circuit unless it can cope with a milliWatt (0dBm or 1mW) Do not apply the output of a circuit to the NanoVNA input unless the circuit is outputting less than a milliwatt. If using a Spectrum analyser or SDR acting as a spectrum analyser this also applies.

If Zin and Zout are not 50 Ohms you can still use 50 Ohm based instrumentation as they will indicate performance if you are going to use the module under test in a 50 Ohm environment - fed by an antenna or other module output with 50 Ohm internal impedance and feeding into the next stage where its input impedance is 50 Ohms. This is how a normal RF system works, 50 Ohm feeds 50 Ohm, if both are the same you get maximum power transferred from one stage to another. And keeping at 50 Ohms keeps the effects of stray capacitance low. If you insert an attenuator (designed for 50 Ohm systems) between stages you restore the effective Zin or Zout back to near 50. 

No discussion of  Zin and Zout would be complete without talking about alternatives ways of describing input and output impedances -  in the RF world we use SWR or return loss (or reflection coefficient) but I will postpone this for now.

Maximum Input amplitude: (Voltage or current) if you double the input amplitude, we expect the output to double as well. Graphically if we plot input against output we expect a straight line at a certain slope (the gain). The straight line cannot go on forever. A real amplifier has a power supply. Normally the output voltage cannot exceed the power supply. 

It can exceed the output voltage or current of the power supply if a transformer is used or if an inductor or capacitor stores energy and then gives it back to the output such that its voltage or current adds to the power supply. For instance a single ended transistor with an inductor as its collector load can output nearly twice the power supply voltage. Nonetheless the output should be the input magnified by a fixed number (the gain). Once the output droops you are nearing the limit.

Linearity: related to the maximum input amplitude. There are several ways of specifying this. In the RF world we use two different methods. If we are looking at the graph of a real amplifier and note that the "straight line" droops by 1dB we call this the P(-1dB) point, sometimes the minus sign is omitted (P1dB) it is an example of gain compression. You could meet an amplifier where the output rises by 1dB but it is uncommon (I've never seen one) You probably should not be running an amplifier beyond the P(-1dB) point and if you are at or near it you are generating a small amount of distortion. If outputting speech you are only distorting on the peaks of speech that take you to the P1dB point, the vast majority of the time you are passing a lower, more linear, signal. This does not apply if you are passing Data or using FM - you might be running at peak output all the time, a good reason to reduce amplitude if using data, apart from the distortion you are stressing the amplifier and its heat sink or its omission is, by design, not able to cope with continuous peak outputs. Be careful overusing speech compression as well. 

The other performance metric for linearity/Strong signal handling ability is related to Inter-Modulation Distortion(IMD) and specifically the amount of third order Intermodulation Distortion. There is a strange relationship between IMD3 and Power out (Pout). As you increase Pout(by increasing Pin of course) the IMD3 increases three times faster (in reasonable, well behaved amplifiers) 

You can graphically plot a straight line for Pout/Pin and IMD3. since the "slope" of the IMD3 line is steeper it will cross the Pout line at some artificially high Pout - remember at some point well before the crossover the Pout line will droop by 1dB and then droop even further until saturating with a straight line - the power supply cannot supply any more power (your devices may well be glowing red hot by this stage and blow up shortly afterwards or before). 

The crossover point is never reached, you have to extend the lines by hand on the graphpaper. It is a theoretical point. The power level where the crossover is drawn is called the third order Intercept point and we use the term OIP3 to represent it. (The Output Intercept Point for third order intermodulation distortion).

You can also mathematically move the figure to the input where it is called the IIP3. You simple subtract the gain (since the figures are in logarithmic dB you subtract rather than dividing by the gain). The IIP3 and OIP3 are important even if they are theoretical. It is easy to work out a combined figure when you have a chain of amplifiers and you can calculate when a strong signal will cause distortion. If you are dealing with a single stage the P(1db) is easier to measure. 

There is even a rough rule of thumb that the OIP3 is usually about 10 to 12 dB higher than the one dB gain compression point P(-1db), at least if using ordinary bipolar transistors, FETs are usually show about a 7 or 8dB difference. Crude but useful...

Apart from using the rule of thumb you can use a formula based on a graphical technique. If Pout increases at a rate 'x' and IMD3 increases at '3x' then IMD is catching up with Pout at '2x' if you have a specific measurement of both - usually taken from a spectrum analyser then you can calculate the crossover point, the third order intercept. 

For example if the Pout is at 20dBm and the IMD3 is 6dBm then if we "theoretically" increased Pout to 24dBm we would expect IMD3 to go to 18dBm - because it increases three times faster (up 4 and up 12 dBm). If we increase Pout another 3dBm then IMD3 goes up 9dBm so when Pout=27dBm IMD3 would be also 27dBm - the crossover point. An easier calculation is to take half the difference between the real Pout and the IMD3 taken at a specific Pin, the difference in the example above 20dBm - 6dBm which is 14dB, half is 7 and we add the 7 to Pout to get 27dBm.  This works because the difference between Pout and IMD3 increases is a factor or 2.  

OIP3 = Pout + 1/2 (Pout-IMD3 )

We can do this easily using a two tone oscillator and a spectrum analyser.

Other parameters of amplifiers we would like to measure are;

Input and Output Impedances: Easily done with a nanoVNA (it is what it is designed to do) but we must take into account the strength of the VNA output and add an attenuator for amplifiers used for small signals and we might even want to add an amplifier(of known gain and return losses) to test medium and higher power amplifiers under more realistic conditions. Secondly the output of the device under test may be too strong for the input port of the VNA. Luckily attenuators can be knocked up by soldering three cheap resistors in a "pi" or "T" arrangement. 

see https://www.rfcafe.com/references/electrical/attenuators.htm

There is an alternative to a NanoVNA that is cheaper; A return loss bridge (RLB) is a simple device, at its heart it is a simple 4 resistor bridge, with one of the resistors omitted - you put the amplifier input or output in its place. Applying a signal from a signal generator will give no reading at the detector output if everything is 50 Ohms and a maximum reading when either shorted or left open circuited. You can infer the impedance of the amplifier depending on how far away from maximum the detector sees. The detector output needs a Balun or choke to allow it to measure things with respect to ground. You can buy a cheap RLB from Ebay for a tenner, or make one for under a quid.  (see https://www.qsl.net/kl7jef/Build a Return Loss Bridge.pdf ) The NanoVNA uses this method and has RLBs inside it - but the signal levels and sensitivity are fixed which is a nuisance sometimes. I will do a future article on RLBs.

When measuring Zout you need to terminate the amplifier input with a 50 Ohm resistor, you should check with a dummy load and scope that the amplifier is not outputting anything, if it is you will damage your test gear. I was nervous measuring Zout - you apply outputs from your test gear to the output of the amplifier, it is wise to check the output is zero before connecting up your nanoVNA, RLB or signal generator! With the input shorted to ground through a 50 Ohm resistor, the output should be zero but it is wise to check, a spurious oscillation might be happening (usually called instability - a bad thing!) Also make sure there is a DC block in the amplifier (there usually is). This can be a capacitor or transformer. Don't apply DC to your nanoVNA or Spectrum Analyser.

Measuring Zout in a non-linear amplifier is of limited use, it varies all over the place. You can pick a particular power out and try and measure Zout at this point. If you cannot use the methods described above, a SWR bridge can be of some use. Alternatively apply a load near what you think Zout is, take readings of both voltage and current (record phase). Now make a small change to the dummy load and get a second set of readings, you can model (pretend) the amplifier output is a voltage source and an unknown impedance) at that particular power output, the operating point) and solve simultaneous equations to find it. The answer is only valid at that particular output power and load. You have performed a small signal linearisation about a particular operating point. I think this is called the load pull technique.

Isolation: I shall mainly ignore this, apart from one particular parameter. Some amplifiers have an annoying feature where if they are outputting to a device whose internal impedance varies then you experience variations in input impedance, an amplifier is said to be Termination Insensitive if it doesn't do this.

The particular amplifier I am testing here is known to be a TIA - a Termination Insensitive Amplifier I have simulated it in LTSpice, It is a bit fiddly to measure it in real life. You need to take a number of Zin and Zout measurements with differing load impedances. I will use 25, 50 and 100 Ohms and see what happens.

Noise figure/ Noise factor/ Noise temperature: These measure the same thing and are related to each other by simple formulae. I am still working out how to do this. The traditional method uses a noise source of known value (a "calibrated" noise source) and takes two readings, with it switched on and off. I do not yet have a source and they are expensive. The related topics of measuring Signal to noise ratio and sensitivity( Minimum Discernible Signal (MDS)) can wait until I have a complete receiver built.

Power Consumption/Efficiency: The output power and the power consumed by the Power supply contribute to the efficiency. Easier to do with simulation than actually measure. More important with the final power amplifier. To discuss this we should discuss amplifier Classes. Remembering that it is hard to generate an output voltage that is bigger than the power supply. (or twice the supply if you have collector/drain loads that are inductors)

A simple amplifier with a sine wave applied to it has an input that swings positive and negative (and usually passes through a capacitor). In a single-ended power supply, e.g +12V and Ground. The output can probably only swing plus or minus 6 volts. (actually 0 to +12V but if you use a capacitor you can consider it to be AC.) This means the amplifier output is sitting halfway between 0 and +12 when no signal is applied. This usually means there is base current bias applied and the transistor is half on. If it is half on, it is wasting power and the power consumption is maybe 50% of what you see with a big signal passing through. 

However, at least the output is faithfully following the input even if several times bigger (the gain). This shows linearity. That's class A. I will discuss the other classes when testing high power amplifiers. Most transceivers use Class A for all but the final transmit amplifier to minimise distortion, we accept some distortion in the finals to keep the power consumption efficiency low where consumption is likely to be highest.

A recent topic is that power consumption efficiency matters in the first stage of a receiver. It affects battery life if you are portable. An easy but inefficient way to get good strong signal handling and coping with nearby strong signals whilst receiving weak signals is to pass a high standing current (known as the quiescent current) down through the active device, or to parallel the active devices - some high end receivers use four FETs in parallel - and hence consume four times the current, Might only involve less than 100mA but it will affect battery life. So a compromise must be reached and it is worth measuring the power consumption when testing an amplifier.

---

Here are some practical tests I undertook on the three transistor TIA amplifier used in the uBitx, the unit I tested had the 2n3904s swopped for BFW93s to improve noise figure. I also simulated the circuit in LTspice.

My first test was to measure OIP3, I used my homebrew Two Tone Oscillator with its output reduced by variable attenuator set to 30dB  and fed the amplifier to the Spectrum Analyser - after checking it was below -10dBm where the SA has better linearity.

I got the waveform below;

So the Pout of the first tone, f1=13.035MHz is -12.9dBm and the IMD of twice f1 minus f2 is -67.7dBm (at 13.021MHz). The OIP3 is (Half the difference of the IMD and POUT) - POUT 

i.e (67.7-12.9)/2 + (-12.9) = +14.5dBm,

not brilliant but ok. Perhaps the BFR93AW are poor performers, I will repeat the experiment with 2N3904s. I ran the BFR93AW version with 35, 25 and 40 db of attenuation and got OIP3 of +12.8dBm, +14.25dBm and +12.15dBm. The slightly worse figures at low signals might be evidence of some leakage direct to the SA so a figure of +14.5 dBm is probably the right one. (They should all be the same)

My next measurements used the NanoVNA, I used an inline 20dB attenuator, sometimes on the input, sometimes on the output of the amplifier. 

S21 is the gain, but as I had a 20dB attenuator in circuit the gain is actually +14, nearly +15 dB and the frequency response is very good - In real life I will have filters either side of all the amps so the three dB points are irrelevant.(I think)


I was running out of time for this issue of contact so I did a quick test of Zin - with 50 Ohms on the output of the amplifier I applied the output port of the VNA to the amp and plotted the S11 return loss - expressed as Ohms and got...
I need to repeat this as I was expecting closer to 50 and the discontinuity must have happened when I moved something. Moving on to Zout, here I put a 50 Ohm load on the INPUT and checked the output with a scope, it was zero. Adding the output of the VNA to force a signal INTO the OUTPUT got me the S11 results below. Again I will repeat these, and also do them with an RLB (It is always good to measure things in two different ways). More in a month or two! I am off sailing...


It will be interesting to make a few more amplifiers and make measurements with different test equipment. 


Sunday 3 April 2022

28 - Diode Ring Mixers:

 Diode Ring Mixers:

One of the four building blocks in making a transceiver is a mixer. (the other three are filters, amplifiers and oscillators). Mixers have two inputs and one output. Usually the output contains the addition of the two input frequencies and the subtraction of the two frequencies. I.e if you apply f1 and f2 to a mixer you get (f1+f2) and (f1-f2) at the output. (or (f2-f1) if you prefer - if the subtraction gives a negative frequency you just pretend it is positive)

The uBitx Diode Double Balanced Mixer (DDBM)

The design of the uBitx requires three mixers, Two and a half really as the third is half a DDBM. They are each used twice, once for receive and once for transmit. In receive a low level signal of 3 to 30MHz is mixed with a Local Oscillator(LO) that can vary from 48 to 75MHz. For example an input of 14MHz is mixed with a LO of 59MHz. The two largest signals coming out of the mixer are the sum and subtraction of these two frequencies, i.e 45MHz or 73MHz. and lots of other frequencies, albeit at a lower level. The output of the mixer is passed to a 45MHz filter with a passband of 15kHz so most of the spurious signals are blocked from proceeding further in the signal chain. The other DDBM has an amplified 45MHz signal (+/ 7.5kHz) which is mixed with a second local oscillator of either 33 or 57MHz depending on whether you are receiving USB or LSB, the frequency difference frequency is 11.059MHz - again the other frequencies are mostly blocked by a 11.059 Crystal filter, this time it has a bandwidth of 2.4KHz and this is the desired SSB signal. A further amplifier passes this SSB signal to a third mixer, this time not a full DDBM and a third local oscillator, conventionally known as a BFO is mixed to convert the SSB signal into audio. This is a dual conversion superhet.

So how does a ring mixer work? The dots show the start of a winding.


Mathematically multiplying two sine waves together gives two new sine waves at the sum and difference of the input frequencies. Again, exactly what we want in a mixer.

Cos(f1) x Cos(f2) = 1/2 Cos(f1+f2) + 1/2 Cos(f1-f2) more or less...

Note this is simplified; the correct mathematical expression includes t and traditionally uses angular frequencies - in Radians/second rather than Hertz.

Below is a photograph of my diode double balanced mixer. I used 7 or 8 turns of trifilar would enamelled wire on a FT37-43 as per the uBitx instructions, I selected 4 diodes from a packet of ten that were within a millivolt or two on the diode test function of my multimeter. The transformers winders could be neater, I will make another and compare the test results.

Testing: Let us perform two tests with the mixer,

Test 1: We will apply a single tone - a frequency of 13.035MHz (one of my home made oscillators can generate this at just over 0dBm i.e 1mW or 224 mV into 50Ohms) and apply a strong 10MHz local oscillator voltage of 1.4V initially (this is 16dBm). The spectrum analyser (really my SDRPlay rsp1a sdr) will allow the following measurements.
What can we expect with two frequencies f1 and f2 entering a mixer?

In came as a shock to me when I actually tried this, there were quite a few more frequencies being generated. I showed last month how even just two frequencies can easily generate over 60 different combinations of all the harmonics, below is a real spectrum plot. At least the highest peaks are the desired f1+f2 and f1-f2.


It would be tedious to measure the height and reason for every peak. ~There is a facility in the spectrum analyser software to save a CSV file of the screen (or the entire FFT) and when I imported this into Excel, I was able to sort on the strength of each peak. There is a slight frequency mismatch if using the screen data although trawling through the FFT data showed the correct frequencies. I did not exhaustively search the FFT data as it is so large. (over a million lines long) – it would have been exhausting! I present a summary of the screen data below; I left the SA running in “average” mode which reduced the noise floor to -100dB and kept the peaks correctly, with some frequency drift of the test oscillator (tens of hertz)


The desired frequency of f1+f2 (23.035) shows a amplitude of -4.6 dB and since the incoming RF is at +2.8 dBm this gives an insertion loss of only 7.4dB which is ok - figures of 6 to 8dB usually quoted

It is interesting to note that the 3rd and 5th harmonics of my test oscillator seem to feature in the IMD products, perhaps I need a cleaner oscillator!

Whilst not shown above the response to the 10Mhz signal generator coming out the IF port is way down at -49.7dB, the 13.035MHz signal does come out the IF at only –33 to 35dB or -37dBc below the input. So one input is balanced out and the other one is nearly balanced out (-37.8dB is about 3mV of leakage. I will build another mixer and test it, I might just need some shielding. But as it stands it is fine for a receiver mixer, might need to be careful when used as a transmit mixer to make sure the carrier gets suppressed properly. The advantage of having my £92 Spectrum Analyser is that I can measure it easily.

So, the mixer has passed Test 1, insertion loss and carrier suppression is ok.

Test 2 is to see what the strong signal handling capability is like. Usually done by looking at a two tone response and using the third order intercepts, either referred to the input (IIP3) or output (OIP3). These differ by the loss, which we now know is 7.4dB.

We need three oscillators to measure IMD, a two tone oscillator with the two tones close to each other, mine are 13.0352 and 13.049, 14kHz apart, these will be applied to the RF port of the mixer, the LO is connected to a third signal generator. This time I will set it 59MHz as this is closer to what will happen in the uBitx.

The mixer should produce two new frequencies (if we concentrate on the f1-f2 terms)

i.e (59-13.035) and (59-13.049) these are 45.965 and 45.951MHz respectively

However, the third order product of (2f1-f2) and (2f1-f2) will also be present.

i.e ( 59 – (2*13.035 – 13.049) which is 45.979MHz

and (59 – (2*13.049 – 13.035) which is 45.937 MHz

The Intermodulation Distortion is defined as the distance below the main tone, and we get the intercept figure by adding half this to the power of the tone, either at the input or the output to get IIP3 or OIP3. The first time I did this the readings were low – I was overloading the mixer, I added a 20 dB attenuator and got better (expected) results.


(actually I think the IM3 is actually the height of the green bar - a mistake in the application note?)


I zoomed in and took readings of the power of one of the tones = -14.3dBm and the power of the 3rd IMD product = - 57.7 dBm. The difference between these (as a positive number) is  +43.4, half of this is 21.7, added to -14.3 gives a value of +7.4 as the OIP3. Coincidently the same number as my insertion loss.

The IIP3 is +7.4 + the insertion loss, measured as 7.4 = +14.8 dBm. My signal generator was outputting about +7 dBm. A rule of thumb is that the IIP3 should be 9dB more than the LO power so it looks like the mixer is working ok. (7+9=16!)

In summary, we want mixers with;

1. Low insertion loss (i.e a loss of 7.4 dB, most will be between 6 and 8)

2. Low LO breakthrough – mine is over 57dB below the input

3. Low RF breakthrough – mine is 33 to 37 dB below the input, need to watch this when using it to generate SSB, it affects carrier suppression, although the filter will help reduce it further

4. Good signal handling capability, whilst an IIP3 of nearly +15 is not great it is ok, a higher LO power would help it a bit, but I will use it as is in my uBitx, and see what LO power is best. I can improve it later.

One more of the building blocks done, next month I will cover the three transistor amplifier, 4 of them form the heart of the uBitx.