## Browse By

Update: Now you can plot the impedance vs. distance/time plot. Click here to learn the concept.

Original Post: Having a VNA opens up so many possibilities. Just last week, I reviewed the nanoVNA and found to be an interesting device to have. Having handled expensive Vector Network analyzers (VNA) in the past and present, my excitement grew tremendously to compare it with the Keysight FieldFox N9952A 50GHz VNA. After achieving comparable results, my happiness knew no bounds because I knew I was going to be able to develop and test the RF circuits at my home without needing to take them to my workplace. The Time domain reflectometry (TDR) measurement on the FieldFox happens to be one of my favourites. I even use TDR regularly for various test cases. One of the test-cases is one-port cable length measurement.

In this article, we will go through some mathematics on deriving TDR response with VNA data. Further, I will explain to you a few use-cases where accurate cable length measurement comes handy. Of course, I will provide you with a shabbily written Python script in this article for you to try all this at home.

## Deriving Time response from Return loss

Remember that the VNA does its measurements in the frequency domain. The X-axis represents the frequency whereas the Y-axis represents the magnitude of return loss or insertion loss in dB. We all know the basic relation of frequency and time.

$$F = \frac{1}{t}$$

If we transform the frequency domain data into the time domain, we should see the time domain nature of our measurement. In order to understand this, we need to understand the concept of return loss. Imagine, you have an open-ended coaxial cable connected to your radio transmitter. If you happen you transmit through this open cable, the entire signal is going to propagate to the end of the cable and reflect back towards your transmitter.

As we all know, VSWR of an open or short circuit cable is always very high. In terms of return loss, we are going to see 0dB on our charts. So, if return loss tells us about the reflected signal, it should also tell us some information about the source of reflection. The answer to this lies in the phase of the return signal. By using the magnitude and phase of the signal measured throughout the frequency sweep, we can compute the distance from where reflection occurred.

### A little math

A few of you might know that Discrete Fourier transform (DFT) helps us visualize our signals in the frequency domain. The waterfall or the spectrum that you see with the help of RTL-SDR uses Fast Fourier Transform, commonly known as FFT (A faster DFT algorithm). In short, Fourier transform helps us transform our time-domain signal into the frequency domain. In the case of our VNA measurements, our return loss data is already in the frequency domain. How do we work from there? We have inverse Fourier transform that will transform frequency domain data back into the time domain representation.

We will use exactly that principle in our little experiment here.

$$\text {Return Loss} \stackrel { \mathcal{IFFT}} {\rightarrow} \text {Time Domain reponse}$$

The maximum cable length that we can measure depends on the frequency step size. For example, the nanoVNA can only measure 101 points in any given frequency span. If we set the frequency span starting with 10MHz and ending at 295MHz, the frequency step size is going to be 2.82MHz.

$$\Delta F = \frac{\text{Stop Frequency - Start Frequency}}{\text{Number of points}}$$

$$\text{Therefore, } \Delta F = \frac{\text{295MHz - 10MHz}}{\text{101}} = 2.82MHz$$

Now that we know the frequency step size, we can calculate the maximum reflection time we can measure.

$$\text{Maximum reflection time} = \frac{1}{\Delta F} = \frac{1}{\text{2.82MHz}} = 354.6 ns$$

### Converting time to distance

The result of the above equation comes out in terms of few hundred nanoseconds. Remember, we are still talking in terms of time and frequency. We still need to calculate the maximum cable length. The maximum cable length will differ from cable to cable. This is because the signal travels at different velocities in different types of cables. For example, the signal travels at a speed of 83% of speed of light. In case of RG405, the signal travels at a speed of 70.3% speed of light. This velocity of propagation is denoted mathematically as $$v_p$$.

$$\text{Therefore, maximum cable length }= v_p \times \mathcal{c}$$

There's nothing to be afraid of. We are all familiar with the relation of $$\text{speed, distance & time}$$.

$$speed = \frac{distance}{time}$$

Now, try to relate this with the equation stated previously to compute maximum cable length.

Our basics are now clear, so we should be fine to proceed with handling the actual data from the VNA.

Now, how do we get access to our return loss data? Like we saw in our previous nanoVNA review, we will make use of the nanoVNA Windows application here. Make sure that you calibrate your device before proceeding further. Again, if you wish to know how to calibrate nanoVNA, head back here. Now, coming back to our main question, how do we access return loss data? The windows application allows us to save a touchstone S-parameter file. It is marked as "S1P" on one of the buttons. We shall use this feature to retrieve the data.

## The setup

Before we move any further, let me explain the setup.

All you need is your nanoVNA kit and a piece of cable with a connector on one end that can be attached to the VNA. Oh, you will also need a PC to run the VNA application and the python script.

As indicated above, calibrate your VNA and connect a piece of cable to the VNA port. Make sure that the other end of the cable is left open and not connected anywhere.

Now, click the "Save S1P" button to save the one port return loss measurement.

## The python script

I wrote a little script that does the following things:

• Read the S1P file and get S-parameter data $$S_{\text{11}}$$
• Get the frequency step size. $$\Delta F$$
• Calculate maximum reflection time and in turn, calculate maximum distance measurable
• Transform $$S_{\text{11}}$$ from frequency domain to time domain using Inverse Fast Fourier Transform
• Find the peak in time data and corresponding time at which it occurred. This peak corresponds to the reflection occurring from the open end of the cable
• Compute the distance by multiplying $$v_p$$ with time.

For everyone's relief, I am attaching the entire script here.

## Real Results

Everyone must be looking forward to watching this section of the article. I tested this script by connecting a small 36 inches of RG405 cable which comes to approximately 0.91 meters. The velocity factor for RG405 cable is 70.3% which is set in the code at line 8. After doing all sort of computation, line 25 prints out the distance in meters.

Comparing the actual cable length which is 0.91 meters and then looking at our results gives me great satisfaction. The error is quite small and it could even be due to calibration or temperature drift. Of course, an error of 3cm is unacceptable if you are working in the GHz range and you shouldn't be even using this instrument in the first place.

Let us measure another cable, this time a LMR200. Now, the exact length of cable we are about to test is unknown to me. According to the markings on the cable, it should be somewhere in the range of 9.5 to 10 meters. The peak indicating reflection from the open end of the cable shifted to the right. This indicates that our concept is definitely working.

The most noticeable change on the graph is the shifted peak. Our source of reflection, which is the open end of the cable extended further due to a larger cable length. The time taken by the signal to traverse through the cable is much more. On the other hand, our script computed the cable length and it matches our expectation. Considering an error of 3cm based on our previous measurement of a shorter cable, we can say that this reading is totally ACCEPTABLE! Our expectation of the cable length was somewhere between 9.5 meters to 10 meters and our script computed the length as 9.639 meters!

## Where do I plan to use this?

When you are constructing antenna arrays, the feed cable length needs to be precise. This is required so that the antennas are phased correctly and in turn operate as expected. Without relying on expensive equipment, I can now do cable length matching sitting at home.

Our little script can also work to find faulty cables. Distance to fault can be known by looking at the graph and observing the measurements carefully.

Additionally, we can also figure out bad, faulty connectors by looking at the time domain graph. Badly soldered connectors are quite common and sometimes hard to spot but not anymore with TDR!

Having a nanoVNA surely opens many avenues for hobbyists. I am hoping that once enough people get their hands on this device, we will start to see so many other interesting experiments starting to pop-up over the internet. Not to forget, we might even see a FULL 2-port VNA pop up someday which could be affordable by hobbyists like me.