gritulator.control#

This package contains example controllers.

Subpackages#

Classes#

ComplexFFPICtrl

2DOF Synchronous-frame complex-vector PI controller with feedforward.

ComplexPICtrl

2DOF synchronous-frame complex-vector PI controller.

RateLimiter

Rate limiter.

DCBusVoltCtrl

PI DC-bus voltage controller.

PICtrl

2DOF PI controller.

PWM

Duty ratios and realized voltage for three-phase PWM.

Package Contents#

class gritulator.control.ComplexFFPICtrl(k_p, k_i, k_t=None, L_f=None)[source]#

2DOF Synchronous-frame complex-vector PI controller with feedforward.

This implements a discrete-time 2DOF synchronous-frame complex-vector PI controller similar to [2], with an additional feedforward signal. The gain selection corresponding to internal-model-control (IMC) is equivalent to the continuous-time version given in [1]:

u = k_p*(i_ref - i) + k_i/s*(i_ref - i) + 1j*w*L_f*i + u_g_ff

where u is the controller output, i_ref is the reference signal, i is the feedback signal, u_g_ff is the (filtered) feedforward signal, w is the angular speed of synchronous coordinates, ‘1j*w*L_f’ is the decoupling term estimate, and 1/s refers to integration. This algorithm is compatible with both real and complex signals. The integrator anti-windup is implemented based on the realized controller output.

Parameters:
  • k_p (float) – Proportional gain.

  • k_i (float) – Integral gain.

  • k_t (float, optional) – Reference-feedforward gain. The default is k_p.

  • L_f (float, optional) – Synchronous frame decoupling gain. The default is 0.

v#

Input disturbance estimate.

Type:

complex

u_i#

Integral state.

Type:

complex

Notes

This contoller can be used, e.g., as a current controller. In this case, i corresponds to the converter current and u to the converter voltage.

References

output(i_ref, i, u_ff, w)[source]#

Compute the controller output.

Parameters:
  • i_ref (complex) – Reference signal.

  • i (complex) – Feedback signal.

  • u_ff (complex) – Feedforward signal.

  • w (float) – Angular speed of the reference frame (rad/s).

Returns:

u – Controller output.

Return type:

complex

update(T_s, u_lim)[source]#

Update the integral state.

Parameters:
  • T_s (float) – Sampling period (s).

  • u_lim (complex) – Realized (limited) controller output. If the actuator does not saturate, u_lim = u.

class gritulator.control.ComplexPICtrl(k_p, k_i, k_t=None)[source]#

2DOF synchronous-frame complex-vector PI controller.

This implements a discrete-time 2DOF synchronous-frame complex-vector PI controller, whose continuous-time counterpart is [2]:

u = k_t*i_ref - k_p*i + (k_i + 1j*w*k_t)/s*(i_ref - i)

where u is the controller output, i_ref is the reference signal, i is the feedback signal, w is the angular speed of synchronous coordinates, and 1/s refers to integration. This algorithm is compatible with both real and complex signals. The 1DOF version is obtained by setting k_t = k_p. The integrator anti-windup is implemented based on the realized controller output.

Parameters:
  • k_p (float) – Proportional gain.

  • k_i (float) – Integral gain.

  • k_t (float, optional) – Reference-feedforward gain. The default is k_p.

v#

Input disturbance estimate.

Type:

complex

u_i#

Integral state.

Type:

complex

Notes

This contoller can be used, e.g., as a current controller. In this case, i corresponds to the stator current and u to the stator voltage.

References

output(i_ref, i)[source]#

Compute the controller output.

Parameters:
  • i_ref (complex) – Reference signal.

  • i (complex) – Feedback signal.

Returns:

u – Controller output.

Return type:

complex

update(T_s, u_lim, w)[source]#

Update the integral state.

Parameters:
  • T_s (float) – Sampling period (s).

  • u_lim (complex) – Realized (limited) controller output. If the actuator does not saturate, u_lim = u.

  • w (float) – Angular speed of the reference frame (rad/s).

class gritulator.control.RateLimiter(rate_limit=np.inf)[source]#

Rate limiter.

Parameters:

rate_limit (float, optional) – Rate limit. The default is inf.

class gritulator.control.DCBusVoltCtrl(zeta, alpha_dc, p_max=np.inf)[source]#

Bases: PICtrl

PI DC-bus voltage controller.

This provides an interface for a DC-bus controller. The gains are initialized based on the desired closed-loop bandwidth and the DC-bus capacitance estimate. The PI controller is designed to control the energy of the DC-bus capacitance and not the DC-bus voltage in order to have a linear closed-loop system [3].

Parameters:
  • zeta (float) – Damping ratio of the closed-loop system.

  • alpha_dc (float) – Closed-loop bandwidth (rad/s).

  • p_max (float, optional) – Maximum converter power (W). The default is inf.

References

class gritulator.control.PICtrl(k_p, k_i, k_t=None, u_max=np.inf)[source]#

2DOF PI controller.

This implements a discrete-time 2DOF PI controller, whose continuous-time counterpart is:

u = k_t*y_ref - k_p*y + (k_i/s)*(y_ref - y)

where u is the controller output, y_ref is the reference signal, y is the feedback signal, and 1/s refers to integration. The standard PI controller is obtained by choosing k_t = k_p. The integrator anti-windup is implemented based on the realized controller output.

Notes

This contoller can be used, e.g., as a speed controller. In this case, y corresponds to the rotor angular speed w_M and u to the torque reference tau_M_ref.

Parameters:
  • k_p (float) – Proportional gain.

  • k_i (float) – Integral gain.

  • k_t (float, optional) – Reference-feedforward gain. The default is k_p.

  • u_max (float, optional) – Maximum controller output. The default is inf.

v#

Input disturbance estimate.

Type:

float

u_i#

Integral state.

Type:

float

output(y_ref, y)[source]#

Compute the controller output.

Parameters:
  • y_ref (float) – Reference signal.

  • y (float) – Feedback signal.

Returns:

u – Controller output.

Return type:

float

update(T_s, u_lim)[source]#

Update the integral state.

Parameters:
  • T_s (float) – Sampling period (s).

  • u_lim (float) – Realized (limited) controller output. If the actuator does not saturate, u_lim = u.

class gritulator.control.PWM(six_step=False)[source]#

Duty ratios and realized voltage for three-phase PWM.

This contains the computation of the duty ratios and the realized voltage. The realized voltage is computed based on the measured DC-bus voltage and the duty ratios. The digital delay effects are taken into account in the realized voltage, assuming the delay of a single sampling period. The total delay is 1.5 sampling periods due to the PWM (or ZOH) delay [4].

Parameters:

six_step (bool, optional) – Enable six-step operation in overmodulation. The default is False.

realized_voltage#

Realized voltage (V) in synchronous coordinates.

Type:

complex

References

static six_step_overmodulation(u_s_ref, u_dc)[source]#

Overmodulation up to six-step operation.

This method modifies the angle of the voltage reference vector in the overmodulation region such that the six-step operation is reached [5].

Parameters:
  • u_s_ref (complex) – Reference voltage (V) in stator coordinates.

  • u_dc (float) – DC-bus voltage (V).

Returns:

u_s_ref_mod – Reference voltage (V) in stator coordinates.

Return type:

complex

References

static duty_ratios(u_s_ref, u_dc)[source]#

Compute the duty ratios for three-phase PWM.

This computes the duty ratios using a symmetrical suboscillation method. This method is identical to the standard space-vector PWM.

Parameters:
  • u_s_ref (complex) – Voltage reference in stator coordinates (V).

  • u_dc (float) – DC-bus voltage (V).

Returns:

d_abc – Duty ratios.

Return type:

ndarray, shape (3,)