A precision LED/LDR-based Attenuator

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



That same flood-fill could also basically eliminate the effects of sharing the single "current out" trace by currents from multiple LEDs, which would probably be a good idea, so that the distributed voltages induced along the traces (which would basically appear back at every LED cathode) by current from one LED, flowing through the trace impedance, wouldn't affect another LED, and using more of a plane would also minimize the effect of each LED's own current on its own downstream voltage, which overall would present a more-constant "ground" voltage to the more-negative end of each LED.


Cheers,

Tom

Tom, please look at the schematic with the planes removed.

You can see that there is a star ground with individual parts of the circuit grounded directly to a single point, which is the main capacitor on the output of the regulator. I've tried to avoid having various currents interfere with other parts of the circuit. The PIC has it's own ground, the analog op-amps have their own ground, the LDRs have their own ground, the status LED has it's own ground (and the LED will change state (flash) only when the PIC is actually moving the input to the op-amps. When the op-amp input is steady, the LED will always be steady and no abrupt current changes will occur..

On each channel, all LEDs will spend most of their time consuming maybe a single milliamp or two per R1 and R2 leg, given typical listening levels. At the worst, only one leg will be at 'full power' which will be somewhere between 5ma and 10ma. So, total maximum current consumption per channel is 10ma.

So, having seen the details, are you still concerned about ground circuits?

Second, will you please be much more explicit in what you are talking about with regard to Zin and Zout? I'm not sure how I can control that except by changing the resistance value of the simulated potentiometer. Is there something that I'm not seeing?

Thanks for your comments.
 

Attachments

  • ScreenShot013.jpg
    ScreenShot013.jpg
    324.9 KB · Views: 584
<snipped>

Second, will you please be much more explicit in what you are talking about with regard to Zin and Zout? I'm not sure how I can control that except by changing the resistance value of the simulated potentiometer. Is there something that I'm not seeing?

Thanks for your comments.

Background:

Zin and Zout are the input and output impedances of the two-port attenuator network.

Ideally, Zin would be very high and Zout would be very low, so that they would cause minimal adverse effects when combined with the source and the load.

With a DC-type device, such as this, you could measure the input impedance, Zin, by connecting a fixed-value constant current source across the input terminals, and connect a representative load resistance across the output terminals (repeating the entire test for various different load resistances, e.g. maybe 10k, 20k, 50k, 100k, 1Meg.), and then measure and record the voltage across the input terminals as the attenuation was varied from minimum to maximum. Make sure that you go slowly, to allow the LDR response to stabilize at each level to be measured. Then you would plot the measured voltage across the input terminals, divided by the amplitude of the current from the current source that was applied between/across them, versus the attenuation control setting.

With that setup, it would probably also be a good idea to plot the output voltage divided by the input voltage (the gain), or, the attenuation, versus the attenuation control's setting.

I use a constant current source, for the above, when doing simulations. But on a test bench I don't see (at least not at this hour) why you couldn't just use a DC voltage source with a series resistance, instead, even if it sagged. It seems like the ratio of the voltage to the current should still always be the correct input impedance, at each attenuation control setting, as long as the internal voltages and currents always stayed within the LDRs' normal limits. Maybe you could just try some different series resistances, to see if it made a difference.

NOTE that you would need to measure both the current and the voltage, if the source was not guaranteed to be absolutely constant at a fixed value (and you might as well assume it's not, in any case).

To measure the output impedance, Zout, you would connect a resistance across the input terminals (probably repeating the testing with various resistances, to simulate different source resistances, e.g. 0 Ohms to several kOhms). You would disconnect any load resistance and connect a fixed-value constant current source between the output terminals. Then measure and record the voltage across the output terminals as the attenuation control is varied from minimum to maximum. Then plot the voltage divided by the current versus the control setting. (Previous comments about the actual source used for bench testing might apply.)

Concerns:

Without buffers, the input and output impedance of a series/shunt attenuator vary, when the attenuation is varied.

The maximum of the series and shunt resistances is usually the largest determining factor in the ranges that the input and output impedances can have.

If you imagine a simple case where the two resistances change linearly as the volume control is varied from min to max, such as from 10k to 0 Ohms for the series element as the shunt element goes from 0 Ohms to 10k Ohms, you can probably see that the output impedance is basically their parallel combination (assuming an ideal source impedance of zero Ohms). So the output impedance would vary from zero to a maximum of 5K || 5K (i.e. 2.5k) and then back to zero.

A lower output impedance is better, so the lower the maximum resistances of the series and shunt elements are, the better, since that would mean a lower maximum Zout (the parallel combination of 1/2 of each element's maximum value) at the midpoint of the volume control's travel.

Unfortunately, the input impedance would be better-behaved if the maximum resistances of the series and shunt elements were as high as possible. Zin is basically the series combination of a) the load impedance in parallel with the shunt element's resistance, and, b) the series element's resistance. At minimum volume setting, Zin will start at about the series element's resistance. Then as the shunt element's resistance comes up, as the volume is increased, and the series element's resistance decreases, the input impedance will tend to slope downward, until, at max volume, it's equal to the shunt element's maximum resistance in parallel with the load resistance. That value is pretty-much guaranteed to be less than the maximum shunt element resistance, since it would be in parallel with the load resistance.

It seems like 10k Ohms is a good minimum input impedance, if you want to be able to handle tube amplifier outputs as the source (although 20k or more would be better). But if you have a 10k input impedance as your load, then your input impedance, with a 10k max shunt resistance, will go down to 5k Ohms, at max volume.

That should be OK for most solid state sources' output impedances, and probably more-or-less OK for anything with up to 500 Ohms or so, although I might want to stick with 50 Ohms or less for the source impedance if I was trying to drive 5k Ohms.

Also, at the same time, the output impedance will peak at 2.5k Ohms, at mid-volume. That's pretty high and the amp being driven should probably have 10x to 100x that much as its input impedance; so 25k Ohms, or maybe much more.

Anyway, those figures were for linear resistance profiles, which are probably not the optimal profiles. For example, if the resistance curves were a little-bit "concave-upward", sagging a bit where they intersect at the mid-volume setting, then you should get a lower maximum output impedance, which would be better. If you let the shunt element have a higher maximum resistance, you might get a better (higher) minimum input impedance at maximum volume. Note that each of those would also affect the overall gain profile (as plotted versus the volume control setting). But you will probably want to play around with the resistance profiles, in order to try to get the best combination of minimum input impedance (the higher the better) and maximum output impedance (the lower the better). I guess that, generally, raising the maximum element resistances while letting their response curves sag more where they cross could improve things, especially for Zout, up to a point. And I like the idea of a higher max resistance for the shunt element but I haven't actually tried it, or even thought it through. But if it works then it might solve part of the Zin problem, so that maybe you could keep it from going below 10k Ohms. Unfortunately, that will probably prevent you from being able to get to max volume. There are definitely trade-offs to analyze.

Idea: Maybe you could have three switchable modes, so that users could select either better input impedance, better output impedance, or the standard compromise.

Cheers,

Tom
 
Last edited:
ScreenShot015.jpg

Tom,

I think what you are saying is that a full ground backplane is (probably and marginally) better than the star configuration in this circuit. I personally truly have no idea, and your arguments sound convincing. So, the attached is my interpretation of what I think you said.

1. Have I correctly understood where you were headed?

2. If this is the preferred ground plane, what should I do with the top layer? Leave the traces as-is, with power connections still going to the individual parts of the board in a star configuration?

Comments appreciated.
 
Last edited:
Background:

Zin and Zout are the input and output impedances of the two-port attenuator network.

............................

Anyway, those figures were for linear resistance profiles, which are probably not the optimal profiles. For example, if the resistance curves were a little-bit "concave-upward", sagging a bit where they intersect at the mid-volume setting, then you should get a lower maximum output impedance, which would be better. If you let the shunt element have a higher maximum resistance, you might get a better (higher) minimum input impedance at maximum volume. Note that each of those would also affect the overall gain profile (as plotted versus the volume control setting). But you will probably want to play around with the resistance profiles, in order to try to get the best combination of minimum input impedance (the higher the better) and maximum output impedance (the lower the better). I guess that, generally, raising the maximum element resistances while letting their response curves sag more where they cross could improve things, especially for Zout, up to a point. And I like the idea of a higher max resistance for the shunt element but I haven't actually tried it, or even thought it through. But if it works then it might solve part of the Zin problem, so that maybe you could keep it from going below 10k Ohms. Unfortunately, that will probably prevent you from being able to get to max volume. There are definitely trade-offs to analyze.

Idea: Maybe you could have three switchable modes, so that users could select either better input impedance, better output impedance, or the standard compromise.

Cheers,

Tom

Tom, great explanation, thank you! For the most part, I think I already knew the first parts of this explanation, and I understand that for an unbuffered pot there are compromises between ideal Zin and Zout values.

I'm trying to do an LDR volume control even with all the compromises involved, and I want to do it without buffers.

Presently, my goal is to build a 10K, logarithmic response potentiometer made entirely of LDRs. It's my goal because with my limited understanding, it is the optimal compromise of all the competing demands that you so eloquently listed above. It appears that there is no solution that is optimal for all the competing aspects of the circuit.

There seem to be two pieces you are suggesting that I have not looked at, do I have them right?

1) Different curves for the series and the shunt resistances -- so the series resistance and the shunt resistance do not always add up to 10K at each point in a 10K pot's rotation.

2) A pot with three different (selectable) pot values of, say, 10K, 15K, and 25K.

The first seems doable, the second would be difficult due to memory space constraints within the PIC. However, each individual version of the circuit could be built to be any value pot desired, as long as the LDR is still controllable at that resistance value. I think a 50K pot would be beyond the ability of the circuit as I have it presently designed.
 
Tom, great explanation, thank you! For the most part, I think I already knew the first parts of this explanation, and I understand that for an unbuffered pot there are compromises between ideal Zin and Zout values.

Tom, I didn't say it in so many words, but here is my quandry: It appears to me that there are, as you say, tradeoffs to be made and, the thing is, it seems to me that the tradeoff is unavoidable and each limitation can be ameliorated only by making another tradeoff condition worse. Aside from making the pot of a different value, say 20K instead of 10K, is there any action to be taken that doesn't turn the resulting device into a specialized pot that is optimized for a specific source and load? I want to design a pot that is suited for the preponderance of applications.
 
View attachment 284915

Tom,

I think what you are saying is that a full ground backplane is (probably and marginally) better than the star configuration in this circuit. I personally truly have no idea, and your arguments sound convincing. So, the attached is my interpretation of what I think you said.

1. Have I correctly understood where you were headed?

2. If this is the preferred ground plane, what should I do with the top layer? Leave the traces as-is, with power connections still going to the individual parts of the board in a star configuration?

Comments appreciated.

Actually, I was only talking about filling the area around the LDRs; basically just a partial ground plane for the LED ground returns.

But I will compare your last posted layout to the previous one, when I get back to my computer.
 
:cop: I've had to remove a number of posts due to a personal attack, and colateral damage.


Bit quick on the trigger there Wintermute, a blind man could see what was going on. I believe AndrewT was in his rights to express it, maybe not in his Scottish sledgehammer way, but still had the right.
Lucky I didn't say anything, being Aussie I would have said it even less tactfully.


Cheers George
 
This post was removed. Wintermute was kind-enough to send it to me ao I could repost it after removing the offending quoted message.

There are people who understand all of the nuances of the theory and practice of ground and power planes and pcb design and analysis. I've got a lot of their scientific and technical papers and journal articles and books. It's a little difficult to generalize about, sometimes. But for particular cases, simulations and analysis can pretty-much tell you everything. And if nothing else the likely alternatives can simply be tested.

There are a few people who frequent diyaudo.com whostudy and design PCB planes etc for a living. But I am not one of them.

At any rate, I'm not a huge expert and I'm not saying that it would make a big difference, because I really don't know. But I can say with certainty that it would be better than what you currently have, just not by how much. I was and still am just wondering if you had a good reason for not planing that area (becuase if you didn't, I assumed that you would have done so).

