Main Content

Use Superposition Signal Generator Block for Offline Frequency Response Estimation

Since R2024b

This example shows how to use the Superposition Signal Generator block to create a superimposed sinusoidal input signal and perform an offline frequency response estimation experiment. In practice, you can use this approach to perform the experiment in real-time against a physical plant. In this example, you perform the experiment on a plant modeled in Simulink®.

Examine Model

This example uses a model that contains a plant in a closed-loop configuration with a PI controller. The model is preconfigured with a Superposition Signal Generator block that adds a perturbation signal to the control signal, and injects the summation of these signals at the plant input. The model also collects the output response data using the Data Logging for 'frestimate' subsystem, which you can use for offline frequency response estimation.

Open the model.

mdl = "SuperpositionSigGenForOfflineFREDataLogging.slx";
open_system(mdl)

modelDiagram.png

Signal Parameter Settings

The Superposition Signal Generator block is parameterized to generate a perturbation signal for 20 logarithmically-spaced frequency points between 1 rad/s and 100 rad/s, all with amplitudes of 1. The Signal Length section of the block parameters displays the required experiment length based on the current block parameter settings. To ensure a comprehensive experiment, you must configure the start/stop port such that the signal injects for at least that long.

paramDialogBasic.png

The Advanced Settings section contains parameters that you can use to configure the signal type and form. You can choose to generate sine signals, cosine signals, or both using the Waveform Type parameter. You can also use the Phase Shift parameter to configure a consistent phase shift in the generated signals.

The Generate three-phase perturbation signal parameter allows you to generate balanced three-phase perturbation signals. The generated signal is balanced because the summation of these three-phase signals always equals zero. You can use these signals to analyze three-phase alternating current (AC) electric circuits. In this example, the block uses default values for the advanced settings.

paramDialogAdvanced.png

Collect Experiment Data

The Data Logging for 'frestimate' subsystem collects experiment data in the data object SigGenDataLog. The subsystem logs the Ready, Perturbation, PlantInput, and PlantOutput signals in the data object. Inside the Data Logging for 'frestimate' subsystem, the Subtract Nominal Values subsystem removes the nominal values from the logged input and output signals.

Simulate the model. The model injects the generated superposition perturbation signals into the closed-loop system and collects the measurements. Since the PI controller is still in the loop, you can conduct frequency response estimation experiment at the desired operating points.

sim(mdl)

The model collects the data in the format compatible for offline frequency response estimation using frestimate.

SigGenDataLog
SigGenDataLog = struct with fields:
           Ready: [1x1 timeseries]
    Perturbation: [1x1 timeseries]
      PlantInput: [1x1 timeseries]
     PlantOutput: [1x1 timeseries]
            Info: [1x1 struct]

The Ready field is a timeseries signal that contains a logical signal that indicates the duration of the superposition signal.

Estimate Frequency Response

To perform the frequency response estimation offline, use the collected data with the frestimate function.

Use the SigGenDataLog structure and the specified frequencies as inputs to the frestimate function. frestimate processes SigGenDataLog to obtain a frequency response data model that contains the estimated responses at the specified frequencies.

sys_estim = frestimate(SigGenDataLog,w,"rad/s");
size(sys_estim)
FRD model with 1 outputs, 1 inputs, and 20 frequency points.

Examine Estimated Frequency Response

Compare the frequency response estimation result with the result obtained in the example Collect Frequency Response Experiment Data for Offline Estimation.

load("FREResultComparisonForSuperposition.mat");
linsys = c2d(tf(10,[1 10 1000]),0.005);
opts = bodeoptions;
opts.XLim = [1 100];
opts.YLim = {[-60 -25];[-200 0]};
figure
bodeplot(linsys,"k-",sys_estim,"b*",sys_freblk,"ro",opts);
legend("Linear Plant Model","Using Superposition Signal Generator",...
    "Using Frequency Response Estimator","Location","southwest");

MATLAB figure

The Bode plot shows identical frequency response estimation results. Therefore, you can use the Superposition Signal Generator block to conduct offline frequency response estimation as an alternative to the sinestream perturbation signal. Compared to the Frequency Response Estimator block, the Superposition Signal Generator block is more flexible and provides better customization for the signal parameters. More importantly, you can use the signal generator blocks to reduce the hardware requirement in a deployed environment with limited computational resources.

See Also

| |

Related Topics