Reply by Tim August 28, 20112011-08-28
On Fri, 26 Aug 2011 03:20:16 -0500, resampled wrote:

> Ok, I'll try to explain my problem again with a few more details. > > First of all I have a discrete controller structure as shown in the > following picture: > > http://www.engin.umich.edu/group/ctm/examples/motor/Ss1.GIF > > with > > A = [ 0.9999066, -0.0069878;-0.0008812 0.9178842]; B = [-0.0337198 > 0.0118804]'; > C = [-1.0340817 -0.0915291]; > > and the feedback gains K = [-2.0831 0.9667] > > The controller works although the steady state is not equal the > reference input. For a step input the steady state of the output y is > 0.49. Therefore I need to scale the reference input with a scalar, lets > call it N. > > This scalar has to be 1/0.49=2.04 to drive the output y to 1.0 (again if > a unit step is applied) > > My problem now is, that I don't know how to optain this result > mathematically. For a continious controller the scalar factor N may be > calculated by using following scheme. > > s = size(A,1); > Z = [zeros([1,s]) 1]; > NN = inv([A,B;C,D])*Z'; > Nx = NN(1:s); > Nu = NN(1+s); > N=Nu + K*Nx; > > But how do I calculate N for a discrete controller (without transfering > the discrete state space back to a continious one).
First: you have not answered the question "what are you trying to _do_". You have just reiterated a bunch of -- not even math, but Scilab code -- in slightly more detail. _Doing_ something would be "I am doing homework" or "I am trying to get my motor to settle out exactly where I want it to" or "I am incubating ostrich eggs and I don't want them either too cold or too hot". Second: You don't know how to get the answer for the continuous-time case. You only think you do. What you know how to do is to copy some Matlab code from your notes. Here's a hint from the Solution Manual of Life: real engineers speak math. Poseurs speak Matlab. You will be successful on your current path until the moment that you need to do something that Matlab can't. Then you'll crash and burn. This means that you will be forever at the mercy of the folks at The Mathworks. Is that a comfortable feeling? Third: You ignored a perfectly good suggestion for making your system robust to the inevitable variations in plant performance that plague all real systems. As an exercise, when you get your answer for your pretend- perfect plant, change the plant gain by 20%, and see how far off your 'perfect' system ends up being. Try it again with a 50% change in plant gain. To restate what you are doing _in English_, you are finding the DC gain of your naively controlled system (ignoring the behavior of your observer), and you are making a slightly less naive system by dividing out that DC gain. So _in math_ your controlled system has a transfer function T(s) = C * (I * s - (A + B * K))^-1 * B + D (How do I know this? How did I arrive at this result? Does my sign convention match yours?) Solving this for the gain at DC just means taking the limit as s goes to zero, which (we hope) means just substituting: T(0) = C * (I * 0 - (A + B * K))^-1 * B + D And solve. So, if your transfer function in the z domain is T(z) = C * (I * z - (A + B * K))^-1 * B + D, what is the gain of that transfer function at DC? -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Reply by resampled August 26, 20112011-08-26
Ok, I'll try to explain my problem again with a few more details.

First of all I have a discrete controller structure as shown in the
following picture:

http://www.engin.umich.edu/group/ctm/examples/motor/Ss1.GIF

with 

A = [ 0.9999066, -0.0069878;-0.0008812  0.9178842];
B = [-0.0337198 0.0118804]';
C = [-1.0340817  -0.0915291];

and the feedback gains K = [-2.0831 0.9667]

The controller works although the steady state is not equal the reference
input. For a step input the steady state of the output y is 0.49. 
Therefore I need to scale the reference input with a scalar, lets call it
N.

This scalar has to be 1/0.49=2.04 to drive the output y to 1.0 (again if a
unit step is applied)

My problem now is, that I don't know how to optain this result
mathematically. For a continious controller the scalar factor N may be
calculated by using following scheme. 

s = size(A,1); 
Z = [zeros([1,s]) 1]; 
NN = inv([A,B;C,D])*Z'; 
Nx = NN(1:s); 
Nu = NN(1+s); 
N=Nu + K*Nx;

