Pen Plotter Project
control.ClosedLoop Class Reference

Interface with closed loop controller. More...

Public Member Functions

def __init__ (self, PID, satLim, setPoint)
 Constructs a closed loop controller. More...
 
def update (self, Read, startTime)
 Updates the controller for timing and error between a read value and the setpoint. More...
 
def get_Times (self)
 Returns time array for a step response. More...
 
def getPositions (self)
 Returns motor positions array for a step response. More...
 
def get_PID (self)
 Gets PID object. More...
 
def set_PID (self, PID)
 Sets PID gains. More...
 
def set_setPoint (self, setPoint)
 Sets or resets setpoint to a certain value.
 
def sat (self, sat_duty)
 Saturation functionallity. More...
 

Public Attributes

 firstTime
 Instantiates PID controller with gains. More...
 
 i
 
 PID
 
 satLim
 Instantiates duty saturation upper and lower bounds.
 
 setPoint
 
 esum
 Sum of error over a difference in time.
 
 laste
 Previous error.
 
 times
 
 motorPositions
 

Detailed Description

Interface with closed loop controller.

Contains all methods that will be used in task_hardware to set the duty cycle based on closed loop control.

Constructor & Destructor Documentation

◆ __init__()

def control.ClosedLoop.__init__ (   self,
  PID,
  satLim,
  setPoint 
)

Constructs a closed loop controller.

Creates variables necessary to instantiate a controller such as timing, PID gains, saturation limit, setpoint value, error, and arrays used in recording a step response

Parameters
PIDis a list containing the three gain values for Kp/Ki/Kd
satLimis a list containing the upper and lower bounds of saturation

Member Function Documentation

◆ get_PID()

def control.ClosedLoop.get_PID (   self)

Gets PID object.

Quick method to determine what controller is using for PID gains.

◆ get_Times()

def control.ClosedLoop.get_Times (   self)

Returns time array for a step response.

Returns
Contains array of time over a step response

◆ getPositions()

def control.ClosedLoop.getPositions (   self)

Returns motor positions array for a step response.

Returns
Contains encoder read positions of a motor over a step response

◆ sat()

def control.ClosedLoop.sat (   self,
  sat_duty 
)

Saturation functionallity.

Controls if a duty is too large from what is calculated in update method.

Parameters
sat_dutyis the value sent by what is calculated in update method.
Returns
Sends back either the saturated limit if duty is too high or original duty based on bounds.

◆ set_PID()

def control.ClosedLoop.set_PID (   self,
  PID 
)

Sets PID gains.

Sets PID gains to some new list of values for Kp/Ki/Kd

Parameters
PIDis a list containing the three gain values for Kp/Ki/Kd

◆ update()

def control.ClosedLoop.update (   self,
  Read,
  startTime 
)

Updates the controller for timing and error between a read value and the setpoint.

Parameters
Readis the value returned by the sensor detecting the current state of the system (encoder position)
startTimeis the initial time for a step response.
Returns
Sends back saturated duty value using sat method.

Member Data Documentation

◆ firstTime

control.ClosedLoop.firstTime

Instantiates PID controller with gains.

Error signal which is the difference between a reference and input (current) value.


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