diyAudio (
-   Analog Line Level (
-   -   A precision LED/LDR-based Attenuator (

wapo54001 16th July 2010 05:18 PM

A precision LED/LDR-based Attenuator
1 Attachment(s)
Here's an early (and incomplete) drawing of the setup of my board, this is about as small as it's gonna get at two-sided 2.5"x4.0". I haven't finalized pin assignment on the PIC yet, so those lines aren't shown. I figure I'll have one pin left on the PIC when this is done, and resolution might be limited by memory size of the PIC to 1 dB steps, though I hope for 1/2 dB steps down to -55 dB. Each channel will use four opto devices in a T configuration mounted on a 24 pin header, and the board can operate as stereo with balance or dual mono with two volume controls. Controls will be linear, but board will output as audio taper.

Power is a standard LM317T with protective diodes, capacitive smoothing on the control pin, and a load resistor to insure good regulation. Pot will control from 4.85~5.15 volts, and must be set precisely to 5.00V to insure accurate operation.

All control is DC voltage -- including potentiometers, and opto control. There is NO digital signal running around this board, except within the PIC itself.

Audio is all at one end of the board, completely separate from power and PIC. In testing the concept I found that control could be very precise, though at this point I'm not sure how precise the LDRs are going to be so can't predict how accurate overall it will turn out. All circuitry, aside from the PIC itself, is entirely linear, no digital. Only mosfets operating in their linear range actually touch the optos so no digital contamination. In steady state (controls not being moved), the control signals from the PIC to the mosfets are infrequent and so small you can hardly see it happening on a 'scope at maximum resolution so it should be very quiet.

I'm getting ahead of myself doing the hardware before the software, but I have more fun with hardware so it always gets done first.

I'm just throwing this image up for the fun of it, it's not final, it's not even tested, so I'm not going to talk details.

wapo54001 17th July 2010 04:50 PM

1 Attachment(s)
Board finished. :)Now I need to number the components so I can run a netlist check against the schematic for errors. I hate that part of it, so tedious.

I packed the control lines vertically so there's room available for an Omron relay and controls so I could add a "total mute" position that will not only put the series optos in the megaohm range, but also put a dead short in the vertical part of the T for total mute. Not sure if it's necessary, though, if the optos are all turned off and the two series optos are sitting in the megaohm range, the R2 value shouldn't matter that much. Opinions, anyone?

Also wound up with two unused pins on the PIC. I'm thinking I could use one to make the choice of linear pot or log pot for the volume control a user-selectable option. That might be useful, but that still leaves one still available. Can anyone think of a good further use for a jumper or switch option for any other purpose?

wapo54001 17th July 2010 07:57 PM

A precision LED/LDR-based Attenuator
1 Attachment(s)
I got interested in the Silonex NSL32SR2 optocoupler device through reading about GeorgeHiFi's "Lightspeed" LDR attenuator. It seemed a nifty approach to creating a totally passive preamplifier with absolutely no switches, relays, or potentiometers in the signal path.

On the other hand, I was not excited by the necessity of hand-matching multiple LDR devices in order to build properly balanced and tracking stereo systems, and there seems to be no practical way to build any kind of consistent system involving three or more channels due to the requirement to hand-match so many LDR pairs. I thought I'd look for a better way, and I think I've found it.

My approach is opposite to that of the Lightspeed crowd -- I do not intend to match LDR devices beyond a basic "does it meet the specifications" check. Instead, I propose to use a PIC to first test and memorize the specific characteristics of each LDR device used in a system, then use that information to apply the correct control voltage to each LDR to achieve accurate performance. If the method works, it should be possible to build multiple, matched, LDR-based passive attenuators or potentiometers, as well as LDR-based input switching systems.

I've made considerable progress in making this happen. The attached circuit card is my first cut at a practical two-channel 55dB stepped attenuator. I have previously verified that the control system works, using a simpler PIC and a single LDR. My proposed two-channel full attenuator uses four devices per channel in a "T" attenuator format with two devices creating the two sides of the top, and two devices wired in modified parallel forming the trunk. Each set of four will be installed in a 24 pin DIP header and will constitute one T attenuator.

Tinitus has kindly agreed to move some posts of mine from another thread, and those posts will contain more detail. I'll post more info when this new thread is established and my posts have been moved over and I know what's already here.

tinitus 17th July 2010 08:54 PM

just in case some find anything confusing, post 2 and 3 are moved to this new thread from lightspeed thread

good luck :cop:

Badge 17th July 2010 09:01 PM

I am looking forward to your actual tests of this circuit.

wapo54001 17th July 2010 10:08 PM


Originally Posted by Badge (
I am looking forward to your actual tests of this circuit.

The next step (after thoroughly rechecking the board) is to build a few using ZIF sockets for the PIC and one LDR header and, leaving the other header socket empty in order to use those control and read lines from the empty side to make a test & calibration capability.

That will allow me to create sets of 1 PIC and two headers that will form the basis for a fully calibrated stereo/dual mono board. As long as the two headers and the customized program in the PIC stay together as a set, all other components will not have an impact on system accuracy (as long as the power supply voltage is maintained accurately.

gootee 18th July 2010 04:48 AM

Cool!! Good work!

I have pspice models of the LDRs, that I have used in LTspice, if you are into spice and would like to have them. You can check out my posts in the lightspeed thread and in the other LDR attenuator thread. I did some work on keeping the input and output impedances from varying so much, as they do with the Lightspeed, and on making them what you want (by adding simple passive resistances in the right places, covered to some extent in my old posts).

Also, I wonder if there might be any payoff to using actual near-real-time feedback of the average input and output levels, instead of, or maybe in addition to, memorizing each LDR's characteristics.


Tom Gootee

wapo54001 18th July 2010 10:18 AM

Thank you for the offer, I have never used Spice at all, I've never actually done much with designing circuits. What I'm trying to do here is really simple, hardware-wise.

Interesting that you'd mention using resistors in the right places to better control LDRs in the Lightspeed configuration. I, too, felt that circuit could benefit a lot from some simple optimizing, but I never saw your posts. I went through those 3000+ posts pretty fast, I confess. I could not see that the circuits, as published in the Lightspeed thread, did anything to limit the operating resistance range of the LDRs to a "useful" range.

With regard to 'near real time feedback' how would you even achieve it without touching the audio circuit somehow? I know that PerkinElmer produces units with dual LDRs built in, but the basic specs for those units make them unattractive for audio, I think.

I went back and reread other threads that addressed LDRs and was surprised by how many attempts there have been to make the concept practical both commercially and for the diy-er. It appears that my approach is entirely different -- for a start I'm working toward a T attenuator which has constant input and output impedance. In spreadsheeting the values, it appears that a wide range of impedances is possible from a few kilo ohms up to maybe 10K, so a pair (or set of many) could be made for specific values.

At one point I got excited when I read that you can design a T attenuator with high input Z and lo output Z, but when you run the numbers it turns out that some of the resistors have negative values until you get into pretty high attenuation levels. Not practical.

gootee 18th July 2010 04:53 PM

You should be able to find most of my posts by searching for "LDR gootee".

Yes, to get feedback you would have to connect to the audio. But if you had an extremely-high-impedance input, for that circuit, there would be no effect on the audio.

But I don't know that it would be a potential improvement. It might just be another way of getting a similar result. And it would certainly add complexity. And it might be difficult to get it to work well. So carry on!

P.S. I also designed a circuit that can completely linearize the normally more like logarithmic resistance vs control current response curve of any LDR. Unfortunately, it requires a second LDR that is an exact match to the one being linearized, in order to precisely linearize it.



wapo54001 18th July 2010 07:07 PM


Originally Posted by gootee (

P.S. I also designed a circuit that can completely linearize the normally more like logarithmic resistance vs control current response curve of any LDR. Unfortunately, it requires a second LDR that is an exact match to the one being linearized, in order to precisely linearize it.



If you've already done this, you could provide some very useful information to me: I want to know how close the LDR curve is to a log curve, and if it makes sense to control it from a log control. Just from one hour of testing, it appears to me that the Lightspeed crowd is doubling the curve by using a log taper control to run the already-log NSL32. Am I right, or is a log control necessary to get a log output from the LDR?

All times are GMT. The time now is 07:39 AM.

Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 18.75%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Copyright ©1999-2018 diyAudio