Go Back   Home > Forums > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

Analog Line Level Preamplifiers , Passive Pre-amps, Crossovers, etc.

A precision LED/LDR-based Attenuator
A precision LED/LDR-based Attenuator
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 6th April 2011, 07:40 PM   #111
Alex Zhyk is offline Alex Zhyk  Netherlands
diyAudio Member
 
Join Date: Jan 2011
You probably should be prepared for making the PIC average the LDR resistance over the time and only adjust when it exceeds certain delta. I noted they have tendency to drift especially with not very stable current supplies.
Another thought. If your aim is to use unmatched LDRs (I may here mistake your project with some other) then you may also consider an option of putting two LDRs in parallel for the shunt to lover their minimum resistance. This way series LDRs will not have to go too high for the same level of attenuation and may even fit the range of your adc.
Just the thoughts of a lamer. Don't kick me too much if it does not makes any sense.
  Reply With Quote
Old 7th April 2011, 01:21 PM   #112
wapo54001 is offline wapo54001  United States
diyAudio Member
 
Join Date: Nov 2008
A precision LED/LDR-based Attenuator
Quote:
Originally Posted by Alex Zhyk View Post
You probably should be prepared for making the PIC average the LDR resistance over the time and only adjust when it exceeds certain delta. I noted they have tendency to drift especially with not very stable current supplies.
Another thought. If your aim is to use unmatched LDRs (I may here mistake your project with some other) then you may also consider an option of putting two LDRs in parallel for the shunt to lover their minimum resistance. This way series LDRs will not have to go too high for the same level of attenuation and may even fit the range of your adc.
Just the thoughts of a lamer. Don't kick me too much if it does not makes any sense.
Alex, you make good points.

Almost surely, the way to measure the LDRs is by a combination of averaging and time delay -- to make a change to PIC output, wait for, say, half a second, then make a series of measurements and average or, better yet, keep measuring until you get a series of identical measurements. Or use a variable delay depending upon the size of the change commanded.

Current will be actively controlled -- measured and continuously adjusted by the PIC, so substantial long-term current drift is not an issue, but there is a slight variability around the control limit of the LED, which is .00488V. This is trivial across most of the range, but becomes significant above about 100K ohms of LDR resistance, and we'll have to see how much of a difference this makes in real-world terms. My guess is that when the shunt is above 100K, the series resistor will be more in control, so the slight variation in shunt resistance won't matter.

I do plan to use unmatched LDRs. My goal is a flat Z of 5K across the attenuation band and minimum attenuation of .25dB. That would require a series resistance range of about 150 ohms to 5K ohms, and a shunt resistance range of 150K ohms to 40 ohms, and the 40 ohms requirement is the limiting factor. A parallel LDR would lower that to 20 ohms and that, frankly, is not a big difference in dB of attenuation. It may not be worth the trouble.
  Reply With Quote
Old 7th April 2011, 01:49 PM   #113
jackinnj is offline jackinnj  United States
diyAudio Member
 
jackinnj's Avatar
 
Join Date: Apr 2002
Location: Llanddewi Brefi, NJ
A precision LED/LDR-based Attenuator
Ya got RAM on that PIC, correct? Excercise the device, record the values and create a look-up table. At any rate, you CAN NOT use a linear approximation, averaging and the equation on the Silonex site, while close, isn't good enough.
  Reply With Quote
Old 7th April 2011, 02:36 PM   #114
wapo54001 is offline wapo54001  United States
diyAudio Member
 
Join Date: Nov 2008
A precision LED/LDR-based Attenuator
Quote:
Originally Posted by jackinnj View Post
Ya got RAM on that PIC, correct? Excercise the device, record the values and create a look-up table. At any rate, you CAN NOT use a linear approximation, averaging and the equation on the Silonex site, while close, isn't good enough.
I know what the capabilities of the PIC are, and I think I know what needs to be done. I'm not sure what it is that I said that leads you think otherwise.

With regards to the lookup table, keep in mind that each LDR requires a separate table, and each table will have almost 100 entries (about 45 dB in 1/2 dB steps). That's almost 400 entries for four devices (stereo, 2 devices per channel). Each entry, if done with brute force, must be capable of storing a value in excess of 256, which makes it a word (2 bytes), which results in a table of roughly 800 bytes, not including overhead. That's a lot of space to use for a lookup table. The methods that you have described are not the only options available, and none of them are the right option, in my opinion. However, I will not be discussing the code that I use.

I disagree with your suggestion that the data on the Silonex site is "close." It is nowhere near close. I certainly agree that it isn't good enough to depend on to create a functioning well-behaved attenuator. Each device must be measured individually.
  Reply With Quote
Old 7th April 2011, 05:21 PM   #115
jackinnj is offline jackinnj  United States
diyAudio Member
 
