Author Topic: NanoVNA Custom Software  (Read 553237 times)

0 Members and 9 Guests are viewing this topic.

Online Bicurico

  • Super Contributor
  • ***
  • Posts: 1783
  • Country: pt
    • VMA's Satellite Blog
Re: NanoVNA Custom Software
« Reply #100 on: August 18, 2019, 05:43:02 pm »
Hi,

Here is my quick update...

I have returned from the first part of my holidays, so I had this afternoon to sit at my shack and try the NanoVNA.

Coming from pure spectrum analysis, the VNA is totally new to me, so here is what I understood so far and I welcome any correction. I write this as if thinking out loud and to allow others to learn from the little insight I got so far. Again, please do correct me (hopefully in a friendly manner - this is just a hobby, I am not a RF engineer by education or trade).

1) The VNA can be used to tune antennas. The idea is that you want as little as possible of the outgoing wave to be reflected by the antenna - this causes the signal to travel back into the device. There are two problems with this: a) If the signal is reflected instead of being transmitted, it is not transmitted! This is kind of useless... b) The signal going back into the the device might actually break the device.

When measuring the antenna, we want to determine the minimum reflection of the wave at a given frequency. Any antenna is typically tuned for a specific frequency. The S11 logarithmic measurement will show a notch at this frequency. By making the antenna longer or shorter or whatever, you can increase the loss of signal return (=maximum transmission of the signal) - the notch will become greater. And, you can especially move the frequency of the notch. This is what is called antenna tuning.

2) Resistance and Capacitance at AC behave differently from DC: they vary with frequency and a capacitor actually acts as a resistor. Plus: it lets the AC flow through it!
By plotting the variation of the capacitance through frequency, we can analyse the behaviour of the DUT. One way to represent this is by means of a SMITH chart, which plots the data in a polar diagram, considering the complex number nature of capacitance/phase vs frequency. Sorry - at this point I am lost... What do you ACTUALLY measure? Why and what for?

3) S11 and S21: this is easy to explain: there are two ports on the NanoVNA: Port 1 and Port 2. When you only use port 1, you send out a signal on port 1 and then read the reflection of this signal back into port 1. So you measure 1-->1 = S11. S21 means that you generate a signal at port 2 and send it through a DUT. From the output of the DUT you read the signal in port 1: 2 --> 1 =  S21. My guess is that S11 = measure antennas and/or signal reflection / SWR. S21 allows to measure how a DUT messes up a signal: phase (due to delay?), attenuation?

Regarding writing a custom PC software:

1) The NanoVNASharp software works without any problem for me, so I wonder why people are so motivated to write their own software? The reason I ask is to understand what OTHER measurements COULD be implemented. Also, what functionality is missing that would be required?

2) The connection to the NanoVNA, as already discussed, is fairly simple: just open Putty, configure the respective COM port and off you go. Type "help" and you can see all commands. Their output is quite self explanatory and the data (literally "data") can be easily copy&pasted to Excel for initial tests.

The data consists 101 samples made of the two components of a complex number, x and y, as usual with impedance measurement.

To represent the data in a polar chart (Freq/Vector):
Vector= 180/PI*Atan2(y, x)

To represent the data in a linear Freq/dB chart:
dB = Sqrt(x^2+y^2)

To represent the data in a logarithmic Freq/dB chart:
dB = 20*Log10(Sqrt(x^2+y^2))

I am not 100% sure this is correct, but first tests look good.

The "frequencies" command will output the frequency matching each of the 101 samples, which is nice, as you don't have to calculate them yourself (which would not be a big deal anyway).

I did not figure out what the "dump" command outputs.

Hope this helps and I am with joeqsmith: let's see what comes out! Again, I am at this point unsure on how to improve the NanoVNASharp software, so my personal desire to make my own software is not so big right now - I don't even know all the applications of the NanoVNA in the first place.

I, personally, don't believe in freeware/open source, btw. Any work done for free is normally to be considered "worthless" by those using it...

@joeqsmith: Can you explain what a GaAs transfer relay is and what purpose it has? I tried to google it without success, as the results want to show a GAS relay. So much about AI.

Regards,
Vitor

« Last Edit: August 18, 2019, 05:54:23 pm by Bicurico »
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #101 on: August 18, 2019, 05:56:39 pm »
@joeqsmith: Can you explain what a GaAs transfer relay is and what purpose it has? I tried to google it without success, as the results want to show a GAS relay. So much about AI.

Regards,
Vitor

I assume you watched the video I posted where the person demonstrated a mechanical transfer relay.   I also assume you watched the first video I made where I talked about the use of a transfer relay.    GaAs, Gallium Arsenide is the technology used in my relay.  You can find information about that in Wiki. 
   
https://www.eevblog.com/forum/rf-microwave/nanovna-custom-software/msg2616768/#msg2616768
https://en.wikipedia.org/wiki/Gallium_arsenide

Quote
The signal going back into the the device might actually break the device.
The VNA is designed to handle 100% reflected.  Obviously if you are testing PAs, all bets are off.  You could easily destroy it with the forward power as well.

Quote
I wonder why people are so motivated to write their own software?
As I stated before and demonstrated during the video, I started out because of the flicker when using the cursors. 

Offline edigi

  • Regular Contributor
  • *
  • Posts: 184
  • Country: hu
Re: NanoVNA Custom Software
« Reply #102 on: August 18, 2019, 08:03:48 pm »
Here is my take (or guess if you like) how NanoVNA operates, it requires no higher education, although it helps if you know quadrature signals.
For that you may check https://dspguru.com/files/QuadSignals.pdf (it contains a lot more than needed here but it never hurts to know more).

I re-iterate that may be know already from elsewhere:
There is a clock chip with 3 outputs that beyond clocking the ADC and MCU chips (with the same clock) outputs 2 RF signals (one for downmixing, one for reference) with a small difference between them (that falls into audio range where the ADC can operate after mixing).
One of the RF signals is used to down mix to audio band and there are 3 double balanced mixers that share the same RF signal for downmixing:
- 1 mixer for the signal that is used to feed a resistor bridge (the reference RF signal)
- 1 mixer for the middle of the bridge (that measures unbalance)
- 1 mixer for the input of the VNA (RX)

In the resistor bridge instead one of the resistors the output of the VNA connected (TX).

If the VNA output is impedance matched (meaning pure resistive 50 Ohm), there is no signal in the middle of the bridge as it's balanced.
If the output is mismatched but still pure resistive there is signal in the middle of the bridge but it's phase aligned with the reference (that is feeding the bridge).
If the output is totally mismatched (meaning also reactive component) the middle of the bridge will show a phase shifted signal.

Checking in the source dsp.c file the ADC output of the downmixed signal is correlated with sine and cosine (5 periods in 48 samples, meaning like 5kHz difference between the RF signals with 48kSa/s that is my take or 10kHz with 96kSa/s with no practical difference) both for the signal being checked and the reference. The phasor difference between them is calculated and stored in rectangular form.
This is done for all the points in the scanned frequency range and plotted in the form that is desired (starting around line 430 of plot.c).
The same phasor difference is done for the input port in case of S21 measurement.

Like Bicurico already wrote, with S11 you can check the frequency dependent characteristic of a component (antenna included) what resistive and reactive part it has at various frequencies.
With S21 you can check what transfer characteristic of a component like filter, amplifier etc. has again at various frequencies.

In the what could be enhanced part for me the range extension occurred first. The clock chip is just 200MHz that is extended with many already documented tricks till 900 MHz but that is still not that high and due to the extension dynamic range is compromised as well...
Luckily the whole thing is open source (and very far from worthless) so anyone can enhance, correct.

Note: there are different sources, one from the original Japanese author (trftech) and then who makes this product:

https://github.com/ttrftech/NanoVNA
https://github.com/hugen79/NanoVNA-H
« Last Edit: August 18, 2019, 08:53:13 pm by edigi »
 
The following users thanked this post: horo

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #103 on: August 19, 2019, 05:56:52 am »
Today I made up a USB cable to control the transfer relay and finished up the software to support it.   Switching happens automatically when running a calibration or a 2-port sweep.   

Sadly the prototype has proven to be worthless.  I was hoping that the Nano's performance was poor enough that the error from the GaAs switches would be negligible but this wasn't the case.  This would have a been a fairly low cost solution.   If you are curious about the T check, Rohde Schwarz published a paper on it that may be worth the read.     

https://scdn.rohde-schwarz.com/ur/pws/dl_downloads/dl_application/application_notes/1ez43/1ez43_0e.pdf

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 4065
  • Country: ua
Re: NanoVNA Custom Software
« Reply #104 on: August 19, 2019, 11:29:58 am »
If you are curious about the T check, Rohde Schwarz published a paper on it that may be worth the read.     

do you have T-check results for nanoVNA?
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #105 on: August 19, 2019, 02:43:41 pm »
If you are curious about the T check, Rohde Schwarz published a paper on it that may be worth the read.     

do you have T-check results for nanoVNA?

I'm not sure what you are asking as a T-check for the Nano wouldn't make sense as it can't measure all four S parameters.   The reason I added this basic metric to my software is to help validate the transfer relay (and bias Ts).   

If you read the document I posted and understood it, looking at the picture I had attached, notice that the Function is set to 2-Port T-Check.  I am sweeping from 1 to 150MHz which is the X-axis of the graph.  The Y-axis it is in percent deviation from a perfect system, as shown in the Rohde Schwarz paper.  Even at just 150MHz, you can see it is already 15% low which is a fail.  It gets much worse.   

As I mentioned, I have an old transfer relay that I could easily drop in and use but my goal wasn't to just show an old relay connected to the Nano like the video I had linked.  That video doesn't show anything about how it is actually used and I doubt many people would want to see me just connect a relay.   I would like to sort out something cost effective that could be replicated.   

The end goal would be one last video showing how it could be used to create a full 2-port Touchstone file for a more complex device (RF transistor) and use it as part of an amplifier circuit modeled in SPICE. 

I was looking at that Siglent setup but it looks like it suffers from the same problems.   Being a modern system and over $1000, I was expecting more.    I was actually hoping they had a low cost test set as I can't believe anyone would disturb their cables when making measurements, let alone swap them.    Had they, and if it was cost effective, maybe adapt it to the Nano.     

Oh well, strike one. 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #106 on: August 19, 2019, 07:21:27 pm »
The plan is to switch to a mechanical relay like hagster had pointed out.   Teledyne and others make some that have some decent specs.    The ones used in my DSO have a very low profile.  I would like to keep the size down like the first attempt.   It will take another week or so to get something together to try. 

It's too bad that they didn't offer this as an accessory.  Maybe it's getting too specialized. 

A few people have been asking me about the PCBs used for the cal standards.  I don't have a store where I try to sell anything but again, maybe this is another opportunity for the people making the Nano.   

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 4065
  • Country: ua
Re: NanoVNA Custom Software
« Reply #107 on: August 19, 2019, 08:04:39 pm »
I'm not sure what you are asking as a T-check for the Nano wouldn't make sense as it can't measure all four S parameters.   The reason I added this basic metric to my software is to help validate the transfer relay (and bias Ts).   

If I understand correctly, T-check can be done with 2-port. But I'm not sure what are meaning of these S21* and S12* (marked with star) on equation (12) in the document (see page 5).

If I understand correctly, S11 and S21 are measured on usual T-connector with some dummy load on a third port.

Technically we can measure S22 and S12 by just turn T-connector in different direction. But since we're using symmetric T-connector, the result should be almost the same, so we can assume that S22 = S11 and S12 = S21. Is it correct?

But what means S21* and S12* (with star)? How to measure it?
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #108 on: August 19, 2019, 08:25:02 pm »
I'm not sure what you are asking as a T-check for the Nano wouldn't make sense as it can't measure all four S parameters.   The reason I added this basic metric to my software is to help validate the transfer relay (and bias Ts).   

If I understand correctly, T-check can be done with 2-port. But I'm not sure what are meaning of these S21* and S12* (marked with star) on equation (12) in the document (see page 5).

If I understand correctly, S11 and S21 are measured on usual T-connector with some dummy load on a third port.

