design pid controller using simulated i/o data -凯发k8网页登录
this example shows how to tune a pid controller for plants that cannot be linearized. you use pid tuner to identify a plant for your model. then tune the pid controller using the identified plant.
this example uses a buck converter model that requires simscape™ electrical™ software.
buck converter model
buck converters convert dc to dc. this model uses a switching power supply to convert a 30v dc supply into a regulated dc supply. the converter is modeled using mosfets rather than ideal switches to ensure that device on-resistances are correctly represented. the converter response from reference voltage to measured voltage includes the mosfet switches. pid design requires a linear model of the system from the reference voltage to the measured voltage. however, because of the switches, automated linearization results in a zero system. in this example, using pid tuner, you identify a linear model of the system using simulation instead of linearization.
for more information on creating a buck converter model, see (simscape electrical).
open_system('scdbuckconverter') sim('scdbuckconverter')
the model is configured with a reference voltage that switches from 15 to 25 volts at 0.004 seconds and a load current that is active from 0.0025 to 0.005 seconds. the controller is initialized with default gains and results in overshoot and slow settling time.
open_system('scdbuckconverter/scope 1') open_system('scdbuckconverter/scope 2')
simulate model to generate i/o data
to open the pid tuner, in the feedback controller subsystem, open the pid controller block dialog, and click tune. pid tuner indicates that the model cannot be linearized and returned a zero system.
pid tuner provides several alternatives when linearization fails. in the plant drop-down list, you can select one of the following methods:
import - import a linear model from the matlab workspace.
re-linearize closed loop - linearize the model at different simulation snapshot times.
identify new plant - identify a plant model using measured data.
for this example, click identify new plant to open the plant identification tool. for plant identification, you must specify a finite value for the simulink model stop time.
to open a tool that simulates the model to collect data for plant identification, on the plant identification tab, click get i/o data > simulate data.
on the simulate i/o data tab, you simulate the plant seen by the controller. the software temporarily:
removes the pid controller block from the model.
injects a signal where the output of the pid block used to be.
measures the resulting signal where the input to the pid block used to be.
this data describes the response of the plant seen by the controller. the pid tuner uses this response data to estimate a linear plant model.
configure the input signal as a step input with the following properties:
sample time () = 5e-6 - controller sample rate.
offset () = 0.51 - output offset value that puts the converter in a state where the output voltage is near 15v and gives the operating point around which to tune the controller.
onset time () = 0.003 - delay to allow sufficient time for the converter to reach the 15v steady state before applying the step change.
step amplitude () = 0.4 - step size of the controller output (plant input) to apply to the model. this value is added to the offset value so that the actual plant input steps from 0.51 to 0.91. the controller output (plant input) is limited to the range [0.01 0.95].
select show input response, show offset response, and show identification data. then, click the run simulation. the plant identification plot is updated.
the red curve is the offset response. the offset response is the plant response to a constant input of . the response shows that the model has some transients with a constant input, in particular:
the [0 0.001] second range where the converter reaches the 15v steady state. recall that this signal is the control error signal and hence drops to zero as steady state is reached.
the [0.0025 0.004] second range where the converter reacts to the current load being applied while the reference voltage is maintained at 15v.
the 0.004 second point where the reference voltage signal is changed from 15v to 25v resulting in a larger control error signal.
the [0.005 0.006] second range where the converter reacts to the current load being removed.
the blue curve shows the complete plant response that contains the contributions from the initial transients (significant for times < 0.001 seconds), the response to the cyclic current load (time durations 0.0025 to 0.005 seconds), reference voltage change (at 0.004 seconds), and response to the step test signal (applied at time 0.003 seconds). in contrast, the red curve is the response to only the initial transients, reference voltage step, and cyclic current load.
the green curve is the data that will be used for plant identification. this curve is the change in response due to the step test signal, which is the difference between the blue (input response) and red (offset response) curves taking into account the negative feedback sign.
to use the measured data to identify a plant model, click apply. then, to return to plant identification, click close.
plant identification
pid tuner identifies a plant model using the data generated by simulating the model. you tune the identified plant parameters so that the identified plant response, when provided the measured input, matches the measured output.
you can manually adjust the estimated model. click and drag the plant curve and pole location (x) to adjust the identified plant response so that it matches the identification data as closely as possible.
to tune the identified plant using automated identification, click auto estimate. the automated tuning response is not much better than the interactive tuning. the identified plant and identification data do not match well. change the plant structure to get a better match.
in the structure drop-down list, select underdamped pair.
click and drag the 2nd order envelope to match the identified data as closely as possible (almost critically damped).
click auto estimate to fine tune the plant model.
to designate the identified model as the current plant for controller tuning, click apply. pid tuner then automatically tunes a controller for the identified plant and updates the reference tracking step plot.
controller tuning
the pid tuner automatically tunes a pid controller for the identified plant. the tuned controller response has about 5% overshoot and a settling time of around 0.0006 seconds. click the reference tracking step plot to make it the current figure.
the controller output is the duty cycle for the pwm system and must be limited to [0.01 0.95]. to confirm that the controller output satisfies these bounds, create a controller effort plot. on the pid tuner tab, in the add plot drop-down list, under step, click controller effort. move the newly created controller effort plot to the second plot group.
in the controller effort plot, the tuned response (solid line) shows a large control effort required at the start of the simulation. to achieve a settling time of about 0.0004 seconds and overshoot of 9%, adjust the response time and transient behavior sliders. these adjustments reduce the maximum control effort to the acceptable range.
to update the simulink block with the tuned controller values, click update block.
to confirm the pid controller performance, simulate the simulink model.
bdclose('scdbuckconverter')
see also
related topics
- (simulink control design)
- (simulink control design)
- (simulink control design)
- (simulink control design)