tune gain-凯发k8网页登录
this example shows how to tune a gain-scheduled controller for a permanent magnet synchronous motor (pmsm) in just one simulation using the closed-loop pid autotuner block.
pmsm model
the pmsm model is based on the motor control blockset™ mcb_pmsm_foc_sim
model. the model includes:
a subsystem to model inverter and pmsm dynamics
inner-loop (current) and outer-loop (speed) pi controllers to implement a field-oriented control algorithm for motor speed control
you can examine this model for more details.
in this example, the original model is modified to use a gain-scheduled controller to control the rotational speed of the motor. the gains of the gain-scheduled controller are updated in real-time using dynamic lookup tables. the speed of the motor plant is originally controlled by a single pi controller in the mcb_pmsm_foc_sim
simulink® model.
the following sections describe how to modify the mcb_pmsm_foc_sim
model to tune and implement a gain-scheduled pi controller. alternatively, use the preconfigured scd_pid_gs_mcb_pmsm_foc_sim
model provided with this example.
speed control pi controller with gain scheduling and closed-loop pid autotuner
the speed control subsystem consists of a single pi controller with external inputs for the proportional and integral gains, integrator reset, and integrator initial condition. the pi controller is set up to use integral gain multiplied by sample time, i*ts, instead of the integral gain i.
the closed-loop pid autotuner block is located within the autotuning subsystem. the block outputs the perturbations used to estimate the plant required to tune the controller gains. the closed-loop pid autotuner block tunes gains for p and i but not for i*ts. to properly update the gains used in the pi controller, multiply the integral gain by the sample time, as shown in the section of this example.
the gain scheduling subsystem contains blocks for both the proportional and integral gains. for more details, see the section. the speed breakpoints constant block is a vector containing the three breakpoints used in the gain-scheduling lookup tables; this vector is set to [0.2 0.5 0.8] for this example. the data store memory blocks are used to update the gain-scheduled controller gains and pass them to the dynamic lookup tables and then to the controller.
closed-loop pid autotuner with gain updates
the autotuning subsystem contains the closed-loop pid autotuner block, subsystems to update and store the tuned gains, and a subsystem to determine which breakpoint to tune to properly update the scheduled gains.
closed-loop pid autotuner block configuration
the design requirements used in this example are in the form of closed-loop step response characteristics.
overshoot less than 5%
rise time less than 0.01 seconds
to tune the pi controller to meet the above design requirements, parameters of the closed-loop pid autotuner block are pre-populated. the tuning tab has three main tuning settings.
target bandwidth — determines how fast you want the controller to respond. the target bandwidth is roughly 2/desired rise time. for a desired rise time of 0.01 seconds, set the target bandwidth to 2/0.01 = 200 rad/s.
target phase margin — determines how robust you want the controller to be. in this example, start with a default value of 60 degrees.
experiment sample time — sample time for the experiment performed by the autotuner block. use a value of –1 to inherit the sample time of the speed controller.
the experiment tab has three main experiment settings.
plant type — specifies whether the plant is asymptotically stable or integrating. in this example, the inverter and motor plant is stable.
plant sign — specifies whether the plant has a positive or negative sign. the plant sign is positive if a positive change in the plant input at the nominal operating point results in a positive change in the plant output when the plant reaches a new steady state. in this example, the inverter and motor plant has a positive plant sign.
sine amplitudes — specifies amplitudes of the injected sine wave perturbations. in this example, specify a sine amplitude of 0.01 to ensure less than 15% perturbation amplitude from the setpoints.
these target bandwidth and phase margin are set to values comparable to the default set of gains in the original model. the closed-loop pid autotuner in this example is preconfigured with these settings.
the data store memory blocks used to update the gains are configured to update only a single element at a time to tune individual setpoints and update them in the gain-scheduled controller.
to determine if the current operating point coincides with a breakpoint in the gain-scheduled lookup tables, the current commanded speed reference, n_ref
, is compared to the vector of breakpoints used in the gain-scheduled lookup tables. if the current speed is equal to one of the breakpoints and autotuning takes place, then the gains at that breakpoint are updated.
update pi controller gain-scheduled gains during simulation
typically, the gain-scheduling workflow requires multiple simulations to run the system, tune the gains, update the gains, and then run the system again to demonstrate how to tune gain-scheduled controllers. this example performs all these steps in single a simulation using dynamic lookup tables.
for this example, before 2 seconds, a static set of gains is used. these gains were tuned at the middle breakpoint of the gain-scheduled lookup tables 0.5 n_ref
and are used to demonstrate a typical system response if not using gain scheduling. after 2 seconds the gain-scheduled controller gains are used and tuned at three different breakpoints: 0.2, 0.5, and 0.8 n_ref
. all breakpoints are tuned using the same settings in the closed-loop pid autotuner block.
add nonlinear load torque to inverter and motor plant model
to demonstrate how gain scheduling is used to increase performance in the presence of nonlinearities, the load torque profile contains a nonlinear load torque instead of a static load torque.
in this example, the nonlinear load is , where is the load torque, is the load torque constant equal to , and is the mechanical speed of the motor. from this equation you can see that the load torque and damping in this system increases by mechanical speed squared. this relationship means that at low speed there is little damping, thus requiring smaller controller gains compared to higher speeds wheremuch higher damping is required to achieve the same level of performance.
tune gain-scheduled controller at multiple operating points
with the model setup, you can now perform tuning at multiple operating points to create a gain-scheduled controller and test the performance of these gains against the gains tuned at 0.5 n_ref
in a single simulation. the model is setup to perform a step change at the beginning of the simulation, tune the controller at three operating points (0.2, 0.5, and 0.8 n_ref
) and then perform the same step change at the end. this figure shows the profile of the speed reference signal.
simulate the model to tune the gains at the three operating points, update the gains in the lookup tables, and test the performance of the tuned gains.
mdl = 'scd_pid_gs_mcb_pmsm_foc_sim';
simout = sim(mdl);
next, plot a comparison of the initial step response performed with gains tuned at 0.5 n_ref
to the response at the end of the simulation performed with gain scheduling.
idx = [0.5 0.75 9.5 9.75]./ts; time_nogs = simout.tout(idx(1):idx(2))-simout.tout(idx(1)); speedfdbk_nogs = simout.logsout{2}.values.data(idx(1):idx(2)); time_wgs = simout.tout(idx(3):idx(4))-simout.tout(idx(3)); speedfdbk_wgs = simout.logsout{2}.values.data(idx(3):idx(4)); figure; plot(time_nogs,speedfdbk_nogs,time_wgs,speedfdbk_wgs) legend('no gs', 'with gs') grid on title({'step response comparison of speed controller'; 'with and without gain scheduling'}) xlabel('time [sec]') ylabel('speed feedback [-]')
the gain-scheduled controller leads to larger overshoot for a smaller rise time and settling time, compared to a single set of gains tuned at one operating point.
tuned gain-scheduled controller performance over operating range
you can achieve similar performance for a given step change using a static set of gains obtained at 0.8 n_ref
instead of 0.5 n_ref
.
however, using this single set of gains to step from 0 to 0.5 n_ref
results in poor performance compared to using a gain-scheduled controller.
gain-scheduling allows for a more consistent and an overall better performance over the operating range compared to just using a static set of gains.
this workflow is useful when you want to tune a gain-scheduled controller using the closed-loop pid autotuner block.
close the model.
close_system(mdl,0);
see also
closed-loop pid autotuner | | |