Author 
Message 
Peter Nachtwey science forum addict
Joined: 06 Nov 2005
Posts: 68

Posted: Thu Jul 13, 2006 8:21 pm Post subject:
Re: Fit a transfer function to gain and phase data



Jan C. Hoffmann wrote:
Quote:  "Peter Nachtwey" <pnachtwey@comcast.net> schrieb im Newsbeitrag
news:3oOdnfDxmcYJ0yvZnZ2dnUVZ_ridnZ2d@comcast.com...
"Jan C. Hoffmann" <janch@arcor.de> wrote in message
news:44b61da6$0$26257$9b4e6d93@newsread2.arcoronline.net...
 How do you find the coefficients C and D of the system to be controlled?

 e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)
I have know idea what
 e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)
is supposed to be.
I don't know what you are asking for. Gid is the resulting transfer
function
>Gid
Gid =
2
2.8143084 + 0.1316710s + 1.9930258s

2 3 4
0.7009256 + 1.1251421s + 1.8071075s + 1.2745791s + s
Sorry for being unprecise in asking.
Let's assume you have an existing system in a power plant. You apply a step
function to get information about the system to be controlled.
What is the approach to find the coeffients Ci of e.g.
C3*s^3+C2*s^2+C1*s+C0=0, if degree 3 is (for some reason) applicable?
First, C3*s^3+C2*s^2+C1*s+C0=0 is not a transfer function with poles. 
See http://www.controlguru.com how to find a simple FOPDT transfer
function.
For more sophisticated systems I use the CO and PV, not the gain and
phase. I then start with a simple model. I find the coefficients for
that model using a minimization program like what can be found in
Mathcad ( Minerr ) or Scilab ( lsqrsolve) . I then try a different
model. After I have tried all probable models I choose the one with
the best fit. This choice must be tempered by a sanity check. I get
much better results than the gain and phase with frfit above.
Note the gain can and probably will be nonlinear. It is possible to
compute Gp(PV) using these nonlinear minimization techniques.
The quickest/cheapest way to is to download Scilab and use the
lsqrsolve.
Get Modeling and Simulation in Scilab/Scicos
http://www.amazon.com/gp/product/0387278028/10476581753679138?v=glance&n=283155 

Back to top 


Jan C. Hoffmann science forum beginner
Joined: 13 Jul 2006
Posts: 2

Posted: Thu Jul 13, 2006 6:12 pm Post subject:
Re: Fit a transfer function to gain and phase data



"Peter Nachtwey" <pnachtwey@comcast.net> schrieb im Newsbeitrag
news:3oOdnfDxmcYJ0yvZnZ2dnUVZ_ridnZ2d@comcast.com...
Quote: 
"Jan C. Hoffmann" <janch@arcor.de> wrote in message
news:44b61da6$0$26257$9b4e6d93@newsread2.arcoronline.net...
 How do you find the coefficients C and D of the system to be controlled?

 e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)
I have know idea what
 e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)
is supposed to be.
I don't know what you are asking for. Gid is the resulting transfer
function
>Gid
Gid =
2
2.8143084 + 0.1316710s + 1.9930258s

2 3 4
0.7009256 + 1.1251421s + 1.8071075s + 1.2745791s + s

Sorry for being unprecise in asking.
Let's assume you have an existing system in a power plant. You apply a step
function to get information about the system to be controlled.
What is the approach to find the coeffients Ci of e.g.
C3*s^3+C2*s^2+C1*s+C0=0, if degree 3 is (for some reason) applicable?
Thanks for answering.

Regards / Gruss Jan C. Hoffmann 

Back to top 


Peter Nachtwey science forum addict
Joined: 06 Nov 2005
Posts: 68

Posted: Thu Jul 13, 2006 1:45 pm Post subject:
Re: Fit a transfer function to gain and phase data



"Jan C. Hoffmann" <janch@arcor.de> wrote in message
news:44b61da6$0$26257$9b4e6d93@newsread2.arcoronline.net...
 How do you find the coefficients C and D of the system to be controlled?

 e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)
I have know idea what
 e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)
is supposed to be.
I don't know what you are asking for. Gid is the resulting transfer
function
>Gid
Gid =
2
2.8143084 + 0.1316710s + 1.9930258s

2 3 4
0.7009256 + 1.1251421s + 1.8071075s + 1.2745791s + s
Peter Nachwey 

Back to top 


Jan C. Hoffmann science forum beginner
Joined: 13 Jul 2006
Posts: 2

Posted: Thu Jul 13, 2006 10:16 am Post subject:
Re: Fit a transfer function to gain and phase data



"Peter Nachtwey" <peter@deltacompsys.com> schrieb im Newsbeitrag
news:1152570122.578315.257210@m73g2000cwd.googlegroups.com...
Quote:  The example program for Scilab's frfit function would be a good place
to start.
w=0.01:0.01:2;s=poly(0,'s');
G=syslin('c',2*(s^2+0.1*s+2), (s^2+s+1)*(s^2+0.3*s+1));
fresp=repfreq(G,w);
Gid=frfit(w,fresp,4);
frespfit=repfreq(Gid,w);
bode(w,[fresp;frespfit])

