This post describes the design of a software controlled voltage regulator. At this point I am still trying to determine if the design is feasible within the limits of the components I have available.

I have been toying around with ideas for small software controlled modules I can use for circuit analysis and testing. As well as the normal measurement modules you would expect (voltage and current sensing for example) there are also some signal injection modules that would be useful.

One of these is a software controlled voltage regulator which could be used to simulate a battery discharging or test a circuits response to under and over power conditions. One of my first thoughts was to use a digital to analog converter (DAC) and feed the output through an OpAmp to increase the current it could provide.

When I came across a MCP4261 digital potentionmeter (digipot) in my parts collection I decided I could use it instead to control the adjustment pin of an LM317 adjustable voltage regulator. This would give me software control (over SPI in the case of the MCP4261) over the adjustment pin of the regulator letting me control the output voltage while the regulator can provide up to 1.5A of current.

LM317 Circuit

The circuit above shows the details. In a typical LM317 circuit R1 and R2 control the output voltage, R1 is typically fixed and R2 is a trim pot that can be adjusted to fine tune the output. By replacing R2 with a resistor network that includes the digipot I can control the adjustment pin to generate the output level desired.

There are two reasons to use the resistor network rather than just connect the digipot directly as a replacement for R2. The first is scaling - the MCP4261 supports ranges of 0 to 5K, 0 to 10K, 0 to 50K and 0 to 100K. By adding a resistor in parallel (marked as 'SCALE' in the schematic above) we can adjust this range to something more suitable that ensures all possible 255 resistor values that the digipot can be set to result in a valid output voltage.

Parallel Resistors

The graph above shows the effective total resistance of a parallel resistor network with various scaling values. The line marked R is the digipot itself, in this case ranging from 0 to 10K resistance. The other lines show the total resistence of the network when combined with 2K, 10K and 20K scaling resistors.

The second reason to use a resistor network is to help control the current flowing through the digipot - the MCP4261 is only rated for 2.5mA. The resistor marked as 'OFFSET' sets the minimum resistance of the digipot side of the parallel resistor network and should provide more control over the current passing through the digipot.

The graph below shows the output voltage generated with the digipot set to a 0 to 10K range. With these values the output voltage can be controlled from 2.15V up to 9.99V (I am using a 12V input voltage so the maximum output is limited to around 10V anyway). This range is good enough to simulate a 9V battery discharging (or a battery back of 4.5V or greater).

Voltage Output

My next step is to make sure that the current flowing through the digipot doesn't exceed 2.5mA at any of the generated output voltages. The LM317 specifications state that it keeps the current on the adjustment pin at 100uA but I'm not entirely sure what that means for the current flowing through R2. It's time to dig out my electronics textbooks again and do some research.

This is still an idea I'm playing with at the moment, any and all feedback or suggestions are welcome so please leave them in the comments.