A Cheap Electronically Controllable DC Supply

Mark Zachmann
Home Wireless
Published in
3 min readMar 10, 2024

--

This story describes how to convert a manually set DC supply to one you can set remotely or by computer.

Introduction

Recently a new kind of switching DC supply has come available — one that is adjustable with a potentiometer across a wide range of values.

Drok 0 to 48V 10A Power Supply

The above supply, for example, will produce 0…48VDC depending on the potentiometer.

So, I decided to remove the potentiometer and add electronic control from an ESP32 microprocessor. Note there is a companion video at Youtube showing the working demo: watch here

Electronic Control of Adjustable DC Supply (youtube.com)

Overview

I investigated the Drok power supply and found that the potentiometer has 0 and 5V on the end terminals and the voltage in the middle determines the output with a gain of 10. So, 4.8V -> 48VDC full-scale and 1.5V -> 15VDC, for example.

The ESP32-S3 has no DAC output to provide an analog voltage value, so instead I used a PWM output with a simple PWM->DC convert circuit. The circuit is this->

ESP32 setting the DC Supply voltage

The potentiometer 5VDC supply from the Drok is used on the right of the isolator and the rest of the circuitry is driven by USB or other 5V source.

Here’s the D/A circuit. It takes a PWM input and applies a low-pass filter to do the D/A conversion.

Simple PWM->DC Voltage (D/A)

Here’s the opamp with nominal 3x gain and optical isolator. The opamp gain and 15K load resistor ensure that a duty cycle of about 60% is enough to pin the output at full-scale.

Gain of 3 opamp then optoisolator with 0…5V

The simple python I used for demo is below. It tells the ESP32 to set a persistent 1MHz pwm signal to pin D6 on my Feather ESP32-S3 board then it sets the duty cycle to ~50% (maximum count is 16 bit-1 or 65535).

from board import *
import pwmio
x=pwmio.PWMOut(D6,frequency=1000000)
x.duty_cycle=30000

Here’s a photo of the oscilloscope display. Trace 1 (yellow) is the PWM signal from the ESP32 and trace 2 (blue) is the D/A converted and amplified signal.

Note the VRMS measurements on the right

--

--

Mark Zachmann
Home Wireless

Entrepreneur, software architect, electrical engineer. Ex-academic.