anti aliasing filters for digital control loops

"Steve Minshull" wrote in news:HBGre.13082$ snipped-for-privacy@newsfe5-win.ntli.net:

You tune things to the PWM frequency, not the control loop frequency.

Look at some pseudo code

main(){ set PWM frequency to 40K set PWM duty cycle to 50%

while (1){

if timerflag=1 { sample the voltage and/or current calculate next PWM duty cycle set PWM duty cycle timerflag=0 }

}

} timer_isr(){ timerflag=1 timercount=timercount+offset (to give you 1kHz control loop) }

Whenever the timer rolls over (goes from ffff to 0) the interrupt service routine gets triggered, setting the timer flag, and then adding any offset to the count register that you need to give you the control rate you need. Thus, your main loop sits there doing nothing until the timer rolls over, but your hardware PWM is ticking away at 40K, at whatever duty cycle it was last set to.

The only waveform your buck converter sees is the PWM switching at 40K. This is the frequency that you select all your components for. The control loop is merely how often you change the duty cycle.

Scott

Reply to
Scott Seidman
Loading thread data ...

Hi

Thanks, I understand the difference between the PWM freq and the control loop sampling frequency. I understand you can choose the inductor size to get a certain current ripple at the PWM switching frequency. I was referring to choosing the inductor size to get the converter bandwidth down as low as 10Hz. I think I may be getting confused in how to work out the loop bandwidth as the sampling frequency should be ~10x this loop bandwitdh. I was assumning the loop bandwidth was determined by the frequency response (bandwidth) of the plant (buck converter) and such i would need a large inductor/capacitor in order to limit the controller bandwidth to 10Hz. Presumably i'm going wrong somewhere?

Steve

Reply to
Steve Minshull

No! You size L and C to get the desired ripple and/or transient response. The only thing the filter has to do with the control bandwidth in this case is that you won't have good transient response -- but for charging batteries that's not going to be a big issue.

You'll be limited by the PIC's ability to sample, which will limit your bandwidth. I'd choose a sampling rate, then see what I could tune the PIC up to do. You will, of course, want to have a PID controller on the PIC to get good DC accuracy (depending on your exact driver topology you may only need an integrator, in this case).

See

formatting link
for guidance on writing the software, if you need it.

Reply to
Tim Wescott

If you want to respond quickly to things like an output short circuit, you need a fast current control loop, though it can be crude and sloppy. The fast possible way to control current is cycle at a time. This might be as simple as a proportional only feedback loop that samples the current once per PWM cycle (at the time you would expect the current to peak, just as the PWM output is turning off) and alters the PWM duty cycle once per PWM cycle, to correct the current on the next cycle toward the current setpoint. This gives you the ability to react to over current conditions before any damage is done, even on a short. The output filter inductor is the only filtering component involved in this process.

The setpoint for this simple, high speed loop would be the output of a much slower voltage control loop that probably incorporates both proportional and integral effects, but in the case of a battery charger may have a droop effect that allows the integrator to be satisfied with a voltage somewhat less than the voltage setpoint, and the amount of this "somewhat" is proportional to the output current. The tuning of the voltage loop gain and integral time sets its response to a voltage error, since the battery is the main filter component that smooths the voltage. The voltage measurement should be low pass filtered enough that whenever it is sampled, the current ripple from the PWM filter inductor is averaged out over at least a few ripple cycles. I doubt you need an output filter capacitor, unless you want the regulator to be stable with no battery connected.

Reply to
John Popelish

Normally I'm a big fan of all-digital control loops, but if this were necessary I'd give serious consideration to using a current-mode switching conttroller for the inner loop. Why? The loop is very fast compared to the processor speed, it doesn't need precision control, and those chips do almost _everything_.

Don't know which way I'd end up going, though.

Reply to
Tim Wescott

Agreed. The only way I would do this with the micro would be if it had to be there for other, less demanding things and had lots of time and I/O to spare. Which means, it probably wasn't wasn't critically selected, in the first place. I hate to trust power control, moment by moment, to software. The initial debug can be very destructive, till you get it right. POP! Oops, forgot to reset the watchdog.

Reply to
John Popelish

I do power control with microprocessors -- for some odd reason we use hardware current limits, and hardware watchdogs that shut things down if the processor stops diddling a bit.

Reply to
Tim Wescott

Tim Wescott wrote in news:11auuhgf440gbd0 @corp.supernews.com:

The OP stated up front that he knew there were better ways to do this, and he was in it for the educational experience.

FWIW, the PIC 18 series can clock at 40MHz, giving a 10MHz instruction cycle; 5kHz control should not be a real problem (so long as he limited himself to integer math), if that's what he decided to shoot for. That's still probably slower than a switching controller--but if he took that approach, he wouldn't be learning embedded systems.

Scott

Reply to
Scott Seidman

"Steve Minshull" wrote in news:z1Ire.13225$ snipped-for-privacy@newsfe5-win.ntli.net:

Sample at a rate reasonable to your platform, like 1K. if you need to slow down the loop even more, you can use digital filtering and decimation.

Scott

Reply to
Scott Seidman

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.