A twisted tale about a logarithmic relay attenuator

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Twisted Log Attenuator:

A few weeks ago I began studying my options when I really needed a great attenuator to match my new Twisted XBOSOZ preamplifier. I really did not want to have to solder a lot of resistors around a rotary switch and wanted to be able to easily handle balanced signals.

Well I searched and searched and found a lot of really cool relay switched attenuators, which very much appealed to me, I really wanted a true logarithmic approach, one switch on, one logarithmic step. Most of the examples I found where either R-2R or a string of switches like a rotary attenuator. Those are great, but not exactly what I wanted right now. Still, since I was in the mood to experiment I built an R-2R ladder attenuator which further fueled the desire to push even further, as it worked very well indeed.

So, I found a site developed by Jos van Eijndhoven which was a wonderful resource for me. Jos is very generous to have shared so much great information on his site. He also has a very cool implementation of his own which I think is superb. The site can be found here at :

http://jos.vaneijndhoven.net/switchr/index.html

At the site you can read all about the approach I chose, which is a logarithmic ladder, or as some have called it a 7 bit addressable LPAD register, which makes sense too. In fact that is pretty much how it works. The output impedance of the circuit is constant while the input impedance varies. This is very desirable for some circuits as change output impedance can change change input characteristics of the target circuit, this can be a less than desirable thing. But the biggest win is that you get a nice truly logarithmic curve with steps precisely as you design them.

This project is an open project. Everything I have done is public domain knowledge and I intend to share the design, PCB PDFs, schematics, and experiences freely with the hope that some will be able to contribute and make the design better, and that some will be able to do something they might not have otherwise attempted.

I won't try to rewrite all the good information on Jos' site instead I will explain what I have done to implement what I have learned.

First of all I wrote a small Java application to generate the resistor values for me, and determine the closest E96 resistor value for each resistor in each stage. I will post it later after I polish it up a bit.

Then I designed a PCB which would allow me to build the circuit with a lot of flexibility. My best success so far has been to calculate the first stage as if it has a perfect source, or if you know the actual output impedance of the source you can plug that in too, but in most cases the input impedance is low enough to be dominated be the first stage, so not knowing the exact value is just fine. The circuit I designed is for 7 relays which works out great for .5db step from -63.5db to 0 db attenuation.

If you have a very high output impedance source like a tube DAC or something you could do a couple of things, you can calculate the first stage for the actual output impedance of the source (which is the input impedance to the attenuator) or you could use a buffer in front of the attenuator and calculate for a (nearly) perfect source.

For my own initial implementation and for the purposes of providing a springboard for further development I designed a simple firmware application for my circuit and a controller PCB for it. This controller is very simple which should help people who just want a simple attenuator, and not a lot of bells and whistles. The human interface is a simple linear single pot (5-20K is fine) which does not need to be anything fancy at all, no signal goes through it. The micro controller is a PIC16F690 of which I am only using a small number of the I/O pins (8) leaving the others for other things like display, mute, or whatever you like. The pot is attached on one end to VCC and to the other VSS and the ADC on the PIC reads the voltage at the wiper in reference to VCC and sits the 7 bit relay register based on the value returned by the ADC.

That controller worked very well, and work very much like a standard LOG audio pot. A very conventional and useful controller implementation. :)

Now, there are some tricks I used in the firmware to get past a few things. First, if you progress upward through the 7 bit register from 0 to 128 you will notice as get reach the more more significant bits as that high bit turns on (or off in the downward progression) and all of the bits below it turn off (or on) the input impedance will jump (or fall) significantly which leads to an annoying pop. Not to worry, there was a very simple way to address this in the firmware. The little G6K relays I am using switch pretty dang fast. :) So I was able to switch off (or on) the relays below the most significant on(or off) one at a time till I only have one of them on (which matches the input impedance roughly of the significant bit I am transitioning to), then I set the significant bit. Pop is then totally eliminated, and it happens so fast (a few ms) you don't notice it. The firmware code (C code) will be posted here soon so you can see how I did it.

So the bottom line is this logarithmic attenuator works very well, I would venture its as good as the best and better than the rest. ;) You can use nice resistors, and the soldering is easy. Both channels can be matched perfectly, so you get perfect channel matching. Give it a try I think you will find what I have, your new attenuator. :cool:

Some other details. The PCBs I am providing are single sided and easy to etch. Also they are the same size (controller and attenuator PCBs are separate) and designed to be stackable so you can easily do balanced (2 attenuator boards and one controller) or SE (one of each) and not take up much case real estate at all.

More details and PCB and schematic images coming soon (today) just tidying them up.

Cheers!
Russ
 

Attachments

  • attenuator.png
    attenuator.png
    36.3 KB · Views: 12,720
Resistor Values

Here is a list of resesitor values for a 2.2K impedance between stages:

----------------
db attenation = -0.5 -- R IN = 0 - R OUT = 2200
R1 = 2330(2320) OR (2320 + 10), R2 = 39328(39200) OR (39200 + 127), R3 = 0(0) OR (0 + 0)

----------------
db attenation = -1.0 -- R IN = 2200 - R OUT = 2200
R4 = 268(267) OR (267 + 0), R5 = 0(0) OR (0 + 0), R6 = 20230(20000) OR (20000 + 232)

----------------
db attenation = -2.0 -- R IN = 2200 - R OUT = 2200
R7 = 570(576) OR (562 + 0), R8 = 0(0) OR (0 + 0), R9 = 10697(10700) OR (10500 + 196)

----------------
db attenation = -4.0 -- R IN = 2200 - R OUT = 2200
R10 = 1287(1300) OR (1270 + 16), R11 = 0(0) OR (0 + 0), R12 = 5961(5900) OR (5900 + 61)

----------------
db attenation = -8.0 -- R IN = 2200 - R OUT = 2200
R13 = 3326(3320) OR (3320 + 0), R14 = 0(0) OR (0 + 0), R15 = 3655(3650) OR (3650 + 0)

----------------
db attenation = -16.0 -- R IN = 2200 - R OUT = 2200
R16 = 11681(11800) OR (11500 + 182), R17 = 0(0) OR (0 + 0), R18 = 2614(2610) OR (2610 + 0)

----------------
db attenation = -32.0 -- R IN = 2200 - R OUT = 2200
R19 = 85384(84500) OR (84500 + 887), R20 = 0(0) OR (0 + 0), R21 = 2257(2260) OR (2210 + 46)
 
Simulation results:

