ME 305
Public Member Functions | Public Attributes | List of all members
closedloop.ClosedLoop Class Reference

ClosedLoop Class. More...

Public Member Functions

def __init__ (self, Kp_initial, Vdesired)
 Initializes object in ClosedLoop class. More...
 
def run (self, Vmeasured)
 Calculates CL duty. More...
 
def set_Kp (self, Kp_input)
 Changes the Gain Value. More...
 
def __init__ (self, Kp_initial, Kd_initial)
 Initializes object in ClosedLoop class. More...
 
def run (self, Pmeasured, Vmeasured)
 Calculates CL duty. More...
 
def set_Kp (self, Kp_input)
 Changes the Gain Value. More...
 
def __init__ (self)
 Initializes ClosedLoop class. More...
 
def setgain (self, Kp, Kd, Ki)
 Sets gains to user input from task_user.py. More...
 
def run (self, Pref, Pmeasured, Vmeasured, Kisign)
 Calculates output of each closed loop. More...
 

Public Attributes

 Kp
 Proportional gain. More...
 
 Vdesired
 
 CLduty
 
 Kd
 Derivative gain. More...
 
 Ki
 Integral gain. More...
 
 start
 Start time of when class instance first initialized.
 
 accum
 Contains accumulation of angular position error.
 
 CLvalue
 Final value of closed loop after application of various gains.
 

Detailed Description

ClosedLoop Class.

Consists of methods and variables to calculate the closed loop duty cycle. Combined with main.py and task_user.py, it sets the duty cycle to a value that will produce an output speed close to Vdesired

Consists of methods and variables to calculate the closed loop duty cycle. Combined with main.py and task_user.py, it sets the duty cycle to a value that will produce an output speed close to Kd initial

Consists of methods and variables to calculate the duty cycle to automatically balance a ball. The task_user.py runs the instances of this class for cascaded control

Constructor & Destructor Documentation

◆ __init__() [1/3]

def closedloop.ClosedLoop.__init__ (   self,
  Kp_initial,
  Vdesired 
)

Initializes object in ClosedLoop class.

Takes input and creates an object that will calculate the output duty cycle

Parameters
Kp_initialInitial gain for closed loop
VdesiredDesired speed for motor
Returns
None

◆ __init__() [2/3]

def closedloop.ClosedLoop.__init__ (   self,
  Kp_initial,
  Kd_initial 
)

Initializes object in ClosedLoop class.

Takes input and creates an object that will calculate the output duty cycle

Parameters
Kp_initialInitial gain for closed loop
VdesiredDesired speed for motor
Returns
None

◆ __init__() [3/3]

def closedloop.ClosedLoop.__init__ (   self)

Initializes ClosedLoop class.

Returns
None

Member Function Documentation

◆ run() [1/3]

def closedloop.ClosedLoop.run (   self,
  Pmeasured,
  Vmeasured 
)

Calculates CL duty.

Uses Vmeasured as well as initalized parameters to

Parameters
Vmeasured
Returns
The closed loop duty cycle CLduty

◆ run() [2/3]

def closedloop.ClosedLoop.run (   self,
  Pref,
  Pmeasured,
  Vmeasured,
  Kisign 
)

Calculates output of each closed loop.

The output of the outer closed loop will provide the reference position to be used in the inner loop. The final output is the duty cycle.

Parameters
PrefReference position
PmeasuredMeasured position of ball or platform
VmeasuredMeasured velocity of ball or platform
KisignControls positive or negative magnitude of integral gain
Returns
Reference position of platform for first loop, then duty cycle for the second loop

◆ run() [3/3]

def closedloop.ClosedLoop.run (   self,
  Vmeasured 
)

Calculates CL duty.

Uses Vmeasured as well as initalized parameters to

Parameters
Vmeasured
Returns
The closed loop duty cycle CLduty

◆ set_Kp() [1/2]

def closedloop.ClosedLoop.set_Kp (   self,
  Kp_input 
)

Changes the Gain Value.

Changes the Gain value for the closed loop duty cycle calculation

Parameters
Kp_inputInput gain from user for integral control
Returns
None

◆ set_Kp() [2/2]

def closedloop.ClosedLoop.set_Kp (   self,
  Kp_input 
)

Changes the Gain Value.

Changes the Gain value for the closed loop duty cycle calculation

Parameters
Kp_inputInput gain from user for integral control
Returns
None

◆ setgain()

def closedloop.ClosedLoop.setgain (   self,
  Kp,
  Kd,
  Ki 
)

Sets gains to user input from task_user.py.

Parameters
KpProportional gain
KdDerivative gain
KiIntegral gain
Returns
None

Member Data Documentation

◆ Kd

closedloop.ClosedLoop.Kd

Derivative gain.

Initializes to be used in various other methods. Initially 0.

◆ Ki

closedloop.ClosedLoop.Ki

Integral gain.

Initializes to be used in various other methods. Initially 0.

◆ Kp

closedloop.ClosedLoop.Kp

Proportional gain.

Initializes to be used in various other methods. Initially 0.


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