Showing posts with label amateur-radio. Show all posts
Showing posts with label amateur-radio. Show all posts

Monday, March 07, 2016

MATLAB Smith Charts

Last time, I posted a procedure for creating Smith charts by hand.


This time, I’d like to continue the process by showing my procedure for using Matlab® or GNU Octave to create these charts.


I should note that Matlab® already has a “smithchart” function, that does a pretty good job. But if you’d like to customize the chart or do it in GNU Octave, this process might be better. Matlab®’s function will plot a reflection coefficient for you, while the script presented here does not.


Matlab® or Octave, the smithchart function or script doesn’t do the \(Z\) to \(\Gamma\) conversion for you. The function simply draws the circles on in Cartesian coordinates. You still have to convert an impedance to a reflection coefficient.


$$\Gamma = \frac{Z - Z_0}{Z + Z_0}$$


where is the basis impedance for the chart.

The real and imaginary part of the reflection coefficient will be the and coordinates that to plot.

Zero reactance line

The zero reactance line is the axis. We just draw a line from -1 to 1.


x = linspace (-1, 1, 256);
y = zeros (1, length (x));

plot (x, y,'k');

% We don't show the axis, but we need to scale it.
axis ([-1.15, 1.15, -1.15, 1.15]);
axis off;

hold on


Zero Reactance Line




Resistance Circles



We will not plot complete circles for all resistances. This will lead to a very cluttered chart on the right hand side. Instead we will start and stop them at strategic locations on the chart.


The complex impedance can be broken down into


$$Z=A+jB$


Where is the resistance and is the reactance. In a Smith Chart, all impedances are normalized to one. The reflection coefficients for the circles become



A = [.2 .5 1 2]; Blim = [1 2 5 2];

for idx = 1:length(A);
    B = linspace (-Blim(idx), Blim(idx), 256);
    rho = (A(idx)^2 + B.^2 - 1 + 2i * B) ./ ...
      ((A(idx) + 1).^2 + B.^2);

    plot (rho, 'k');
end


Resistance Circles


Some resistances can have full circles, namely, the -, -, and circles. However, we will never be able to complete the circles using the technique above. The right hand side of the chart is infinity.

Instead, we just make Cartesian circles at those points. It’s easier and saves memory.


theta = linspace (0, 2 * pi, 256); A = [0 5 10];

for idx = 1:length (A)
    cx = A(idx) ./ (A(idx) + 1);
    rx = 1 ./ (A(idx) + 1);

    plot (rx * cos (theta) + cx, rx * sin (theta), 'k');
end

Full resistance circles at 0, 5, and 10 ohms.


Constant Reactance

Like resistance, we don’t draw complete circles for the reactances. They start at and end at various resistance circles in the chart. The technique is the same, but we don’t have any reactances that go all the way to the side of the chart.


Alim = [.5 .5 1 1 2 2 5 5 10 10]; % Resistance endpoints
                                  % for each reactance
                                  % line
B = [-.2 .2 -.5 .5 -1 1 -2 2 -5 5];

for idx = 1:length (B)
    A = linspace (0, Alim(idx), 256);
    rho = (A.^2 + B(idx)^2 - 1 + 2i * B(idx)) ./ ...
      ((A + 1).^2 + B(idx)^2);
    plot (rho, 'k');
end
Reactance Arcs


Resistance and Reactance Markings

% Resistance markings are on the zero-reactance line.
A = [0.2 0.5 1 2 5 10]; B = zeros (1, length (A));
rho = (A.^2 + B.^2 - 1 + 2i * B) ./ ((A + 1).^2 + B.^2);

% Offset the text slightly
xoffset = [0.1 0.1 0.05 0.05 0.05 0.075]; 
yoffset = -0.03;

for idx = 1:length (A)
    text (real (rho(idx)) - xoffset(idx), ...
        imag (rho(idx)) - yoffset, num2str (A(idx)));
end

% Let's put the reactance markings outside of the
% zero-resistance circle.
A = [-0.075 -0.075 -0.075 -.1 -0.125];
rho = (A.^2 + B.^2 - 1 + 2i * B) ./ ((A + 1).^2 + B.^2);

for idx = 1:length (B)
    text (real (rho(idx)), imag (rho(idx)), ...
        strcat ('j', num2str (B(idx))));
    text (real (rho(idx)), -imag (rho(idx)), ...
        strcat ('-j', num2str (B(idx)))); end

% Zero for resistance and reactance. 
rho = (-0.05.^2 + 0.^2 - 1) ./ ((-0.05 + 1).^2 + 0.^2);

text (real (rho), imag (rho), '0');

hold off;
Resistance and Reactance Markings


