[time-nuts] PI Math question
WarrenS
warrensjmail-one at yahoo.com
Thu Apr 17 21:45:49 UTC 2014
Agree, not so clear. I did not expect this to be so hard to explain. See if
this helps any.
The code snippets are from a S/W simulator program that loops thru one of
these code versions, producing a new Output each time a new Input value is
made available.
In most programs an index i is not used or needed because most past data
need not be saved, the S/W just loops thru the code to produce a new output
value on each pass, saving only what is necessary, in this case as "Last_x".
Inalize everything to zero in each code.
> 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#1 = I#1 + (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
I thought the above format would be clearer than the index format below,
which can save everything.
This is another way to look at the same code;
The input can be considered as a saved data stream of length n, in the form
of Input(i) where i is a value from 1 to n.
Initialize all starting values registers(0) to zero
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
a)
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
c)
I#1(i) = I#1(i-1) + K1*Input(i)
Output(i) = Output(i-1) + (K2+k3)*Input(i)
Increment i from 1 until i = n
The question is, Can some math person/programer show that the outputs(1 thru
n) are the same in each code version above when given the same Input(1 thru
n) data stream, using simple math?
I'm not asking what the code will do, Just if the codes above will produce
the same outputs, when given the same set of inputs?
ws
********************************
Warren,
I understand your message as an afterwards try to put some sense in your
original question, but if you write
> D = (Input - Last_Input)
then this clearly denotes the differential part of a PID controller
(with the multiplication with the coefficient for the differential part
coming later)
If you add now
> In a complete controller the input to this
> gain block would typically come from a
> pre-filter, and the prefilter's input
> from the error difference between
> the setpoint and the feedback, etc.
saying that "input is something complete different then I fear that this
discusion is drifting into complete nonsense because if "Input" denotes an
entity which contains an error signal in any form then
> D = (Input - Last_Input)
is something that is ill defined and has nothing to do with the differential
part of a PID controller.
> I wanted to keep the math as simple as possible...
Good idea but if simplification creates something wrong then the
simplification has gone one step to far.
Best regards
Ulrich
*************************
> -----Ursprungliche Nachricht-----
>
> Ulrich
>
> That is correct, none of these simple code blocks form a
> controller. This is just a block of code that could be used
> for the PI gain function of a controller.
> In a complete controller the input to this gain block would
> typically come from a pre-filter,
> and the prefilter's input from the error difference between
> the setpoint and the feedback, etc.
> I wanted to keep the math as simple as possible by only
> including this section of code.
>
> My question was does the math in these four blocks of code
> all provide the same exact input to output function.
> What the code is being used for is not really relevant to the answer.
>
> simple example:
> Does the code X = 3Y have the same input to output function
> as X = 4 + 2 + (1+2) *Y - 6?
> Just because they look different does not mean they are
> different. The question was meant to be a simple math
> exercise like does 3y = (1+2)y? The answer does not need any
> high level math or depend on the value of y or
> what the code is being used for.
>
> ws
>
> *******************
> ----- Original Message -----
> From: "Ulrich Bangert" <df6jb at ulrich-bangert.de>
> To: "'Discussion of precise time and frequency measurement'"
> <time-nuts at febo.com>
> Sent: Thursday, April 17, 2014 1:14 AM
> Subject: Re: [time-nuts] PI Math question
>
> > Warren,
> >
> > the job of a controller, regardless of P, PI od PID, is to minimize
> > the error between a process value and its setpoint. Since I see no
> > setpoint value in any of your versions my 50 ct is that none of them
> > really incorporates a controller at all and that for this reason the
> > question whether they produce the same output is close to being
> > irrelevant.
> >
> > Best regards
> >
> > Ulrich
> >
> >> -----Ursprungliche Nachricht-----
> >>
> >> A question to the math time-nuts
> >>
> >> 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,
> >>
> >> Given this PID type of controller;
> >> 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)
> >>
> >> Is the above Input to Output's transfer function any different than
> >> any of the following more simplified versions of PI controllers?
> >> Or asked another way, if each of the four codes are given the exact
> >> same
> >> input string and same K Gains, will the difference between any of their
> >> outputs ever be non zero?
> >>
> >>
> >> a)
> >> D = Input - Last_Input
> >> Last_Input = Input
> >> I#1 = I#1 + (K1 * Input) + (K2 * D)
> >> Output = (K3 * Input) + I#1
> >>
> >> b)
> >> D = (Input - Last_Input)
> >> Last_Input = Input
> >> Output = Output + (K1 * Input) + (K2 + K3) * D
> >>
> >> c)
> >> I#1 = I#1 + (K1 * Input)
> >> Output = I#1 + ((K2 + K3) * Input)
> >>
> >> ws
> >>
More information about the Time-nuts_lists.febo.com
mailing list