Hi folks,
I've been reading around for a while and since I came to the conclusion that you are a nice folk I thought I'd ask my question here.

(looks like the correct subforum, doesn't it?!)
Currently at work we're reviewing a new PCB revision with some more options and, so far, it works pretty well ...
There's just a simple section that won't do exactly as we wish.
I'm was sitting on that part for the past two days and my colleague was resoldering some resistors here and there to make my life easier.
So it's not a "do my homework request"
It's more like I don't understand why that happens and my colleague can't deliver me a proper explanation as well...
It just totally bugs me...Ok, on to the problem: in the attached schematic you'll find the extracted portion which gives me/us headache. This part shall deliver approx 7.2V (minimum) to external sensors (need at least 7V supply).
This is accomplished via three options
1. voltage divider with hard wired resistors (beneath the 470k comes the second one)
2. via a potentiometer (replaces the 470k and it's companion)
3. via PWM generated by the µC (my part)
Well, only the PWM part makes the problem and so I extracted the schematic for that part out of the big plan (left out the other two options).
So what exactly is required and what happens?
Requirement is simple: set a voltage between 7V and 8 V via software.
The used voltage regulator (
http://www.ti.com/product/lp2951 ) needs some steps before going active with PWM
0. disable the shutdown
1. check continuously the error active pin (=low -> error)
2. decrement the duty cycle by 1 digit
3. repeat with (1) until error active pin is high
4. wait until the circuit is charged (delta of voltages between two cycles equals 0)
5. decrement pulse until desired voltage is reached.
Sounds simple... might be, but it's not. Sadly the circuit "discharges" with like 1mV/sec.. and even faster with load attached.
So I need to DECREMENT the duty cycle by at least one digit to have it recharged once again.
Fun fact: I can only decrement the duty cycle, but ONE increment discharges the whole thing...
Please refer to the attached picture to see what I mean (I increased the cycle wait time to show the effect)
The problem is: even if I only decrement by one each say 200 mV, it will come the time I'm at the limit of the duty cycle where the feedback voltage goes too low and the regulator switches through, full 12V at the external sensor -> boom

It's not that I'm too slow or too fast at all...
The µC runs on 64 MHz, and so does the PWM; therefore 1 digit equals approx 15.6ns. The PWM runs (rock stable) at 16kHz, so I have 4000 digits. I re-adjust everything within 10ms cycle time and added a delay to the duty cycle adjustment by three measurement cycles (yields better results (charge time)).
The current solution I came up with is shown in the other attachment... I do the described steps and change the duty cycle by 1 digits back and forth every cycle without delay... works "good" in case you can call 60mV ripples on the output supply line "good".

There just one drawback in this solution... I happened to see "sudden discharges"...once in a while which puts my output supply beneath 3V.... ugh... don't know what happens here.

Big talk...

So what me bugs is that one digit less initiates a full charge and one digit more initiates a full discharge.

(And I can't find a good SW solution, that bugs me even more

)
Is someone able to explain me what happens behind the scene? Or does someone eventually have a HW solution in mind (feel free to alter the schematics

)?
I'm actually a full fledged software engineer and only partly an electrical engineer (I walked the path of technical information technology), so I just understand a little more than the basics but not all too much more beyond that

(but feel free to give me all you've got

).
Thank you for reading that long text!!

In hope of nice answers...
Have a nice day!
Kind regards,