Vout/Vin[dB] Vout/Vin[ratio] Rin Rout Q1 Q2 Q3 Q4 Q5 Q6 Q7
-63.54048 6.6523615E-4 5414.239 2203.1501 0 0 0 0 0 0 0
-63.041058 7.046073E-4 5549.779 2203.1501 1 0 0 0 0 0 0
-62.53672 7.467308E-4 5665.7983 2203.1501 0 1 0 0 0 0 0
-62.037292 7.90925E-4 5848.384 2203.1501 1 1 0 0 0 0 0
-61.533173 8.38188E-4 5805.4966 2203.1501 0 0 1 0 0 0 0
-61.033745 8.8779506E-4 6016.024 2203.1501 1 0 1 0 0 0 0
-60.529118 9.409013E-4 6218.407 2203.1501 0 1 1 0 0 0 0
-60.029694 9.965873E-4 6519.28 2203.1501 1 1 1 0 0 0 0
-59.49919 0.0010593523 5906.695 2203.1501 0 0 0 1 0 0 0
-58.999763 0.0011220488 6138.2847 2203.1501 1 0 0 1 0 0 0
-58.49507 0.001189177 6365.61 2203.1501 0 1 0 1 0 0 0
-57.995644 0.001259557 6701.5493 2203.1501 1 1 0 1 0 0 0
-57.4944 0.0013343813 6765.389 2203.1501 0 0 1 1 0 0 0
-56.994976 0.0014133549 7204.356 2203.1501 1 0 1 1 0 0 0
-56.48978 0.0014979971 7691.434 2203.1501 0 1 1 1 0 0 0
-55.990356 0.0015866541 8414.698 2203.1501 1 1 1 1 0 0 0
-55.542675 0.0016705764 5730.0405 2203.1501 0 0 0 0 1 0 0
-55.043247 0.0017694472 5925.3125 2203.1501 1 0 0 0 1 0 0
-54.538673 0.001875281 6109.8125 2203.1501 0 1 0 0 1 0 0
-54.039246 0.001986267 6385.787 2203.1501 1 1 0 0 1 0 0
-53.53703 0.0021044982 6406.4243 2203.1501 0 0 1 0 1 0 0
-53.0376 0.0022290503 6752.3574 2203.1501 1 0 1 0 1 0 0
-52.5326 0.0023624902 7119.857 2203.1501 0 1 1 0 1 0 0
-52.033176 0.0025023108 7659.9478 2203.1501 1 1 1 0 1 0 0
-51.50073 0.0026605024 6969.424 2203.1501 0 0 0 1 1 0 0
-51.0013 0.0028179605 7465.4565 2203.1501 1 0 0 1 1 0 0
-50.496006 0.0029867562 8028.1826 2203.1504 0 1 0 1 1 0 0
-49.99658 0.0031635235 8871.424 2203.1504 1 1 0 1 1 0 0
-49.500164 0.0033495908 9357.07 2203.1501 0 0 1 1 1 0 0
-49.00074 0.003547832 10767.108 2203.1501 1 0 1 1 1 0 0
-48.49459 0.0037607152 12752.872 2203.1501 0 1 1 1 1 0 0
-47.995163 0.0039832885 16406.893 2203.1501 1 1 1 1 1 0 0
-47.52965 0.004202594 5455.292 2203.15 0 0 0 0 0 1 0
-47.030224 0.004451319 5598.225 2203.15 1 0 0 0 0 1 0
-46.525856 0.0047174497 5722.5825 2203.1501 0 1 0 0 0 1 0
-46.02643 0.0049966457 5916.3677 2203.1501 1 1 0 0 0 1 0
-45.522568 0.0052950694 5880.8306 2203.1497 0 0 1 0 0 1 0
-45.02314 0.005608451 6106.971 2203.1497 1 0 1 0 0 1 0
-44.518463 0.005943973 6327.8164 2203.1497 0 1 1 0 0 1 0
-44.019035 0.0062957597 6654.6074 2203.1497 1 1 1 0 0 1 0
-43.48827 0.006692472 6032.284 2203.1501 0 0 0 1 0 1 0
-42.988846 0.0070885564 6290.9834 2203.1501 1 0 0 1 0 1 0
-42.484066 0.007512711 6550.826 2203.1501 0 1 0 1 0 1 0
-41.984642 0.007957341 6933.0684 2203.1501 1 1 0 1 0 1 0
-41.48406 0.00842941 7031.408 2203.1494 0 0 1 1 0 1 0
-40.98463 0.008928293 7545.3887 2203.1494 1 0 1 1 0 1 0
-40.479305 0.009463128 8132.257 2203.1494 0 1 1 1 0 1 0
-39.97988 0.01002319 9014.441 2203.1494 1 1 1 1 0 1 0
-39.532223 0.0105533125 6033.045 2203.1494 0 0 0 0 1 1 0
-39.0328 0.0111778965 6291.9116 2203.1494 1 0 0 0 1 1 0
-38.52802 0.0118467435 6551.957 2203.1497 0 1 0 0 1 1 0
-38.028595 0.012547878 6934.4893 2203.1497 1 1 0 0 1 1 0
-37.528015 0.0132922735 7033.0483 2203.1475 0 0 1 0 1 1 0
-37.028587 0.014078959 7547.508 2203.1475 1 0 1 0 1 1 0
-36.523262 0.014922337 8135.0225 2203.1477 0 1 1 0 1 1 0
-36.023838 0.015805496 9018.254 2203.1477 1 1 1 0 1 1 0
-35.489716 0.016807932 8247.292 2203.1504 0 0 0 1 1 1 0
-34.990288 0.017802687 9173.5625 2203.1504 1 0 0 1 1 1 0
-34.484474 0.01887019 10358.326 2203.1511 0 1 0 1 1 1 0
-33.98505 0.019986996 12302.223 2203.1511 1 1 0 1 1 1 0
-33.49279 0.02115244 13957.52 2203.145 0 0 1 1 1 1 0
-32.993366 0.02240432 18741.518 2203.145 1 0 1 1 1 1 0
-32.486397 0.023750905 29405.879 2203.1462 0 1 1 1 1 1 0
-31.98697 0.02515657 89837.37 2203.1462 1 1 1 1 1 1 0
-31.552883 0.026445746 5414.467 2196.8567 0 0 0 0 0 0 1
-31.053457 0.028010903 5550.048 2196.8567 1 0 0 0 0 0 1
-30.54912 0.029685475 5666.1133 2196.8584 0 1 0 0 0 0 1
-30.049694 0.03144237 5848.7603 2196.8584 1 1 0 0 0 0 1
-29.545572 0.033321258 5805.913 2196.8435 0 0 1 0 0 0 1
-29.046148 0.03529333 6016.526 2196.8435 1 0 1 0 0 0 1
-28.541521 0.03740451 6219.0093 2196.8464 0 1 1 0 0 0 1
-28.042095 0.03961825 6520.0225 2196.8464 1 1 1 0 0 0 1
-27.511591 0.042113412 5907.3833 2196.8618 0 0 0 1 0 0 1
-27.012165 0.04460584 6139.119 2196.8618 1 0 0 1 0 0 1
-26.50747 0.047274455 6366.6177 2196.8665 0 1 0 1 0 0 1
-26.008045 0.050072327 6702.803 2196.8665 1 1 0 1 0 0 1
-25.506805 0.053046867 6766.823 2196.8284 0 0 1 1 0 0 1
-25.00738 0.056186378 7206.18 2196.8284 1 0 1 1 0 0 1
-24.502182 0.059551246 7693.77 2196.836 0 1 1 1 0 0 1
-24.002758 0.06307571 8417.835 2196.836 1 1 1 1 0 0 1
-23.555077 0.06641194 5731.6523 2196.8345 0 0 0 0 1 0 1
-23.05565 0.07034245 5927.2466 2196.8345 1 0 0 0 1 0 1
-22.551075 0.074549764 6112.1226 2196.8462 0 1 0 0 1 0 1
-22.05165 0.07896189 6388.618 2196.8462 1 1 0 0 1 0 1
-21.54944 0.08366195 6409.6235 2196.7512 0 0 1 0 1 0 1
-21.050014 0.088613376 6756.3447 2196.7512 1 0 1 0 1 0 1
-20.54501 0.093918145 7124.8374 2196.77 0 1 1 0 1 0 1
-20.045584 0.09947657 7666.416 2196.77 1 1 1 0 1 0 1
-19.513126 0.10576542 6975.477 2196.8672 0 0 0 1 1 0 1
-19.0137 0.112025 7473.2495 2196.8672 1 0 0 1 1 0 1
-18.508402 0.118735306 8038.309 2196.897 0 1 0 1 1 0 1
-18.008978 0.12576249 8885.3 2196.897 1 1 0 1 1 0 1
-17.512585 0.13315907 9374.382 2196.6562 0 0 1 1 1 0 1
-17.013159 0.14103991 10792.838 2196.6562 1 0 1 1 1 0 1
-16.507006 0.14950293 12793.462 2196.7039 0 1 1 1 1 0 1
-16.00758 0.15835106 16482.365 2196.7039 1 1 1 1 1 0 1
-15.5420885 0.16706888 5464.553 2196.464 0 0 0 0 0 1 1
-15.042664 0.17695662 5609.17 2196.464 1 0 0 0 0 1 1
-14.538286 0.18753645 5735.4307 2196.5388 0 1 0 0 0 1 1
-14.038861 0.19863553 5931.78 2196.5388 1 1 0 0 0 1 1
-13.535057 0.2104976 5897.9365 2195.9375 0 0 1 0 0 1 1
-13.035631 0.22295563 6127.6763 2195.9375 1 0 1 0 0 1 1
-12.530941 0.23629414 6352.799 2196.0562 0 1 1 0 0 1 1
-12.031515 0.2502789 6685.6265 2196.0562 1 1 1 0 0 1 1
-11.500689 0.2660514 6061.0894 2196.6704 0 0 0 1 0 1 1
-11.001264 0.2817973 6326.159 2196.6704 1 0 0 1 0 1 1
-10.496467 0.29865974 6593.7095 2196.86 0 1 0 1 0 1 1
-9.997041 0.31633553 6987.0225 2196.86 1 1 0 1 0 1 1
-9.496606 0.33509636 7093.7495 2195.336 0 0 1 1 0 1 1
-8.997181 0.35492858 7626.0723 2195.336 1 0 1 1 0 1 1
-8.491825 0.37619132 8237.782 2195.6367 0 1 1 1 0 1 1
-7.9923987 0.3984557 9160.366 2195.6367 1 1 1 1 0 1 1
-7.544749 0.41952956 6105.202 2195.5796 0 0 0 0 1 1 1
-7.0453224 0.4443589 6380.1377 2195.5796 1 0 0 0 1 1 1
-6.5404983 0.4709503 6659.6753 2196.051 0 1 0 0 1 1 1
-6.041073 0.49882287 7070.277 2196.051 1 1 0 0 1 1 1
-5.54086 0.5283929 7190.205 2192.2615 0 0 1 0 1 1 1
-5.041435 0.55966514 7751.484 2192.2615 1 0 1 0 1 1 1
-4.536036 0.593196 8402.759 2193.0093 0 1 1 0 1 1 1
-4.03661 0.6283035 9390.366 2193.0093 1 1 1 0 1 1 1
-3.5021136 0.6681813 8599.741 2196.8816 0 0 0 1 1 1 1
-3.0026882 0.7077267 9668.007 2196.8816 1 0 0 1 1 1 1
-2.496758 0.75017416 11077.018 2198.0776 0 1 0 1 1 1 1
-1.9973323 0.79457223 13466.366 2198.0776 1 1 0 1 1 1 1
-1.506002 0.84081393 15679.786 2188.4722 0 0 1 1 1 1 1
-1.0065768 0.89057636 22457.365 2188.4722 1 0 1 1 1 1 1
-0.49942598 0.94412327 41520.0 2190.366 0 1 1 1 1 1 1
-5.177194E-7 0.99999994 1.0E9 2190.366 1 1 1 1 1 1 1

