Re: PWM in a digital control loop



There's a much easier way than messing around with look-up tables.

I never used a lookup table for that. You can perhaps view the
technique
like yielding what a sigma-delta would, however being forced to do it
at the minimum possible ripple point at any moment. It just does what
a sigma-delta would do if performing ideally for that application,
and is actually simpler to implement than a complete sigma-delta
convertor.
Perhaps I should describe in some more detail the technique, I
thought I had reinvented the obvious when I did it back then, but there
you go, may be I have not.

Dimiter

------------------------------------------------------
Dimiter Popoff Transgalactic Instruments

http://www.tgi-sci.com
------------------------------------------------------


Tim Wescott wrote:
Didi wrote:
(top posting fixed)
Joerg wrote:

Hello John,



I would like to use PWM in a control loop for power-saving purposes.
The controlled device needs to operate over a wide range of powers as
setpoint, so I was thinking of using 16-bit PWM from a microcontroller.
This would potentially have a range from 1/65000 to 1. It occurs to me
that the control will be grainier when operating at narrower duty
cycles. For example, if full power is at 50% duty cycle, and I want to
operate at full power/1000, the duty cycle control number will be
32000/1000 = 32. The minimum adjustment will be +/- 1, or 3% of that
level.
I have two questions about this-
1 Should the gain of the loop be adjusted to different levels depending
on the setpoint, i.e., should correcting signals be adjusted to a
percentage of the current level?

That depends entirely on the characteristics of your load and feedback.
Do a quick model of the system and check to see if it is linear
(obviously you have to linearize your PWM before you do the check). If
it is, then you don't have to change your gain.


By linearize the PWM, do you mean the level should be considered to be
the logarithm of the duty cycle?


If you're doing the modeling in mathmagic land I just mean taking the
average duty cycle as the number.

You seem to be caught up in logarithmic relationships here, where
PWM-powered things are generally quite linear. I'm wondering why.


I would like it to be able to work over a wide dynamic range, maybe
1000:1, of duty cycle. I was just concerned that operating around the
lowest setpoint might be dynamically different than around the highest.
I guess I'll try to model it linearly; it would be simpler.



In
most PWM applications you can take the PWM to be a linear stage, where
the output is just the average of the PWM, which means the duty cycle --
so if you command a 1% duty cycle the effective output is 0.01 times
your voltage, a 99% duty cycle gives an effective output of 0.99 times
your voltage, etc.

In case granularity at low set points remains a concern you might
consider a 2nd PWM. This would become your "vernier" PWM. You can do a
current summing into the main PWM output. The max current average from
that 2nd PWM would correspond to the min current average of your 1st PWM
when it is set to minimum. If you go all out and provide another 16bit
as the 2nd PWM that should give you a granularity down to noise level :-)

Of course, you need to have access to an uncommitted CCR to do that.

--
Regards, Joerg

http://www.analogconsultants.com


> My solution to a similar problem 10 years ago was to switch between
> two consecutive pulse widths every few cycles - say, if every 10
> cycles you do PW=100 nine times and once 99, or 8 times 100 and
> twice 99 etc., this will give you 10 times the resolution. Somewhat
> more ripple but not that much as the values differ only by 1 clock
> cycle.
> I used it successfully in a HV supply (200V - 5kV), most PWM values
> EEPROM-able, using a HC11 @ 2MHz (its PWM granularity is 0.5 uS).
> It worked (still does, actually :-) at frequencies between 1 kHz and
> 10 kHz, initially I did some tweaking to see what it could, that is.
>
There's a much easier way than messing around with look-up tables. See
the code in http://www.wescottdesign.com/articles/sigmadelta.html.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google? See http://cfaj.freeshell.org/google/

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html

.



Relevant Pages

  • Re: how to control LED array?
    ... >>> I disagree on the refresh rate. ... Having just experimented with PWM ... >>> the flicker is much more visible on the LEDs. ... > flicker was not visible to me even with a 1/256 duty cycle. ...
    (sci.electronics.basics)
  • Re: PWM in a digital control loop
    ... so I was thinking of using 16-bit PWM from a microcontroller. ... that the control will be grainier when operating at narrower duty ... For example, if full power is at 50% duty cycle, and I want to ... PWM-powered things are generally quite linear. ...
    (sci.electronics.design)
  • Re: Minimum Oscillator Frequency
    ... On each PWM period, the output will be high for a certain time T, and low for the rest of the period, or Ts-T. ... You could implement it with a DDS (to generate the sine samples) which outputs a sample every Ts. ... Then using a main clock, of frequency Fc, you decrement this counter. ... Now using the minimum and maximum duty cycle specs of your class-D amp, you can determine that your sine samples should be between 2% and 98% of 200, this means 4 and 196. ...
    (comp.arch.fpga)
  • Re: solution for a linear led driver
    ... Duty cycle PWM not going to change with voltage if you servo the ... PWM output. ...
    (sci.electronics.design)
  • Re: PWM in a digital control loop
    ... setpoint, so I was thinking of using 16-bit PWM from a microcontroller. ... For example, if full power is at 50% duty cycle, and I want to ... PWM-powered things are generally quite linear. ...
    (sci.electronics.design)