Tuesday, October 23, 2012

RF Signal leakage

The attenuator project has been going well, but we are still working on getting the signal isolation secure enough to take the WiFi signal level to less than about -80 dB.  After a bit of research, we realized that our single-shielded SMA cables inside the attenuator were not really up to the task.  They are made with RG-316 cable, which is only single shielded.  It's hard to get solid numbers on how well it actually shields, but some similar cable was reported to shield at only -50 dB or so.  For the attenuator to work well, we need shielding at > 90 dB.

It is actually fairly easy to order SMA to SMA cables that have double-shielded cable, I had just not realized the importance when ordering the previous batch.  I put in an order for some cables using KSR-100 cable, which has an aluminium shield as well as woven shield, and claims > 90 dB shielding.

But, that will take a week or two to arrive...  I had previously ordered a roll of copper tape, and thought wrapping my existing single-shielded cables with copper tape would add some much needed signal shielding.  After a bit of fairly tedious work, all 6 cables were done and back in the attenuator.

I reconnected the AP and Station machines to the attenuator and ran some more tests.  Throughput was around 340Mbps at lower attenuation levels, which is great performance.  But, even when the attenuator was set to 95 dB attenuation, I still saw signal strength of around -71.  This was significantly worse signal leakage than before!  I then took some aluminium foil and wrapped the (fanless) AP and Station machines as completely as I could, being careful to crimp it in around the cables.  After wasting several yards of aluminium foil, I was disappointed to see that I had at most shaved 1 dB off the leakage.  I removed all the foil...

I knew that the SMA to U.fl pigtails inside the AP and Station were also single-shielded, and even thinner than the SMA to SMA cables.  So, I took those machines apart and copper-clad those cables a well.  While looking closely at the U.fl ends, I noticed that there is a small bit of cable that is without shielding.  I tried to wrap this part with copper tape as well.  I again connected everything together and ran some more tests.  Now the signal level would go a bit lower, around -76 dB with full attenuation.  This is still worse than before I copper-clad anything, but at least cladding the U.fl pigtails seemed to help a little.

At this point, I could only assume that adding copper cladding to the cables in the attenuator made them leak more instead of less.  Perhaps the small amount of signal that leaks out of the cable shielding is then amplified by the copper tape I had added.  I cut open a double-shielded LMR-195 cable and noticed that its foil layer was just under the woven metal shielding (and the woven shielding was under a rubber insulating layer).  Maybe that makes all the difference.  I removed all the copper clad cables and put the unmodified single-shielded cables back in place.

I directly connected some LMR-195 cables from the AP to the attenuator modules.  I had to leave the Station modules using the single-shielded cable since I had only 3 of the correct type of SMA adapters for the LMR-195 cables.  This brought total isolation back up to around -80 dB, right around where I started at the beginning of the day!

There are companies (such as rfmall.com) that sell double-shielded SMA to U.fl cables, so I ordered a few sets of pigtails from them.  I'll try this all again when the new cables arrive.

In summary:  WiFi signal isolation is not trivial.  You have to pay close attention to cable types and connector construction, and solutions that appear obvious may actually exacerbate the problem!

Monday, October 8, 2012

Programmable Attenuator: Rate v/s Attenuation

I spent some time over the weekend integrating the Attenuator with the LANforge hunt script logic.  The hunt script iterates through packet sizes and attenuation settings.  At each iteration, it runs tests and adjusts the transmit rate to find the highest rate that meets constraints (latency, packet-loss, etc).  The best run for each iteration is saved for reporting.

Here's the Hunt Script configuration for this run:

The graphs below are two views of the 3D graph that shows the relationship between UDP payload size, WiFi RX-Signal level, and RX-BPS.  The test case is an AP connected through the attenuator to a WiFi station system.  The test shows that at very low attenuation (less that you would see in over-the-air testing), throughput suffers, and it starts suffering again at around -55 signal quality.  Larger PDU sizes help throughput as well, but at least some of that is because the AP system has a fairly weak CPU and was running lots of other processes when this test was running.  I still need to work on better RF shielding, so the signal does not go below about -75 dBm.

Friday, October 5, 2012

Programmable Attenuator: Arduino Shields

I received the Arduino Mega shields back from OSH Park a few days ago.  I like they look and feel of the boards, and through some stroke of luck, it seems they actually work as designed.  Here are two of the boards, one partially populated with connectors that will be used to drive the Attenuators.

I soldered on the rest of the parts, stealing headers from an Arduino Mega proto-shield.  I put together another LCD Shield from Adafruit.  I don't yet have the front-panel board, so the LCD was wired directly into the headers.  When the front-panel board is ready, the 12-pin header should connect to it.  The front panel will connect to the two rotary encoders (one for menu selection, one for adjusting attenuator values) and the LCD panel.  Here's the new shield running, but without attenuators attached.

A few days later, I found time to install the new components in a new aluminium case.  Stamping the metal is quite costly, so I did it by hand with a hand punch, drill, and lots of quality time with a 'nibbler' to cut out the rectangular holes for LCD and USB plug.  I put the LCD panel hole too low, so it's been hacked a bit and is no longer level.   I need to move the attenuator modules closer to the panel mounting holes so that the cables don't have to stretch quite as far too.  Will be more careful measuring the next one!

With my new attenuator in hand, I set about trying to test it.  I set up two Atom based systems with Atheros 9380 3x3 MIMO wifi adapters.  These each have three antenna, and I connected on to each of the attenuator modules.  After lots of fiddling around, I had the station uploading to the AP at what I believe is near maximum speed, about 330Mbps UDP throughput.  The download speed from AP to Station is only about 230Mbps, but I have not had time to figure out why there is such a discrepancy.  I updated our LANforge software to graph the rx-signal and wifi link speed and ran some tests with the Attenuator.  The attenuation starts at 20 and is adjusted in increments of 5 up the the max of 95.5.  Due to RF leakage in the AP and Station systems, the signal is never completely extinguished, but it does go to about -82 dBm signal, with noise at about -93.  It is still able to pass traffic reliably (at lower rates) at this attenuation.  Here's a graph of the results.  Note that the signal quality is on the left-hand axis, so it is not to scale with the other graph lines.  Overall, it seems that the system handled the test well.

Wednesday, October 3, 2012

Programmable Attenuator

We have been improving our LANforge WiFi traffic generator at work, and one of the things we were curious about is how the ath9k NIC/driver works over various distances.  One option would be to spend weeks walking around and taking various throughput measurements.  A second option is to use a WiFi programmable attenuator and some co-axial cables.  The attenuator diminishes the signal between AP and Station devices, acting similar to increased physical distance.

There did not seem to be any vendors providing affordable attenuators, so we decided to build one ourselves.  I quickly settled on the Arduino micro-controller as the brains of the attenuator.  There were other interesting systems that could have worked, like the Beagle Board, but the attenuator modules we are using need +5v TTL, and Beagle Board uses +3.  I have been very satisfied with the Arduino Mega.  After mucking with full operating systems all my professional life, it is a joy to work with such a simple programming environment, and at the same time have the ability to easily
sense and control the physical world.

I ordered the Arduino Mega, Arduino proto shield, starter packs and various other electronic goodies from Adafruit, digikey, local hardware stores, and various other places.  The attenuator modules come from Eubus Electronics.

After a few hours of learning curve, I had hello-world working on the Arduino, and shortly after, I had basic functionality controlling the attenuator modules.  Next, I needed some useful physical input/output, so I ordered the Arduino LCD shield from Adafruit.  It comes with a small set of directional buttons so I could select the different attenuator modules and adjust the attenuation up or down.

Since the Arduino Mega has plenty of pins, and there was some question of heat dissipation when the system is enclosed in a real chassis, I added a simple heat sensor.  It has only 3 pins, but I managed to wire it up backwards (+5 to ground, ground to +5).  It got hot enough to melt the plastic insulators on the wires and smoke a bit of my fingers before I got it disconnected.  Luckily, once I had it wired properly, it seemed to work just fine, so I guess it's one tough sensor.

One problem with the LCD panel is that there is no good way to get access to the buttons through the front panel.  We decided to use two rotary encoders (one to select menus, one to adjust values up/down) instead of buttons.  It took a while to get the rotary code working properly, much of which probably can be blamed on me not fully understanding the consequences of using pull-up v/s pull-down logic on the encoders.  Eventually I got it working, using interrupts and a 2ms de-bounce time.

At this point, I began worrying about how we could manufacture this (in small quantities) reliably.  There was quite mess of wires, even with efforts to use ribbon cables where we could, and as working with the Temp Sensor showed, it is way to easy to get pins mixed up.  Smoking a $2 sensor is one thing..but the Attenuator modules cost significantly more!  After poking around, I found an excellent guide for building your own Arduino Shield.  This guide suggests using the Eagle PCB design software, and it seems to work quite well.  After a few days of poking around, I had the first revision finished and ready to send off for printing.  I used OSH Park, as suggested by the Arduino Shield guide.  The price is right, and the web site is simple enough.  I've yet to receive the boards, but hope to do so shortly!

Here's a picture of the Rev-0 attenuator project!