Thursday, September 13, 2012

"Wire-to-wire" emulation with Proxy ARP

In my previous post, I stated a goal of mimicing the connectivity provided by the microwave T-1 connecting the studio and TV transmitter at my work.  I'm pleased to say that I've accomplished that... mostly.  There are still a few peculiar kinks to work out.

It all works through the magic of Proxy ARP.  Basically, what Proxy ARP does is allow one machine to answer ARP queries on behalf of another machine, saying, in effect "I'll take that packet; I know how to get to that machine".  The answering machine then forwards the packet on to the appropriate machine.  This differs from packet routing in that it happens in Layer 2 of IP, rather than Layer 3 (routing).

In practice, what you have to do is set up static routes on the host (which is acting in this case as a bridge) doing Proxy ARP for all hosts the bridge is providing the connection for, then turn on IP forwarding in the kernel, and turn on Proxy ARP for the appropriate interfaces.  Since I have an IPsec / L2TP VPN set up, the interfaces are going to be ppp0 for the VPN (since it's L2TP and IPsec, PPP is involved, where with straight IPsec it wouldn't be) and eth0 for the local network. I'm also going to have to do the same thing on the firewall out at the transmitter.

So, first of all, the studio.  This is based on Using Linux as an L2TP/IPsec VPN client by Jacco de Leeuw.

The xl2tpd configuration file at the studio:

; File: /etc/xl2tpd/xl2tpd.conf at STUDIO
[lac Transmitter]
; transmitter public IP obfuscated for security reasons
  lns = X.X.X.10 
  require chap = yes
  refuse pap = yes
  require authentication = yes
  ; Name should be the same as the username in the PPP authentication!
  name = bridge
  ppp debug = yes
  pppoptfile = /etc/ppp/options.l2tpd.client
  length bit = yes

Note that I'm not using the l2tp-secrets file as it really doesn't provide any additional security, as far as I can tell.

The PPP options file at the studio:
# /etc/ppp/options.l2tpd.client at STUDIO

ipcp-accept-local
ipcp-accept-remote
refuse-eap
noccp
noauth
crtscts
mtu 1410
mru 1410
nodefaultroute
debug
lock
connect-delay 5000

PPP authentication is done in /etc/ppp/chap-secrets:

# File: /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client        server          secret                  IP addresses
bridge          *               "supersecret"
*               bridge          "supersecret"

To set up the static routes, I have set up two scripts in /etc/ppp/ip-up.d. Scripts in this directory are executed by pppd as ip-up scripts - scripts that are executed when the PPP interface is brought up. These set up static routing and turn on Proxy ARP.

#!/bin/bash

# File: /etc/ppp/ip-up.d/0001routes

PPP_INTERFACE=$1
LOCAL_ADDR=$4
REMOTE_ADDR=$5

# These are all the hosts that should be accessible both via the VPN
HOSTS=(
10.1.1.10
10.1.1.11
10.1.1.12
10.1.1.13
)

for HOST in ${HOSTS[*]}
do
        route add -host $HOST $PPP_INTERFACE
done


#!/bin/bash

# File: /etc/ppp/ip-up.d/0002proxyarp

for INTERFACE in ppp0 eth0 ; do
        /sbin/sysctl -w net.ipv4.conf.${INTERFACE}.proxy_arp=1
done




The ipsec (openswan) configuration file at the studio:


# File: /etc/ipsec.conf
# 
config setup
        protostack=netkey
conn Transmitter
        #
        # ----------------------------------------------------------
        # Use a Preshared Key. Disable Perfect Forward Secrecy.
        # Initiate rekeying.
        # Connection type _must_ be Transport Mode.
        #
        authby=secret
        pfs=no
        rekey=yes
        keyingtries=3
        type=transport
        #
        # ----------------------------------------------------------
        # The local Linux machine that connects as a client.
        #
        # The external network interface is used to connect to the server.
        # If you want to use a different interface or if there is no
        # defaultroute, you can use:   left=your.ip.addr.ess
        left=%defaultroute
        #
        leftprotoport=17/1701
        #
        # ----------------------------------------------------------
        # The remote server.
        #
        # Connect to the server at this IP address. (obfuscated for security)
        right=X.X.X.10
        #
        rightprotoport=17/1701
        # ----------------------------------------------------------
        #
        # Change 'ignore' to 'add' to enable this configuration.
        #
        auto=add
        DPDACTion=restart_by_peer
        dpdtimeout=30
        dpddelay=3