Copy and paste it into Excel or open office Calc to get a good look at impedance and the attenuation curve.
 
Russ I can see where this could/might apply to more than 2 channel stereo
say 5, 6 or 7 would iit be possible/feasible to incorporate a sort of preset to each channel? i.e. boost or attenuate each channel independently of overall loudness?.

This would ideally be done through software in your programamable modules.

I realize this is an order of magnitude leap ahead of what you just proposed.
 
Excellent approach Russ, I like the idea of a simple attenuator.:cool:

I would suggest too keep it as simple as possible as you have. As soon as you start adding functions and complexity to the circuit some of us (me included) will shy away from building it.

I guess many on the forum are not digital inclined and have never programmed a PIC (me included once again). So what are the alternatives for those of us at the digital end?
 
SheldonD said:
Russ I can see where this could/might apply to more than 2 channel stereo
say 5, 6 or 7 would iit be possible/feasible to incorporate a sort of preset to each channel? i.e. boost or attenuate each channel independently of overall loudness?.

This would ideally be done through software in your programamable modules.

I realize this is an order of magnitude leap ahead of what you just proposed.

Hi Sheldon,

Certainly, there are a host of things anyone so inclined could do with a controller in the firmware. I will explore some ideas later on in the thread and probably supply some code and layouts to help people out. :)