The fact that the currents are very small also means that they are much more easily affected, and is actually a good argument FOR using either a plane/fill or a separate ground trace for each LED. You have neither.

Separate star ground traces for each LED probably wouldn't fit very well, so using a plane or ground-fill is probably the best option of the two. And for a second reason, discussed farther below, it is the preferred option.

As I said, I haven't done even any rough calculations to see how big the effects might be, of using a single shared ground return for the LED currents. I'm guessing "extremely small". But the LED currents are where the metal hits the meat, so to speak, for this device. They are critical. They ARE "the product". And they go down into the low double-digit microamps. What is the necessary precision, at that level?

OK. I guess we have to do this. Let's "explore", a little:

At 10k Ohms LDR resistance, you're using 20 uA through the LED, and 125 nA (0.125 uA) would change the LDR resistance by about 100 Ohms. You'll have about right at 2 Volts across your LED when it has 20 uA through it and the LDR is at about 10k Ohms.

Then, let's say that another LED is getting 10 mA. And say that goes back to the main ground through four inches of the single LED ground-return PCB trace, and say that has a resistance of roughly 1 milliOhm per inch, for .004 Ohms. That makes 40 uV. But you'd have two doing that, one per channel. So that's 80 uV.

That might change another LED's current by 7 nA or so, which might change a 10k LDR resistance by 10 Ohms, or 0.1%.

Is that enough to worry about? Maybe not. It might have been, if that was a difference between the two channels attenuations, since it might be noticeable as a change in balance. But although your LED ground return is much longer for one channel than it is for the other, the difference in attenuation between the channels would probably be less than 0.05%. Is that enough to worry about?

On the other hand, I didn't have any opamps in mind, above; just voltage sources and resistors and LEDs. So I don't know how your circuit might react or differ, regarding the effect of an 80 uV rise of an LED's ground voltage.


Problem 2:

There WILL, at times, be rather-strong RF (Radio Frequency) fields in the air, which will tend to invade every bit of everything, including inside of your attenuator's case. Those LED traces have some substantial loop area that has been formed by them. The LEDs are diodes, and have a pn junction, and some capacitance. In the RF world, they might also be able to be called detectors or demodulators. Every PN junction can rectify AC currents. In this case, it might be the AC currents that are induced by stray RF, on the LED traces, which look like very nice antennas.

Various "bad things" might happen, in that case. You might simply get a DC offset, if a continuous-wave RF signal is rectified, much like in a linear power supply. Or maybe there'll be an AM radio (or CB) station signal and you'll get the actual audio signal rummaging around in your LED-current traces, causing weird volume fluctuations at the speakers. Or maybe someone will flip a switch or some equipment will suddenly turn on and a very broadband RF burst will be rectified into a substantial DC pulse. Or, maybe, the RF will simply go the other way and enter your op amp circuits' outputs and then zoom backwards through the feedback resistors and enter the negative input pins. Round it goes. Where it stops, nobody knows. But there are lots of pn junctions in an opamp and extra DC from rectified RF could change internal operating points, and also cause all of the other effects just mentioned, but inside of the op amps.

Do you really want to worry about any of that?

Cheers,

Tom
 
Last edited:
A very fundamental question. I have tried to find information of the proper values of series and shunt resistor for my LDR attenuator.
For high frequency transmission a common subject is to match source and load impedances, for this matter there are exact laws of how to create a minimum loss attenuator. But for audio volume control, this seems to be a subject where it is more of a “black art” of how to find to optimal resistor values. In many stepped attenuator common series resistor values are 10kOhm or 100kOhm, but there must be some optimum based on exact theories?
Basically what I like to do is to adjust the current to the LDR:s so at normal listening volume I will have the best source and load impedance match.

In my system I have:
A DAC with 100 Ohm output impedance
Monoblock with 60 kOhm input impedance

Can someone guide me with finding the optimal minimum loss attenuator?
 
one does not "match" impedances with analogue audio frequencies.

"matching" is used for transmission lines and these only become "matched" at VHF, eg. digital (almost squarewaves).
"matching" is also used for maximal power transmission as in RF aerial to RF input of a receiver.

For analogue audio, each Source Receiver combination must be organised such that the passband includes all the audio frequencies you want to hear.
This is usually done by using Source impedance <1k and Receiver impedance >10k

The volume control pot (or your LED/LDR) must be considered a Receiver at the input end and then must be considered a Source at it's output end.
 
I've been on a long break from this project -- I needed to get away, and a photography project had been long beckoning . . .

Attached is a view of my final effort with getting the best possible ground plane for this project. There are two main changes -- one is fewer traces interrupting the ground plane (more traces were moved to the top of the board) and second, the edge where the digital ground plane and the analog ground plane abut was adjusted for a slightly better configuration.

In the next few days I intend to get back to programming the PIC.
 

Attachments

  • ScreenShot002.jpg
    ScreenShot002.jpg
    502.7 KB · Views: 607
My photography project is finally set up and running, so it's time to get back to the LDR project.

When I thought I'd refined the board design to the nth degree, I kept finding little tweaks that seemed to be a bit of an improvement. But I've run out of ideas and the board has gone to manufacturing.

The ground plane has improved some more, additional traces moved from the bottom of the board to the top, see attached image.

The new board should be here Thursday, and digi-key has already delivered the parts for stuffing. Hopefully by the weekend I'll have a board with one LDR path working so I can use that to do some LDR testing. I'll post a photo when I have the board stuffed and ready to test.

Between previous purchases and a recent purchase I think I have fifty + LDRs to test. My test will be fairly straightforward. Can a given unit achieve 50 ohms or less resistance at 11 milliamps of current or less. If yes, I'll test for resistance at .005 milliamps and if the resistance is 20K ohms or more, that will be a shunt LDR. If it passes the 20K test but not the 50 ohm test, it'll be a series LDR. Once I have all of my LDRs tested and sorted, I'll stuff the board with a full complement of six LDRs and start working on expanding the single channel code that's working now into the full four channels needed for a stereo LDR volume control.
 

Attachments

  • ScreenShot2004.jpg
    ScreenShot2004.jpg
    666.7 KB · Views: 449
Here is an image of the partially-stuffed board.

One row of four resistors will not be inserted until I've had a chance to operate one channel to determine the optimal value resistor to operate with the capacitor value I chose. Also I'm holding off on stuffing the row of trimmer resistors until I'm comfortable that the value I chose for the pots will cover all eventualities.

I did not enjoy installing those smt ics and capacitors!
 

Attachments

  • Partially Stuffed PCB.jpg
    Partially Stuffed PCB.jpg
    451 KB · Views: 433
I have been working on this board off-and-on (mostly off!) for some time. I really wanted to keep it simple, and for some time I tried to use voltage control of the LDRs. That simply has not worked out.

Three days ago, I was ready to throw the whole project into the trash and simply forget about it, but then I decided to go back to an earlier, more complicated design that used current control. I worked with that a bit using software that I had been improving while working with the voltage control board. That helped, but wasn't perfect. I had one last thing to modify and when I did, Bingo! This board now controls four channels of variable current from 12ma down to around 20 micro amps with excellent precision. It was a combination of software tweaking (keep it simple and fast!) and adjusting the integrator RC. The last key step was to abandon tantalum which was leaky and required constant large corrections in favor of a smaller value polyester in the integrator.

It turns out that this setup will reliably control LDR resistance to about 75K ohms. Above that, if you reduce the current beyond a certain point it appears that the LED completely extinguishes and it is necessary to increase the current substantially before it will light back up. But it seems a 50K pot would be entirely feasible.

Through measuring, I find that the board draws a maximum of 24ma not including the LDRs, so with the LDRs drawing a maximum of 12ma per channel, the board and LDRs together will draw a maximum of about 50ma. Accordingly, I've replaced the 317T with a 317L which is guaranteed to deliver 100ma under all conditions and 200ma if the in-out differential is kept below 13 volts. That is plenty of leeway. Most of the board current is consumed by the voltage-to-current conversion chips.

I'm finally in a position to start work on combining the travel of a linear potentiometer with the odd response curve of the LDRs and using the PIC to output the log response of a volume control.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.