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

Posted by **Guy Rouleau**,

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.

**Now it is your turn**

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.

**Category:**- Controls,
- Modeling,
- What's new?

## 9 CommentsOldest to Newest

**1**of 9

HI Pravallika,

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

IF YES PLEASE ELABORATE

**2**of 9

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**of 9

@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.

**4**of 9

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**of 9

@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**of 9

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**of 9

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

please help me

reformummah@yahoo.com

**8**of 9

Hi Everyone,

What I’m a little confused about is how to determine how many poles to specify? I mean, you have an experimental bode plot from measurements in the frequency domain, how do I know how many poles to specify? Increasing the number of poles does not bring me closer to the actual bode plot, it just produces wildly different results.

Kind regards

Charles

**9**of 9

Hi Pravallika.

in your video you said that if “we use arduino mega board, we could change command and log the data from the same model we would run on the board using external mode”. I’m using arduino mega adk, so would you please to help me to use external mode. I’m new at this, so if yo can tell or show me the example it would help me a lot.

thanks

## Recent Comments