PWM/DAC voltage and current regulation

Thread Starter

Bradleydof

Joined Jul 22, 2023
3
Hi,
I'm new to this forum (and forums in general). I am starting my second year of engineering school (midlife career change) and have a problem I have been trying for figure out, on and off, for about a year. With an unregulated 35VDC input I am wanting to use a MCU (ESP32 specifically) to regulate voltage and current. I can find loads of voltage and current regulation circuits, however none seem to be easily adapted to run on PWM signal or a variable voltage from a DAC.
I am considering trying to make a simple buck converter and hit that with PWM to get my variable voltage. Then for the current regulation maybe the ADC into a BJT or something, but then I'm worried about response time...
I have even considered how cool it would look with a few motorized slide potentiometers on the top of the thing.

Any advice or direction would be greatly appreciated!
 

Ian0

Joined Aug 7, 2020
10,286
My best advice: DON'T
There's a reason that there are loads of voltage and current regulation circuits - they do a much better job than a microcontroller can.
How well do you understand the work of Hendrik Bode? Could you implement that in software? Do you understand the Nyquist criterion for sampling?
 

Thread Starter

Bradleydof

Joined Jul 22, 2023
3
Thanks for the great reply! I appreciate you tried. However u seem to have missed the point. I don't care how reliable, accurate, efficient, or even sane. It's simply a curiosity I've been wanting to figure out and thought a friendly forum that I just found an answer to another problem on might help. Maybe I was wrong for thinking this is where problems and solutions are discussed. This is a learning exercise in line with my hobby and schooling. I am not trying to make something better than anything. Just something that works. I'm stumped, maybe because I don't know (or truly even care to look) who those people and theories are, since before my first year of school all my learning was at home, trial and error, and plenty of Google. But hey, u kinda tried... thanks :)
 

Thread Starter

Bradleydof

Joined Jul 22, 2023
3
I can't figure out how to close the thread so I'm just unwatching. Thanks for the welcome!
Maybe I can close my account. This forum is quite the fiesty place I see.
 

Ian0

Joined Aug 7, 2020
10,286
It's not impossibe to do it digitally, just that in analogue it's much easier because you don't need to deal with the sampling theory.
https://www.ti.com/seclit/ml/slup340/slup340.pdf will give you the transfer function that you will have to implement digitally (the type III error amplifier)
You'll need to sample at about twice the pwm frequency, and do the calculations for every sample. That's a job for a DSP processor, and probably not within the capabilities of an 8-bit micro.
In analogue, it's just a question of selecting the two feedback resistors, and then the three capacitor and two resistors of the compensation network.
 

crutschow

Joined Mar 14, 2008
34,910
You might consider using Fuzzy Logic to do what you want.
It doesn't require using the analog transfer function or emulating the analog feedback loops of PID control.
It basically would use a series of If-Then-Else statements to control your supply, which is readily done by a small micro.
You could sample the output voltage with an A/D (possibly built in the micro) and use Fuzzy Logic to control the PWM signal from that.
It may not give you optimum response time, but you should be able to get it good enough for your purposes (i.e. stable output at the desired voltage).

Here's a short write-up I made on that, and here's a tutorial, if interested.
 
Last edited:

Jerry-Hat-Trick

Joined Aug 31, 2022
596
Maybe I can close my account. This forum is quite the fiesty place I see.
I hope you are still around and I urge you to stay. I had a similar experience when I first joined but I crept back a few weeks later and I’ve learned a fair bit from some very knowledgeable and experienced people. Indeed, I’ve got involved replying to threads and I’m always chuffed when I get a “like” or a response that builds on mine.

My view is that the ESP32 is fast enough to make a switching voltage converter, where the trusty old Arduino UNO isn’t, but I agree that it’s not really practical with a host of ICs available for that purpose. With a high PWM frequency and capacitor and inductor selected for the target voltage it works okay.

Using a genuine analog output, not PWM, into an op amp into a transistor with current feedback from a resistor to ground works really well to control current.

Nothing wrong with questioning conventional wisdom, be okay with being shot down, once in a while you’ll come up with something ground breaking.
 
Top