Introduction: DIgital Controlled Bench Power Supply
There have been quite a few nice power supply projects based around the XL4015 buck converter module. It is a great module for this type of project as it has a wide range of voltage output and decent current capability. It is also available with modules that give multi-turn potentiometer setting of the voltage and extra circuitry to allow for an adjustable current limit.
The difference with this instructable is that I have made it digitally controlled on both the voltage and current limit settings and provide for measurement and display of the voltage and actual current being drawn. The controller used is an ESP8266 module which means it also gets a web interface and opens up more possibilities for control.
This gives it the following features:
- Output voltage digitally settable between 1.25 and 19.0V
- Current output up to 5A (4A more realistic to avoid thermal shutdown).
- Local control of voltage and current limit via rotary encoders allowing high precision
- Local display of voltage, current draw and current limit on an OLED display
- Secondary fixed output voltage of 3.3V or 5V (1.5A)
- Browser interface to view measure values and set voltage and current limits
- Ability to capture logged voltage and current data to files.
- Ability to playback voltage profiles from files and capture current data
- Browser also allows file system management, configuration and software update.
- XL4015 buck converter with adjustable voltage and current limit
- ESP8266 (ESP12-F) wifi microcontroller module
- ads1115 4 channel 16 bit I2C ADC
- SD1306 0.96" OLED I2C display module
- 2 MCP4725 12 bit I2C DAC
- Mini buck converter with adjustable output (MP2307)
- 2 Rotary encoders EC11
- 12V 40mm fan (can be 20mm or 10mm high)
- mini slide switch
- n-channel MOSFET AO3400
- Electrolytic capacitor 220uF
- Resistors 47R,390R,470R,1K,10K,2K2,11K2,100K
- 2.5 /5.5mm power input jack (vary to suit lap top brick connector
- 4 position spring speaker terminal connector
- 2.5mm bolts and nuts for board mount, 3mm bolts and nuts for fan mount.
- Enclosure. My 3d printed design is at https://www.thingiverse.com/thing:4885911 2 versions depending on fan height.
- Old lap top power brick e.g.19.5V 4A
Step 1: Schematic and Theory
The XL4015 module has 2 multi-turn potentiometers to adjust the output voltage and the current limit.
The voltage adjustment normally works by varying the10K potentiometer which taps down the output voltage across a 270R resistor to provide a feedback voltage into the converter. This is compared against an internal1.25V reference and to vary the duty cycle of the converter. So for example, if the potentiometer was set to be 540 ohm then the output voltage would settle to 3.75 volts. To provide digital control the potentiometer is set to a higher value and then current is fed into the 270R resistor from the DAC output via a 390R resistor. As the DAC output increases then less current is needed from the output via the potentiometer to give the 1.25V across the 270R and so the output voltage drops. At one extreme the DAC output can provide all the current needed to get the 1.25V across the 270R resistor and so the output voltage needed is 1.25V.
The current limit on the XL4015 module works by monitoring the current drawn across a 50 milliOhm shunt. This is then compared with the limit current setting and a op amp then reduces the buck converter to maintain that current. The voltage needed to compare is normally controlled by the limit current potentiometer via some additional resistor division as the voltage range needed is quite small (0->300mV). To provide digital control the potentiometer is set to its maximum and then an override voltage is fed in from a DAC. This is tapped down by the 470R /47R divider to give maximum precision and to keep the impedance of the override as low as possible.
The measurement side is handled by a 4 channel 16 bit ADC (ADS1115). This actually used as a 2 channel differential ADC to provide better accuracy. One pair is used to monitor the output voltage via a 10K/1K tap down. This together with a 2.048V input range on the ADC gives the range required and good precision. The other pair is used to measure the voltage across the XL4015 50milliohm current shunt and so measure the current drawn. As this is quite a small voltage the ADC has a programmeable gain which is used to give greater precision.
Most of the peripherals are I2C devices (ADC, DAC, OLED display) and they are driven from the same bus pins on the ESP8266. The rotary encoders are pure switch contacts and so need 2 GPIO pins a piece. No other signal conditioning is required as this is handled by the software.
A further GPIO pin is used to provide fan control via the MOSFET driver. PWM modulation of this pin allows the fan to be off or its speed controlled.
The power for the electronics is provided by a mini step down buck converter fed from the main input voltage. This is then in turn regulated by a low drop out linear regulator (xc6203) to provide a 3.3V supply for the main electronics. The mini buck converter is nominally set to 3.4V but a slide switch adjusts the setting to allow it to go to 5V. This is so its output can be brought out as secondary logic supply switchable between 3.3V nominal and 5.0V nominal.
Step 2: Construction
The first picture shows the back of the XL4015 buck converter and the wires to be attached.
The smaller wires show the interconnections to the board.
- White is voltage adjust line
- Green is current limit adjust line
- Black is 0V reference (used for differential measurements
- Blue is output voltage measurement
- Yellow is current measurement
As I was using a power input jack I removed the screw terminals on the board (cut off the plastic housing first) and soldered two thick wires on directly. Solder on secondary ground wire and input volts wires for attaching to the rest of the electronics. The other ends go to the power jack socket. Pass jack socket through its hole and secure in place with its nut. Mount the board in place using 2.5mm bolts and nuts.
I constructed the main electronic modules on a piece of two sided prototype board (26 x 6 holes). The picture shows it with the esp-12 and ads fitted together with the xc6201 regulator and fan mosfet on the left. The i2c lines are fed along the board to interconnect all the modules. Note that it is good to preprogram the ESP8266 with the software before mounting. All other software changes may then be done by OTA updates.
Mount the fan in place with its bolts.
Glue the slide switch in place.
Attach 4 wires to the display board and glue in place.
Temporarily attach mini buck converter to a power source and adjust its output to 3.4V. Attach a wire to the feedback pin on the converter and try connecting it to 0V via a 11.2K resistor. The output should go up to about 5.3V. If not try lowering or increasing that resistance. Attach wires to the inputs and outputs of the mini-converter and glue in place. Attach the 11.2k resistor to one side of the slide switch and 0V to the other.
Attach thick wires to right pair of the spring terminals and medium wires to the left pair. Connect the thick pair to the screw output terminals of the xl4015 and the medium pair to the output of the mini buck. The output V and Gnd from the buck converter should also connect to the 0V and regulator input on the electronics board.
The MCP4725 DAC converters can be added to the electronics on the power and i2c bus on the prototype board. To conserve space I cut off the large mounting holes area on these boards as it was redundant and does have any tracks or circuitry.
Connect the secondary earth line from input side of the XL4015 to both the mini buck converter and the 0V line on the electronics board. Connect the power input secondary wire to the positive side of the fan and the negative side of the fan to the drain of the fan switch mosfet.
Attach measurement points to the adc. Vout goes via a 10k/1k tap to A0, shunt volts goes to A2. A1 and A3 go to the black ground on the back of the XL4015. It is important that this ground is not connected to anything else. This allows a differential measurement to be made which is important for the shunt voltage measurement which could otherwise be disturbed by any comon supply current drops down earth wires.
Attach the adjustment points to the DACs via their adjustment resistors. The voltage adjust just has a series 390R. The current adjust has a 470R/47R tap down which can be mounted directly on the DAC.
Attach display to power and I2c on the end of the electronics board.
When hook up is complete and tested you can put a bit of double sided adhesive tape on back of the electronics board and slide it down and attach to the base of the box.
If available it is good to stick a mini-heat sink on top of the main XL4015 IC to assist heat dissipation at higher current loads.
The docs folder has powerpoint label which may be printed out and glued on to the front. Two versions of the label support the 10mm and 20mm enclosure types.
Step 3: Software
The software is available at https://github.com/roberttidey/WifiPowerSupply
This is compiled under the Arduino IDE and first serially uploaded to the board.
It supports wifi management which means that on first use it will open a portal network which can be connected to and browsed to 192.168.4.1 to set up the local wifi connection.
it also supports OTA update by browsing to ip/firmware.
Support files from the data folder should be uploaded one at a time by browsing to ip/upload.
The software runs the local operation, keeping track of the rotary controls, making Vand I adjustments and making measurements and sending them to the OLED display.
It also supports a web server which by browsing to ip will show an interface showing the measurements and allowing setting of V an I limit. It also gives access to status and configuration and allows file operations to capture data and playback voltage profiles.
Access to the filing system is via ip/edit
Note that any changes to the config file will only take effect when it is reloaded. This happens on start up or can be forced by browsing to ip/loadconfig
Step 4: Calibration
There are two forms of calibration; measurement and adjustments.
The measurement side is fairly easy as the ADC used has a good reference and the nominal calibration values should give good results. If you want to tweak the voltage measurement then set a low voltage (e.g 5V) followed by a high voltage (e.g. 15V) and note down the displayed values and those of a known good voltmeter attached to the output. The difference can be used to tweak the adcVSlope and adcVOffset values in the config file. Similarly for the current side add a load resistors to give say 0.5A and 2A outputs and use measured and displayed values to tweak the adcASlope and adcAOffset values in the config file.
For the adjustment side the settings depend on how the on-board potentiometers are set.
The current side is fairly easy as the potentiometer should be at its maximum by rotating clockwise (at least 10 turns). The nominal values for the limit should now be fairly close. They can be tweaked if required by a similar procedure to the measurement calibration. Put a short circuit and current meter across the output. Set a low limit and note the displayed limit and actual current. Set a higher limit and again not ethe values. These can be used to adjust the dacLSlope and dacLOffset.
The voltage adjustment side is a little more complicated as it depends on the potentiometer setting. The easiest way to proceed is to set a particular voltage from the web browser (e.g. 12V) and then adjust the on-board potentiometer until you get close to this value displayed. The nominal values of adjustment may now be checked by setting a low voltage (e.g. 5.0V) from the web interface and then a high voltage (e.g. 15.0V). Any discrepancies can be adjusted by tweaking the dacVSlope and dacVOffset values. For me I was able to get set values within 10mV across the range.
Although not a calibration as such the config file also has a line to control fan speeds. This is set up to support off, low and high speed fan operation depending on how much current is drawn.
Step 5: Operation
Local operation is very simple. The two rotary controls allow setting the voltage and the current limit as shown on the display.
The rotary controls are set up to allow very fine resolution by moving them slowly, but if they are rotated faster then the jumps go up exponentially allowing one to move across the range much more quickly.
The slide switch allows changing the fixed logic voltage output.
For web control browse to ip. There are 4 tabbed screens.
Main shows the measurements and allows setting.
Files allows capture of measurements and playback of profile voltage.
Status shows internal values.
Config shows the values in the config file and allows these to be changed.
Note that for capture the interval and duration can be set.