Next, the transmitter side.  Again, starting with xl2tpd:



; File: /etc/xl2tpd/xl2tpd.conf

[global]
        ipsec saref = no
        listen-addr = X.X.X.10

[lns default]
        ip range = 10.1.1.100 - 10.1.1.255
        local ip = 10.1.1.1
        assign ip = yes
        require chap = yes
        refuse pap = yes
        require authentication = yes
        name = Transmitter
        ppp debug = no
        pppoptfile = /etc/ppp/options.xl2tpd
        length bit = yes

And now PPP:

# File: /etc/ppp/options.xl2tpd

refuse-mschap-v2
refuse-mschap
ms-dns 8.8.8.8
asyncmap 0
auth
lock
hide-password
local
#debug
name l2tpd
#proxyarp
lcp-echo-interval 30
lcp-echo-failure 4


# File: /etc/ppp/chap-secrets

# Secrets for authentication using CHAP
# client                server                  secret                  IP addresses
user1                   *                       "secret1"               10.1.1.0/24
*                       user1                   "secret1"               10.1.1.0/24
user2                   *                       "secret2"               10.1.1.0/24
*                       user2                   "secret2"               10.1.1.0/24
bridge                  *                       "supersecret"           10.1.1.2
*                       bridge                  "supersecret"           10.1.1.2

Here I want to pause and note something. I have my regular "road warrior" users set up to get any address in 10.1.1.0/24, and in my xl2tpd config, I have that further restricted to addresses in the range of .100 - .255. The "bridge" user is restricted to 10.1.1.2, which is how I allow my "road warriors" and the bridge at the studio to coexist. The appropriate scripts in /etc/ppp/ip-up.d at the transmitter:


#!/bin/bash

# File: /etc/ppp/ip-up.d/0001routes
# The hosts here are made accessible to the transmitter network via the firewall, which is acting as a bridge similar to the one at the studio

PPP_INTERFACE=$1
LOCAL_ADDR=$4
REMOTE_ADDR=$5


# only set up the routes for the VPN bridge
case $REMOTE_ADDR in
10.1.1.2)
        for HOST in     10.1.1.20 \
                        10.1.1.21 \
                        10.1.1.22 \
                        10.1.1.23 ; do
                route add -host $HOST $1
        done
esac



#!/bin/bash
PPP_INTERFACE=$1
LOCAL_ADDR=$4
REMOTE_ADDR=$5

# File: /etc/ppp/ip-up.d/0002proxyarp
# only set up Proxy ARP for the VPN bridge
case $REMOTE_ADDR in
10.1.1.2)
        for INTERFACE in $PPP_INTERFACE eth0 ; do
                /sbin/sysctl -w net.ipv4.conf.${INTERFACE}.proxy_arp=1
        done
esac

And finally the ipsec (openswan) configuration, based on Configure L2TP/IPSec VPN on Ubuntu by Riobard Zhan:

#
# File: /etc/ipsec.conf
#

# Transmitter Firewall Side

config setup
    oe=off
    protostack=netkey
    nat_traversal=yes

conn L2TP-PSK-NAT
    rightsubnet=vhost:%no
    also=L2TP-PSK-noNAT

conn L2TP-PSK-noNAT
    authby=secret
    pfs=no
    auto=add
    keyingtries=3
    rekey=no
    ikelifetime=8h
    keylife=1h
    type=transport
        left=X.X.X.10
    leftprotoport=17/1701
    right=%any
    rightprotoport=17/%any
    dpdaction=restart_by_peer
    dpdtimeout=30
    dpddelay=3

So the way to accomplish this "wire-to-wire" emulation is with two bridges, one for each network to be bridged. If you want to try something like this, I wish you the best of luck, and I hope my experiences help.

Tuesday, August 21, 2012

Setting up an IPsec VPN

Posted here mostly for my own reference, but mayhap this will prove useful for someone else.

The setup: a remote network at the TV transmitter, with Internet access both through a commercial provider and a dedicated, but increasingly unreliable, microwave T-1 link to the studio.

