Contenido principal

Validate Controller Gains with Frequency Response Estimation on Hardware

R2026b

In this step of the LLC Resonant Converter Controller Design Workflow example, you measure the small-signal frequency response of the LLC resonant converter plant on real hardware. The controller runs on a Texas Instruments® C2000™ F28379D LaunchPad™, the plant is emulated by a Speedgoat® HIL machine, and a host model streams the response back to MATLAB so you can build an FRD object for controller tuning.

Load Converter Parameters

To make the injection, target, and host models see a consistent set of converter parameters, load the shared HIL data file first. resonantllcconverterhildata populates the base workspace with the converter, controller, and interface parameters used by every model in this workflow.

resonantllcconverterhildata;

Frequency Response Estimation

Configure FRE Injection Parameters

To characterize the plant, define the perturbation signal and the time budget for the estimation. Ts_fre (5 µs) is the target sample time for the sinestream generator; it must be short enough to resolve the highest injection frequency. freq lists the injection frequencies chosen to span the expected control bandwidth of the LLC plant. Amplitudes is the peak of the sinusoidal perturbation applied on top of the operating point; keep it small enough to remain in the linear regime but large enough to overcome measurement noise. NumSetPeriod and NumEstPeriod control how many periods per frequency are used to settle transients and to estimate the response, respectively. Increase them if transients contaminate the estimate.

Ts_fre      = 5e-6;                          % FRE sample time [s]
freq        = [500 800 1000 1300 1700 2000]; % Frequencies to be injected [Hz]
Amplitudes  = 10000;                         % Amplitude of sine signals to be injected [Hz]
NumSetPeriod = 5;                            % Number of settling periods for the frequency injection
NumEstPeriod = 2;                            % Number of estimation periods for the frequency injection
TestTime = 0;

% Calculate time to inject the frequencies
for index = 1:length(freq)
    TestTime = TestTime + (NumSetPeriod+NumEstPeriod) / freq(index);
end
TestTime = TestTime*1.01;

TestTime is the total duration required to inject and estimate every frequency, with a 1% margin added to absorb model-dependent overhead. The value shown above is the minimum simulation stop time you should use for the injection model.

Perform FRE on Hardware

Create Perturbation Table

To keep the C2000 target real-time deterministic, precompute the perturbation waveform on the host and download it as a lookup table. The LLCFreSineStream model generates the concatenated sinestream and the corresponding index signal that steps through it, so the target only has to read from a table rather than synthesize sinusoids online.

modelName2 = 'LLCFreSineStream';
load_system(modelName2);
TestTime = 0;
for index = 1:length(freq)
    TestTime = TestTime + (NumSetPeriod+NumEstPeriod) / freq(index);
end
TestTime = TestTime*1.01;
SimTime2 = TestTime;
out = sim(modelName2);
close_system(modelName2);
sineLUT = out.FreInj;
IdxLUT  = out.Idx;
disp(['Look up table length = ' num2str(length(sineLUT))]);

The lookup-table length equals TestTime / Ts_fre and directly sets the memory the C2000 target must reserve for the perturbation table. Confirm that this value fits comfortably within the LaunchPad's available RAM before deployment.

Inject Perturbations and Capture Converter Response

To exercise the plant on hardware, deploy the target model to the C2000 F28379D LaunchPad. LLCFreF28379d embeds the perturbation lookup table into the deployed image, injects the sinestream on top of the open-loop switching frequency, and streams the plant response back to the host over serial. simTime3 adds a 20 ms tail (+ 0.02) after the last injected sample to guarantee the final period is captured before the run stops.

modelName3 = 'LLCFreF28379d';
simTime3 = length(sineLUT) * Ts_fre + 0.02;
open_system(modelName3);

To visualize the streamed response and manage the injection run, open the host model. The host model receives frames from the target, unpacks them, and provides the simout signal used in the next step. Ensure host model simulation is stopped before proceeding to next step.

open_system('LLCFreF28379dHost');

Process Host Model Data

The target sends data in fixed-size frames, but frequency response estimation needs a single continuous time series aligned with the perturbation table. To recover that time series, flatten the framed output.

continuousData = reshapetocontinuous(simout);

To align the captured response with the perturbation lookup table, sample the continuous data at the rising edges of the target's injection strobe. The result is one response sample per injected perturbation sample, with the same length as sineLUT.

FREresponse = extractOnRisingEdge(continuousData, length(sineLUT));
plot (FREresponse)

The plot shows the raw response after alignment. Confirm the signal transitions cleanly between injection frequencies and does not clip. Clipping indicates the perturbation amplitude is too large and biases the estimate.

Post-Process Injection and Response

To compute the transfer function from the aligned data, replay the injection and captured response through a post-processing model that packages both signals as a SignalGenerator and a logged output. LLCFrePostProcess does this in a single simulation and produces the SigGenDataLog used by frestimate. w converts the injection frequencies from Hz to rad/s because frestimate expects the frequency vector in rad/s.

modelName4 = 'LLCFrePostProcess';
load_system(modelName4);
w = freq * 2 * pi;
SimTime4 = (length(FREresponse) + 1) * Ts_fre;
sim(modelName4);
close_system(modelName4);

To convert the logged sinestream data into an identified frequency response, call frestimate. It returns an FRD model containing one complex sample per injection frequency, ready for Bode analysis or controller tuning.

sys_estim_sinestream = frestimate(SigGenDataLog,w,"rad/s");
size(sys_estim_sinestream)

The returned FRD has one input, one output, and one frequency point per entry in freq. If the frequency-point count does not match length(freq), some frequencies were excluded due to insufficient settling. Increase NumSetPeriod and rerun.

Plot the Bode Response

To review the estimated plant response in familiar units, plot the FRD on a Bode chart with the frequency axis in Hz. Displaying frequency in Hz rather than rad/s makes it easier to correlate the plot with the injection frequencies you selected earlier.

opts=bodeoptions;
opts.FreqUnits='Hz';
opts.Grid='On';
opts.MagVisible ='On';
opts.PhaseVisible ='On';

LLC_FREResponse = frd(sys_estim_sinestream, freq * 2 * pi);
rootFolder = currentProject().RootFolder;
save (rootFolder+'\Data\llcPlantfreHW.mat',"LLC_FREResponse");clear rootfolder;
figure('Name','FRE plot')
bodeplot(LLC_FREResponse,'b*-',opts);
title('LLC');

The markers on the Bode plot show the measured magnitude and phase at each injected frequency. A smooth, monotonic magnitude curve confirms the plant response is well captured; sharp discontinuities point to insufficient settling time or transient contamination.

See Also

Topics