CALPOLY MECHATRONICS
Documentation for all Mechatronics Labs
pid.ClosedLoop Class Reference

A Class that implements a standard PID controller. More...

Public Member Functions

def __init__ (self, kp=0, ki=0, kd=0, sat=100)
 A method to initialize a ClosedLoop object. More...
 
def update (self, posError, velError)
 A method to update the response of the PID controller to a given error signal. More...
 
def get_Kp (self)
 Get the proortional gain value, Kp. More...
 
def get_Ki (self)
 Get the integral gain value, Ki. More...
 
def get_Kd (self)
 Get the derivative gain value, Kd. More...
 
def set_Kp (self, kp)
 Set the proortional gain value, Kp.
 
def set_Ki (self, ki)
 Set the integral gain value, Ki.
 
def set_Kd (self, kd)
 Set the derivative gain value, Kd.
 
def get_J (self)
 Get the PID controller performance metric, J. More...
 
def reset_J (self)
 Reset the performance metric, J.
 

Public Attributes

 kp
 The proportional gain, Kp, of the PID controller.
 
 ki
 
 kd
 The derivative gain, Kd of the PID controller.
 
 iError
 The integral of the position error over time (Reiman sum)
 
 jk
 J (performance metric) times K (number of updates)
 
 k
 Number of updates since self.reset_J has been called.
 
 sat
 The maximum absolute vlaue of the response.
 

Detailed Description

A Class that implements a standard PID controller.

The ClosedLoop class is used to calculate the response to an error signal using PID control. The ClosedLoop object also evlauates its performance over time using the Remon sum of the squares of the velocity and postion error over time.

Constructor & Destructor Documentation

◆ __init__()

def pid.ClosedLoop.__init__ (   self,
  kp = 0,
  ki = 0,
  kd = 0,
  sat = 100 
)

A method to initialize a ClosedLoop object.

Parameters
kpThe proportional gain, Kp, of the PID controller.
kiThe integral gain, Ki, of the PID controller.
kdThe derivative gain, Kd of the PID controller.
satThe maximum absolute vlaue of the response.

Member Function Documentation

◆ get_J()

def pid.ClosedLoop.get_J (   self)

Get the PID controller performance metric, J.

Returns
The PID controller performance metric, J.

◆ get_Kd()

def pid.ClosedLoop.get_Kd (   self)

Get the derivative gain value, Kd.

Returns
The derivative gain.

◆ get_Ki()

def pid.ClosedLoop.get_Ki (   self)

Get the integral gain value, Ki.

Returns
The integral gain.

◆ get_Kp()

def pid.ClosedLoop.get_Kp (   self)

Get the proortional gain value, Kp.

Returns
The proportional gain.

◆ update()

def pid.ClosedLoop.update (   self,
  posError,
  velError 
)

A method to update the response of the PID controller to a given error signal.

Parameters
posErrorThe closed loop position error: desired - measured.
velErrorThe closed loop velocity error: desired - measured.
Returns
The PID controller response to the given error signal.

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