Smart Bench Power Supply Unit

by m_aditya in Circuits > Electronics

272 Views, 5 Favorites, 0 Comments

Smart Bench Power Supply Unit

1733845373959.jpg

Anyone working with electronics needs a reliable power supply. I had an old 45W laptop AC-DC adapter lying around, so I decided to repurpose it into a DIY adjustable power supply using an LM2596 buck converter.

To measure real-time voltage and current consumption, I integrated an INA219 current sensor with an Arduino Nano. For monitoring these values, I added a 16x2 I2C LCD display.

While the LM2596 buck converter provides constant voltage regulation, it lacks a built-in constant current feature—unlike modern bench power supplies. So, I attempted to implement a software-controlled constant current mode. However, things didn’t go as planned—more on that later.

Supplies

1733845374119.jpg
1733845374156.jpg
1733845374130.jpg

AC-DC Adapter (45W or higher)

Arduino Nano

INA219 Current Sensor Module

LM2596 Buck Converter (Recommended: A higher current-rated buck converter)

10kΩ Precision Multi-turn Potentiometer

KY-040 Rotary Encoder

16x2 LCD Display with I2C Interface (Recommended: 0.96-inch OLED display)

2 × Banana Socket Binding Post (Female)

2 × Banana Plug (Male)

USB Type-A Female Port

How a Buck Converter Works?

A buck converter is a DC-DC step-down voltage regulator that efficiently lowers a higher input voltage. It works by rapidly switching a MOSFET on and off, controlling energy flow. When the MOSFET is ON, current flows through an inductor, storing energy while supplying power to the output. When the MOSFET is OFF, the inductor releases its stored energy, and a diode (or synchronous MOSFET) maintains the current flow. A capacitor at the output smooths the voltage. The output is regulated using Pulse Width Modulation (PWM), where the duty cycle (the ratio of ON to OFF time) determines the output voltage—a higher duty cycle increases the voltage, while a lower one reduces it.

The LM2596 buck converter regulates voltage through its feedback pin, which senses the output voltage via a resistor divider and feeds it to an internal error amplifier. This amplifier compares the feedback voltage with a 1.23V reference voltage and adjusts the duty cycle accordingly. If the output voltage is too high, the duty cycle decreases; if it's too low, the duty cycle increases. This feedback mechanism ensures a stable output voltage despite variations in input voltage or load. The LM2596 operates at a fixed switching frequency of 150 kHz to maintain efficient voltage regulation.

To better understand how buck converters work and how they regulate voltage and limit current, I highly recommend checking out GreatScott!'s video. Watch it here: GreatScott! YouTube Video

Logic Behind the Constant Current Model

The idea behind implementing constant current (CC) mode is to manipulate the feedback pin of the LM2596 using a high-frequency PWM signal from an Arduino Nano. When the real-time current consumption, measured by the INA219 current sensor, exceeds the set current limit, the Arduino increases the feedback pin voltage beyond the 1.23V reference voltage. This forces the buck converter to reduce its duty cycle, lowering the output voltage and effectively limiting the output current. This technique enables software-controlled constant current regulation for the power supply.

While this method works, the LM2596 isn't designed for precise constant current control, so performance may not be as stable as dedicated CC regulators. It works best with resistive loads, but inductive loads may cause oscillations.

For a deeper understanding of constant voltage and constant current regulation using an Arduino with voltage/current feedback, I highly recommend checking out Electronoobs' video, which served as a reference for this approach. Video Link: Electronoobs YouTube Video

Additionally, if you understand Hindi, I recommend watching Free Circuit Lab’s video on implementing a constant current feature for the LM2596. He demonstrates a simple yet effective design using a shunt resistor, amplifier, and comparator. Video Link: Free Circuit Lab - Current Control Feature on LM2596

The Flaw in This Design

The LM2596 regulates its output voltage by maintaining a fixed reference voltage of 1.23V at its feedback (FB) pin. It does this using an internal control loop that adjusts the duty cycle to keep the FB voltage stable. However, the FB pin is designed to receive a steady analog voltage, not a rapidly changing signal.

Applying a high-frequency PWM signal directly to the FB pin disrupts the regulation process. The LM2596’s internal error amplifier expects a stable DC voltage, and since it does not have a high-bandwidth feedback system, the fast-switching nature of PWM can confuse the regulation loop, leading to instability, unpredictable behavior, or oscillations in the output voltage.

In my case, PWM interference significantly affected the voltage adjustment potentiometer. It became overly sensitive, meaning even a slight turn caused a drastic voltage increase, making precise voltage control difficult even with the multiturn potentiometer. Despite this issue, the constant current feature worked as expected.

Possible Solutions: A practical solution is to convert the PWM signal into a smooth analog voltage before applying it to the FB pin. This can be achieved using a low-pass filter—a simple LC filter can smooth out the PWM waveform into a steady DC voltage. However, I would highly recommend using a DAC (Digital-to-Analog Converter) instead, as it offers a more stable and precise voltage output, making it easier to implement in this case.

Coding and Testing

1733845374151.jpg

The complete code, along with the connections, is available on my GitHub repository:

🔗 SmartBenchPSU GitHub Repository

For better performance, I recommend testing with a different buck converter, as the LM2596 is only suitable for applications with current consumption below 2A.

Additionally, thorough testing of the constant current feature is essential to ensure it functions as expected and delivers stable results.

Circuit Design

1733845374103.jpg
1733845374108.jpg

I initially designed a PCB for this project but faced challenges during the fabrication process. As a result, I decided to build the circuit on a perf board instead.

To power the entire system with 5V DC, I used a Mini360 buck converter to step down the voltage from the laptop adapter.

If you plan to fabricate the PCB yourself, you can find the Gerber files and a PDF version of the PCB layout on my GitHub repository.

Enclosure

1733845374098.jpg
1733845374087.jpg
1733845373968.jpg

For the enclosure, I used a 5 × 7-inch white PVC box, commonly used for electrical fittings. I made cutouts for the USB port, LCD screen, and an ON/OFF output switch, along with holes for the banana socket connectors, rotary encoder, and potentiometer. To keep the design compact, I also mounted the laptop adapter inside the case.

The most challenging part was fitting the LCD display, as its large size made placement difficult. I would highly recommend using a smaller OLED display, as it has a smaller footprint, better flexibility, and improved clarity.

Additionally, taking a modular approach when designing the enclosure is important, as it allows for future modifications or upgrades.

The Final Look

1733845373950.jpg

Despite the design flaw, the project looks clean and functions well in most cases. It has the potential to be a versatile lab bench power supply, suitable for various applications.

I am planning to develop a second, upgraded version with more features, a smaller footprint, and improved design to eliminate the flaws found in this version.

Thank You for Your Time!

I hope you enjoyed this project and learned something new along the way. If you found it useful, consider following for more content like this.

Stay tuned for future projects and upgrades! 🚀😊