# A real control post! Transfer function conversion to time series or state model

In case there are still real control people checking this sadly degraded group...
This isn't a homework question, rather I've been in the industrial control
trenches too long to remember much of what I learnt on basic transfer function theory many years ago. I use a home-developed simulation tool, which is basically an analog computer in C++, models are built as state machines using integrators. I've just joined a project where models are provided as unfactorised transfer functions - eg. (1+bs)/(c*s^2 + d^s + e) - and I want to either generate a time series response from an arbitrary input (generated elsewhere in the simulation), or a state machine based on my integrators than I can then run.
I've already had a go, an unfactorised 2-conjugate-pole transfer function was fairly straightforward, but ideally I'd like to be able to handle a transfer function with an arbitrary number of poles and zeros. Can anyone point me to a reference that explains how to do this?
BTW, the factorisation option has occurred to me, it's just fairly laborious when there are a significant number of models inolved. TIA
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
On 12/02/2010 04:30 AM, Noodnik wrote:

Can I interest you in a solutions manual? Or offer you a chance to publish a paper at a symposium of 3rd-rate professors who need to publish before they perish? How about a raft of dirty pictures, hidden behind a link -- just click on "infect_my_computer.exe" and you'll be there!
It could be worse -- someone could start talking politics.

You _really_ want to get Scilab, or Octave, or even Matlab. They do what your home-brew does, and lots, lots more.

You really don't want to do that. As the number of poles goes up, you run into serious numerical problems -- it's the old "big numbers with small differences, subtract and get noise" problem. It's maybe not as bad for practical systems in the Laplace domain (as opposed to the z domain), but it's still there.
"Linear Systems" by Thomas Kailath is a classic for good reason. In it you'll find the four canonical ways to realize a transfer function in an analog computer -- this should help get you there.

Factorization is good. Unfortunately, part of the problem you'll run into is that as polynomial order gets large, polynomial factorization itself runs into numerical difficulties.
I'd factor. I use Scilab, which helps you factor -- so I'd use Scilab, factor the transfer functions into as many real 1st-order ones as I could, followed by 2nd-order resonant ones. Doing this well is something of an art (at least I don't know of any good automatic ways to do this), but if you've just got tons of transfer functions then you can maybe get by with doing it automatically.
--

Tim Wescott
Wescott Design Services
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Thanks guys, nice to see some good guys hanging in here.
Noodnik, aka Bruce Varley
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

I use different techniques depending. I think using something like Runge-Kutta is the best way to go. State space methods assume a linear model whereas Rung-Kutta does not. For very simple things I would solve your problem in the S domain. In between and linear systems I would solve using state space.
Scilab is a good place to start. look here for an example SOPDT temperature system simulation written in Scilab. http://www.deltamotion.com/peter/Scilab/SOPDT / This simulation is easy but if you are modeling a heat exchanger then you must take into account the log mean temperature difference and then you should use Runge-Kutta or something more sophisticated.
I find a fixed interval RK4 works well more my needs but I will use whatever Scilab, wxMaxima or Mathcad provide..
Peter Nachtwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Finally gave up on trying to create a time simulation that handled zeros in a rigorous manner, using state variable integrators. The problem was when there are no non-complex poles in the denominator to null them out against. Took the easy way out and implemented a basic differentiator - (now - last)/delta_t. By putting the derivative after the denominator model the derivative infinity (delta function) is avoided and the full transfer function is calculated cleanly and, AFAICT, with more or less complete accuracy. Easy peasy. :-)
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

I don't understand. It is easy to simulate systems with zeros. It is easy to design a controller that not only places the poles it also places the zeros. Pole placement alone can leave the zeros in undesirable spots so sometimes the controller gains in the forward path are different from those in the feedback path. The controller is no longer a true PID anymore but if you are rolling your own controller it should make any difference.
For simple simulations I use Laplace transforms. For the most complex I use RK4. Using Laplace transforms is easy ONCE you know the tricks. RK4 is by far the most straight forward and flexible for use with arbitrary control signals.
Peter Nachtwey