Cheers!
Russ
 
apassgear said:
Excellent approach Russ, I like the idea of a simple attenuator.:cool:

I guess many on the forum are not digital inclined and have never programmed a PIC (me included once again). So what are the alternatives for those of us at the digital end?

Thanks Tony, Coming from you that means a lot to me.

I am still in many ways just a beginner here, so having some little bit of success here really makes me feel great. :)

As for the PIC programming I am going to be posting a layout for a simple serial port programmer I did which is based on the "RCD" PIC programmer. Very simple to use with open source free software. Once you have that and the HEX code all you need are the PICs to program. :)

Alternatively, as Choky said Brian and I may well decide to sell some of these as kits. Have not made any hard fast decissions yet.

Cheers!
Russ
 
The attenuator looks great.
The pads and holes though for the resistors look a bit small.
Bigger pads are easier to solder.
Will the pcbs be double sided with vias or single sided?
It looks like single sided to me so maybe larger pads are a good idea.
Using the DAC with the a normal pot is also a good idea because there is know need for a display.
I also like the idea of a 7bit control because its more stable and not so many steps. 6 would also would be ok.

The relays are very good. I think one could also use others but I am not so sure how universal they are.

If the input selection is also so simple and good I will be surely using them.
A mute Relay would be helpful to make a time delay on turn on etc.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.