uC + 2xMCP42100 to control LDR attenuator - some measurements

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

I'm in the process of rebuilding my LDR+DCB1 preamp and I decided to use the microController already on board to manage the volume. Looking around I've seen few people using a uC to control a digital potenziometer replacing the mechanical double pot used with the LDR attenuator, but I don't see any relevant advantage a part from the fact you can increase/decrease the volume with 2 buttons (or a remote) without the need for a motorized pot.

What I'm doing here (and I'd like to share to have your feedback) is driving each optocoupler separately, removing the need for any trimmer and the need for matched optocouplers. I'm going to control the volume using a rotary encoder and I'm going to program the uC to increase/descrease the volume of 1dB per step. I'm trying to understand how good this solution is in terms of balancing between the two channels and accuracy of the attenuation.

The scenario I'm testing: the brain is an Arduino Nano and the digital potentiometers are MCP42100 (8bit dual 100k pot). I'm attaching the schema of the test bed: POT0 and POT1 are the first and second pots of each MCP42100 and Vcc is the +5V directly from Arduino +5V pin that is powered by the USB port. Consider that Vcc is actually 4.8-4.7V (because of the way I'm feeding the Arduino).
The two test points are used by the same Arduino to measure the voltage differences (A0 and A5 pin) coming from the resistive divider made by the load and shunt resistors. I'm attaching Vref pin to Vcc to have a full scale reading [0;1023].

Now, why am I reading the output of the res divider instead of the values of each opto resistence? For two reasons:
1) to measure a voltage is easier with the Arduino
2) I wrote a super simple sketch to test all the possible 65k combinations of POT0 and POT1 values and log the related voltage drop. It takes a lot of time to run but it's just machine time (no my time ;) ) and I get a detailed matrix as output of the process without the need for any manual measure

Considering the Arduino has a 10bit ADC, theorically we could measure an attenuation of 60dB - that's not exactly true but we can say we have good readings up to 40-45dB.

Regarding the difference between the real attenuation drop and what is estimated, the mean squared error in the range [0;-40db] is 0,00885. Or if you prefer, the average distance between the estimated attenuation and the real measure is in the range +/-0,19%. Or if you prefer, if you are looking for an attenuation of -20.0dB you can set the digital potentiometer to have -20.0255dB.
Increasing the attenuation, the error increases as expected and we cannot just select any single value we want - but this is related to the resolution of the ADC-DAC I used. Just to give you an idea, below -40dB we can manage: -41, -42, -43, -45, -46, -48, -51, -54 and -60dB attenuation with a MSE=0,057 (+/-0,47%)... not so bad.

Regarding the balancing between the two channels, I can say we can be really accurate because we can control the input channels separatly (2 MCP42100 used here), so if the unmatched optocouplers need different voltages on load and shunt res of the left and right channel, we can just manage that: two dig pots give us a huge number of combinations.
The idea, to make it easy, is to run a calibration procedure and create four fine tuned look up tables (one for each pot), save them in the EEPROM memory of the uC and use the volume level as an index of the LUTs.

Once I'll finish the audio section of the preamp I'll be able to run another calibration test including input relay, mute relay and the B1 buffer to have the real end-to-end attenuation.
 

Attachments

  • test_scenario.jpg
    test_scenario.jpg
    48.5 KB · Views: 198
Zen, believe me it's just 3 lines of code to talk with the dig pot.
I decided to use an Arduino just because I got one on my desk but I guess it's the same with a PIC.

The first test gives a lot of different combinations to have the same attenuation, so I decided to run another test session focused on resistance of each opto measured separately to have as many info as possible.
At the end of the day, I have to program the 4 dig pots with 4 different values in the range [0;255] (it's a 8bit dig pot) - let's call it the 'working point' of the pot.

I guess the choice of the best 'working point' should be based on:
1) the accuracy of the attenuation we want to reach
2) the balance between the two channels (the distance between the attenuations on left and right input)
3) the resistance provided by the sum of load and shunt res

No issue with first and second points, but regarding the last one there is something I'd like to share. Let me do an example: let's assume I want to obtain a -7dB attenuation.
In this case the best choise is:
-left ch: -6.986dB working point (156;159)
-right ch: -6.995dB working point (197;188)

In percentage, the error on left channel is 0.2% and on right channel in 0,07% - as expected. The distance between the two channels is 0.13%

It seems we have a winner, but... as you can see the 'working points' are not so close and that has an impact on the total resistance (load+shunt) that is:
- left ch: 5554Ohms
- right ch: 2507Ohms

Measures are not really accurate but they give you an idea of what I'm talking about.

So my question here is how much those values are relevant considering this is the first resistance the input signal finds on its own path.
Should I choose closer working points even sacrificing a bit the attenuation accuracy?
Should I choose a total resistance as higher as I can?
 
Official Court Jester
Joined 2003
Paid Member
if you put decent buffer** in front of it and after (yes , two of them) , all those problems are irrelevant

seems complicated , but usually that approach (buffer in front and after) is viable for plain ole pot

**say complementary JFET buffer (F4 , F6 as examples ....also known as Borbely or Curl buffer) , with decent PSU ; either shunt or series followed with cap multipliers
 
I'd like to avoid an input buffer if not strictly needed (at the very beginning my idea was to have a passive preamp, with just an attenuator :D )

Let's say that in the range [0dB;-40dB] the resistance made by the sum of load and shunt res is in the range [3000Ohm;6000Ohm]. It's possible to find combinations to have left and right resistance pretty close. Just to remain on the same -7dB example, a possible solution is:
-left ch: -6.79dB => tot res = 3280Ohm, working point (181;183)
-right ch: -6.72dB => tot res = 3100Ohm, working point (188;178)

If 3K is a reasonable value, I'll try to keep it simple not adding any input buffer. In any case I guess this is a standard value for LDR attenuator: this value doesn't depend on the particular way I'm trying to drive the optocouplers.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.