But how do I calculate N for a discrete controller (without transfering the
discrete state space back to a continious one).
Reply by HardySpicer August 26, 20112011-08-26
On Aug 26, 7:08&#4294967295;am, Tim Wescott <t...@seemywebsite.com> wrote:
> On Thu, 25 Aug 2011 04:31:55 -0500, resampled wrote: > > Hi at all > > > I'm currently designing a fullstate feedback controller with the > > following state space > > > A = [ 0.9999066, -0.0069878;-0.0008812 &#4294967295;0.9178842]; B = [-0.0337198 > > 0.0118804]'; > > C = [-1.0340817 &#4294967295;-0.0915291]; > > D = [0]; > > > and the feedback gains K = [-2.0831 0.9667]. > > > The controller itself together with the kalman filter to estimate the > > states works without any problems. However, to use a reference input it > > has to be scaled. But I can't seem to get the scaling factor right. I > > found the following listing a few times on the web to calculate the > > scaling factor: > > > % compute Nbar > > s = size(A,1); > > Z = [zeros([1,s]) 1]; > > N = inv([A,B;C,D])*Z'; > > Nx = N(1:s); > > Nu = N(1+s); > > Nbar=Nu + K*Nx; > > > With the matrices above the solution of Nbar leads to -27.3076 which > > does not do the job. Through trial and error I found the right solution > > to be around 2, altought I have no clue how to get to this result > > mathematically. > > > Maybe anybody could tell me what I'm doing wrong? Thanks in advance! > > Where are you inserting your reference input? > > What are you trying to _do_? > > I can't remember the details (most real-world problems are either > basically SISO, or MIMO with enough nonlinearities that you're better off > treating them as "decorated SISO", so I forget). &#4294967295;IIRC, however, if you > model an offset to the output as an uncontrollable integrator (which > means you need to augment your system by one state) then you can just > feed your Kalman filter with an error signal equal to y_kalman + > y_desired - y_actual. &#4294967295;The uncontrolled integrator in your system model > will make the Kalman into an integrating observer, which will end up > giving your whole system a PID action, which is usually good. > > I'd actually have to crank through some math to give you a better answer > -- sorry. > > --www.wescottdesign.com
With integral action it will be crap anyway.
Reply by Tim Wescott August 25, 20112011-08-25
On Thu, 25 Aug 2011 04:31:55 -0500, resampled wrote:

> Hi at all > > I'm currently designing a fullstate feedback controller with the > following state space > > A = [ 0.9999066, -0.0069878;-0.0008812 0.9178842]; B = [-0.0337198 > 0.0118804]'; > C = [-1.0340817 -0.0915291]; > D = [0]; > > and the feedback gains K = [-2.0831 0.9667]. > > The controller itself together with the kalman filter to estimate the > states works without any problems. However, to use a reference input it > has to be scaled. But I can't seem to get the scaling factor right. I > found the following listing a few times on the web to calculate the > scaling factor: > > % compute Nbar > s = size(A,1); > Z = [zeros([1,s]) 1]; > N = inv([A,B;C,D])*Z'; > Nx = N(1:s); > Nu = N(1+s); > Nbar=Nu + K*Nx; > > With the matrices above the solution of Nbar leads to -27.3076 which > does not do the job. Through trial and error I found the right solution > to be around 2, altought I have no clue how to get to this result > mathematically. > > Maybe anybody could tell me what I'm doing wrong? Thanks in advance!
Where are you inserting your reference input? What are you trying to _do_? I can't remember the details (most real-world problems are either basically SISO, or MIMO with enough nonlinearities that you're better off treating them as "decorated SISO", so I forget). IIRC, however, if you model an offset to the output as an uncontrollable integrator (which means you need to augment your system by one state) then you can just feed your Kalman filter with an error signal equal to y_kalman + y_desired - y_actual. The uncontrolled integrator in your system model will make the Kalman into an integrating observer, which will end up giving your whole system a PID action, which is usually good. I'd actually have to crank through some math to give you a better answer -- sorry. -- www.wescottdesign.com
Reply by resampled August 25, 20112011-08-25
Hi at all

I'm currently designing a fullstate feedback controller with the following
state space

A = [ 0.9999066, -0.0069878;-0.0008812  0.9178842];
B = [-0.0337198 0.0118804]';
C = [-1.0340817  -0.0915291];
D = [0];

and the feedback gains K = [-2.0831 0.9667].

The controller itself together with the kalman filter to estimate the
states works without any problems. However, to use a reference input it has
to be scaled. But I can't seem to get the scaling factor right. 
I found the following listing a few times on the web to calculate the
scaling factor:

% compute Nbar 
s = size(A,1); 
Z = [zeros([1,s]) 1]; 
N = inv([A,B;C,D])*Z'; 
Nx = N(1:s); 
Nu = N(1+s); 
Nbar=Nu + K*Nx;

With the matrices above the solution of Nbar leads to -27.3076 which does
not do the job. Through trial and error I found the right solution to be
around 2, altought I have no clue how to get to this result mathematically.

Maybe anybody could tell me what I'm doing wrong?
Thanks in advance!