How do you find the coefficients C and D of the system to be controlled?
e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)

Regards / Gruss Jan C. Hoffmann 

Back to top 


Peter Nachtwey science forum addict
Joined: 06 Nov 2005
Posts: 68

Posted: Mon Jul 10, 2006 10:22 pm Post subject:
Re: Fit a transfer function to gain and phase data



The example program for Scilab's frfit function would be a good place
to start.
w=0.01:0.01:2;s=poly(0,'s');
G=syslin('c',2*(s^2+0.1*s+2), (s^2+s+1)*(s^2+0.3*s+1));
fresp=repfreq(G,w);
Gid=frfit(w,fresp,4);
frespfit=repfreq(Gid,w);
bode(w,[fresp;frespfit])
The above was copied out of the Scilab documentation. It generates the
data which is in a complex form. The OP would have to convert the
magnitude and phase to complex numbers but then the rest looks so easy.
The Gid is the identified tranfer function.
The last two lines just print out the source transfer function and the
resulting 'ID' for comparison.
Peter Nachtwey 

Back to top 


Fred Stevens science forum beginner
Joined: 29 Apr 2005
Posts: 32

Posted: Mon Jul 10, 2006 5:34 pm Post subject:
Re: Fit a transfer function to gain and phase data



Tim Wescott wrote:
Quote:  Roza.Mahmoodian@gmail.com wrote:
I have the gain and phase data for which I want to find a transfer
function. None of the results that I get using "invfreqs" really
matches the actual bode plot of the data. Any ideas?
I also get the warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 4.362258e030.
Thanks!
If you're using MatLab it's a good idea to say so. I _assume_ that's
where the 'invfreqs' comes from.
The warning sounds like what you'd get if you've asked for too high an
order of transfer function  there's probably a linear matrix problem
embedded in there that needs sufficient data to get a good answer.
Having said all that  I'm not a big advocate of extracting a transfer
function from measured data, particularly gain and phase data. The
sensible thing to to with extracted transfer functions is to do some
sort of poleplacement design  and this is is really only useful and
safe if you're being ultra conservative or if you already have solid
domain knowledge.
Unless you're going to use some robust design technique with your
extracted transfer function, and that technique requires things in
polynomial form, I would suggest that you just use the measured data
directly to do your design the old fashioned way using Bode and Nyquist
plots. Assuming your measurements are good this leaves little to
chance, and gives you a good probability of getting a safe effective
controller tuning, or at least an understanding of why you _can't_ get a
good safe effective controller tuning.

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

Don't forget that there are actually two functions; invfreqs for
continuous time data and invfreqz for discrete time data. Make sure you
are using the correct one. Also, make sure that you have points over a
wide enough frequency range. Check that you have the correct relative
degree of the transfer function or the algorithm will complain in the
way you describe.
fred. 

Back to top 


Tim Wescott science forum Guru Wannabe
Joined: 03 May 2005
Posts: 292

Posted: Sun Jul 09, 2006 8:24 pm Post subject:
Re: Fit a transfer function to gain and phase data



Roza.Mahmoodian@gmail.com wrote:
Quote:  I have the gain and phase data for which I want to find a transfer
function. None of the results that I get using "invfreqs" really
matches the actual bode plot of the data. Any ideas?
I also get the warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 4.362258e030.
Thanks!
If you're using MatLab it's a good idea to say so. I _assume_ that's 
where the 'invfreqs' comes from.
The warning sounds like what you'd get if you've asked for too high an
order of transfer function  there's probably a linear matrix problem
embedded in there that needs sufficient data to get a good answer.
Having said all that  I'm not a big advocate of extracting a transfer
function from measured data, particularly gain and phase data. The
sensible thing to to with extracted transfer functions is to do some
sort of poleplacement design  and this is is really only useful and
safe if you're being ultra conservative or if you already have solid
domain knowledge.
Unless you're going to use some robust design technique with your
extracted transfer function, and that technique requires things in
polynomial form, I would suggest that you just use the measured data
directly to do your design the old fashioned way using Bode and Nyquist
plots. Assuming your measurements are good this leaves little to
chance, and gives you a good probability of getting a safe effective
controller tuning, or at least an understanding of why you _can't_ get a
good safe effective controller tuning.

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 

Back to top 


Roza.Mahmoodian@gmail.com science forum beginner
Joined: 07 Jul 2006
Posts: 1

Posted: Fri Jul 07, 2006 5:05 pm Post subject:
Fit a transfer function to gain and phase data



I have the gain and phase data for which I want to find a transfer
function. None of the results that I get using "invfreqs" really
matches the actual bode plot of the data. Any ideas?
I also get the warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 4.362258e030.
Thanks! 

Back to top 


Google


Back to top 


