What is frequency response estimation? - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 10:48
Loaded: 1.53%
Stream Type LIVE
Remaining Time 10:48
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 10:48

    What is frequency response estimation?

    Understanding the frequency response of a system, which encompasses the magnitude and phase of its output as a function of input frequency, is pivotal for conducting linear analysis and designing control systems. In this video, you will learn how to compute frequency responses using MATLAB and Simulink. We will also delve into estimating frequency response models for Simulink models, focusing on those with components that challenge linearization, such as triggered subsystems, pulse width modulation, and stateflow diagrams. Furthermore, you'll gain insights into the real-time estimation of frequency response for physical plants.

    Published: 21 Dec 2023

    In this video, you will learn how to estimate frequency response of your systems. As you may know, frequency response is a set of magnitude and phase points as a function of input frequency. These magnitude and phase values show how the system transforms the input signal. Simulink models are often used by control engineers for control design. And we see that they model dynamics of the system in Simulink and want to analyze or use the frequency response of the Simulink model.

    Simulink control design is an add-on to Simulink that allows you to design and analyze control systems. We can use this product to compute the frequency response of the Simulink model. And there are two ways to do it.

    The straightforward approach is to compute LTI model, such as a transfer function or a state space representation that represents the linear dynamics around an operating point. You can compute the LTI representation of your Simulink models at an operating point by computing Jacobians analytically for the individual blocks in the model and combining them or through numerical perturbation. Once you have this model, you can directly compute the frequency response using the bode command.

    The other approach is to treat the Simulink model as a black box, inject some excitation signals, collect the output data, and compute the fast Fourier transform. This process is referred to as frequency response estimation. And this is what we'll be looking at today. This approach is useful when the exact linearization of the system model produces a zero linear model due to discontinuities like triggered subsystems, pulse width modulation, or state flow diagrams.

    Let's consider a scenario where we would like to tune the gains of this PID controller that controls the throttle of an internal combustion engine to get a specific engine speed. Let's try the first approach of linearizing the model and using the linear representation to tune the gains. Let's open the block dialog of the PID controller and attempt to tune it, using the PID tuner app.

    The PID tuner will attempt to linearize the model at the model initial condition and use it to automatically tune the gains. However, we see that it complains that it's not able to linearize the model in this case. Let's see what might be causing this issue.

    For that, let's use the model linearizer app to attempt linearization again and debug the results. Let's switch on the Linearization Advisor to give us some tips on debugging the results. We'll use the model's inputs, outputs, and initial conditions to linearize. And when the linearization process is complete, let's look at the results here.

    We see that the plant has been linearized to 0. And this is unusable for our control design and linear analysis workflows. So, why did this happen?

    If you look at the Linearization Advisor, it points to the blocks that are problematic to linearization. Let's look at the block info for this block in the Compression Subsystem. From the diagnostic messages, we see that since it's in a triggered subsystem, it was linearized to 0. In such scenarios, estimating the frequency response model is an option that we can use to tune the controller.

    So, how do we go about estimating a frequency response of this Simulink model? To do this, we'll navigate to the Estimation tab of the model linearizer app and select an input signal to inject into the model. So we have a couple of options, including Sinestream, Chirp, Random signals, or Pseudo Random Binary Sequences. And for our model, we'll choose Sinestream.

    We can specify the signal's name, units, and simulation order. The simulation order here, determines whether we have one simulation for all the frequencies or one simulation per frequency. Then, we can specify a set of frequency points of the input signal, depending on our frequency range of interest. Choosing these values is iterative and will require some insights of the system dynamics.

    For our scenario, our range of interest will be between 0.1 radians per second to 10 radians per second. We'll specify the number of frequency points to be 30 logarithmically spaced points. Here, you have flexibility in increasing the number of points between certain frequency points if you would like to accurately capture your system's frequency response, such as say, resonance peaks.

    After pressing OK, we can see these 30 points. With this done, we need to define the injected signal properties. And we have several fields to define appropriately to get a good estimation result. First is the amplitude of the signal to be injected. And we need to choose an amplitude that sufficiently excites the system around the operating point. Choosing too small of an amplitude would make it indistinguishable from noise in the system and fail to excite the system in a meaningful manner. And too high of an amplitude would result in larger excitations that would push the system away from the vicinity of their operating point, where the linear dynamics is valid.

    The other parameters that we will specify in our experiment settings are the number of periods, ramp, and settling periods. The ramp periods are the number of periods for ramping up the signal to its maximum value. Here, we do not want any ramp periods. So we'll set it to 0.

    The number of periods, as the name suggests, mentions the number of periods of a particular frequency and amplitude we will inject into the system. We will put in four for this case. So, what does this mean?

    For example, the lowest frequency we inject is 0.1 radians per second. So we will inject four periods of this frequency with our specified amplitude into the system. When you inject these signals, there will be initial transients in the system response before it reaches a steady state. We do not want to include these when calculating the fast Fourier transform. So we will specify a settling period that lets the algorithm wait for a certain number of periods before computing the FFT.

    The estimation algorithm discards the response data collected during the ramp and the settling periods, allowing the transients to die out, and uses the remaining periods to compute the estimated frequency response. Once we press OK, the Sinestream signal in-sine 1 is created. Now, let's estimate the frequency response of the model and plot the results in the existing body plot.

    Additionally, we can utilize the diagnostic tools to gain a better understanding of the results. Upon pressing Estimate, the calculations begin. And if we zoom in on the RPM plot in the Simulink engine model, we can observe the simulation running with the injected signal. As the time progresses, higher frequencies pass through the model. And when the calculation is complete, Simulink control design computes the FFT and presents two plots, the bode plot, displaying the 30 points representing the calculated frequency response, and the diagnostic viewer, featuring the bode diagram magnitude, the filtered steady state time response, and the FFT of the filtered time response.

    This diagnostic viewer allows us to select a specific frequency and analyze the steady state time response and FFT at that frequency. A good frequency response is indicated by minimal FFT values at other frequencies. Finally, we can copy this frequency response model into the MATLAB workspace. And upon inspection, we find the response data, which consists of a vector of frequencies and the corresponding values.

    Now, we can create a parametric model using System Identification Toolbox, using this FRD object, or use it directly for our linear analysis and control design workflows. In our case, we have an option to import this FRD object into the PID tuner and use it to tune the PID gains for the engine control system.

    Now, if you have access to the physical system in operation, you can directly obtain its frequency response model using the Frequency Response Estimator block. And if you have a code generation product such as Simulink Coder, you can generate code to implement the estimation algorithm on hardware. This allows you to deploy the algorithm to hardware and measure the frequency response of a physical plant in real time. A bonus tip if you watch this far, is you can use the Closed-Loop PID Autotuner block to automatically tune the frequency response of your system and use it to tune the PID gains in one single step.

    In summary, we have learned how to estimate the frequency response of a Simulink model or perform online estimation on a physical plant. Please see the references in the description to learn more about the examples and other resources to get started on estimating frequency responses for your systems.

    View more related videos