Ball Balancer Project
Public Member Functions | Public Attributes | List of all members
ClosedLoop.ClosedLoop Class Reference

Contains all of the functions that are responsible for closed-loop PID control. More...

Public Member Functions

def __init__ (self)
 A function that initializes the controller driver. More...
 
def update_inner (self, eul_ang, dt, ang_vel, ref)
 Updates the duty cycle under closed-loop control. More...
 
def update_outer (self, eul_ang, dt, ang_vel, ref, contact)
 Updates the duty cycle under closed-loop control. More...
 
def set_gain_inner (self, Kp, KI, Kd)
 Sets the gain and velocity reference values. More...
 
def set_gain_outer (self, Kp, KI, Kd)
 Sets the gain and velocity reference values. More...
 

Public Attributes

 maxDuty
 
 minDuty
 
 int_error
 
 int_error_o
 
 ang_vel
 
 eul_ang
 
 time_diff
 
 ref
 
 error
 
 deriv_error
 
 Duty
 
 ang_vel_o
 
 eul_ang_o
 
 time_diff_o
 
 ref_o
 
 error_o
 
 deriv_error_o
 
 Duty_o
 
 Kp_i
 
 KI_i
 
 Kd_i
 
 Kp_o
 
 KI_o
 
 Kd_o
 

Detailed Description

Contains all of the functions that are responsible for closed-loop PID control.

This class is used to calculate a value based on a closed loop PID controller architecture. This calculated value can be anything, as long as the correct inputs are given, making this driver very reusable. Separate functions were used for the inner and outer control loops to easily differentiate the variables from each other.

Constructor & Destructor Documentation

◆ __init__()

def ClosedLoop.ClosedLoop.__init__ (   self)

A function that initializes the controller driver.

This fucntion sets the limits for closed-loop duty cycles.

Member Function Documentation

◆ set_gain_inner()

def ClosedLoop.ClosedLoop.set_gain_inner (   self,
  Kp,
  KI,
  Kd 
)

Sets the gain and velocity reference values.

This function passed the user-selected values for gain and Vref and passes them to the update() function.

Parameters
Kpis the share of the user-requested proportional gain.
Kiis the share of the user-requested integral gain.
omega_refis the velocity requested by the user in taskUser.

◆ set_gain_outer()

def ClosedLoop.ClosedLoop.set_gain_outer (   self,
  Kp,
  KI,
  Kd 
)

Sets the gain and velocity reference values.

This function passed the user-selected values for gain and Vref and passes them to the update() function.

Parameters
Kpis the share of the user-requested proportional gain.
Kiis the share of the user-requested integral gain.
omega_refis the velocity requested by the user in taskUser.

◆ update_inner()

def ClosedLoop.ClosedLoop.update_inner (   self,
  eul_ang,
  dt,
  ang_vel,
  ref 
)

Updates the duty cycle under closed-loop control.

This function is in charge of actually using the gains to assign a duty cycle to a motor to minimize error.

Parameters
omega_measis the current velocity of the motor.
Returns
Duty percentage of one motor is returned.

◆ update_outer()

def ClosedLoop.ClosedLoop.update_outer (   self,
  eul_ang,
  dt,
  ang_vel,
  ref,
  contact 
)

Updates the duty cycle under closed-loop control.

This function is in charge of actually using the gains to assign a duty cycle to a motor to minimize error.

Parameters
omega_measis the current velocity of the motor.
Returns
Duty percentage of one motor is returned.

The documentation for this class was generated from the following file: