[time-nuts] PI Math question
WarrenS
warrensjmail-one at yahoo.com
Sat Apr 19 00:09:27 EDT 2014
Dennis
Thanks for giving it some thought,
I stuck your values in my spreadsheet, See Attached,
Your values, like all values I've ever tried, cause all 4 code versions to
come out with the same answer at all input steps, using any set of fixed K
gains that I have tried.
As you sort of say, as long as the math inside of these codes does not
overflow or round the inputs can do anything at all, it does mater because
all 4 version react to any input in the exact same way. Phase wraps, modular
math, or anything else.
The problem is not showing that the answers are all the same all the time on
a simulator or spread sheet, that is easy,
the problem is to use some simple math to proof it is true, beyond any
skeptic's doubt, that the 4 outputs will always be the same no mater what
values they receive as inputs or where the input values come from.
I want to have an answer for the non-believers that like to say "That does
not prove anything, you just have not tried the right set of values yet".
Chris, You are correct, I was using # as a character, I changed it to "_"
below.
ws
**********************
----- Original Message -----
From: "Dennis Ferguson" <
>
> On 16 Apr, 2014, at 09:50 , WarrenS <warrensjmail-one at yahoo.com> wrote:
>> With the values of K1, K2 & K3 constant,
>> and the initial state of I#1, I#2 and Last_Input all zero
>> assuming there is no rounding, clipping or overflow in the math
>> and that if I've made any obvious dumb typo errors that they are
>> corrected,
>
> If we assume that your 'Input' value is a real-valued measurement with
> an unlimited range then I think your algebra is correct. All those
> rearrangements will produce the same value of 'Output'.
>
> Note, though, that 'Input' doesn't have to be a value like that, and
> "overflow in the math" may be unavoidable. It depends on the nature
> of the sensor producing the value. For the particular case that might
> be relevant here, suppose 'Input' is the output of a phase error detector
> with an output limited to a range proportional to [-180, 180] degrees
> (i.e. is truncated to a fraction of one cycle) and the job of the
> controller
> is to try to keep that value at 0. Because the output of the sensor
> "wraps
> around" at +/- 180 you will want to do certain computations (in this case,
> differences between 'Input' values) with modular arithmetic.
>
> For an example of the difference this makes, assume that your first 8
> 'Input' values are
>
> 40 80 120 160 -160 -120 -80 -40
>
> noting that (((-160) - (160)) mod 180) == 40. If you run these values
> through your first and last set of equations I think you'll find the
> value of 'Output' diverges at the wrap-around.
>
> I think the practical issue here is that if the basic PI phase-locked
> loop, as expressed by your last set of equations, has a long time
> constant it may fail to lock if the phase detector output wraps around
> like that and the initial frequency error is large enough to make the
> wrap-arounds occur frequently. The addition of the FLL term with its
> modular difference, as your first set of equations has it, will widen
> the capture bandwidth of the loop by keeping the integral term moving
> in the right direction until you get to a point where the frequency is
> close enough that the PLL becomes effective, at which point the behaviour
> of the loop becomes that of the PLL alone. The latter is what you've
> demonstrated.
>
> Dennis Ferguson
>
**** Typos corrected below ***
Ref)
> D = (Input - Last_Input))
> Last_Input = Input
> I_1 = I_1 + (K1 * Input)
> I_2 = I_2 + (K2 * D)
> Output = I_1 + I_2 + (K3 * Input)
get next Input value and Loop
> c)
> D = Input - Last_Input
> Last_Input = Input
> I_1Plus = I_1Plus + (K1 * Input) + (K2 * D)
> Output = (K3 * Input) + I#1
get next Input value and Loop
> b)
> D = (Input - Last_Input)
> Last_Input = Input
> Output = Output + (K1 * Input) + (K2 + K3) * D
get next Input value and Loop
> a)
> I_1 = I_1 + (K1 * Input)
> Output = I_1 + ((K2 + K3) * Input)
get next Input value and Loop
Another way to look at the same code;
Initialize all starting values & registers(0) to zero
Ref)
D(i) = Input(i) - Input(i-1)
I_1(i) = I_1(i-1) + K1*Input(i)
I_2(i) = I_2(i-1) + K2*D(i)
Output(i) = I_1(i) + I_2(i) + K3*Input(i)
Increment i from 1 until i = n
c)
D(i) = Input(i) - Input(i-1)
I_1(i) = I_1(i-1) + K1*Input(i) + K2*D(i)
Output(i) = K3*Input(i) + I#1(i)
Increment i from 1 until i = n
b)
D(i) = Input(i) - Input(i-1)
Output(i) = Output(i-1) + K1*Input(i) + (K2+K3)*D(i)
Increment i from 1 until i = n
a)
I_1(i) = I_1(i-1) + K1*Input(i)
Output(i) = I_1(i) + (K2+K3)*Input(i)
Increment i from 1 until i = n
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ws-Pid gains.gif
Type: image/gif
Size: 31100 bytes
Desc: not available
URL: <http://www.febo.com/pipermail/time-nuts/attachments/20140418/9b3cbd12/attachment-0001.gif>
More information about the time-nuts
mailing list