jackinnj's Avatar
 
Join Date: Apr 2002
Location: Llanddewi Brefi, NJ
A precision LED/LDR-based Attenuator
You can use a piece-wise linear approximation -- here's one I ran:

Click the image to open in full size.
  Reply With Quote
Old 8th April 2011, 06:12 PM   #116
oenboek is offline oenboek  Belgium
diyAudio Member
 
Join Date: Apr 2005
Location: Sint Katelijne Waver
Hi
I solved the calibration and itineration by using the routine described in this post: Sylonex and Arduino preamp
I don't measure every single point as it uses too much memory. I use values spread according a logarithmic scale. And I use interpolation to calculate the final values. This can be lineair as the intervals are small enough.
For calibration I suffered until I did put in delay and a check to have a certain amount of identical values. This is especially important for low resistance where the Sylonex is extremely slow (several seconds). For very high values there is some fluctuation in the results, there I limit the amount of checks before accepting the value.
There are also some limits in the soft to avoid oscillation. This was mainly needed because the speed of the loop is completely different at high resistance and at low resistance.
In practice this works really well, with unpaired optocouplers.
  Reply With Quote
Old 10th April 2011, 04:04 PM   #117
wapo54001 is offline wapo54001  United States
diyAudio Member
 
Join Date: Nov 2008
A precision LED/LDR-based Attenuator
Quote:
Originally Posted by oenboek View Post
Hi
I solved the calibration and itineration by using the routine described in this post: Sylonex and Arduino preamp
I don't measure every single point as it uses too much memory. I use values spread according a logarithmic scale. And I use interpolation to calculate the final values. This can be lineair as the intervals are small enough.
For calibration I suffered until I did put in delay and a check to have a certain amount of identical values. This is especially important for low resistance where the Sylonex is extremely slow (several seconds). For very high values there is some fluctuation in the results, there I limit the amount of checks before accepting the value.
There are also some limits in the soft to avoid oscillation. This was mainly needed because the speed of the loop is completely different at high resistance and at low resistance.
In practice this works really well, with unpaired optocouplers.
I visited your thread -- what a very impressive project, indeed! Very cool.

My main goal is to do something similar to what you have done, but to do it very simply, with a minimum of components. We'll see if it can work . . .

But initially, I'd like to run a detailed current/resistance analysis of all the LDRs I currently have (about 30 of them) to get a good feel for the extremes of production variation and to find the appropriate break points for the various slopes on the overall curve. Regrettably, I don't have consistent time to spend on the project, so I'm once again held up at this point.

Also looked very briefly at your program code, it appears that we are on a similar page in terms of needing to manage the vagaries of the Silonex device.

Thank you for pointing out your project, it was a very interesting read.
  Reply With Quote
Old 12th April 2011, 02:26 PM   #118
oenboek is offline oenboek  Belgium
diyAudio Member
 
Join Date: Apr 2005
Location: Sint Katelijne Waver
I made similar Current/Resistance curves before choosing the final optocouplers in my system. It seemed that most were in a similar range, but some were completely out of range and unusable in any way. I'm not at home this week, I'll post the curves when I'm home again. These curves were made without checking the stability of the reading. I should do them again using the part of the algorythm for calibration assuring stable values. But as everything is soldered now, I guess I'll just post my "old" curves.
  Reply With Quote
Old 22nd May 2011, 10:50 PM   #119
wapo54001 is offline wapo54001  United States
diyAudio Member
 
Join Date: Nov 2008
A precision LED/LDR-based Attenuator
Latest board design.
1. 2.5"x3.8" with lots of free space so can be made smaller yet
2. Different PIC -- 18 pin instead of 20 pin does the same job but in smaller package. This PIC is capable of multi-tasking four tasks simultaneously via time-slicing. This means that the overall task can be divided into three -- each two devices can be one task (1 channel) to maintain tight control of the devices while a third task handles the less time-sensitive overhead (reading input, calculating individual device corrections, etc). PIC will run up to 32MHz, so plenty fast for three tasks.
3. Two 8-pin .3" DIP carriers instead of one 24-pin .6" DIP makes for much less space used for the LDRs.
4. Converted to on-board wall wart plug for easy connection and minimal noise (no AC in the box). A hole in back of box will allow wall wart to plug directly into board.
5. Eurostyle screw terminal block for front-panel connections to pots and LED.
6. Easy to drive two boards (four channels) from a single power supply if desired. This will require a decent heat sink for the LM317, or bolt it to a metal case for heat dissipation.
7. Kept the three main power circuits -- LED, PIC, LDRs -- separately home-runned to regulator for minimal interaction. Plenty of bypassing.

The extra standoff holes at other than the corners of the board are for use with the three rows of bed-of-nails pins loaded on the programming & testing circuit board.