Technically we can measure S22 and S12 by just turn T-connector in different direction. But since we're using symmetric T-connector, the result should be almost the same, so we can assume that S22 = S11 and S12 = S21. Is it correct?

But what means S21* and S12* (with star)? How to measure it?

https://en.wikipedia.org/wiki/Complex_conjugate

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 4065
  • Country: ua
Re: NanoVNA Custom Software
« Reply #109 on: August 19, 2019, 08:36:45 pm »
ok, thanks, I will try to measure it when I get nanoVNA.

So the last screenshot in the post #110 is ct value multiplied by 100 for 1..150 MHz range, measured on your nanoVNA? Is it correct?

I'm just confused because there is a word "Gain", so I thought this is something other in dB... :)


15% error at 150 MHz looks much worse than example from T-check document. Is it really so bad?

What is usual error of other amateur VNA?
« Last Edit: August 19, 2019, 08:44:34 pm by radiolistener »
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #110 on: August 19, 2019, 08:52:45 pm »
ok, thanks, I will try to measure it when I get nanoVNA.

So the last screenshot in the post #110 is ct value multiplied by 100 for 1..150 MHz range, measured on your nanoVNA?

If swapping the cables, there's no need for the full 2-port cal, no need for the transfer relay, no need for the T-check.   Of course, ideally you would want to mechanically lock everything down when making measurements. 

Yes, like in the  Rohde Schwarz paper, I have multiplied by 100.  Yes, 1 to 150MHz.  Yes, measuredish on my Nano.   Ish, meaning that I am not taking the time to torque things or taking care to keep things from moving.  More of a check to see if it was even worth spending any time with.  It wasn't. 

I'm just confused because there is a word "Gain", so I thought this is something other in dB... :)

You have just discovered first hand the reason for not releasing the software.  It's really an engineering tool.   These little details like "Gain" vs something like "T-Check Percent (see RS paper.....)" would eat up a lot of time trying to explain and clean up for the general user.     

I suspect that most people will have no need for a full 2-port setup or want to play with things like Touchstone files and SPICE.   

missing word
« Last Edit: August 21, 2019, 07:51:15 pm by joeqsmith »
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #111 on: August 19, 2019, 09:08:13 pm »
15% error at 150 MHz looks much worse than example from T-check document. Is it really so bad?

What is usual error of other amateur VNA?

The NanoVNA is really my only reference for a cheap amateur VNA so I really can't say what to expect.  The problem I see with the cheap systems, like the Nano or the Siglent is there is no test set.  Which again.... see my last post.   So, if I ever get something I feel is good enough to use for a video,  you will have at least one data point.   Still, this will be custom one-off hardware, so there is a lot at play.   Right now, I would say your guess is as good as mine.   

Yes, 15% is pretty bad, especially when you consider that the full working range of the Nano is 900MHz.  It's just the first prototype.  Hopefully rev 2 will be better. 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #112 on: August 20, 2019, 03:10:58 pm »
Running the Nano for about 5 minutes after SOLT cal.  Then with the 50 ohm standard applied, let it run for roughly 18 minutes.  The histogram is for every sample.  So 101 samples per sweep multiplied by the 1600 sweeps,  or 160K.    I suspect if I were to do this for 0-300Mhz, it would look gaussian. 

The software just records the raw data for both channels and the frequency.  I can then calculate what ever I want to look at from that even though there are only six parameters listed.     

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #113 on: August 20, 2019, 04:37:15 pm »
Zooming into the 300MHz area, I suspect the reason we are seeing a pattern still is the lack of points. 

The scatter plot is showing the mag phase for the 50 ohm standard.  If it were perfect, we would just see a line from 0,0 at 50KHz to 0,0 at 900MHz. 

Offline erikka

  • Regular Contributor
  • *
  • Posts: 190
  • Country: nl
Re: NanoVNA Custom Software
« Reply #114 on: August 20, 2019, 04:48:40 pm »
The nanoVNA switches to harmonics mode when measuring above 300MHz. (see this code)
Code: [Select]
  if (freq > 900000000) {
    freq /= 5;
    ofreq /= 7;
  } else if (freq > 300000000) {
    freq /= 3;
    ofreq /= 5;
  }
