# Guy and Seth on Simulink

## Estimating Continuous-Time Transfer Functions with System Identification Toolbox

Today guest blogger Pravallika describes how she used new features of the System Identification Toolbox to design a controller for a DC motor

Any controls engineer knows that the key to designing a good controller is having a good plant model. But what do you do if you don’t have the underlying equations?

System identification can help in that case. In R2012a, the System Identification Toolbox added support for estimating parameters of a model type that is most intuitive and easiest to work with for controls engineers – continuous-time transfer functions. You can specify how many poles and zeros you want your transfer function to have, and the toolbox determines locations of poles and zeros automatically. If the system you are trying to model has a delay, the toolbox can automatically determine its value.

The Setup

I have been working with the setup shown in the image below. It is very simple; it is a small DC motor connected to an Arduino board.

I applied a voltage to the motor and recorded the resulting motion. I imported this data in MATLAB and constructed an iddata object.

Here is what the data look like, using the iddata plot command.

Estimation

Let’s begin by estimating the simplest possible transfer function – first-order, with no zeros. For that, we use the new function tfest.

After the estimation is completed, we can compare the output of the model with the measured shaft angle. The comparison shows that the model does a good job in capturing dynamics of the motor.

Validation

To ensure that the estimated transfer function represents motor dynamics, we need to validate this transfer function against an independent data set.

I tried feeding other sets of data acquired experimentally through the identified transfer function and compared the result with the measured shaft angle. Even though the fit is not perfect, the identified transfer function does a pretty good job in capturing system dynamics.

Using the Estimated Transfer Function

Now let's use the identified transfer function model to design a PID controller using pidtune.

One notable quality of models obtained with System Identification Toolbox is that they not only contain the information about the “nominal” parameter values, but also carry information about parameter uncertainty. We can check the effect of this parameter uncertainty on the bode plot magnitude of the estimated transfer function.

We can also use the function rsample to sample this parameter uncertainty to create an array of transfer functions to test our controller.

The plot above shows the closed-loop step response for the nominal plant as well as the additional ten step responses for the sampled parameter uncertainty. We can see that the PID controller we designed works well in the face of uncertainty in estimated transfer function parameters.

Estimating Other Model Types

In addition to estimating continuous-time transfer functions, System Identification Toolbox lets you estimate continuous-time state-space models and process models (special, low-order transfer functions). You can quickly compare different models and pick the one that is most appropriate for your problem.

How do you develop plant models? Try using new capabilities for continuous-time transfer function estimation and let us know what you think by leaving us a comment here.

### 7 Responses to “Estimating Continuous-Time Transfer Functions with System Identification Toolbox”

1. ALI replied on :

HI Pravallika,

IS IS POSSIBLE TO VISULIZE ANY SYSTEM BY WRITING A PROGRAM ON MATLAB?

2. Paul replied on :

Excellent post. I’m very much looking forward to seeing the results and performance of the new continuous time transfer function identification routine on some existing SISO data I have that spans a wide frequency range and has time delay. This new feature of the toolbox should save me significant time setting up optimisation problems in the optimisation toolbox to achieve the desired result. Well done.

3. Pravallika replied on :

@Ali: Given that you have input/output datasets from the system that capture its important dynamics, you can use various System Identification techniques to construct a mathematical model for the system in MATLAB. You can choose the technique to be used based on what is needed for your application. The following webinar will help you get started on the System Identification Toolbox:

http://www.mathworks.com/company/events/webinars/wbnr54213.html?id=54213&p1=869915375&p2=869915393

4. Akarsh Gupta replied on :

Hi Pravallika,
I have matlab R2010a on my PC, I am getting the following error while executing:

sys=tfest(data,2,0,delay*data.Ts)

??? Undefined function or method ‘tfest’ for input arguments of type ‘iddata’.

How to solve this error?

5. Arkadiy Turevskiy replied on :

@Akarsh: as the blog post mentions, functionality for estimating continuous-time transfer functions was added to System Identification Toolbox in release R2012a. This functionality was not in the earlier releases, and that is why you are getting the error message.

To gain access to new functionality, you will need to install release R2012a.

6. Rick Groff replied on :

The voltage-to-angle transfer function should not be a first order transfer function. If it was first order, then a constant voltage should result in a constant angle at steady state. I was confused about how your model fit the experimental data so well until I noticed that your estimated time constant is 1/0.02988 = 33s. The triangle wave that you see is just the very beginning of a very slow step for the estimated model. In order to illustrate the problem clearly, consider a square wave input that varies between 0V and 1V. The actual motor will take successive steps in the same direction, whereas yhe estimated model will always return to 0deg when the input is 0V. This is actually a nice example of how easily one can be misled by a model that fits “pretty well.”

7. reformummah replied on :

I don’t know anything but I have to do final year project about motor. I want to know how can I start to learn the system identification, how can I estimate input and output. Input is a voltage and output is an angle. Then how can i build the motor’s model.

Thank you very much
reformummah@yahoo.com

 Name (required) E-mail (required, will not be published) Website (optional) Spam protection (required): What is 3 + 9 ?

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>


If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).

Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.

These postings are the author's and don't necessarily represent the opinions of MathWorks.