I'm in the middle re-numbering the components, so there are duplicates and omitted numbers in the drawing.
Attached Images
File Type: jpg ScreenShot003.jpg (231.3 KB, 511 views)
  Reply With Quote
Old 23rd May 2011, 05:57 AM   #120
gootee is offline gootee  United States
diyAudio Member
 
Join Date: Nov 2006
Location: Indiana
(I haven't looked at your very interesting thread for a long time and I might not be understanding what some of your components and connections are, so please forgive me if I am just completely wrong about what something in your circuit is, anywhere below.)

Looks pretty good except that you allowed a lot of loop area to be formed between the +5V and Gnd that wouldn't have to be there. (Example: downstream from each of the caps labeled C4. What's up with THAT?) ANY loop area that's formed will allow AC and RF in the air to induce corresponding currents in the loop (or, the loop could transmit RF or AC _INTO_ the air, in the case where your loop already had its own time-varying currents). Either way can be "a bad thing", under the wrong conditions, which probably will eventually occur, so you need to prevent it from affecting your circuit.

Instead, each part of a power rail trace and its ground return should always and everywhere be as close to each other as possible. In your case that could mean overlapping them, on opposite sides of the board, absolutely as much as possible. But you should probably just fill in everything you can with a ground plane, on that (green) side of the board (or several large portions of ground plane, if you're keeping the LED, PIC, and LDR power circuits separated).

The same "avoid loop area" idea applies to ALL natural pairs of conductors, such as audio signal and gnd, AC power pair, DC power pair, speaker or output pair, etc etc. Some are "transmitters" and some are "receivers". Just avoid them all. (If they're wires instead of traces, use shielded twisted pair, where the shield is used ONLY as a shield, and is connected to gnd at one end only. Next-best common way is probably twisting a pair of individual wires together, tightly.)

Is C6 a bypass capacitor for a chip's power pins? If so, it is WAY too far from the pins. Try putting it _directly_ across the pins, probably soldered on the bottom of the board, if you can. Every millimeter counts(!), there, especially for digital stuff. The inductance of the longer traces (like you currently have) will make it really difficult for the cap to act as a good point-of-load power supply, which is what it needs to do to not have demands for fast-changing supply currents induce voltage spikes on the power rail. And where C6 currently is (after you move it to be directly across the pins), I'd put something like a 10 uF or larger electrolytic, with a not-especially-low ESR, although the electrolytic too should be MUCH closer to the chip's power pins, if at all possible.

Always try to put a pair of bypass caps (a small cheap ceramic and a small cheap electrolytic in parallel are usually best) RIGHT AT the exact point where the changing demand for current needs to be met.

Similarly, C5 and C2 are too far away from the regulator. What kind of cap is C5, anyway? Is that the adjust pin that it's bypassing? That would be very good, but you'd probably want something like a cheap (i.e. not-too-low ESR) 22uF electrolytic for that.

Also, I'd seriously consider putting in an RF low-pass filter wherever anything comes in from off your board, and also wherever a trace becomes an input to anything, and also after any trace that's more than a couple of inches long. Wherever you have a resistor, or a resistance, you can usually stick a small ceramic or film cap to ground just downstream, with the C calculated for each R so that the lowpass cutoff frequency is a few hundred kilohertz (or as low as you can get away with). I would even do it at the LDRs', in the audio path (especially there, probably).

One last thing: If you don't use ground planes, make sure that you don't run dis-similar ground returns through the same length of conductor. Keep them separate _ALL_ the way back to the big smoothing caps. Otherwise, the voltages induced across the distributed inductance of the ground return conductor will appear back at the upstream end of ALL of the ground returns. Anything with dynamic (fast-changing) ground-return currents will be a big polluter, even if the currents have low amplitude, since the amplitude of a voltage induced across an inductance is proportional to the RATE-OF-CHANGE of the current.

Sorry to have blathered-on about all of that, for so long.

Cheers,

Tom

Last edited by gootee; 23rd May 2011 at 06:00 AM.
  Reply With Quote

Reply


A precision LED/LDR-based AttenuatorHide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LDR photoresistor attenuator preamp, in general romana Analog Line Level 54 14th December 2013 02:32 AM
TUBEpre and Lightspeed LDR attenuator tinitus Analog Line Level 5 31st January 2010 05:08 PM
LDR attenuator questions Carlp Analog Line Level 15 21st January 2010 01:01 AM
LED to LDR amplifier electro samurai Analogue Source 8 21st March 2004 05:07 PM
Spectrol, high precision, 10k attenuator. Peter Daniel Swap Meet 3 4th February 2004 05:15 PM


New To Site? Need Help?

All times are GMT. The time now is 05:53 PM.


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