Author Topic: Digitally-Controlled Linear Power Supply Based on STM32 – Classic Design  (Read 4128 times)

0 Members and 1 Guest are viewing this topic.

Offline iskelTopic starter

  • Contributor
  • Posts: 10
  • Country: bg
Hi all,
I’d like to share with you a project I recently completed – a digitally-controlled linear power supply built around the STM32F030CCT6 microcontroller.
The power stage uses a classic analog linear regulator topology, known for its simplicity, reliability, and low output noise. To bring it into the modern age, I’ve added:
🔹 Digital control and monitoring using STM32F030CCT6
🔹 LCD display with rotary encoder for local control
🔹 Remote control via I²C interface
🔹 Possibility to link and control multiple units in coordination
🔹 Fully open source – schematics, firmware, and documentation available
This is a well-working and stable design, ideal for home-built lab power supplies. It’s intended for electronics hobbyists who want a practical, reproducible, and expandable project that combines classic analog performance with basic digital control features.

🔗 Project page: https://www.stm32dds.tk/stm32-psu - A link to Telegram is provided at the bottom of the page.

 
The following users thanked this post: bingo600, hugo, moffy, Doctorandus_P, ledtester

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5368
  • Country: nl
As it happened, I found your website about a week ago and I really liked this article. Both the idea of reusing the existing (and extremely cheap) kit, mentioning of the magazine with the original project https://worldradiohistory.com/UK/Practical-Electronics/70s/Practical-Electronics-1978-10.pdf and the thorough writeup and sharing the sourcecode on a git site.

 I'm still struggling with getting STM32 to work on a real project (I've done some blinking LED projects) and this is a project I may build at some time in the future, just to get some more experience with a real STM32 project. (I'll put it in a "Black Pill a.k.a. STM32F411CEU).

I am also curious about your Lattice DDS project. <url>https://www.stm32dds.tk/stm32-ddslatt</url> Have you looked at what others have already done? There are several DDS projects with ICE40 on github.

https://html.duckduckgo.com/html?q=site%3Agithub.com+ice40+dds
« Last Edit: June 15, 2025, 08:13:53 pm by Doctorandus_P »
 

Offline iskelTopic starter

  • Contributor
  • Posts: 10
  • Country: bg
Hello, thank you for your interest in my site, and also for the useful information you provide me (in connection with my future project). Yes, I am aware that there are many implementations of this platform - STM32 + FPGA. My idea is not to rediscover "hot water", but simply to pack it in a suitable package and "sell" it to you for free :-)
 
The following users thanked this post: croma641

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5368
  • Country: nl
On you website you write:
Code: [Select]
These days I was reading a rather interesting article on the issue of carbon resistors,
which by painting them blue, the Chinese comrades are pushing us to consider metal-film
resistors - this is not relevant for our project, but anyone who is interested in how to recognize
 them (I suggest - by their temperature coefficient) can search and read on the internet

But I don't agree with this. You are using 10-bit R-2R networks for your DAC, and these need quite accurate resistors, and the carbon resistors normally have a 5% tolerance (some are indeed sold as 1%, but out of spec and indeed also a bad TCR) For 10 bit, you need approximately 0.1% tolerance (or hand sorted) resistors, and you do need quite accurate (metal film) resistors.

I also find your choice of using THT for everything except the uC curious. Personally I find SMT resistors and capacitors (down to 0603 size) easier to use then THT. You don't have to bend and cut wires, you don't have to turn the PCB around all the time. And on the PCB, there are no drilled holes and you have the back side available for either a good GND plane or for routing some tracks. Especially when you go to 4 or more layers, the extra PCB space becomes significant. (Also, for 100+ PCB's, the price difference between 2 or 4 layer PCB's becomes quite small, even though 4-layer prototypes are still relatively expensive).

Still curious about your DDS interests...

I just found the AD9102. It's a dedicated DDS IC with 4k*14bit RAM and built in DAC. and costs USD 24 (10+).
A nice DAC alone costs over USD 12 (12 bit <35ns settling time).
R-2R based DAC is possible, and also used in function generators such as the JDS6600 but they need pretty good quality resistors for some decent accuracy. For 10 bit accuracy, your resistors need <0.1% accuracy and stability. (Or at least a few of the most significant bits). For DIY, manual sorting is a good option.

An interesting idea is to use an R-2.01R network, as presented in the thread below.
https://www.eevblog.com/forum/metrology/digital-null-meter-design/
This would also require individual calibration, and then re-compilation of the FPGA code for each device.