Plotting on the Chart

To plot a value on the chart, calculate the reflection coefficient for the point and use Matlab’s plot function after issuing the hold on command.

Sunday, January 24, 2016

DIY Smith Charts

The Smith chart is an elegant way to visualize the complex values used in an electronic design. When appropriate, I like to include one when I present my antenna and transmission line work. The chart papers that you can buy are good for doing the actual calculations, but it is hard to get them into an online presentation.

The term "Smith Chart" is a trademark of Analog Instruments Company of Providence, NJ, which distributes printed charts. Blank charts are also available from the American Radio Relay League, of Newington, CT, http://www.arrl.org

This tutorial gives a procedure for making simple Smith charts. It can be applied to many different drawing packages, including Microsoft Office Shapes, Inkscape, or even to drawing them by hand.

Drawing the charts by hand takes patience, but it can be done. I recommend using a set of dividers to accurately position the circles and arcs on their respective axes.

Mathematics


The basis for the chart is the reflection coefficient, \(\rho\), defined by the equation

$$\rho = \frac{\frac{Z}{Z_0} - 1}{\frac{Z}{Z_0} + 1}$$

Where \(Z\) is the complex impedance, \(R+jX\), and \(Z_0\) is a reference impedance to normalize it. \(Z_0\) is often chosen to be the characteristic impedance of a transmission line we are working with, like 50 or 450 ohms.
\(\frac{Z}{Z_0}\) is itself a complex value. If we let A be the real (resistance) part, and B the imaginary (reactance) part, the expression for \(\rho\) becomes

$$\rho = \frac{A^2 + B^2 - 1 + j2B}{\left(A + 1\right)^2 + B^2}$$

The lines on the chart are reflection coefficient points where either the resistance is held constant and the reactance varies from minus to plus infinity or vice versa.

Because of the logarithmic nature of the chart, choosing indices of 0.2, 0.5, 1.0, 2.0, 5.0 and 10 yields nice, even divisions.\

Zero Resistance, Zero Reactance


Zero resistance is represented by the circle that defines the outer edge of the chart. The left side of the circle is \(A=0\), \(B=0\). Looking at the equation above, you can see that as \(A\) gets very large, \(\rho\) approaches \(1\). This is the right side of the circle.

Zero reactance is a line through the middle of the chart. You can also think of this as another circle of infinite radius, centered at infinity.

Zero Resistance Circle, Zero Reactance Line
Zero Resistance, Zero Reactance

It helps to draw a line perpendicular to the zero reactance line when constructing the chart with a compass and ruler. This line is the \(A=\infty\) axis, and is where the constant reactance circles are centered.

Constant Resistance Circles


Constant Resistance Circles

Now the chart gets interesting. From the reflection coefficient equation, we can show\footnote{See notes at the end of the tutorial.} that the radius of each constant resistance circle is

$$r = \frac{1}{A+1}$$

and that the center is at

$$x = \frac{A}{A+1}$$

where \(x\) is the linear value along the \(B=0\) axis, \(-1\) to \(1). These values are shown below.

ACenterRadius
001
0.20.1666670.833333
0.50.3333330.666667
1.00.50.5
2.00.6666670.333333
5.00.8333330.166667
100.9090910.090909

Constant Reactance Circles


Adding Constant Reactance Circles

It can also be shown that the center of each constant reactance circle along the \(A=\infty\) axis is

$$y = \frac{1}{B}$$

The radius is

$$r = \left|\frac{1}{B}\right|$$

The centers and radii for the circles are shown in the following table.

BCenterRadius
-5.0-0.20.2
-2.0-0.50.5
-1.0-1.01.0
-0.5-2.02.0
-0.2-5.05.0
0.25.05.0
0.52.02.0
1.01.01.0
2.00.50.5
5.00.20.2

By the way, setting\(A\)equal to zero in the reflection coefficient equation gives the point where the constant reactance and zero resistance circles intersect.

$$\rho = \frac{B^2 + j2B - 1}{B^2 + 1} = -\frac{1-jB}{1+jB}$$


Numbering and Formatting


I like to number the resistance circles along the zero reactance line, and number the reactance circles around the zero resistance circle.

Instead of complete constant resistance circles, I suggest stopping them at strategic points. Since everything on a Smith chart is centered on the right side at \(B=0\), it tends to get a little cluttered there.

The Decluttered Chart


To create the chart above, select the desired circle that is being drawn, and then the conjugate circle where it stops. Enter these as A and B.

$$\left(x - \frac{A}{A+1}\right)^2 + y^2 = \left(\frac{1}{A+1}\right)^2$$

$$\left(x - 1\right)^2 + \left(y - \frac{1}{B}\right)^2 = \frac{1}{B^2}$$

Simplifying,

$$y^2 = \left(\frac{1}{A+1}\right)^2 - \left(x - \frac{A}{A+1}\right)^2 \\
>= x^2 - \frac{2A}{A+1}x + \frac{A^2+1}{\left(A+1\right)^2}$$

$$y = x - \frac{\frac{2A}{A+1} \pm \sqrt{\frac{4A^2}{\left(A+1\right)^2}-\frac{4A^2+4}{\left(A+1\right)^2}}}{2} = x - \frac{A\pm2}{A+1}$$

$$x^2 - 2x + 1 + y^2 - \frac{2y}{B} + \frac{1}{B^2} = \frac{1}{B^2} \\
x^2 - 2x + y^2 - \frac{2y}{B} = -1$$


Of course, to draw the chart by hand, simply use the centers and radii found in the tables above.

Notes


Derivation Radius and Position of the Constant Resistance Circles


Setting \(B\) to zero in the reflection coefficient equation gives the point where the right side of the constant resistance circle intersects the zero reactance axis.

$$\rho = \frac{A^2-1}{\left(A+1\right)^2} = \frac{A-1}{A+1}$$

The radius of the circle will be the distance from there to the right side of the zero resistance circle (\(x=1\)).

$$\frac{1 - \left(A - 1\right)/\left(A + 1\right)}{2} = \frac{1}{A+1}$$

And the center will be

$$1 - \frac{1}{A+1} = \frac{A}{A+1}$$

This gives a standard form for the equation of the circles as

$$\left(x - \frac{A}{A+1}\right)^2 + y^2 = \left(\frac{1}{A+1}\right)^2$$

Derivation of the Height of the Constant Reactance Circles


Constant Reactance Circle Construction

Right triangle DEF has angle \(\alpha\) at the point where the constant reactance circle intersects the zero resistance circle.



Since sides D and H are parallel, angles \(alpha\) and \(rho\) are equal. This means that triangles DEF and FGH are similar, because they share a side and each have two equal angles (angle-angle-side).  Therefore, the ratios of side F to side D for triangle DEF is the same as the ratio of triangle FGH side H to side F. We can express side H in terms of sides F and D



$$H=\frac{F}{D} F = \frac{F^2}{D}$$



From Pythagorean theorem,



$$F=\sqrt{D^2 + E^2}$$



\(E\) is the radius of the zero resistance circle, \(1\) minus the real part of the zero-resistance - constant reactance intersection, \(C\).



This gives us the expression for \(H\).



$$H = \frac{D^2 + \left(1-C\right)^2}{D}$$



\(C\) and \(D\) come from the reflection coefficient equation.



$$H=\frac{\left(\frac{2B}{B^2+1}\right)^2+\left(1-\frac{B^2-1}{B^2+1}\right)^2}{\frac{2B}{B^2+1}}=\frac{4B^2+4}{{2B}\left(B^2+1\right)}=\frac{2}{B}$$



The center and radius of the constant reactance circle will be\(1/2H = 1/B\).



The standard form for the circle becomes



$$\left(x - 1\right)^2 + \left(y - \frac{1}{B}\right)^2 = \frac{1}{B^2}$$

Tuesday, May 19, 2009

Hamvention

I went to the Dayton Hamvention last Friday. I ended up traveling by myslef, but it was a great time. With it being a one-day trip, I skipped the forums, and concentrated on what was going on in the exhibit halls.

My biggest purchase was a new Byonics TinyTrak4 and GPS. I told Byon that I didn't need a null modem, as I had one at home, and couldn't find it when I got back. I then realized that Walmart no longer carries any serial cables or other accessories. Same for many of the other department stores. I haven't had a chance to pop into my local electronics store.

I had one bum purchase...I bought a digital photo frame. I usually don't go for non-ham items at hamfests, but we've been wanting one, and these seemed like a good deal; new in box, great price. I got home and discovered that the fluorescent panel behind the LCD was not working. I ended up throwing it away. Yes, I could have messed with it...I have heard of people turning them into LCD projectors, other things, but I have plenty to keep me busy. I learned a lesson, and I won't buy open stock at a hamfest anymore. I sort of wish these guys would stop taking up space there.

Tuesday, April 14, 2009

SWR Indicator

I added the Hendricks QRP Kits SWR Indicator to the MFJ QRP Cub this week. I found room for it on the back panel of the little box.

This is a little return-loss bridge that was designed by Dan Tayloe, N7VE.

The kit went together fairly well, and the instructions were easy to understand, especially with all of the photos. The hardest part was how to get the signals in and out of the board. I settled on using short pieces of RG-174 running from the RCA plug to the board, and from the board to a new BNC bulkhead connector. Even with RG-174, it was hard getting the shield into the holes on the board. I eventually got it, but it looks a little ugly.

Pictures to follow as soon as I can take some

Wednesday, August 20, 2008

More Satellite Page Hacking

Writing bookmarklets can become addictive. Here is one similar to the AMSAT hack for Heavens-Above. Go to the Heavens-Above amateur satellites page (once you've registered,) and then paste the following code in the Address bar:

javascript:(function(){var%20minElev=Number(prompt("Enter%20minimum%20elevation.","30"));var%20table4=document.getElementsByTagName('table')[4];var%20row=2;while(row<table4.rows.length){if(table4.rows[row].cells[5].innerText<=minElev){table4.deleteRow(row);}else{row=row+1;}}})()

Monday, August 11, 2008

Outer Banks and Radio


I just came back from a vacation to the outer banks. While we were planning, Lennie found a ham radio connection there. It turns out that the Outer Banks is where Reginald Fessenden proved the viability of AM Radio during tests he made there in 1901-1902. The photo is from the marker at Weir Point. There is another marker just over the bridge to Pea Island. We passed it, but were pretty tired from our trip to Ocracoke and didn't feel like stopping. Besides, as Lennie said, "How many Fessendens does any one person need?" More info and a photo of the other marker are in a paper by VE2VC (PDF).

I got a chance to operate QRP from the beach this trip. My station consisted of an MFJ 40-meter QRP Cub transciever, an MFJ 30-meter 9030 transciever, and a Hendricks QRP Kits SL Tuner. For most of the trip, I used a 51-foot length of copperweld tied to the wooden handrail of the walkway leading out to the deck. I had a 16-foot length of copperweld dangling down to the sand for a counterpoise. I didn't have much luck on either 40 or 30 meters. Finally, on the last day, I got out my DJ9SQ mast and set it up with a "folded vertical" fed by the SLT. The 51-foot length of copperweld became another radial. This time I had better luck on 30 meters. I just need to brush up my code. Apologies to those I assaulted with it.

Update: Another great article on Fessenden and the Outer Banks is at coastalguide.com.

Posted by Picasa

Thursday, July 31, 2008

Why do hams hate proprietary codecs?

Recently, WinDRM took down its downloads because it used the MELP codec by default for encoding voice. It was restored to change the default to an open-source codec. Read about it at ARRL's web site

I have heard people telling me they won't use D-Star because it uses the proprietary AMBE 2020 codec. Never mind that the rest of the protocol is free for amateurs to use.

The normal way these codecs are used is to embed them in a chip, which, when you pay for it, goes to license the intellectual property inside.

Think of it this way. DeForest vigorously defended his patents. You could use his tubes in your radio, but if you tried to copy his tube and sell it as your own, you got sued.

It gets more complicated in the WinDRM case, and the analogy gets a little frayed. WinDRM used a freely-available copy of what is normally sold by TI and other companies. Back in 1915, no one would think of making a copy of an Audion tube and giving it away, but imagine someone did. Maybe they hated Dr. DeForest. Do you think that it would go unchallenged?

TI and the other rights holders are protecting their interests. They winked at hams for a while, but no more. If they don't protect their interest in this codec, which is used by the US Department of Defense and others, they will appear to have abandoned it and will no longer be able to sell it.

Either buy the chips, license the codec (in which case you'd have to start charging for WinDRM) or come up with your own. Amateur HF digital voice is begging for an open-source codec with a similar performance. How about a homebrew transciever in QST that uses AMBE-2020 chips?

Friday, July 11, 2008

More AMSAT Website Hacking

AMSAT has a page that predicts satellite passes. My problem with it is that it lists ALL of the passes, including ones that just graze the horizon. I generally tend to avoid them.

The following bookmarklet clears out all passes from the table of results that are less than 30 degrees above the horizon. Go to the AMSAT Prediction and get a list of passes for a satellite. Then paste the following code in your browser's address window and tell it to go. It should shorten the table.

***UPDATE - An error crept in when I posted this before...I had the row variable running to row <= table5.rows.length, and it ran over the end of the table, giving errors. The version below seems to work better.

***UPDATE - Added a prompt for the minimum elevation.

javascript:(function(){var minElev=Number(prompt("Minimum Elevation","30"));var table5=document.getElementsByTagName('table')[5];var row=2;while(row<table5.rows.length){if(table5.rows[row].cells[4].innerText<minElev){table5.deleteRow(row);}else{row=row+1;}}})()

It works in IE 6 and Firefox 2.0.0.15.