Philip Pemberton wrote: > Nope. I don't want to make the PSU too clever... I'm using this > algorithm at the moment: > > volts = do_ad_conversion() > if (volts > setpoint) then > if (pwm_duty > 0) then pwm_duty = pwm_duty - 1 > else if (volts < setpoint) > if (pwm_duty < 0xFF) then pwm_duty = pwm_duty + 1 > end if But this is exactly the sort of algorithm that will have slow transient response. Current demand can change very suddenly. Look how long it would take this algorithm to ramp the PWM duty cycle from one end of full scale to the other. Also, you could use a comparator instead of A/D to get the high/low decision unless you are making the setpoint soft. The 16F648A is pretty much the same chip with comparator instead of A/D. A comparator will allow a simple control loop to be run more often, which can often compensate for it being more simple. > What I'm getting is a spike of about 10V, This is when a large load is suddenly removed? As I said before, this is expected for this kind of algorithm. If the PWM was at maximum and just keeping the voltage right, then the load is suddenly removed, it will take quite a few cycles before it ramps down to the new correct steady state value. The area under the curve is the overshoot energy. > followed by a slow (one > second or so) drop to the 5V setpoint. Thats whatever small remaining load current (or perhaps just internal current for A/D divider or whatever) slowly draining the output caps now at 10V down to the regulation threshold. Start out with something really simple, then go from there if you still need to tweak it: loop: if voltage too low then do a pulse endif goto loop This might not get the last percent of efficiency especially at low currents, but it has the strong advantage of not be too clever by 1/2, as you folks like to say accross the pond. ****************************************************************** Embed Inc, Littleton Massachusetts, (978) 742-9014. #1 PIC consultant in 2004 program year. http://www.embedinc.com/products -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist