StartLimitCurrent

class StartLimitCurrent(encoder: AbsoluteRotaryEncoder, tachometer: Tachometer, motor: DCMotor, target_angular_position: AngularPosition, limit_electric_current: Current)

Bases: RuleBase

StartLimitCurrent object.

It can be used to make a gradual start of the powertrain’s motion and limit the motor absorbed electric current to be lower than or equal to a limit_electric_current value. It computes a pwm to apply to the motor up until the encoder’s target’s angular_position equals target_angular_position.

For an optimal pwm management, it is suggested to set the motor as the tachometer’s target.

Methods

apply()

It computes the pwm to apply to the motor in order to limit its absorbed electric current to be lower or equal to limit_electric_current, until the encoder’s target rotating object’s angular_position equals the target_angular_position.

Raises

TypeError
ValueError
  • If the motor cannot compute electric_current property (DCMotor.electric_current),

  • if limit_electric_current is negative or null.

See Also

DCMotor.pwm

apply() None | float | int

It computes the pwm to apply to the motor in order to limit its absorbed electric current to be lower or equal to limit_electric_current, until the encoder’s target rotating object’s angular_position equals the target_angular_position.

Returns

float or int or None

PWM value to apply to the motor in order to limit its absorbed electric current to be lower or equal to limit_electric_current

Notes

It checks the applicability condition, defined as:

\[\theta \le \theta_t\]

where:

  • \(\theta\) is the encoder’s target angular_position,

  • \(\theta_t\) is the target_angular_position.

If the applicability condition is not met, then it returns None, otherwise it computes the pwm as:

\[D \left( \dot{\theta} \right) = \frac{1}{2} \, \left( \frac{\dot{\theta}}{\dot{\theta}_0} + \frac{i_{lim}}{i_{max}} + \sqrt{ \left( \frac{\dot{\theta}}{\dot{\theta}_0} \right)^2 + \left( \frac{i_{lim}}{i_{max}} \right)^2 + 2 \frac{\dot{\theta}}{\dot{\theta}_0} \frac{i_{lim} - 2 i_0}{i_{max}} } \right)\]

where: