I'm using a 3.3v atmega328p(arduino pro mini)for this project. Mosfet is IRLB3813(fully saturates at 2.5v). 2.5v 0.05% external voltage reference(lm4040 2.5v). I'm working with it at the default 480hz.
My original idea was to use an N channel MOSFET and get the average atty voltage using a filter. Well, that's bogus due to the low side being switched and the MCU references ground that's constant. Next, I used an NFET to switch a PFET that handled the load. I couldn't get the Pfet by itself to work, but that's another story. The PFET I'm working with works, and I can parallel them, but there's another issue. I added the filter and calibrated the average against the scope reading of the average.
Problem here is the mean isn't what the atty is putting out, it's much higher, especially at lower duty cycles. After talking to people, I learned that RMS voltage is what we need. I figured I can ditch the analog input for the atty and use this idea I had. I mapped the 8 bit 0-255 for analogWrite to 0-100 for duty cycle. I'm using a voltage divider(2s iput)to get battery voltage. Since the battery voltage is the peaks, I tried this:
rmsVoltage = peak * sqrt(dutyCycle / 10)
The idea works.

To control the rms voltage at the atty, I tested with a few simple if statements. Not code, just for the idea.
If attyVoltage < rmsVoltage dutyCycle = dutyCycle + 1
If attyVoltage > rmsVoltage dutyCycle = dutyCycle -1
if attyVoltage = rmsVoltage dutyCycle = dutyCycle
What happens now is the battery voltage is jumpy due to sag. To fix this, I'm averaged the analogReads to the point where it regulated the rms voltage pretty well.

It is a bit slow, but it can be worked out. I'm using 2 18650's, so sag does seem to cause an issue. I think a 2s lipo would be much better, since it wouldn't need so much averaging due to less sag.
The final real issue is that it sure doesn't seem like it's putting out 5.5v when it says it is. If I have time before my next job today, I'm going to check it out on the scope to see what's going on. Do you see anything wrong with my math or anything else? I'm thinking about using much higher PWM frequency. I would think that would really smooth it out.
I'll look into hacking the frequencies on this little 8mhz MCU.