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!

No comments:

Post a Comment