When considering cost (I.e, a commercial design) FPGA + DAC is already getting close to the cost of the AD9102 (maybe there are similar but less powerful and cheaper DDS IC's).
« Last Edit: July 31, 2025, 08:42:47 pm by Doctorandus_P »
 

Offline iskelTopic starter

  • Contributor
  • Posts: 10
  • Country: bg
Hello  Doctorandus_P, thank you for the quality comments and sorry for the late reply. I don't follow this forum regularly. The answers in short:
1. The accuracy of the resistors in R-2R: they are not part of the set I buy from Aliexpress. They are metal-film, with a tolerance of 1% and I buy them from a local store ( comet.bg) with a proven reputation. This accuracy, as you mention, is on the limit for a 10-digit resistor ladder, but this will be valid if we always want to output an exact value - for example, if we type it from a keyboard and develop an ultra-precise device. In our case, the inaccuracy of the resistors affects specific values - understand the unevenness in the height of the steps in the output signal. There is an oscillogram published on the site where you can see this. And yes, if I were to generate audio or video or any other form-precise signal - I wouldn't use such a solution
2. THT? - is it convenient for you, and for all the others who are taking their first steps in this field, is it so? (well, they often don't have anything else besides a soldering iron and a multimeter from the nearby supermarket - that's why I suggested they take the processor to be soldered to the nearby GSM service)
3. AD9102? - 180MSPS - not bad, but with 16 bits from the FPGA chip I'm hoping for 250. Plus, to tickle my old ego with VHDL programming
 

Offline iskelTopic starter

  • Contributor
  • Posts: 10
  • Country: bg
To be honest, this is the first time I've heard of R-2.01R (no wonder, I've never done any nanovolt measurements). I read everything in the discussion, drew my own conclusions, and to be absolutely sure, I asked the AI:
......and which circuit is better if we want to generate a signal via DDS?
And the answer was:
Quote
✅ Short Answer:
The R-2R ladder is the better choice for DDS applications.

🧠 Explanation:
1. 🎯 Accurate and linear amplitude response is critical
In Direct Digital Synthesis (DDS), a lookup table of sine values is used to output a waveform. If the DAC does not reproduce each step linearly, the output waveform will suffer from:

Harmonic distortion

Amplitude modulation (AM) errors

Reduced SFDR (Spurious-Free Dynamic Range)

👉 An R-2R DAC provides a highly linear output (assuming accurate resistors), ensuring equal voltage steps – which is crucial for maintaining waveform integrity.

2. ⚡ DDS operates at high speeds
The digital input updates rapidly and continuously.

Each bit must settle quickly and uniformly, without timing skew.

👉 R-2R ladders have:

Consistent output impedance

Uniform capacitive loading

Superior dynamic performance

In contrast, R-2.01R DACs introduce:

Bit-dependent delay and loading

Asymmetry and transient errors

Poor performance at high update rates

3. 🧩 R-2.01R is tailored for precision DC, not AC
DDS and audio systems produce AC signals.

R-2.01R designs are meant for static precision applications like digital null meters or Kelvin-Varley dividers.

They prioritize DC matching over dynamic performance, and are not suited for waveform synthesis.

📊 Comparison Table
Criterion                                   R-2R DAC ✅                           R-2.01R DAC ❌
Linearity                                   Excellent                                   Lower, sensitive to tolerances
Speed & Frequency Response   Suitable for high-speed DDS   Poor for dynamic signals
Bit Timing Symmetry                   Yes                                           No
Use Case                                   DDS, audio, signal generation   Precision DC nulling
DC Measurement Accuracy           Good                                           Excellent near zero point

🏁 Conclusion
For DDS waveform generation, an R-2R DAC is clearly the superior option due to its:

Linear response

High-speed capability

Timing symmetry

Alternatively, for optimal performance, consider using a dedicated high-speed DAC chip (often based on R-2R or segmented thermometer architecture) designed specifically for signal synthesis.
 

Offline iskelTopic starter

  • Contributor
  • Posts: 10
  • Country: bg
A few days ago I officially finished working on the project and started the next one:
https://www.stm32dds.tk/stm32-ddslatt

Meanwhile, as part of the preliminary preparation for it, I made a resistor selection form with the help of artificial intelligence:

Why?: Very often in experimental prototyping it is necessary to assemble R-2R DACs with separate individual resistors.

Problem?: Assembling a 9-bit DAC usually does not cause a problem with the provision of components, since resistors with an accuracy of 0.1% are sufficient for it, and what if we want more digits? With more digits, resistors with a much higher accuracy are needed. Their prices and delivery times are sometimes unacceptable. A possible solution is the manual selection of each pair of connected resistors. In other words, the condition R=2R does not need to be fulfilled for the entire ladder, but for each specific pair forming the voltage for the corresponding bit.

Solution: First, we need to know the required accuracy of the resistors for each bit. Then we need a table in which, by filling in a specific measured value R, we can obtain the possible range for 2R for the specific bit for which we are selecting the pair - or vice versa from 2R to obtain for R. We want this in a single HTML file - so that there is no need for installation, it is easily portable, and it can be run offline in a browser. We explain all this to the artificial intelligence and get the solution....

The result: https://stm32dds.tk/data/files/dac_resistor_matching_form.html

Note 1: For those of you who want to use the tool offline, after opening the table in the browser they should find something like "Download page" or "Save as file" or something similar and a file named "dac_resistor_matching_form.html" will appear somewhere on their device (according to the specific system settings)

Note 2: While writing these lines I had not even thought that this would work on every device and operating system :-)
« Last Edit: August 26, 2025, 05:31:39 am by iskel »
 

Offline iskelTopic starter

  • Contributor
  • Posts: 10
  • Country: bg
Due to the closure of the ".tk" domains, the new server address is www.stm32dds.org
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->