My own build VNA using SI5351 and 3 SE612 uses the same aproach
This switching to 3rd and 5th harmonic when using above 300MHz is relatively ok because of the relative phase and amplitude  measurement but as the main signal drops more then 10dB it is a interesting test for the linearity of the onboard ADC.
Even when using a high end USB audio input the transition to harmonic mode its still observable
 

Offline erikka

  • Regular Contributor
  • *
  • Posts: 190
  • Country: nl
Re: NanoVNA Custom Software
« Reply #115 on: August 20, 2019, 05:26:55 pm »
My own cables and calibration set is insufficient to do a good TEE test. (My VNA uses the same measurement approach and has many same components except ADC and controller)



OK till about 600Mhz but deteriorating at higher frequencies.

Mind you, calibrating a standard 50 ohm load and measuring from 0.1 till 900MHz gives a very repeatable outcome at the accuracy level I am interested in. But then I am measuring with 24bit 192kHz ADC instead of the nanoVNA 16bit 48kHz ADC
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #116 on: August 20, 2019, 06:09:24 pm »
The nanoVNA switches to harmonics mode when measuring above 300MHz. (see this code)
Code: [Select]
  if (freq > 900000000) {
    freq /= 5;
    ofreq /= 7;
  } else if (freq > 300000000) {
    freq /= 3;
    ofreq /= 5;
  }
My own build VNA using SI5351 and 3 SE612 uses the same aproach
This switching to 3rd and 5th harmonic when using above 300MHz is relatively ok because of the relative phase and amplitude  measurement but as the main signal drops more then 10dB it is a interesting test for the linearity of the onboard ADC.
Even when using a high end USB audio input the transition to harmonic mode its still observable

Covered a long time ago but yes.
https://www.eevblog.com/forum/rf-microwave/nanovna-custom-software/msg2566308/#msg2566308

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #117 on: August 20, 2019, 06:11:18 pm »
Looks good.  What language did you use? 
« Last Edit: August 20, 2019, 07:28:35 pm by joeqsmith »
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 4065
  • Country: ua
Re: NanoVNA Custom Software
« Reply #118 on: August 20, 2019, 06:22:39 pm »
According to application icon this is .net.  :)

https://github.com/erikkaashoek/Tapr-VNA

« Last Edit: August 20, 2019, 06:26:11 pm by radiolistener »
 

Offline erikka

  • Regular Contributor
  • *
  • Posts: 190
  • Country: nl
Re: NanoVNA Custom Software
« Reply #119 on: August 20, 2019, 06:42:27 pm »
Yes. PC software to control hw similar to nanovna
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #120 on: August 20, 2019, 07:27:19 pm »
Is your plan to port it to the NanoVNA? 

Offline wwoofbum

  • Newbie
  • Posts: 4
  • Country: us
Re: NanoVNA Custom Software
« Reply #121 on: August 20, 2019, 10:28:06 pm »
The nanoVNA appears to be based on a kit, the Vector Impedance Analyzer, produced by the Austin QRP Club.  The website on which this kit was available (currently sold out), https://www.qsl.net/k5bcq/Kits/Kits.html, has considerable documentation which might be of use.
Just because you can, doesn't mean you should.
 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #122 on: August 20, 2019, 11:24:15 pm »
I tried running a narrow band sweep, set to 909 data points rather than 101.  The standard deviation is still not real good. 

Offline joeqsmithTopic starter

  • Super Contributor
  • ***
  • Posts: 11969
  • Country: us
Re: NanoVNA Custom Software
« Reply #123 on: August 20, 2019, 11:28:03 pm »
Cleaned all the connectors, torqued everything then repeated the test with the same settings.  It had a fairly dramatic effect.   

Offline gardner

  • Regular Contributor
  • *
  • Posts: 154
  • Country: ca
Re: NanoVNA Custom Software
« Reply #124 on: August 21, 2019, 05:03:41 am »
The website on which this kit was available

You had an extra comma in the URL which caused it to totally fail.  It took me a few mins to figure it out since the main page has no links to this stuff.

https://www.qsl.net/k5bcq/Kits/Kits.html
--- Gardner
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf