main content

automatically and sequentially tune multiple pid control loops in field-凯发k8网页登录

automatically and sequentially tune multiple pid control loops in field-oriented control application

since r2020a

libraries:
motor control blockset / controls / controllers

description

the field oriented control autotuner block allows you to automatically tune pid control loops in your field-oriented control (foc) application in real time. for more information on field-oriented control, see .

you can automatically tune pid controllers associated with the following loops:

  • direct-axis (d-axis) current loop

  • quadrature-axis (q-axis) current loop

  • speed loop

  • flux loop

for each loop the block tunes, the field oriented control autotuner block performs the autotuning experiment in closed-loop without a parametric model associated with that loop. the block allows you to specify the order in which the control loops are tuned. when the tuning experiment is running for one loop, the block has no effect on the other loops. during the experiment, the block:

  1. injects a test signal into the plant associated with that loop to collect plant input-output data and estimate frequency response in real time. the test signal is combination of sinusoidal perturbation signals added on top of the plant input.

  2. at the end of the experiment, tunes pid controller parameters based on estimated plant frequency responses near the target bandwidth.

  3. writes updated pid gains at the block output, allowing you to transfer the new gains to existing controllers and validate the closed-loop performance.

you can use the field oriented control autotuner block to tune the existing pid controllers in your foc structure. if you do not have the initial pid controllers, you can use the estimate control gains and use utility functions workflow to obtain them. you can then use the field oriented control autotuner block for refinement or retuning.

if you have a code-generation product such as simulink® coder™, you can generate code that implements the tuning algorithm on hardware, letting you tune in real time, using or without using simulink to manage the autotuning process.

if you have a machine modeled in simulink with motor control blockset™ and an initial foc structure with pid controllers, you can perform closed-loop pid autotuning against the modeled machine. doing so lets you preview the plant response and adjust the settings for pid autotuning before tuning the controller in real time.

the block supports code generation with simulink coder, embedded coder®, and simulink plc coder™. it does not support code generation with hdl coder™. for real-time applications, deploy the generated code on a rapid prototyping hardware such as speedgoat® real-time target machine.

for more information about using the field oriented control autotuner block, see .

this block requires simulink control design™ software.

ports

input

this port accepts the output of the d-axis controller pid_daxis, which is the output of pid controller that regulates the d-axis current of the motor. the controller generates the d-axis voltage reference vd_ref, while the foc autotuner block generates perturbations used during the tuning experiment for the d-axis current loop.

figure showing d-axis current loop connection with autotuner

dependencies

to enable this port, select tune d-axis current loop.

data types: single | double

this port accepts the d-axis current obtained from the measured (sensed or estimated) motor currents.

dependencies

to enable this port, select tune d-axis current loop.

data types: single | double

this port accepts the output of the q-axis controller pid_qaxis, which is the output of pid controller that regulates the q-axis current of the motor. the controller generates the q-axis voltage reference vq_ref, while the foc autotuner block generates perturbations used during the tuning experiment for the q-axis current loop.

figure showing q-axis current loop connection with autotuner

dependencies

to enable this port, select tune q-axis current loop.

data types: single | double

this port accepts the q-axis current obtained from the measured (sensed or estimated) motor currents.

dependencies

to enable this port, select tune q-axis current loop.

data types: single | double

this port accepts the output of the speed controller pid_speed, which is the output of pid controller that regulates the speed of the motor. the controller generates the q-axis current reference iq_ref, while the foc autotuner block generates perturbations used during the tuning experiment for the speed loop.

figure showing speed loop connection with autotuner

dependencies

to enable this port, select tune speed loop.

data types: single | double

this port accepts the measured (sensed or estimated) speed from the motor.

dependencies

to enable this port, select tune speed loop.

data types: single | double

this port accepts the output of the flux controller pid_flux, which is the output of pid controller that regulates the flux of the motor. the controller generates the d-axis current reference id_ref, while the foc autotuner block generates perturbations used during the tuning experiment for the flux loop.

figure showing flux loop connection with autotuner

for a permanent magnet synchronous motor (pmsm), there is no flux loop controller as the rotor flux is fixed and id_ref is set to zero. in some applications you can provide a negative id_ref value to implement field-weakening control and achieve higher rotor speeds at the cost of a higher current.

dependencies

to enable this port, select tune flux loop.

data types: single | double

this port accepts the measured (sensed or estimated) flux from the motor.

dependencies

to enable this port, select tune flux loop.

data types: single | double

to externally start and stop the autotuning process, provide a signal at the start/stop port and the activeloop port.

  • the experiment starts when the value of the signal changes from negative or zero to positive.

  • the experiment stops when the value of the signal changes from positive to negative or zero.

for the duration of the experiment, for each loop, the block injects sinusoidal perturbations at the plant input associated with the loop, near the nominal operating point, to collect input-output data and estimate frequency response. when the experiment stops, the block computes pid gains based on the plant frequency responses estimated near the target bandwidth.

when the experiment is not running, the block does not inject any perturbations at the plant inputs. in this state, the block has no impact on plant or controller behavior.

typically, you can use a signal that changes from 0 to 1 to start the experiment, and from 1 to 0 to stop it. consider the following when you configure the start/stop signal.

  • start the experiment when the motor is at the desired equilibrium operating point. use the initial controller to drive the motor to the operating point.

  • avoid any input or output disturbance on the motor during the experiment. if your existing closed-loop system has good disturbance rejection, then the experiment can handle small disturbances. otherwise, large disturbances can distort the plant output and reduce the accuracy of the frequency-response estimation.

  • let the experiment run long enough for the algorithm to collect sufficient data for a good estimate at all frequencies it probes. there are two ways to determine when to stop the experiment:

    • determine the experiment duration in advance. a conservative estimate for the experiment duration is 200/ωc in superposition experiment mode or 550/ωc in sinestream experiment mode, where ωc is your target bandwidth.

    • observe the signal at the convergence output, and stop the experiment when the signal stabilizes near 100%.

  • when you stop the experiment, the block computes tuned pid gains and updates the signal at the pid gains port.

you can configure any logic appropriate for your application to control the start and stop times of the experiment. the start/stop signal is specified along with activeloop. activeloop takes integer values 1 to 4 and specifies which loop to tune.

alternatively, if you are tuning in simulation or external mode, you can specify the tuning experiment sequence, start time and duration in the block parameters.

dependencies

to enable this port, on the block tab under parameters source, select use external source for start/stop of experiment.

data types: single | double

set the activeloop value to specify which loop to tune when providing an external source for the start and stop times of the tuning experiment.

activeloop valueloop to tune
1d-axis current loop
2q-axis current loop
3speed loop
4flux loop

you can configure any logic appropriate for your application along with the start/stop port to control the sequence and the time at which the loop tuning experiment runs. activeloop takes integer values from 1 to 4 and specifies which loop to tune. any other number will result in no tuning taking place regardless of the start/stop signal. for example, when you supply a constant value 2 at activeloop and the signal at start/stop rises, the block starts the tuning experiment for the q-axis current loop.

alternatively, you can specify the tuning experiment sequence, start time, and duration in the block parameters.

dependencies

to enable this port, on the block tab under parameters source, select use external source for start/stop of experiment.

data types: single | double

supply the values for the target bandwidth (rad/sec) parameter for each loop to be tuned. if you are tuning multiple loops, you can specify the bandwidth as a vector or bus, entries of which correspond to the target bandwidth for the loops in this order:

  • d-axis current loop

  • q-axis current loop

  • speed loop

  • flux loop

the vector signal must be specified as a n-by-1 or 1-by-n signal or if specified as a bus must have n elements, where n is the number of loops to be tuned. for instance, if you are tuning the q-axis current loop and the speed loop, and you specify a vector [5000, 200] at this port, the block tunes the q-axis current controller with the target bandwidth 5000 rad/sec and the speed loop controller with the target bandwidth 200 rad/sec.

if you are tuning multiple loops and specify a scalar value at this port, then the block uses the same target bandwidth to tune all the controllers. for effective cascade control, the inner control loops (d-axis and q-axis) must respond much faster than the outer control loops (flux and speed). therefore, you must supply the target bandwidth as a vector or bus signal when tuning multiple loops.

alternatively, you can specify target bandwidth for individual loops in block parameters. for more information on how to choose a bandwidth, see that parameter description.

dependencies

to enable this port, on the block tab under parameters source, select use external source for bandwidth.

data types: single | double

supply a value for the target phase margin (degrees) parameter for each loop to be tuned. if you are tuning multiple loops, you can specify target pm as a vector or bus, entries of which correspond to the target phase margin for the loops in this order:

  • d-axis current loop

  • q-axis current loop

  • speed loop

  • flux loop

the vector signal must be specified as a n-by-1 or 1-by-n signal or if specified as a bus must have n elements, where n is the number of loops to be tuned. for instance, if you are tuning q-axis current loop and speed loop, and you specify a vector [60, 45] at this port, the block tunes q-axis current controller with target phase margin 60 degrees and speed loop controller with target phase margin 45 degrees.

if you are tuning multiple loops and specify a scalar value at this port, then the block uses the same target phase margin to tune all the controllers.

alternatively, you can specify target phase margin for individual loops in block parameters. for more information on how to choose a target phase margin, see that parameter description.

dependencies

to enable this port, on the block tab under parameters source, select use external source for target phase margin.

data types: single | double

supply a value for the sine amplitudes parameter for each loop to be tuned. specify one of the following:

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning.

  • n-by-5 matrix, where n is the number of loops to be tuned. each row entry must be of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc .

if you are tuning multiple loops and specify a vector of length 5 at this port, then the block uses the specified amplitude for all the loops at each of [1/10, 1/3, 1, 3, 10]ωc corresponding to that loop.

alternatively, you can specify the sinusoidal perturbation amplitude for individual loops in block parameters. for more information, see the parameter description.

dependencies

to enable this port, on the block tab under parameters source, select use external source for sine amplitudes.

data types: single | double

output

perturbation signal input used for estimating the frequency-response data model associated with the d-axis current control loop. inject the perturbation signal from this port by using a sum block to the output of the pid controller that regulates the d-axis current.

  • when the experiment is running, the block generates perturbation signals at this port.

  • when the experiment is not running, the signal at this port is zero. in this state, the block has no effect on the plant.

dependencies

to enable this port, select tune d-axis current loop.

data types: single | double

perturbation signal input used for estimating the frequency-response data model associated with the q-axis current control loop. inject this perturbation signal from this port by using a sum block to the output of the pid controller that regulates the q-axis current.

  • when the experiment is running, the block generates perturbation signals at this port.

  • when the experiment is not running, the signal at this port is zero. in this state, the block has no effect on the plant.

dependencies

to enable this port, select tune q-axis current loop.

data types: single | double

perturbation signal input used for estimating the frequency-response data model associated with the motor speed control loop. inject this perturbation signal from this port by using a sum block with the output of the pid controller that regulates the speed of the motor.

  • when the experiment is running, the block generates perturbation signals at this port.

  • when the experiment is not running, the signal at this port is zero. in this state, the block has no effect on the plant.

dependencies

to enable this port, select tune speed loop.

data types: single | double

perturbation signal input used for estimating the frequency-response data model associated with the motor flux control loop. inject this perturbation signal from this port by using a sum block to the output of the pid controller that regulates the flux linkage of the motor.

  • when the experiment is running, the block generates perturbation signals at this port.

  • when the experiment is not running, the signal at this port is zero. in this state, the block has no effect on the plant.

dependencies

to enable this port, select tune flux loop.

data types: single | double

this 4-element bus signal contains the tuned pid gains p, i, d, and the filter coefficient n for each control loop the block tunes. these values correspond to the p, i, d, and n parameters in the expressions given in the form parameter. initially, the values are 0, 0, 0, and 100, respectively. the block updates the values when the experiment ends. the bus signal corresponding to each loop the block tunes always has four elements, even if you are not tuning a pidf controller.

data types: single | double

the block uses perturbation signals to estimate the frequency response of the plant associated with each loop at several frequencies around the target bandwidth for tuning. convergence indicates how close to completion the estimation of the plant frequency response is. typically, this value quickly rises to about 90% after the experiment begins, and then gradually converges to a higher value. stop the experiment when it levels off near 100%.

data types: single | double

this port outputs the estimated phase margin achieved by the tuned controller for the most recently tuned loop, in degrees. the block updates this value when the tuning experiment ends for each loop. the estimated phase margin is calculated from the angle of g(c)c(c), where g is the estimated plant for that loop, c is the tuned controller, and ωc is the crossover frequency (bandwidth). the estimated phase margin might differ from the target phase margin specified by the target phase margin (degrees) parameter. it is an indicator of the robustness and stability achieved by the tuned system.

  • typically, the estimated phase margin is near the target phase margin. in general, the larger the value, the more robust is the tuned system, and the less overshoot there is.

  • a negative phase margin indicates that the closed-loop system might be unstable.

dependencies

to enable this port, on the block tab, select estimated phase margin achieved by tuned controllers.

data types: single | double

this port outputs the frequency-response data estimated by the experiment for most recently tuned loop. initially, the value at frd is [0, 0, 0, 0, 0]. during the experiment, the block injects signals at frequencies [1/10, 1/3, 1, 3, 10]ωc, where ωc is the target bandwidth. at each sample time during the experiment, the block updates frd with a vector containing the complex frequency response at each of these frequencies. you can use the progress of the response as an alternative to convergence to examine the convergence of the estimation. when the experiment stops, the block updates frd with the final estimated frequency response used for computing the pid gains.

dependencies

to enable this port, on the block tab, select plant frequency responses near bandwidth.

data types: single | double

this port outputs a vector containing the plant input and plant output for the most recently tuned loop or the loop currently being tuned. these values are the plant input and output at the nominal operating point at which the block performs the experiment.

dependencies

to enable this port, on the block tab, select plant nominal input and output.

data types: single | double

this 4-element bus signal indicates whether the tuning experiment for each loop tuned by the block is active or not. for each signal in the bus, the port outputs the logical value 1 (true) for the loop when the tuning experiment is running. the value is logical 0 (false) when the experiment is over or has not yet started. you can use this port to trigger updates of pid gains for individual loops.

dependencies

to enable this port, on the block tab, disable use external source for start/stop of experiment and select start/stop of autotuning process.

data types: single | double

parameters

use this parameter to enable or disable d-axis current loop autotuning.

programmatic use

block parameter: tunedaxisloop
type: character vector
values: 'on' | 'off'
default: 'on'

use this parameter to enable or disable q-axis current loop autotuning.

programmatic use

block parameter: tuneqaxisloop
type: character vector
values: 'on' | 'off'
default: 'on'

use this parameter to enable or disable speed loop autotuning.

programmatic use

block parameter: tunespeedloop
type: character vector
values: 'on' | 'off'
default: 'on'

use this parameter to enable or disable flux loop autotuning.

programmatic use

block parameter: tunespeedloop
type: character vector
values: 'on' | 'off'
default: 'on'

select this parameter to enable the same tuning and experiment settings for d-axis and q-axis current loops. when enabled, the block uses the same controller settings, target bandwidth, phase margin, and other experiment settings to tune d-axis and q-axis current loops.

programmatic use

block parameter: usesamesettingsinner
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable the same tuning and experiment settings for speed and flux loops. when enabled, the block uses the same controller settings, target bandwidth, phase margin, and other experiment settings to tune speed and flux loops.

programmatic use

block parameter: usesamesettingsouter
type: character vector
values: 'off' | 'on'
default: 'off'

specify the sample time of the frequency response estimation experiment performed by the block in seconds.

by default, the experiment sample time is set to inherited (–1) and the block performs the frequency response estimation experiment, for each loop, at the inherited sample time. use this parameter to specify a sample time for the frequency response estimation experiment that is different from the tuning and pid gain calculation sample rates. for each loop that you tune, the frequency responses are estimated at the sample time specified in this parameter.

when you specify different sample times for tuning, experiment, and loops, you can configure simulink to treat each block module rate as a separate task to enable multitasking execution for your model. this multitasking mode helps improve performance on hardware. for more information, see .

programmatic use

block parameter: tsexperiment
type: scalar
value positive scalar
default: –1 (inherited)

tuning tab

by default, the block runs tuning for each loop at the same sample time that you specify in the controller sample time (sec) parameter for that loop. enable this parameter to run tuning at a sample rate that is different from the sample rate of the pid controllers you are tuning and the frequency response estimation experiment performed by the block. the pid gain tuning algorithm is computationally intensive, and when you want to deploy the block to hardware and tune a controller with a fast sample time, some hardware might not complete the pid gain calculation in a single time step. to reduce the hardware throughput requirements, specify a tuning sample time slower than the controller sample time using the tuning sample time (sec) parameter.

programmatic use

block parameter: usetuningts
type: character vector
value 'off' | 'on'
default: 'off'

specify the sample time of the tuning algorithm in seconds.

if you intend to deploy the block on hardware with limited processing power and want to tune a controller with a fast sample time, specify a sample time such that the tuning algorithm runs at a slower rate than the pid controllers you are tuning. for each loop that you tune, after the frequency response estimation experiment ends, controller tuning occurs at the sample time specified in this parameter.

dependencies

to enable this parameter, select use different sample time for tuning.

programmatic use

block parameter: tstuning
type: scalar
value positive scalar
default: 0.2
d-axis current loop

specify the type of pid controller associated with the d-axis current control loop.

the controller type indicates what actions are present in the controller that regulates the loop. the following controller types are available for pid autotuning:

  • p — proportional only

  • i — integral only

  • pi — proportional and integral

  • pd — proportional and derivative

  • pdf — proportional and derivative with derivative filter

  • pid — proportional, integral, and derivative

  • pidf — proportional, integral, and derivative with derivative filter

make sure the controller type matches the controller that regulates the loop.

programmatic use

block parameter: pidtypedaxis
type: character vector
values: 'p' | 'i' | 'pi' | 'pd' | 'pdf' | 'pid' | 'pidf'
default: 'pi'

specify the pid controller form associated with your d-axis current control loop.

the controller form determines the interpretation of the pid coefficients p, i, d, and n.

  • parallel — in parallel form, the transfer function of a discrete-time pidf controller is

    c=p ifi(z) d[n1 nfd(z)],

    where fi(z) and fd(z) are the integrator and filter formulas (see integrator method and filter method).

    other controller actions amount to setting p, i, or d to zero.

  • ideal — in ideal form, the transfer function of a discrete-time pidf controller is

    c=p[1 ifi(z) d(n1 nfd(z))].

    other controller actions amount to setting d to zero or setting i to inf. (in ideal form, the controller must have proportional action.)

make sure the controller form matches the controller that regulates the loop.

tunable: yes

programmatic use

block parameter: pidformdaxis
type: character vector
values: 'parallel' | 'ideal'
default: 'parallel'

specify the sample time of your pid controller associated with the d-axis current control loop in seconds. this parameter sets the sample time used to calculate the pid controller gains for the loop.

to perform pid tuning, the block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts ωc is the controller sample time that you specify with the controller sample time (sec) parameter.

make sure the controller sample time matches the controller that regulates the loop.

tips

if you want to run the deployed block with different sample times in your application, set this parameter to –1 and put the block in a . then, trigger the subsystem at the desired sample time. if you do not plan to change the sample time after deployment, specify a fixed and finite sample time.

programmatic use

block parameter: tsdaxis
type: scalar
value positive scalar | –1
default: 0.001

specify the discrete integration formula for the integrator term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the integrator method parameter determines the formula fi as follows.

integrator methodfi
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller integrator method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes integral action.

programmatic use

block parameter: integratormethoddaxis
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

specify the discrete integration formula for the derivative filter term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the filter method parameter determines the formula fd as follows.

filter methodfd
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller derivative filter method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes derivative action with a derivative filter term.

programmatic use

block parameter: filtermethoddaxis
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

the target bandwidth is the target value for the 0 db gain crossover frequency of the tuned open-loop response cp, where p is the plant response associated with the loop, and c is the controller response. this crossover frequency roughly sets the control bandwidth. for a rise time τ seconds, a good guess for the target bandwidth is 2/τ rad/sec.

to perform pid tuning, the autotuner block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts is the controller sample time that you specify with the controller sample time (sec) parameter. because of this condition, the fastest rise time you can enforce for tuning is about 6.67ts. if this rise time does not meet your design goals, consider reducing ts.

for best results, use a target bandwidth that is within about a factor of 10 of the bandwidth with the initial pid controller. to tune a controller for a larger change in bandwidth, tune incrementally using smaller changes.

to provide the target bandwidth by using an input port, on the block tab, select use external source for bandwidth.

programmatic use

block parameter: bandwidthdaxis
type: positive scalar
default: 100

specify a target minimum phase margin for the tuned open-loop response associated with the d-axis current control loop at the crossover frequency.

the target phase margin reflects the desired robustness of the tuned system. typically, choose a value in the range of about 45°–60°. in general, a higher phase margin reduces overshoot, but can limit the response speed. the default value 60° tends to balance performance and robustness, yielding about 5–10% overshoot, depending on the characteristics of your plant.

to provide the target phase margin by using an input port, on the block tab, select use external source for target phase margins.

tunable: yes

programmatic use

block parameter: targetpmdaxis
type: scalar
values: 0–90
default: 60
q-axis current loop

specify the type of pid controller associated with the q-axis current control loop.

the controller type indicates what actions are present in the controller that regulates the loop. the following controller types are available for pid autotuning:

  • p — proportional only

  • i — integral only

  • pi — proportional and integral

  • pd — proportional and derivative

  • pdf — proportional and derivative with derivative filter

  • pid — proportional, integral, and derivative

  • pidf — proportional, integral, and derivative with derivative filter

make sure the controller type matches the controller that regulates the loop.

programmatic use

block parameter: pidtypeqaxis
type: character vector
values: 'p' | 'i' | 'pi' | 'pd' | 'pdf' | 'pid' | 'pidf'
default: 'pi'

specify the pid controller form associated with your q-axis current control loop.

the controller form determines the interpretation of the pid coefficients p, i, d, and n.

  • parallel — in parallel form, the transfer function of a discrete-time pidf controller is

    c=p ifi(z) d[n1 nfd(z)],

    where fi(z) and fd(z) are the integrator and filter formulas (see integrator method and filter method).

    other controller actions amount to setting p, i, or d to zero.

  • ideal — in ideal form, the transfer function of a discrete-time pidf controller is

    c=p[1 ifi(z) d(n1 nfd(z))].

    other controller actions amount to setting d to zero or setting i to inf. (in ideal form, the controller must have proportional action.)

make sure the controller form matches the controller that regulates the loop.

tunable: yes

programmatic use

block parameter: pidformqaxis
type: character vector
values: 'parallel' | 'ideal'
default: 'parallel'

specify the sample time of your pid controller associated with the q-axis current control loop in seconds. this parameter sets the sample time used to calculate the pid controller gains for the loop.

to perform pid tuning, the block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts ωc is the controller sample time that you specify with the controller sample time (sec) parameter.

make sure the controller sample time matches the controller that regulates the loop.

tips

if you want to run the deployed block with different sample times in your application, set this parameter to –1 and put the block in a . then, trigger the subsystem at the desired sample time. if you do not plan to change the sample time after deployment, specify a fixed and finite sample time.

programmatic use

block parameter: tsqaxis
type: scalar
value positive scalar | –1
default: 0.001

specify the discrete integration formula for the integrator term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the integrator method parameter determines the formula fi as follows.

integrator methodfi
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller integrator method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes integral action.

programmatic use

block parameter: integratormethodqaxis
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

specify the discrete integration formula for the derivative filter term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the filter method parameter determines the formula fd as follows.

filter methodfd
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller derivative filter method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes derivative action with a derivative filter term.

programmatic use

block parameter: filtermethodqaxis
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

the target bandwidth is the target value for the 0 db gain crossover frequency of the tuned open-loop response cp, where p is the plant response associated with the loop, and c is the controller response. this crossover frequency roughly sets the control bandwidth. for a rise time τ seconds, a good guess for the target bandwidth is 2/τ rad/sec.

to perform pid tuning, the autotuner block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts is the controller sample time that you specify with the controller sample time (sec) parameter. because of this condition, the fastest rise time you can enforce for tuning is about 6.67ts. if this rise time does not meet your design goals, consider reducing ts.

for best results, use a target bandwidth that is within about a factor of 10 of the bandwidth with the initial pid controller. to tune a controller for a larger change in bandwidth, tune incrementally using smaller changes.

to provide the target bandwidth by using an input port, on the block tab, select use external source for bandwidth.

programmatic use

block parameter: bandwidthqaxis
type: positive scalar
default: 100

specify a target minimum phase margin for the tuned open-loop response associated with the q-axis current control loop at the crossover frequency.

the target phase margin reflects the desired robustness of the tuned system. typically, choose a value in the range of about 45°–60°. in general, a higher phase margin reduces overshoot, but can limit the response speed. the default value 60° tends to balance performance and robustness, yielding about 5–10% overshoot, depending on the characteristics of your plant.

to provide the target phase margin by using an input port, on the block tab, select use external source for target phase margins.

tunable: yes

programmatic use

block parameter: targetpmqaxis
type: scalar
values: 0–90
default: 60
speed loop

specify the type of pid controller associated with the speed control loop.

the controller type indicates what actions are present in the controller that regulates the loop. the following controller types are available for pid autotuning:

  • p — proportional only

  • i — integral only

  • pi — proportional and integral

  • pd — proportional and derivative

  • pdf — proportional and derivative with derivative filter

  • pid — proportional, integral, and derivative

  • pidf — proportional, integral, and derivative with derivative filter

make sure the controller type matches the controller that regulates the loop.

programmatic use

block parameter: pidtypespeed
type: character vector
values: 'p' | 'i' | 'pi' | 'pd' | 'pdf' | 'pid' | 'pidf'
default: 'pi'

specify the pid controller form associated with your speed control loop.

the controller form determines the interpretation of the pid coefficients p, i, d, and n.

  • parallel — in parallel form, the transfer function of a discrete-time pidf controller is

    c=p ifi(z) d[n1 nfd(z)],

    where fi(z) and fd(z) are the integrator and filter formulas (see integrator method and filter method).

    other controller actions amount to setting p, i, or d to zero.

  • ideal — in ideal form, the transfer function of a discrete-time pidf controller is

    c=p[1 ifi(z) d(n1 nfd(z))].

    other controller actions amount to setting d to zero or setting i to inf. (in ideal form, the controller must have proportional action.)

make sure the controller form matches the controller that regulates the loop.

tunable: yes

programmatic use

block parameter: pidformspeed
type: character vector
values: 'parallel' | 'ideal'
default: 'parallel'

specify the sample time of your pid controller associated with the speed control loop in seconds. this parameter sets the sample time used to calculate the pid controller gains for the loop.

to perform pid tuning, the block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts ωc is the controller sample time that you specify with the controller sample time (sec) parameter.

make sure the controller sample time matches the controller that regulates the loop.

tips

if you want to run the deployed block with different sample times in your application, set this parameter to –1 and put the block in a . then, trigger the subsystem at the desired sample time. if you do not plan to change the sample time after deployment, specify a fixed and finite sample time.

programmatic use

block parameter: tsspeed
type: scalar
value positive scalar | –1
default: 0.1

specify the discrete integration formula for the integrator term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the integrator method parameter determines the formula fi as follows.

integrator methodfi
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller integrator method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes integral action.

programmatic use

block parameter: integratormethodspeed
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

specify the discrete integration formula for the derivative filter term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the filter method parameter determines the formula fd as follows.

filter methodfd
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller derivative filter method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes derivative action with a derivative filter term.

programmatic use

block parameter: filtermethodspeed
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

the target bandwidth is the target value for the 0 db gain crossover frequency of the tuned open-loop response cp, where p is the plant response associated with the loop, and c is the controller response. this crossover frequency roughly sets the control bandwidth. for a rise time τ seconds, a good guess for the target bandwidth is 2/τ rad/sec.

to perform pid tuning, the autotuner block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts is the controller sample time that you specify with the controller sample time (sec) parameter. because of this condition, the fastest rise time you can enforce for tuning is about 6.67ts. if this rise time does not meet your design goals, consider reducing ts.

for best results, use a target bandwidth that is within about a factor of 10 of the bandwidth with the initial pid controller. to tune a controller for a larger change in bandwidth, tune incrementally using smaller changes.

to provide the target bandwidth by using an input port, on the block tab, select use external source for bandwidth.

programmatic use

block parameter: bandwidthspeed
type: positive scalar
default: 1

specify a target minimum phase margin for the tuned open-loop response associated with the speed control loop at the crossover frequency.

the target phase margin reflects the desired robustness of the tuned system. typically, choose a value in the range of about 45°–60°. in general, a higher phase margin reduces overshoot, but can limit the response speed. the default value 60° tends to balance performance and robustness, yielding about 5–10% overshoot, depending on the characteristics of your plant.

to provide the target phase margin by using an input port, on the block tab, select use external source for target phase margins.

tunable: yes

programmatic use

block parameter: targetpmspeed
type: scalar
values: 0–90
default: 60
flux loop

specify the type of pid controller associated with the flux control loop.

the controller type indicates what actions are present in the controller that regulates the loop. the following controller types are available for pid autotuning:

  • p — proportional only

  • i — integral only

  • pi — proportional and integral

  • pd — proportional and derivative

  • pdf — proportional and derivative with derivative filter

  • pid — proportional, integral, and derivative

  • pidf — proportional, integral, and derivative with derivative filter

make sure the controller type matches the controller that regulates the loop.

programmatic use

block parameter: pidtypeflux
type: character vector
values: 'p' | 'i' | 'pi' | 'pd' | 'pdf' | 'pid' | 'pidf'
default: 'pi'

specify the pid controller form associated with your flux control loop.

the controller form determines the interpretation of the pid coefficients p, i, d, and n.

  • parallel — in parallel form, the transfer function of a discrete-time pidf controller is

    c=p ifi(z) d[n1 nfd(z)],

    where fi(z) and fd(z) are the integrator and filter formulas (see integrator method and filter method).

    other controller actions amount to setting p, i, or d to zero.

  • ideal — in ideal form, the transfer function of a discrete-time pidf controller is

    c=p[1 ifi(z) d(n1 nfd(z))].

    other controller actions amount to setting d to zero or setting i to inf. (in ideal form, the controller must have proportional action.)

make sure the controller form matches the controller that regulates the loop.

tunable: yes

programmatic use

block parameter: pidformflux
type: character vector
values: 'parallel' | 'ideal'
default: 'parallel'

specify the sample time of your pid controller associated with the flux control loop in seconds. this parameter sets the sample time used to calculate the pid controller gains for the loop.

to perform pid tuning, the block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts ωc is the controller sample time that you specify with the controller sample time (sec) parameter.

make sure the controller sample time matches the controller that regulates the loop.

tips

if you want to run the deployed block with different sample times in your application, set this parameter to –1 and put the block in a . then, trigger the subsystem at the desired sample time. if you do not plan to change the sample time after deployment, specify a fixed and finite sample time.

programmatic use

block parameter: tsflux
type: scalar
value positive scalar | –1
default: 0.1

specify the discrete integration formula for the integrator term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the integrator method parameter determines the formula fi as follows.

integrator methodfi
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller integrator method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes integral action.

programmatic use

block parameter: integratormethodflux
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

specify the discrete integration formula for the derivative filter term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the filter method parameter determines the formula fd as follows.

filter methodfd
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller derivative filter method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes derivative action with a derivative filter term.

programmatic use

block parameter: filtermethodflux
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

the target bandwidth is the target value for the 0 db gain crossover frequency of the tuned open-loop response cp, where p is the plant response associated with the loop, and c is the controller response. this crossover frequency roughly sets the control bandwidth. for a rise time τ seconds, a good guess for the target bandwidth is 2/τ rad/sec.

to perform pid tuning, the autotuner block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts is the controller sample time that you specify with the controller sample time (sec) parameter. because of this condition, the fastest rise time you can enforce for tuning is about 6.67ts. if this rise time does not meet your design goals, consider reducing ts.

for best results, use a target bandwidth that is within about a factor of 10 of the bandwidth with the initial pid controller. to tune a controller for a larger change in bandwidth, tune incrementally using smaller changes.

to provide the target bandwidth by using an input port, on the block tab, select use external source for bandwidth.

programmatic use

block parameter: bandwidthflux
type: positive scalar
default: 1

specify a target minimum phase margin for the tuned open-loop response associated with the flux control loop at the crossover frequency.

the target phase margin reflects the desired robustness of the tuned system. typically, choose a value in the range of about 45°–60°. in general, a higher phase margin reduces overshoot, but can limit the response speed. the default value 60° tends to balance performance and robustness, yielding about 5–10% overshoot, depending on the characteristics of your plant.

to provide the target phase margin by using an input port, on the block tab, select use external source for target phase margins.

tunable: yes

programmatic use

block parameter: targetpmflux
type: scalar
values: 0–90
default: 60
current loops (q-axis d-axis)

specify the type of pid controller associated with the current control loops.

the controller type indicates what actions are present in the controller that regulates the loop. the following controller types are available for pid autotuning:

  • p — proportional only

  • i — integral only

  • pi — proportional and integral

  • pd — proportional and derivative

  • pdf — proportional and derivative with derivative filter

  • pid — proportional, integral, and derivative

  • pidf — proportional, integral, and derivative with derivative filter

make sure the controller type matches the controller that regulates the loop.

programmatic use

block parameter: pidtypeallinner
type: character vector
values: 'p' | 'i' | 'pi' | 'pd' | 'pdf' | 'pid' | 'pidf'
default: 'pi'

specify the pid controller form associated with your current control loops.

the controller form determines the interpretation of the pid coefficients p, i, d, and n.

  • parallel — in parallel form, the transfer function of a discrete-time pidf controller is

    c=p ifi(z) d[n1 nfd(z)],

    where fi(z) and fd(z) are the integrator and filter formulas (see integrator method and filter method).

    other controller actions amount to setting p, i, or d to zero.

  • ideal — in ideal form, the transfer function of a discrete-time pidf controller is

    c=p[1 ifi(z) d(n1 nfd(z))].

    other controller actions amount to setting d to zero or setting i to inf. (in ideal form, the controller must have proportional action.)

make sure the controller form matches the controller that regulates the loop.

tunable: yes

programmatic use

block parameter: pidformallinner
type: character vector
values: 'parallel' | 'ideal'
default: 'parallel'

specify the sample time of your pid controllers associated with the current control loops in seconds. this parameter sets the sample time used to calculate the pid controller gains for the loop.

to perform pid tuning, the block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts ωc is the controller sample time that you specify with the controller sample time (sec) parameter.

make sure the controller sample time matches the controller that regulates the loop.

tips

if you want to run the deployed block with different sample times in your application, set this parameter to –1 and put the block in a . then, trigger the subsystem at the desired sample time. if you do not plan to change the sample time after deployment, specify a fixed and finite sample time.

programmatic use

block parameter: tsallinner
type: scalar
value positive scalar | –1
default: 0.001

specify the discrete integration formula for the integrator term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the integrator method parameter determines the formula fi as follows.

integrator methodfi
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller integrator method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes integral action.

programmatic use

block parameter: integratormethodallinner
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

specify the discrete integration formula for the derivative filter term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the filter method parameter determines the formula fd as follows.

filter methodfd
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller derivative filter method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes derivative action with a derivative filter term.

programmatic use

block parameter: filtermethodallinner
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

the target bandwidth is the target value for the 0 db gain crossover frequency of the tuned open-loop response cp, where p is the plant response associated with the loop, and c is the controller response. this crossover frequency roughly sets the control bandwidth. for a rise time τ seconds, a good guess for the target bandwidth is 2/τ rad/sec.

to perform pid tuning, the autotuner block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts is the controller sample time that you specify with the controller sample time (sec) parameter. because of this condition, the fastest rise time you can enforce for tuning is about 6.67ts. if this rise time does not meet your design goals, consider reducing ts.

for best results, use a target bandwidth that is within about a factor of 10 of the bandwidth with the initial pid controller. to tune a controller for a larger change in bandwidth, tune incrementally using smaller changes.

to provide the target bandwidth by using an input port, on the block tab, select use external source for bandwidth.

programmatic use

block parameter: bandwidthallinner
type: positive scalar
default: 1

specify target minimum phase margin for the tuned open-loop responses associated with the current control loops at the crossover frequency.

the target phase margin reflects the desired robustness of the tuned system. typically, choose a value in the range of about 45°–60°. in general, a higher phase margin reduces overshoot, but can limit the response speed. the default value 60° tends to balance performance and robustness, yielding about 5–10% overshoot, depending on the characteristics of your plant.

to provide the target phase margin by using an input port, on the block tab, select use external source for target phase margins.

tunable: yes

programmatic use

block parameter: targetpmallinner
type: scalar
values: 0–90
default: 60
outer loops (speed flux)

specify the type of pid controllers associated with the outer control loops.

the controller type indicates what actions are present in the controller that regulates the loop. the following controller types are available for pid autotuning:

  • p — proportional only

  • i — integral only

  • pi — proportional and integral

  • pd — proportional and derivative

  • pdf — proportional and derivative with derivative filter

  • pid — proportional, integral, and derivative

  • pidf — proportional, integral, and derivative with derivative filter

make sure the controller type matches the controller that regulates the loop.

programmatic use

block parameter: pidtypeallouter
type: character vector
values: 'p' | 'i' | 'pi' | 'pd' | 'pdf' | 'pid' | 'pidf'
default: 'pi'

specify the pid controller form associated with your outer control loops.

the controller form determines the interpretation of the pid coefficients p, i, d, and n.

  • parallel — in parallel form, the transfer function of a discrete-time pidf controller is

    c=p ifi(z) d[n1 nfd(z)],

    where fi(z) and fd(z) are the integrator and filter formulas (see integrator method and filter method).

    other controller actions amount to setting p, i, or d to zero.

  • ideal — in ideal form, the transfer function of a discrete-time pidf controller is

    c=p[1 ifi(z) d(n1 nfd(z))].

    other controller actions amount to setting d to zero or setting i to inf. (in ideal form, the controller must have proportional action.)

make sure the controller form matches the controller that regulates the loop.

tunable: yes

programmatic use

block parameter: pidformallouter
type: character vector
values: 'parallel' | 'ideal'
default: 'parallel'

specify the sample time of your pid controllers associated with the outer control loop in seconds. this parameter sets the sample time used to calculate the pid controller gains for the loop.

to perform pid tuning, the block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts ωc is the controller sample time that you specify with the controller sample time (sec) parameter.

make sure the controller sample time matches the controller that regulates the loop.

tips

if you want to run the deployed block with different sample times in your application, set this parameter to –1 and put the block in a . then, trigger the subsystem at the desired sample time. if you do not plan to change the sample time after deployment, specify a fixed and finite sample time.

programmatic use

block parameter: tsallouter
type: scalar
value positive scalar | –1
default: 0.1

specify the discrete integration formula for the integrator term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the integrator method parameter determines the formula fi as follows.

integrator methodfi
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller integrator method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes integral action.

programmatic use

block parameter: integratormethodallouter
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

specify the discrete integration formula for the derivative filter term in your controller. in discrete time, the pid controller transfer function assumed by the block is

c=p ifi(z) d[n1 nfd(z)],

in parallel form, or in ideal form,

c=p[1 ifi(z) d(n1 nfd(z))].

for a controller sample time ts, the filter method parameter determines the formula fd as follows.

filter methodfd
forward euler

tsz1

backward euler

tszz1

trapezoidal

ts2z 1z1

for more information about the relative advantages of each method, see the block reference page.

make sure the controller derivative filter method matches the controller that regulates the loop.

tunable: yes

dependencies

this parameter is enabled when the controller includes derivative action with a derivative filter term.

programmatic use

block parameter: filtermethodallouter
type: character vector
values: 'forward euler' | 'backward euler' | 'trapezoidal'
default: 'forward euler'

the target bandwidth is the target value for the 0 db gain crossover frequency of the tuned open-loop response cp, where p is the plant response associated with the loop, and c is the controller response. this crossover frequency roughly sets the control bandwidth. for a rise time τ seconds, a good guess for the target bandwidth is 2/τ rad/sec.

to perform pid tuning, the autotuner block measures frequency-response information up to a frequency of 10 times the target bandwidth. to ensure that this frequency is less than the nyquist frequency, the target bandwidth ωc must satisfy ωcts ≤ 0.3, where ts is the controller sample time that you specify with the controller sample time (sec) parameter. because of this condition, the fastest rise time you can enforce for tuning is about 6.67ts. if this rise time does not meet your design goals, consider reducing ts.

for best results, use a target bandwidth that is within about a factor of 10 of the bandwidth with the initial pid controller. to tune a controller for a larger change in bandwidth, tune incrementally using smaller changes.

to provide the target bandwidth by using an input port, on the block tab, select use external source for bandwidth.

programmatic use

block parameter: bandwidthallouter
type: positive scalar
default: 1

specify a target minimum phase margin for the tuned open-loop responses associated with the outer control loops at the crossover frequency.

the target phase margin reflects the desired robustness of the tuned system. typically, choose a value in the range of about 45°–60°. in general, a higher phase margin reduces overshoot, but can limit the response speed. the default value 60° tends to balance performance and robustness, yielding about 5–10% overshoot, depending on the characteristics of your plant.

to provide the target phase margin by using an input port, on the block tab, select use external source for target phase margins.

tunable: yes

programmatic use

block parameter: targetpmallouter
type: scalar
values: 0–90
default: 60

experiment tab

experiment start/stop

specify the simulation time when the d-axis current loop tuning experiment starts.

programmatic use

block parameter: starttimedaxis
type: positive scalar
default: 1

specify the d-axis current loop tuning experiment duration.

programmatic use

block parameter: durationdaxis
type: positive scalar
default: 0.05

specify the simulation time when the q-axis current loop tuning experiment starts.

programmatic use

block parameter: starttimeqaxis
type: positive scalar
default: 1.1

specify the q-axis current loop tuning experiment duration.

programmatic use

block parameter: durationqaxis
type: positive scalar
default: 0.05

specify the simulation time when the speed loop tuning experiment starts.

programmatic use

block parameter: starttimespeed
type: positive scalar
default: 2

specify the speed loop tuning experiment duration.

programmatic use

block parameter: durationspeed
type: positive scalar
default: 3

specify the simulation time when the flux tuning experiment starts.

programmatic use

block parameter: starttimeflux
type: positive scalar
default: 6

specify the flux loop tuning experiment duration.

programmatic use

block parameter: durationflux
type: positive scalar
default: 3
loop experiment settings

specify whether the perturbation at each frequency is applied sequentially (sinestream) or simultaneously (superposition).

  • sinestream — in this mode, the block applies perturbation at each frequency separately. for more information about sinestream signals for estimation, see (simulink control design).

  • superposition — in this mode, the perturbation signal includes all specified frequencies at once. for frequency response estimation at a vector of frequencies ω = [ω1, … , ωn] at amplitudes a = [a1, … , an], the perturbation signal is:

    δu=iaisin(ωit).

sinestream mode can be more accurate and can also be less intrusive, because the total size of the perturbation is never bigger than the values specified by the sine amplitudes parameter. however, due to the sequential nature of the sinestream perturbation, each frequency point you add increases the recommended experiment time (see the start/stop input port for details). thus, the estimation experiment is typically much faster in superposition mode with satisfactory results.

sinestream signals reduce the execution time compared to superposition input signals, but also take longer to estimate the frequency response. frequency response estimation using sinestream signals is useful when you have limited processing power and you want to reduce the execution time.

programmatic use

block parameter: experimentmode
type: character vector
values: 'superposition' | 'sinestream'
default: 'superposition'
d-axis current loop

specify whether the plant associated with the d-axis current control loop is stable or integrating. if the plant has one or more integrators, select integrating.

programmatic use

block parameter: planttypedaxis
type: character vector
values: 'stable' | 'integrating'
default: 'stable'

specify whether the plant associated with the d-axis current control loop is positive or negative. if a positive change in the plant input at the nominal operating point results in a positive change in the plant output, specify positive. otherwise, specify negative. for stable plants, the sign of the plant is the sign of the plant dc gain.

programmatic use

block parameter: plantsigndaxis
type: character vector
values: 'positive' | 'negative'
default: 'positive'

during the experiment, the block injects a sinusoidal signal into the plant associated with the loop at the frequencies [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning. use sine amplitudes to specify the amplitude of each of these injected signals. specify a:

  • scalar value to inject the same amplitude at each frequency

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc

in a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. in such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. however, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower frequency inputs and increasing the amplitude of the higher frequency inputs. it is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

the perturbation amplitudes must be:

  • large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level

  • small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output

when experiment mode is superposition, the sinusoidal signals are superimposed. thus, the perturbation can be at least as large as the sum of all amplitudes. make sure that the largest possible perturbation is within the range of your plant actuator. saturating the actuator can introduce errors into the estimated frequency response.

to provide the sine amplitudes by using an input port, on the block tab, select use external source for sine amplitudes.

tunable: yes

programmatic use

block parameter: ampsinedaxis
type: scalar, vector of length 5
default: 1
q-axis current loop

specify whether the plant associated with the q-axis current control loop is stable or integrating. if the plant has one or more integrators, select integrating.

programmatic use

block parameter: planttypeqaxis
type: character vector
values: 'stable' | 'integrating'
default: 'stable'

specify whether the plant associated with the q-axis current control loop is positive or negative. if a positive change in the plant input at the nominal operating point results in a positive change in the plant output, specify positive. otherwise, specify negative. for stable plants, the sign of the plant is the sign of the plant dc gain.

programmatic use

block parameter: plantsignqaxis
type: character vector
values: 'positive' | 'negative'
default: 'positive'

during the experiment, the block injects a sinusoidal signal into the plant associated with the loop at the frequencies [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning. use sine amplitudes to specify the amplitude of each of these injected signals. specify a:

  • scalar value to inject the same amplitude at each frequency

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc

in a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. in such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. however, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower frequency inputs and increasing the amplitude of the higher frequency inputs. it is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

the perturbation amplitudes must be:

  • large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level

  • small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output

when experiment mode is superposition, the sinusoidal signals are superimposed. thus, the perturbation can be at least as large as the sum of all amplitudes. make sure that the largest possible perturbation is within the range of your plant actuator. saturating the actuator can introduce errors into the estimated frequency response.

to provide the sine amplitudes by using an input port, on the block tab, select use external source for sine amplitudes.

tunable: yes

programmatic use

block parameter: ampsineqaxis
type: scalar, vector of length 5
default: 1
speed loop

specify whether the plant associated with the speed control loop is stable or integrating. if the plant has one or more integrators, select integrating.

programmatic use

block parameter: planttypespeed
type: character vector
values: 'stable' | 'integrating'
default: 'stable'

specify whether the plant associated with the speed control loop is positive or negative. if a positive change in the plant input at the nominal operating point results in a positive change in the plant output, specify positive. otherwise, specify negative. for stable plants, the sign of the plant is the sign of the plant dc gain.

programmatic use

block parameter: plantsignspeed
type: character vector
values: 'positive' | 'negative'
default: 'positive'

during the experiment, the block injects a sinusoidal signal into the plant associated with the loop at the frequencies [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning. use sine amplitudes to specify the amplitude of each of these injected signals. specify a:

  • scalar value to inject the same amplitude at each frequency

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc

in a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. in such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. however, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower frequency inputs and increasing the amplitude of the higher frequency inputs. it is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

the perturbation amplitudes must be:

  • large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level

  • small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output

when experiment mode is superposition, the sinusoidal signals are superimposed. thus, the perturbation can be at least as large as the sum of all amplitudes. make sure that the largest possible perturbation is within the range of your plant actuator. saturating the actuator can introduce errors into the estimated frequency response.

to provide the sine amplitudes by using an input port, on the block tab, select use external source for sine amplitudes.

tunable: yes

programmatic use

block parameter: ampsinespeed
type: scalar, vector of length 5
default: 1
flux loop

specify whether the plant associated with the flux control loop is stable or integrating. if the plant has one or more integrators, select integrating.

programmatic use

block parameter: planttypeflux
type: character vector
values: 'stable' | 'integrating'
default: 'stable'

specify whether the plant associated with the flux control loop is positive or negative. if a positive change in the plant input at the nominal operating point results in a positive change in the plant output, specify positive. otherwise, specify negative. for stable plants, the sign of the plant is the sign of the plant dc gain.

programmatic use

block parameter: plantsignflux
type: character vector
values: 'positive' | 'negative'
default: 'positive'

during the experiment, the block injects a sinusoidal signal into the plant associated with the loop at the frequencies [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning. use sine amplitudes to specify the amplitude of each of these injected signals. specify a:

  • scalar value to inject the same amplitude at each frequency

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc

in a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. in such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. however, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower frequency inputs and increasing the amplitude of the higher frequency inputs. it is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

the perturbation amplitudes must be:

  • large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level

  • small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output

when experiment mode is superposition, the sinusoidal signals are superimposed. thus, the perturbation can be at least as large as the sum of all amplitudes. make sure that the largest possible perturbation is within the range of your plant actuator. saturating the actuator can introduce errors into the estimated frequency response.

to provide the sine amplitudes by using an input port, on the block tab, select use external source for sine amplitudes.

tunable: yes

programmatic use

block parameter: ampsineflux
type: scalar, vector of length 5
default: 1
current loops (d-axis q-axis)

specify whether the plants associated with the current control loops are stable or integrating. if the plant has one or more integrators, select integrating.

programmatic use

block parameter: planttypeallinner
type: character vector
values: 'stable' | 'integrating'
default: 'stable'

specify whether the plants associated with the current control loops are positive or negative. if a positive change in the plant input at the nominal operating point results in a positive change in the plant output, specify positive. otherwise, specify negative. for stable plants, the sign of the plant is the sign of the plant dc gain.

programmatic use

block parameter: plantsignallinner
type: character vector
values: 'positive' | 'negative'
default: 'positive'

during the experiment, the block injects a sinusoidal signal into the plant associated with the loop at the frequencies [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning. use sine amplitudes to specify the amplitude of each of these injected signals. specify a:

  • scalar value to inject the same amplitude at each frequency

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc

in a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. in such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. however, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower frequency inputs and increasing the amplitude of the higher frequency inputs. it is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

the perturbation amplitudes must be:

  • large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level

  • small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output

when experiment mode is superposition, the sinusoidal signals are superimposed. thus, the perturbation can be at least as large as the sum of all amplitudes. make sure that the largest possible perturbation is within the range of your plant actuator. saturating the actuator can introduce errors into the estimated frequency response.

to provide the sine amplitudes by using an input port, on the block tab, select use external source for sine amplitudes.

tunable: yes

programmatic use

block parameter: ampsineallinner
type: scalar, vector of length 5
default: 1
outer loops (speed flux)

specify whether the plants associated with the outer control loops are stable or integrating. if the plant has one or more integrators, select integrating.

programmatic use

block parameter: planttypeallouter
type: character vector
values: 'stable' | 'integrating'
default: 'stable'

specify whether the plants associated with the outer control loops are positive or negative. if a positive change in the plant input at the nominal operating point results in a positive change in the plant output, specify positive. otherwise, specify negative. for stable plants, the sign of the plant is the sign of the plant dc gain.

programmatic use

block parameter: plantsignallouter
type: character vector
values: 'positive' | 'negative'
default: 'positive'

during the experiment, the block injects a sinusoidal signal into the plant associated with the loop at the frequencies [1/10, 1/3, 1, 3, 10]ωc , where ωc is the target bandwidth for tuning. use sine amplitudes to specify the amplitude of each of these injected signals. specify a:

  • scalar value to inject the same amplitude at each frequency

  • vector of length 5 to specify a different amplitude at each of [1/10, 1/3, 1, 3, 10]ωc

in a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. in such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. however, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower frequency inputs and increasing the amplitude of the higher frequency inputs. it is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

the perturbation amplitudes must be:

  • large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level

  • small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output

when experiment mode is superposition, the sinusoidal signals are superimposed. thus, the perturbation can be at least as large as the sum of all amplitudes. make sure that the largest possible perturbation is within the range of your plant actuator. saturating the actuator can introduce errors into the estimated frequency response.

to provide the sine amplitudes by using an input port, on the block tab, select use external source for sine amplitudes.

tunable: yes

programmatic use

block parameter: ampsineallouter
type: scalar, vector of length 5
default: 1

block tab

select this parameter to enable the bandwidth input port of the block. you can specify the target bandwidth for all the loops the block tunes at this port. when this parameter is disabled, specify the target bandwidths at the block parameters. for more details, see the bandwidth port description.

programmatic use

block parameter: useexternalwc
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable the target pm input port of the block. you can specify the target phase margin for all the loops the block tunes at this port. when this parameter is disabled, specify the target phase margins at the block parameters. for more details, see the target pm port description.

programmatic use

block parameter: useexternalpm
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable the start/stop and activeloop input ports of the block. you can specify the start and stop of the experiment and which loop the block tunes at these ports. when this parameter is disabled, specify the start time and duration of the tuning experiment at the block parameters. for more details, see the start/stop and activeloop port descriptions.

programmatic use

block parameter: useexternalsourcestartstop
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable the sine amp input port of the block. you can specify sinusoidal perturbation amplitude for all the loops the block tunes at this port. when this parameter is disabled, supply the sine amplitudes at block parameters. for more details, see the sine amp port description.

programmatic use

block parameter: useexternalampsine
type: character vector
values: 'off' | 'on'
default: 'off'

specify the floating-point precision based on the simulation environment or hardware requirements.

programmatic use

block parameter: blockdatatype
type: character vector
values: 'double' | 'single'
default: 'double'

select this parameter to enable the estimated pm output port of the block. the block returns the phase margin achieved by the tuned controller of the most recently tuned loop. when this parameter is disabled, you can see the tuning results by using the export to matlab parameter. for more details, see the estimated pm port description.

programmatic use

block parameter: useexternalachievedpm
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable the frd output port of the block. the block returns the phase margin achieved by the tuned controller of the most recently tuned loop. when this parameter is disabled, you can see the tuning results by using the export to matlab parameter. for more details, see the frd port description.

programmatic use

block parameter: useexternalfrd
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable the nominal output port of the block. the block returns the plant input and output at the nominal operating point of the most recently tuned loop. when this parameter is disabled, you can see the tuning results by using the export to matlab parameter. for more details, see the port description.

programmatic use

block parameter: useexternalu0
type: character vector
values: 'off' | 'on'
default: 'off'

select this parameter to enable loop start/stops output port of the block. the block returns a signal indicating the times at which the autotuning experiment started and ended for each loop tuned by the block. when this parameter is disabled, you can see the tuning results by using the export to matlab parameter. for more details, see the loop start/stops port description.

programmatic use

block parameter: useexternalactiveloop
type: character vector
values: 'off' | 'on'
default: 'off'

when you click this button, the block creates a structure in the matlab® workspace containing the experiment and tuning results. this structure, foctuningresult, contains the tuning results for each loop the block tunes.

  • daxis — d-axis current loop tuning results

  • qaxis — q-axis current loop tuning results

  • speed — speed loop tuning results

  • flux — flux loop tuning results

for each loop tuned by the block, the result contains the following fields:

  • p, i, d, n — tuned pid gains. the structure contains whichever of these fields are necessary for the controller type you are tuning. for instance, if you are tuning a pi controller, the structure contains p and i, but not d and n.

  • targetbandwidth — the value you specified in the target bandwidth (rad/sec) parameter of the block.

  • targetphasemargin — the value you specified in the target phase margin (degrees) parameter of the block.

  • estimatedphasemargin — estimated phase margin achieved by the tuned system.

  • controller — the tuned pid controller, returned as a pid (for parallel form) or pidstd (for ideal form) model object.

  • plant — the estimated plant, returned as an frd model object. this frd contains the response data obtained at the experiment frequencies [1/10, 1/3, 1, 3, 10]ωc.

  • plantnominal — the plant input and output at the nominal operating point when the experiment begins, specified as a structure with the fields u (input) and y (output).

you can export to the matlab workspace while the simulation is running, including when running in external mode.

extended capabilities

plc code generation
generate structured text code using simulink® plc coder™.

version history

introduced in r2020a

see also

| | | |

topics

    网站地图