The goal: mimic the behavior of the microwave T-1 (though not the unreliability, of course) using the commercial provider's service.  Set up a "virtual wire" between the network at the transmitter and the transmitter at the studio.

I've chosen an IPsec VPN to do this, and I've set things up largely as in Ch. 35 of Linux Home Networking. At the present time I've managed to achieve bidirectional communication between hosts (but not the routers/firewalls) on each network, but to do that I had to set up a private test network as shown below.


So as you can see here, I have a couple of virtual machines set up on the 172.16.1.0/24 network, which is accessible only to those VM's.  The IPsec tunnel is established between Router VM and Transmitter Firewall.  Note that I have replaced Transmitter Firewall's public IP address with "X.X.X.10" for security.

With this setup, I can achieve bidrectional communication between both networks.  Host A can reach Client VM, and Client VM can reach Host A.

Here is the relevant ipsec.conf on Router VM:

#
# File: /etc/ipsec.conf
#
# VPN Test Router VM side
config setup
        protostack=netkey
        oe=off
        nat_traversal=yes

# LEFT: Studio
# RIGHT: Transmitter
conn nettonet
  left=192.168.152.188            # Public Internet IP address of the
                                  # LEFT VPN device
  leftsubnet=172.16.1.0/24        # Subnet protected by the LEFT VPN device
  leftrsasigkey=*removed*

  right=X.X.X.10                  # Public Internet IP address of
                                  # the RIGHT VPN device
  rightsubnet=10.1.1.0/24         # Subnet protected by the RIGHT VPN device
  rightrsasigkey=*removed*
  rightnexthop=%defaultroute
  auto=start


Note here that I'm using RSA keys, rather than PSK's.  The key signatures have been removed for security.

The ipsec.conf on Transmitter Firewall is slightly different:


#
# File: /etc/ipsec.conf
#

# Transmitter Firewall Side

config setup
    oe=off
    protostack=netkey
    nat_traversal=yes

# LEFT: Studio
# RIGHT: Transmitter
conn nettonet
  left=10.1.0.2                   # Public Internet IP address of the
                                  # LEFT VPN device
  leftsubnet=172.16.1.0/24        # Subnet protected by the LEFT VPN device
  leftid=192.168.152.188
  leftrsasigkey=*removed*
  right=X.X.X.10                  # Public Internet IP address of
                                  # the RIGHT VPN device
  rightsubnet=10.1.1.0/24         # Subnet protected by the RIGHT VPN device
  rightrsasigkey=*removed*
  auto=start                      # authorizes and starts this connection
                                  # on booting

Here you'll notice that the argument to left= is 10.1.0.2, which is the public (again, these IP's have been obfuscated for security's sake) address of Studio Firewall. This is because Router VM's ultimate path to the Internet is through Studio Firewall via NAT.

Speaking of NAT, I should point out that there is no NAT of any kind being performed (currently) on Router VM or Transmitter Firewall.  Instead, the entire 172.16.1.0/24 network is visible to the 10.1.1.0/24 network at the transmitter, just as any other public network would be.

I'll note that this does not accomplish the stated goal at the beginning of this post: set up a "virtual wire" between the 10.1.1.0/24 network at the studio and the 10.1.1.0/24 network at the transmitter.  It may turn out to be the case that this "virtual wire" is extremely complicated with regard to routing and suchlike (since we would be using the same IP block on both ends) .  What this does give us, however, is a place to work from.

Friday, December 30, 2011

Making a homebrew HDTV antenna

Since I work for a TV station now, and we're web-casting a lot of University sports, it behooves me to get more familiar with sports broadcasting, and one of the ways I'm doing that is to watch sports on TV.  Now, I'm still too cheap to pay for cable TV, I'm on my holiday break, and most importantly I haven't built an antenna since my J-pole, so I figured I ought to build myself a TV antenna. 

I'm basing this antenna on plans I found for a UHF bowtie antenna here.  Now, being the sort of guy I am, I can't just blindly follow the recipe. :)  I need to screw around with it a bit, and see if I can improve on the design based on my own particular situation. 

I went to TV Fool's signal locator and put in my address.  It gave me a handy list of all the TV broadcast stations in the area, along with their channel assignments (if you're following along at home, note that you need the actual channel assignment, not the virtual channel.  Sometimes these two things are different).  Next, I consulted Wikipedia for a list of TV channels and associated frequencies.  This told me that all the TV stations in town were in the range of 494 MHz to 698 MHz. 

I think it's safe to assume that the original design is tuned for a broader frequency range than I need.  If I tune the design for my narrower range, maybe I can get another dB or two of gain, which will improve my signal quality.  Also, it's more fun that way. :)

Now for the parts.  I went to the hardware store and bought some deck screws, some washers, and a 2 x 4.  They didn't have any 1 x 3's or 2 x 3's, and I didn't much feel like going somewhere else to see what they had.  I also bought a 75Ω to 300Ω balun, as called for in the design (this design has a 300Ω characteristic impedance).  For the antenna bays, I've got some old wire hangers laying around that need to be put to a good use.  I've also got wire laying around that I can use to interconnect the bays.

In the design, each antenna bay is a pair of 14" wires, folded into a "V" whose ends are 3" apart (so an angle of about 25°).  This is a bowtie antenna, so each side of the bay is a dipole 1/2 wavelength long.  14" gives a wavelength of about 420 MHz, well below the minimum frequency I'm looking for. 

Let me pause a moment to detail how I'm calculating the length of the dipole.  Wavelength (λ) is equal to the speed of light (c) divided by the frequency (f).  So:

λ = c/f

An important thing to note here is that c isn't always c, if you take my meaning.  Generally speaking, if someone mentions c in the context of the speed of light, they mean the speed of light (or other electromagnetic radiation) in a vacuum.  In (e.g.) a metal, however, electromagnetic radiation moves more slowly.  So we introduce a velocity factor, a number that describes just how much slower electromagnetic radiation is going to move in the material than in free space.  If we call the velocity factor v, then we get:

λ = cv/f

This is good.  By introducing the velocity factor into the equation, we can more precisely model how electromagnetic radiation (e.g. radio waves) is going to behave in the wire of the dipole.  But I don't have a velocity factor for steel wire (which is what they make wire hangers out of), so I'm just going to use a value of 1 for v

So, back to the antenna, if I want a minimum frequency of 494 MHz, I want to start with a dipole about 12" long.  I can always trim it down later if I need to.

Now, let's get to building!  To start with, I'm going to cut my wire hangers into 8 12" pieces.  And this is tougher than it sounds.  A pair of dikes (diagonal cutters) won't cut it.  Tin snips won't do it.  A stout pair of side-cutters (or "Kleins", electrician's pliers) might do it, but I don't have a pair of those.  What I'm doing instead is taking a big pair of dikes and gripping the wire where I want it to break, then just wiggling the hanger back and forth until it breaks.  Metal fatigue FTW!
8 12" dipoles


As you can see, some of these aren't exactly straight.  A number of wire hangers came from the dry cleaner, and they only have metal on top - the bottom is just thick paper.  So I straightened those as best I could.  I also sanded the center of each dipole because  I'm going to short all the dipoles along each side together at the center.

Dipoles bent so that the distance between each leg is roughly 3"






Here are the bent dipoles.  I've tried to keep the spacing between the two legs to about 3 inches.









Now comes the fun part: drilling the holes and mounting the dipoles.  I got a cordless drill as an early Christmas present; time to put it through its paces!

As per the plans, I drew a line across the board at 2" from one end, then 3 more lines at 5 1/4" intervals (so marks at 2", 7.25", 12.5", and 17.75").  These lines are where the two dipoles in each antenna bay will be placed.




Next, I made two perpendicular marks on each line, 1" apart.  I like things to be even, so I centered the marks, placing them 1.25" from each edge (a 2 x 4 is actually 3.5" wide).  I then drilled pilot holes at each mark for the deck screws.
Here you can see the board with the deck screws already part of the way in.  This makes it easier to place the elements and the connection wire.  I also have two small steel washers on each screw.  The lower holds the dipole element to the board.  The upper will pinch the connection wire between it and the lower washer, providing electrical connectivity.

Next, I added the connection wires between each element. I used insulated wire, and I only stripped those parts of the wire that were going to be in electrical contact with an antenna element.  I've also stripped a place in the center of the antenna to connect the balun.


Here you can see the deck screws where the balun will connect.  Like the other screws, these have washers on them to improve the electrical connection between the wire and the balun.
And this is the antenna with the balun attached.  This is a usable antenna right now, but it's omnidirectional.  Adding a reflector, as recommended in the original plans, will increase the gain of the antenna, but you might want to try this antenna as-is and see how well it works for you. 



I mounted the antenna, sans reflector, in my basement and attached it to my TV.  I'm able to pull in all the stations that TV Fool says are available in my area, including the two analog low-power stations.  But none of those transmitters are more than 30 miles from me, and I don't have any channels from further away.  Once I get the antenna mounted outside, and the reflector attached, I'll report back.







Saturday, April 23, 2011

"What news from Plymouth?"

Well, so far as I am aware, Plymouth continues to be in Massachusetts. If this situation should change, I hope one of you, Dear Readers, will be so good as to tell me.

News in my neck of the woods has nothing to do with Plymouth at all. However, if you're stuck on Plymouth, I suggest this brief riveting look at the court of Elizabeth I (Plymouth was an English colony during her reign).

Now, the news of your humble polymath-in-the-making. To begin with, Dear Reader, you might be wondering why the promised posts from NAB never materialized. This is because I did not go to NAB, and I will not be going to the Radio Ink Convergence Conference either. In fact, I have been disqualified altogether from the Technology Apprenticeship Program, and that's because I got a job at KTBG and KMOS, the public broadcasting service of the University of Central Missouri. I'm an engineer! This is a very exciting time for me - so much to learn! Interning at KCUR taught me a bit about radio (though here we have to worry about a thing called "short-spacing" which means we have to have a cardioid antenna pattern - more on that as I learn about it) but I know nothing (yet) about TV.

One of the things I'll be doing at KTBG/KMOS is applying my IT experience and knowledge to our setup in broadcasting. So there will be some software development for various projects in between my regular engineering duties. For example, a short-term project I have is to take the output from KTBG's automation system and feed it into our new Inovonics RDS encoder. The encoder isn't installed yet - maybe John (the chief engineer for KMOS/KTBG) will let me do that too. If this encoder is anything like the unit at KCUR (also an Inovonics) I don't foresee a lot of difficulty; Inovonics uses RS-232 to feed data to the encoder, and the command syntax should be documented in the manual. So it's just a matter of parsing out the data from the automation system and presenting it in the proper format to the RDS encoder. No sweat.

This past Thursday, I made a presentation to the local SBE chapter on IP security. You can view it here, and maybe I'll make a blog post that elaborates on these points a little more.

Today, at the Ararat Hambash, I took the test to upgrade my amateur radio operator's license from General to Extra (I had previously upgraded from Technician to General at the end of March) and passed! This means I now have authorization to operate on all bands and modes available to the Amateur Radio Service (certain bands and modes are reserved for operators with a given license class). Of course, I still don't have any equipment, but that will come in time.

Friday, March 18, 2011

I'm going to the NAB show!

I recently heard about the NAB's Technology Apprenticeship Program. Basically, this is a program for people starting out in broadcast engineering, or people with skills in other technical disciplines - "IT, digital technologies, ... or other related areas", as the website puts it - to get some hands-on experience in the field. Since that's the line of work I'm trying to get into, I applied, and I was accepted! So here's how my next few months are going to go:

April 9 - 14: I'll be flying out to Las Vegas (on NAB's dime, no less) to the NAB show. There are going to be several activities geared specifically for the apprenticeship program participants, (you know what? I'm going to say "apprentices" from now on. "apprenticeship program participants" is a mouthful) and we apprentices will be meeting with leaders in broadcast technology.

May 18 - 19: I'll be flying out to Silicon Valley for the http://www.radioink.com/ Convergence Conference.

June - July: I complete a two month paid internship at a TV or radio station. No idea what station yet.

Finally, in August, I go to DC for a week to work with NAB's Science and Technology Department to develop a presentation to be delivered via webcast at the end of my visit. If I'm permitted, I'll publish a link or something here.

I'm very excited about all of this. Not only is this going to be a really interesting and unique experience, but this is going to be a great start to my broadcast engineering career.

So stay tuned, Dear Reader, for more thrilling tales of broadcast engineering! ;)

Wednesday, March 16, 2011

Constructing a dummy load

A useful thing to have around is a dummy load. This allows you to tune a new radio (or modifications to an existing radio) without potentially damaging your radio (transmitting without a load connected can damage a transmitter) or causing interference.

Now, I could have bought myself a dummy load for thirty bucks or so. But where's the fun in that? I decided to build one instead, and I found a set of plans for one. Thanks to Ken Kemski, K4EAA for the plans.

To begin with, I went to Westlake Hardware to pick up a 1 qt. paint can and a sheet of aluminum. The original plans recommended brass, but aluminum was cheaper, so I went with that. Little did I know that aluminum is fiendishly difficult to solder with the 60/40 Sn/Pb stuff I have. After I discovered this, I went back to the hardware store and picked up some brass, which turned out to be much nicer to solder.

I then ordered a couple of banana plug posts, 20 3W (Watts)1 k&Omega (1 kΩ = 1000 Ohms); resistors, a 0.01 uF ceramic capacitor, and some BAV21 diodes from Mouser, per K4EAA's part list. For resistors, I went with Vishay metal film resistors. Of the resistors I examined, these had the flattest frequency response curve1.

So what's the point of all these bits? The can, obviously, is to hold everything. The resistors are to absorb the RF energy and turn it into heat. They'll be submerged in oil (some canola oil that I had laying around) to help dissipate that heat. The brass is to make a couple of plates that hold the resistors. The banana plugs, diodes, and capacitor are all for measuring your transmit power.

So to begin with, let's look at a schematic of this dummy load.


There are 20 1 kΩ resistors in parallel. This provides a total resistance of 50 Ω. As each resistor is rated for 3W of power, these resistors can safely dissipate 60 W of power without becoming damaged. Submerged in oil, they will be able to dissipate at least 100W, I expect, and probably a bit more.

You'll notice two sets of terminals in the schematic. One set has the capacitor between them, and is connected to one of the plates by two diodes. These terminals are meant for measuring the peak voltage (remember that radio frequency (RF) energy is alternating current (AC), and in AC, the voltage is always changing in both magnitude and direction) the connected transmitter puts out. The diodes ensure that only the positive side of the AC comes to the capacitor, and the capacitor charges up to your peak voltage. You can then determine your transmit power from your peak voltage 2.

The other set of terminals is where you connect the transmitter. You can use any connector you like for this - K4EAA uses a BNC; I use an SO-239. Next time I might use a BNC, though.

Now that we've got our schematic squared away, let's build the thing. I started out by making the brass plates that I was going to solder the resistors to. K4EAA (you'll notice a lot of hams will refer to each other by call sign, rather than given name. It's a thing.) cut his out with tin snips. That seems like an excellent idea, but I lack tin snips, and I didn't want to shell out for a pair, so I decided to repeatedly bend the metal back and forth until the metal at the bend fatigued and broke. It's not nearly as elegant, and it's not as pretty, but it works. To make the octagon shape (so that the plates would fit in the paint can) I cut off the corners using diagonal wire cutters.

Next, I divided each plate into twenty sections using a Sharpie, and made an "X" near the edge of each section. I was going for a point that was as far as possible from the center of the plate while maintaining maximum separation from its neighboring points. This was fairly inexact, and I'm sure that if I had taken the time to model this mathematically, I could have found a more optimum resistor spacing. But that level of precision is not really called for here - it's a dummy load, and it's meant to absorb RF. If one resistor gets slightly hotter than its neighbors, the oil is going to go a long way towards mitigating that fact.

Now that I had my "X"'s marked, it was time to start poking holes. I did this with a circular (well, tapered cylinder) needle file I had laying around, and it was pretty easy. Just put some pressure on the file and once it's punctured the metal, rotate it a little bit to widen the hole.


Once the holes were poked, it was time to start attaching resistors. And here I may have made a mistake. Figuring that I wanted the maximum spacing between the plates, to allow for maximum heat dissipation, I only put each resistor through its hole a little bit, i.e., I left long leads on the resistors. I figured that since this was a dummy load, any stray reactance wouldn't matter. I may have incorrect in that assumption, as I'll explain later. At any rate, I soldered all twenty resistors to the bottom plate. To maximize conductivity between the resistor lead and plate, I soldered to both the top and bottom of the plate.

K4EAA recommends, when attaching the top plate, that you cut one resistor lead down to your minimum lead length, then cut the rest progressively longer. That way you can insert the leads a few at a time into the top plate. Still operating under the assumption that I wanted maximum spacing between the plates, and feeling like a bit of a mechanical challenge, I decided against that, and instead managed to get all twenty resistors into the holes. It took quite a bit of fiddling. :) After I got all twenty resistors in, I soldered them to the plate, again top and bottom.


I also needed a hole in the top plate for the back of the SO-239 to go into. My original plan was to push the SO-239 through the hole you see here and attach it via the included mounting nut. This did not prove feasible, however, as the banana plugs got in the way. So instead I widened the hole a bit to maintain a space for the center conductor to go through.


Here you see the hole that the center conductor from the SO-239 will connect to.


I wanted the dummy load to be grounded to the chassis - in this case the paint can. It seemed the simplest way to ensure that both the shield of the SO-239 and the black banana post were at the same ground potential. And when I poked holes (again with the needle file and, in the case of the SO-239, my small wire clippers) in the top of the can, the black banana post had an excellent connection to the can lid. The SO-239, however, didn't have as good of a connection, so I sanded away the coating on the bottom of the lid under the hole for the SO-239. That worked much better. The twisted copper wire you see here attached to the shield of the SO-239 ended up connected to the top brass plate. This ensured both a good mechanical connection from the plates to the can, and also a good electrical connection between the top plate and the can (and thus the shield of the SO-239 and the black banana plug).

You'll notice a piece of insulation under the top left bolt in this picture. That's the red banana plug. Just as the black banana plug had a great electrical connection to the paint can lid, so did the red banana plug. So I widened the mounting hole for the red plug, put some bathroom caulk in it to provide a little lateral stability, then took a piece of insulation from some ladder line I had laying around and attached the red plug to that. This ensured that the red plug was electrically isolated from the can.



Here are the banana plugs and the SO-239 attached to the can lid. The white stuff you see is bathroom caulk. Apart from insulating the red banana plug, it serves to fill in any tiny openings where oil might seep through the lid if the dummy load were to be turned on its side or upside down.


Once the banana plugs and the SO-239 were attached to the can lid, the next step was to connect the SO-239 to the plates. I already mentioned the wire connected to the shield. I also needed a wire connected to the center conductor of the SO-239. I had some scrap ladder line laying around, so I stripped part of the conductor from that to for this purpose.


Once I had everything in place on the lid, it was time to mate the lid assembly and the resistor assembly. I bent the shield wire and attached it to the top plate. I attached the center conductor to the bottom plate and made certain it wasn't going to hit the top plate. I then attached the diodes between the red banana jack and the bottom plate.

Finally, it was time to put the lid on the can. I filled up the can with some canola oil I had laying around (I don't cook with canola any more), gently lowered the resistors into the oil, and tapped the lid shut.

Now it was time to measure the performance of my dummy load.

Having borrowed an MFJ-269 from a friend, it was a simple matter to attach it and measure the SWR for various frequency bands. And up through about 30MHz, it was great - nearly 1:1.  And here's the potential mistake I mentioned earlier: what I really wanted this for was 2 meters - 144 - 148 MHz, and there the SWR wasn't so great - between 1.5 and 2 to 1.

Why, you may, ask, did the SWR change as I increased the frequency? It's not as if I'd put any capacitors or inductors in there, just resistors. But a resistor isn't just a resistor. Let's look at a more accurate schematic for the dummy load:


As I said in footnote 1 (you do read the footnotes, don't you?) an actual resistor has some amount of parasitic reactance due to its physical construction. That reactance is made up of both capacitance (as a resistor has two conductive plates separated by some distance) and inductance (due to Lenz's Law). Those values are relatively small3, but they become significant at higher frequencies.

Basically, I had neglected to account for the effects of reactance for 2 meter frequencies.

So what to do? I could shorten the leads. That would reduce, to some degree, the inductance generated by the resistor leads at the cost of increasing the capacitance between the top and bottom plates (because, again, any two conductive plates have some capacitance between them. This might be a good idea, because capacitive reactance is inversely proportional to applied frequency. When I measured the total impedance with the MFJ-269, I got ~23+10j Ω at 146 MHz, and as I increased the frequency, Xs (the reactive part of the impedance) decreased. That indicates that the primary component of the reactance is capacitive. However, the resistive portion of the impedance was 23 Ω Even if I was able to cut the capacitance to zero, I would still have a resistance of 23 Ω when I want 50.

For now, I'm going to stick with the dummy load the way it is. It won't be perfect for tuning a radio on the 2 meter band, but it will do until I can buy or build something better. And if I get some 10 meter gear, this will be perfect.

Here are a few other approaches to building a dummy load:

  • Thread on Worldwide DX with a couple of homebrew dummy loads.  "Captain Kilowatt" in that thread makes an excellent point regarding hot air and a potential need for venting.
  • UHF Dummy Load by SV1BSX.  He neutralizes the capacitive reactance in his load with an inductor.
  • Saltwater Dummy Load by K5LXP.  I'm not sure how well this would work on 2 meters, though, as the electrodes need to remain under a "significant fraction" of a wavelength, but shorter electrodes are going to get hotter faster.
If you've tried any (or all) of these, let me know!

Footnotes


1 While an ideal resistor has the same resistance no matter what frequency of AC you put through it, real resistors have some amount of parasitic reactance that varies with applied frequency.

2 P = V2/R (Power = Voltage2 / Resistance). We can measure peak voltage (less an 0.4 V drop from the diodes) across these terminals. If we take the peak voltage, however, that will give us peak power, when what we really want is average power. So we take the voltage - remembering to add the 0.4V drop back in - divide it by the square root of two to obtain RMS (root-mean-square, or average) voltage, square it, and divide it by 50 Ω to obtain power.

The total inductance in the circuit will be smaller still because the total inductance of a number of inductors in parallel is less than the inductance of any one inductor. However, the total capacitance of a number of capacitors in parallel is the sum of all the individual capacitances.

Sunday, February 13, 2011

Constructing a programming interface

A little while ago, I was given a pair of EF Johnson UHF mobile radios. These put out 35 Watts of power, which is nice, but like most radios not specifically designed for amateur use (and several that are, as I understand it) you can't set the operating frequency directly from the radio. Instead, one must use a special programming cable to store a number of frequencies (in this case, about 100, in banks of 16) in the radio. And these cables aren't free - aftermarket versions run about $40 a pop. And as my motto with ham stuff has lately been "why buy a thing when you can build it?", I decided to make one of my own.

There are a couple of schematics out there for this cable, all based around a MAX232 IC (integrated circuit). I used one designed by Kyle Yoksh, K0KN.

Basically, what the MAX232 does is convert RS-232 signal voltage levels to TTL signal levels. So a lot of the work has already been done in the IC. All I had to do was solder the IC to a circuit board, attach some capacitors, attach a female DB9, and attach an appropriate connector to interface with the radio.

I was able to obtain all the necessary parts from Electronics Supply Company here in town. I probably paid a little more than I would have if I'd bought from, say, Mouser Electronics, but I like supporting local businesses.

Soldering the entire circuit together was a bit of a learning experience, which I won't recount here as it's extremely boring in the telling. I know that if I built this circuit again, I'd do it slightly differently, but I'm still pleased with the way I did it.

Remember how I said "appropriate connector" above? This whole "appropriate connector" business is easier said than done. It's an 8-pin connector that looks like an RJ45, but it's more narrow. I wasn't able to find one online, so I decided to adapt a bit of Cat 5 that I had laying around instead. This also had the advantage of not requiring me to find a crimper for that weird connector. So, instead of using the Johnson connector, I'm filing down (sloooowly) the RJ45 on the end of the aforementioned Cat 5 stub. Once I've done that, I just need to secure the board and try it out.

For a project box, I decided to use an old Altoids tin that I had laying around. I drilled a hole in it for the Cat 5 stub, but for the DB9, I ended up poking a hole in it with my needle nose pliers and then just working at it with a metal file and clippers for a while. I made the holes for the screws to secure the DB9 to the box using a sheet metal screw I had laying around. A bit of pressure and it poked right through the tin.

OK, now for some pictures. :)

Here's the project board inside the Altoids tin. As you can see, it's really not that complicated of a circuit - a few capacitors, a voltage regulator, and the appropriate connectors on either side, and that's it.

Close-up of the project board.

And this is what the thing will look like once it's finished.