Programmable gain non inverting amplifier

I'm a hobbyist and like to design my own tools rather than buying chinese "kits" that teach nothing.

I have been needing all sorts of amplifiers for different things and usually I would just use an op amp and a few resistors to do the job but that's time consuming and I usually end up losing the resistors afterwards XD So I decided to look into making a programmable gain amplifier.

The obvious choice was using digital pots so I had a look at a few microchip application notes in order to have some idea about accuracy and stability of different designs. This one was exactly what I was searching for: http://ww1.microchip.com/downloads/en/Appnotes/01316A.pdf

If you look at figure 6 (page 15) they show a tempco compensated, wide range amplifier which uses 2 pots. I already have a few 10K MCP4652 digital pots which are also perfect for this application, but there are 2 issues:

1) There is no easy way to calculate the gain, unlike other designs, which led me to do a basic analysis to see the range of available gains (using python).

This first graph is the gain vs R1 (I didn't know how to do a 3D graph, ideally it would be a graph of gain vs R1 vs R2): Just wow! it's pretty obvious that a lot of gain values are repeated and multiple resistor values yield the same result. so I made another graph, this time it only includes gain values that are repeated more than once and how many times they have been repeated. For gains of 1 and 2, there are 256 repeats since all values of the pots works, but even for really high gain values, repeated values exist.

I'm not sure how I should go about implementing the software. easiest way seems to be removing the duplicates and sorting the list, then storing it in the MCU memory, then using a lookup table to find the nearest gain to the desired value. this will also allow going through the list iteratively with a manual encoder or similar! but this will use a ton of memory. Please let me know if there are better ways of doing this. Edit: there are a total of 39896 different gain values. if stored as floats (each takes 4 bytes), they will take 159584‬ bytes (almost 156KB), each of the gain values needs two resistor values and since the pot has 257 taps, they need to be int or unsigned int, tripling the memory usage (468KB)! an external EEPROM solves that but that is added cost. Calculating the next higher gain value and the resistor values needed for it seem like a good choice, but I don't think that's possible, especially since the highest resistor combination is most likely not achieved which I discussed in the next part.

2) the more important issue would be the current through R1+R2. the pot is rated for an absolute maximum of 10mA current. for an op amp powered from +/-18V (a very typical supply voltage) this can easily happen if the resistor values are too low. I think using 100K pots instead of 10K, and only saving the highest combination of resistor values for a particular gain should solve that, but again, if there is another way to limit the current, please let me know. I know op amps "can't drive much current" but they can most certainly drive 10mA with ease.

Here is a graph showing current through the resistors when minimum resistance combination is used (18V supply, 10K pots): The maximum current is 3.5mA as you can see. Now the same graph, just using the maximum resistance combination possible: This can exceed 400mA! the op amp can't drive that much current, but this is surely susceptible to damaging the pot. If I want to pre-compute the list, I should be careful to not choose small values.

• "for an op amp powered from +/-18V..." - the MCP4652 has maximum operating voltage of 5.5V, so +/-18V is out of the question anyway. Aug 13, 2019 at 7:02
• I might have not read the datasheet completely and missed that, but there are other pots like MCP41HV, and they have very similar max current ratings and upto 40V operation which certainly fits the +/-18V constraint. Aug 13, 2019 at 7:04

The standard way to achieve this is using a Voltage Controlled Amplifier. If you want uP control, you would typically use a D to A output to drive the VCA.

Of course not all amplifiers are created equal, in terms of noise, THD, frequency range and so on, so some care is needed in selection of type. I link to the page of THAT Corp which specialises in VCA's for use in audio (where they are heavily used in compressors, limiters and other types of dynamic control).

By the way if you want an easy way to find standard (E24) resistor combinations for a particular gain (inverting or non-inverting) I wrote a book some years ago which tabulates that kind of thing.

• they seem like specialty parts, and cost quite a bit more than all the parts I have combine, especially when you add the cost of the DAC and a voltage reference. In terms of resistor values, well they are not standard E24 values, rather small incerements of about 39ohms for the 10K pot and 390ohms for the 100K pots. Aug 13, 2019 at 8:00
• As I said, yes these are high quality parts for the pro-audio market. It all just depends what you want to achieve, and how much time/money you want to spend. I don't know what you mean by the resistor values - what "they" are you referring to? Aug 13, 2019 at 8:24
• I meant the digital pots. they are not standard values like you mentioned that I can use for a given gain. they have a given resistance (usually 5K,10K or 100K) divided into a number of segments (257 segments in my case). 10K/256 is about 39ohms, which means the resistor values that I can use are not standard values. Aug 13, 2019 at 10:56

You're proposing to use the digital pots in rheostat mode. It's more common, and usually much better, to use them in potentiometer mode.

Advantages are reduced component count, better tempco (both resistors on the same piece of silicon) compared to using separate pots, though if it's a dual pot then they're on the same bit anyway.

Table 5 page 6 suggests a disadvantage of this is 'less control over gain'. This is due to the omission of the padding resistors R1 and R2 from figure 3a. These allow you to dilute the effect of adjustments on Pot1, ie control the range of gains that can be programmed. However, these resistors don't match the tempco of Pot1, so destroy the good tempco advantage, and they also prevent extreme gains being programmed, which for the (presumably) general purpose 'tool' you're building, is a disadvantage.

Using a single Pot1 has the incidental advantage of limiting the current taken by the pot to rail/Rpot, regardless of setting. While this looks like an empty advantage that you could enforce in software, it does mean that now software failures can endanger the pot through over-dissipation (what, you mean you never have bugs when you're developing this sort of thing?)

If you have a dual pot to start with, then using one in pot mode as in 5a and the other for the one of the two padding resistors R1 or R2 (they give you different adjustment options) results in all the advantages with none of the disadvantages.

Is there a better way than populating a memory with precomputed ratios? Use C for your MCU, and use its floating point division to compute them at the time.

• those are inverting amplifiers, but I specifically put "non inverting" in the title :) Also when using dual digital pots like the MCP4652 which I mentioned, the tempco matching is almost perfect (1PPM/C or so) since they are also on the same piece of silicon! Also the circuit in figure 6 uses minimum components (a dual digital pot and an op amp) , has very wide gain control (1 to 256) with fine control on the lower gain values. This is by far the best circuit recommended. Aug 13, 2019 at 6:52
• @OM222O Doh, I misread the diagram, but it's exactly the same feedback structure if you switch ground and input, I'll draw my own diagram. I suspect they show inverting because you can get gains below 1 as well as above. No, it's 5b page 14, will update the answer. Aug 13, 2019 at 6:56
• please have a look at the updated post as well, thanks. Also please have a look at table 9 (page 13) which compares the diagrams. it has all 3 possible solutions (5a, 5b and 6c) Aug 13, 2019 at 6:58
• @OM222O then check again, it's obvious that the current through small resistors will be higher than through big ones, unless something else is limiting the current like the amplifier output capability Aug 13, 2019 at 7:02
• yes! I had a small mistake in saving the data points. I have updated the graphs now! I also updated the post again with calculations regarding the data size needed to store pre-computed values. if you have a way of finding the optimal resistances while being able to increment the gains like the list approach allows me to do, please let me know. Aug 13, 2019 at 8:02