> > The problem I'm having at the moment is that the current regulation is > poor > at best. I'm picking up ripple and spikes on the current sense line that > are very persistent - I stuck a lowpass filter on it (a 100nF over the > opamp > feedback resistor, then a 1uF), and there was no detectable effect. That > wouldn't be a problem if the PIC was reading an average voltage, but it > samples the instantaneous voltage in the middle of a 5uS (or so) window. VBG.. Been there, done that.. In the AVR, I was able to sync my current sample to the PWM output, and by trimming nops, put the ADC sample point in a "quiet" zone. What I'm getting *now* is a situation where the ADC's internal R/C clock > generator slips a bit and the ADC ends up sampling on a valley. The PIC > kicks > the current up and >boom<. It doesn't even realise the average current is > a few amps - it still thinks it's locked at 500mA. Then the RC drifts > again > and the PIC settles back down to about 400mA... :-/ How often do you sample for regulation? I used a 10mS interval. Eventually I want to make this thing do "burp" (reflex) mode charging. > That's > going to be great fun with an SMPSU - by the time it ramps up, the charge > pulse will be over. At the moment I'm sticking to constant-current though > (it's easier to get that working for testing, then add reflex mode later). That adds some complexity, but not too bad. Before stopping the current, save your PWM value. Then halt, and at the end of the halt, make the measurements. Then reload the PWM value you had from before, and start regulating again. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist