主要内容

mcb.calcFOCGains

Compute gains and transfer functions for PI controller in field-oriented control of PMSM

Since R2025a

    Description

    [PI_Params,OLTF,CLTF] = mcb.calcFOCGains(motor,Ts,Ts_speed) computes the PI controller gains Kp and Ki, open-loop transfer function OLTF, and closed-loop transfer function CLTF for field-oriented control of a permanent magnet synchronous motor (PMSM) with parameters motor.

    [PI_Params,OLTF,CLTF] = mcb.calcFOCGains(motor,Ts,Ts_speed,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments in the previous syntax. For example, to specify PU system base values, set Base to PU_System where PU_System is a struct of base values.

    The function computes the PI controller gains based on Optimum theory. For more information, see Obtain Controller Gains to Run Motor Using Field-Oriented Control.

    example

    Examples

    collapse all

    Set the pulse-width modulation (PWM) switching frequency and sample times.

    PWM_frequency = 20e3;
    T_pwm         = 1/PWM_frequency;
    Ts            = T_pwm;
    Ts_speed      = 10*Ts;

    Get parameters for your motor and inverter. This example uses a BLY171D PMSM and DRV8312-C2-KIT inverter.

    pmsm = mcb.getPMSMParameters("BLY171D");
    inverter = mcb.getInverterParameters("DRV8312-C2-KIT");

    Get the per-unit base values for the PMSM and inverter.

    PU_System = mcb.getPUSystemParameters(pmsm,inverter);

    Get the PI controller parameters and transfer functions for the PMSM in per-unit system.

    [PI_params,OLTF,CLTF] = mcb.calcFOCGains(pmsm,Ts,Ts_speed,Base=PU_System)
    PI_params = 
    
      struct with fields:
    
            Ti_i: 0.0014
            Kp_i: 6.5531
            Ki_i: 4.6808e+03
           Ti_id: 0.0014
           Kp_id: 6.5531
           Ki_id: 4.6808e+03
        Ti_speed: 0.0023
        Kp_speed: 4.3403
        Ki_speed: 1.8871e+03
    
    
    OLTF = 
    
      struct with fields:
    
        DCurrLoop: [1×1 struct]
        QCurrLoop: [1×1 struct]
          SpdLoop: [1×1 struct]
    
    
    CLTF = 
    
      struct with fields:
    
        DCurrLoop: [1×1 struct]
        QCurrLoop: [1×1 struct]
          SpdLoop: [1×1 struct]

    Get the polynomial coefficients of a transfer function, for example, the d-axis current open-loop transfer function.

    OLTF.DCurrLoop
    ans = 
    
      struct with fields:
    
          Numerator: 2.1364
        Denominator: [7.0000e-08 0.0014 1]

    Set the PWM switching frequency and sample times.

    PWM_frequency = 20e3;
    T_pwm         = 1/PWM_frequency;
    Ts            = T_pwm;
    Ts_speed      = 10*Ts;

    Get parameters for your motor and inverter. This example uses a BLY171D PMSM and DRV8312-C2-KIT inverter.

    pmsm = mcb.getPMSMParameters("BLY171D");
    inverter = mcb.getInverterParameters("DRV8312-C2-KIT");

    Get the per-unit base values for the PMSM and inverter.

    PU_System = mcb.getPUSystemParameters(pmsm,inverter);

    Get the PI controller parameters and transfer functions for the PMSM in per-unit system. Specify the delay in the current loop forward path. For this example, specify two delay elements, one with a gain of 1 and time constant of 1e-4 seconds, and the other with a gain of 0.5 and time constant of 1e-5 seconds.

    delay.Gain = [1 0.5];
    delay.TimeConstant = [1e-4 1e-5];
    [PI_params,OLTF,CLTF] = mcb.calcFOCGains(pmsm,Ts,Ts_speed,...
      Base=PU_System,CLForwardPathDelay=delay)
    PI_params = 
    
      struct with fields:
    
            Ti_i: 0.0014
            Kp_i: 4.0957
            Ki_i: 2.9255e+03
           Ti_id: 0.0014
           Kp_id: 4.0957
           Ki_id: 2.9255e+03
        Ti_speed: 0.0032
        Kp_speed: 3.1392
        Ki_speed: 987.1666
    
    
    OLTF = 
    
      struct with fields:
    
        DCurrLoop: [1×1 struct]
        QCurrLoop: [1×1 struct]
          SpdLoop: [1×1 struct]
    
    
    CLTF = 
    
      struct with fields:
    
        DCurrLoop: [1×1 struct]
        QCurrLoop: [1×1 struct]
          SpdLoop: [1×1 struct]
    

    Get the polynomial coefficients of a transfer function, for example, the d-axis current open-loop transfer function.

    OLTF.DCurrLoop
    ans = 
    
      struct with fields:
    
          Numerator: 1.0682
        Denominator: [2.2400e-07 0.0016 1]

    Input Arguments

    collapse all

    PMSM parameters, specified as a struct.

    Specify lumped linear parameters with the following required fields:

    • Ldd-axis stator winding inductance (in henries), specified as a scalar

    • Lqq-axis stator winding inductance (in henries), specified as a scalar

    • FluxPM — Permanent magnet flux linkage (in webers), specified as a scalar

    • p — Number of pole pairs, specified as a scalar

    • Rs — Stator resistance (in ohms), specified as a scalar

    • B — Viscous damping coefficient (in kg-m2/ sec), specified as a scalar

    • I_rated — Rated current (in amperes), specified as a scalar

    You can create a structure with lumped linear parameters using mcb.getPMSMParameters.

    Alternatively, specify non-linear lookup table data with the following required fields:

    • PMSMLUT.idvecd-axis current breakpoints (in amperes) of lookup tables, specified as a vector

    • PMSMLUT.iqvecq-axis current breakpoints (in amperes) of lookup tables, specified as a vector

    • PMSMLUT.LdTabled-axis inductance (in henries) lookup table, specified as matrix

    • PMSMLUT.LqTableq-axis inductance (in henries) lookup table, specified as a matrix

    • PMSMLUT.FluxPMTable — Permanent magnet flux linkage (in weber) lookup table, specified as a matrix

    or the following required fields:

    • PMSMLUT.idvecd-axis current breakpoints (in amperes) of lookup tables, specified as a vector

    • PMSMLUT.iqvecq-axis current breakpoints (in amperes) of lookup tables, specified as a vector

    • PMSMLUT.FluxDTabled-axis flux linkage lookup table, specified as a matrix

    • PMSMLUT.FluxQTableq-axis flux linkage lookup table, specified as a matrix

    The structure can also contain the following optional fields:

    • model — Manufacturer's model number, specified as a character vector

    • sn — Manufacturer's serial number, specified as a character vector

    • J — Motor inertia coefficient (in kg-m2), specified as a scalar

    • Ke — Back EMF constant (in volts/krpm), specified as a scalar

    • Kt — Torque constant (in Nm/amperes), specified as a scalar

    • N_max — Maximum rotor speed (in rpm), specified as a scalar

    • PositionOffset — Rotor position offset (in PU), specified as a scalar

    • QEPSlits — Number of quadrature encoder pulse (QEP) slits, specified as a scalar

    • T_rated — Rated torque (in Nm), specified as a scalar

    Data Types: struct

    Control system sample time (in seconds), specified as a scalar.

    Data Types: double

    Speed controller sample time (in seconds), specified as a scalar.

    Data Types: double

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,SpdLPFltCoeff=0,.5)

    Base values of PU system for voltage, current, and motor speed, specified as a struct with the following fields:

    • V_base — Base voltage (in volts)

    • I_base — Base current (in amperes)

    • N_base — Base speed (in rpm)

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,Base=PU_System) specifies PU system base values from the PU_System structure.

    Filter coefficient of IIR filter in speed loop, specified as a value greater than 0 and less than or equal to 1.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,SpdLPFltCoeff=0.5) specifies a speed loop filter coefficient of 0.5.

    Data Types: double

    Delay in forward path of current loop, specified as a struct with fields Gain and Time (in sec). Specify these fields as arrays of scalars, one for each delay element.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,CLForwardPathDelay=delay) specifies the delay in the current loop forward path from the delay struct.

    Data Types: double

    Delay in the feedback path of the current loop, specified as a struct with fields Gain and Time (in sec). Specify these fields as arrays of scalars, one for each delay element.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,CLFeedbackPathDelay=delay) specifies the delay in the current loop feedback path from the delay struct.

    Data Types: double

    Delay in the forward path of the speed loop, specified as a struct with fields Gain and Time (in sec). Specify these fields as arrays of scalars, one for each delay element.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,SLForwardPathDelay=delay) specifies the delay in the speed loop forward path from the delay struct.

    Data Types: double

    Delay in the feedback path of the speed loop, specified as a struct with fields Gain and Time (in sec). Specify these fields as arrays of scalars, one for each delay element.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,SLFeedbackPathDelay=delay) specifies the delay in the speed loop feedback path from the delay struct.

    Data Types: double

    Factor multiplying proportional and integral gains of d-axis current controller, specified as a value greater than 0.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,DCurrLoopFactor=2) specifies a d-axis current controller gain multiplier of 2.

    Data Types: double

    Factor multiplying proportional and integral gains of q-axis current controller, specified as a value greater than 0.

    Example: mcb.calcFOCGains(pmsm,Ts,Ts_speed,QCurrLoopFactor=2) specifies a q-axis current controller gain multiplier of 2.

    Data Types: double

    Factor multiplying proportional and integral gains of speed controller, specified as a value greater than 0.

    Example: mcb.calcFOCGains(motor,Ts,Ts_speed,SpdLoopFactor=2) specifies a speed controller gain multiplier of 2.

    Data Types: double

    Output Arguments

    collapse all

    PI controller gains, returned as a struct with the following fields:

    • Ti_iq-axis current controller integral time constant, returned as a scalar

    • Kp_iq-axis current controller proportional gain, returned as a scalar

    • Ki_iq-axis current controller integral gain, returned as a scalar

    • Ti_idd-axis current controller integral time constant, returned as a scalar

    • Kp_idd-axis current controller proportional gain, returned as a scalar

    • Ki_idd-axis current controller integral gain, returned as a scalar

    • Ti_speed — Speed controller integral time constant, returned as a scalar

    • Kp_speed — Speed controller proportional gain, returned as a scalar

    • Ki_speed — Speed controller integral gain, returned as a scalar

    Open-loop transfer function, returned as a struct with the following fields:

    • DCurrLoopd-axis current open-loop transfer function, returned as a struct

    • QCurrLoopq-axis current open-loop transfer function, returned as a struct

    • SpdLoop — Speed loop transfer function, returned as a struct

    Each transfer function structure contains two fields Numerator and Denominator that list polynomial coefficients for the numerator and denominator of the transfer function, respectively.

    Closed-loop transfer function, returned as a struct with the following fields:

    • DCurrLoopd-axis current closed-loop transfer function, returned as a struct

    • QCurrLoopq-axis current closed-loop transfer function, returned as a struct

    • SpdLoop — Speed loop transfer function, returned as a struct

    Each transfer function structure contains two fields Numerator and Denominator that list polynomial coefficients for the numerator and denominator of the transfer function, respectively.

    Version History

    Introduced in R2025a