“While I was working on the power meter function for the latest version of the SNA, I used several fixed attenuators for checking linearity and calibration. It would be a lot easier if I had a variable step attenuator. I have several digital controlled attenuator modules that I bought one eBay a while ago, and I guess it is time to use some of them. There are several models available.
The ones I plan on using are the simplest with only 6 control pins for a total attenuation of 31.5 dB in .5 dB steps. I am going to connect two in series with the control lines paralleled for a total of 63 dB in 1 dB steps.
I will use an Arduino Nano with a small OLED display for control of the attenuator. A rotary encoder will be used to select the attenuation level, and the push button switch will be used to select ether 1 or 10 dB steps. Everything should fit in a small 3D printed cabinet along with a 9 volt battery for power. The attenuator module runs on 3.3 volts, but the current draw is low enough that I can power it directly from the 3.3 volt output of the Nano. The module also needs 3.3 volt logic level, so I will use a simple voltage divider on the control lines to drop the 5 volt level of the Nano down to 3.3 volts. I found that some modules had 10K pull down resistors to ground and others did not. I hand wired the first one, but laid out and ordered some board so I could build several more. I laid out the board with provision for optional pull down resistors if needed. The modules come with female SMA connectors. I replaced one of them with a male connector so I could connect them directly together without having to use a short cable. This also made it easier to do the board and case design.
After building the board I worked on the software. It is very simple, with just checking the rotary encoder and incrementing or decrementing the attenuation value by the step size which can be changed by pressing the encoder button. If there is an encoder event, the attenuator control lines are set to the correct value.”